ngraziano / SharpRTSP

A RTSP handling library
Other
557 stars 182 forks source link

Rtsp over Http tunneling #96

Closed Revan1985 closed 10 months ago

Revan1985 commented 10 months ago

Hi all, I need a little advice for an implementation I would like to add in this great library. I am trying to tunnel the rtsp connection over Http, but I am not able to afford it. I am checking also another library, the RtspClientSharp, that seems to have implemented it, but without lucky. Do you know where can I found some documentation? I am searching in the internet, but cannot found nothing usefull. Or some advice on how to get this to work?

Thank you for any possible advice Have a nice day

ngraziano commented 10 months ago

Hi,

I made some research the only specification I can found is this document : https://opensource.apple.com/source/QuickTimeStreamingServer/QuickTimeStreamingServer-412.42/Documentation/RTSP_Over_HTTP.pdf

If I understand well the client send an initial GET request to "establish" the tunnel, when the client want to send data it send an POST request and when it need data it send a GET request (when it wait for a response) To include in sharprtsp you will need to make an other IRtspTransport with return (for GetStream) a custom Stream which make the HTTP request.

Actually I'm between jobs, so I don't have access to CCTV camera to make some test. Wireshark capture of a dialog may be interesting

Some links I have found https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gst-plugins-base/gst-libs/gst/rtsp/gstrtspconnection.c https://www.happytimesoft.com/knowledge/rtsp-over-http.html https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/rtsp.c with RTSP_MODE_TUNNEL

RogerHardiman commented 10 months ago

I started to implement it with SharpRTSP being the server but never finished it. I used the Apple document and used ffmpeg's 'ffplay' command to connect to my test code to so I could see what the HTTP Headers were like. The main thing was accepting two TCP connections and using information in the HTTP Headers so you know which TCP sockets are the pair needed to send and receive. Then the code that reads and writes the normal RTSP socket needs a wrapper so instead of reading/writing one socket, it has to work with two TCP sockets

Revan1985 commented 10 months ago

Wireshark-over http samsung.zip

Hello ngrazioano, I am attaching a zip file with a wireshark for an rtsp over http, as exposed by a program called ODM (OnvifDM, useful for onvif find). I am not sure this is what correctly needed, as this uses onvif for discovery and connection, but I think is almost what setup by the Rtsp over Http tunneling. Let me know if can be usefull. I have understood what is needed to do, will try to implement it, and maybe, when will works, to merge in the main code...

Have a nice day

Revan1985 commented 10 months ago

We can consider this closed with pull #98