iizukanao / node-rtsp-rtmp-server

RTSP/RTMP/HTTP hybrid server
MIT License
1.1k stars 282 forks source link

HTTP API #10

Open the-eater opened 9 years ago

the-eater commented 9 years ago

Is it possible to create an HTTP API to query who are publishing, with what resolution, how much listeners there are.

Im open to do it myself if you could point me to the right direction :)

iizukanao commented 9 years ago

Yes! Please look for crossdomain.xml in http.coffee (line 1549). You can add HTTP API somewhere around there. However, I will change server.coffee drastically to add support for multiple streams in the coming weeks, so please keep your code simple, or postpone your work until my code is pushed.

Video resolution

detectedVideoWidth and detectedVideoHeight.

Number of clients

clientsCount is the number of currently connected clients.

Who is publishing

There are three ways to publish streams: RTMP, RTSP, and internal protocol. Though there is no dedicated variable to distinguish them, you can add some code to places that are executed when the server starts to receive streams (sorry for the messy code!):

RTMP

Line 129

rtmpServer.on 'video_start', ->
  # here

RTSP

Line 2005

else if req.method is 'RECORD'
  # here

Internal protocol

Line 463

videoControlReceiver.on 'packet', (buf) ->
  # here
the-eater commented 9 years ago

Looking through the code, I think it seems better to wait till you have multiple streams done as the main thing is getting the streams, this is in the current implementation totally ignored. I don't know what the idea is for the new code but having a class Publisher or something like that would be really rad.