Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forward RTSP stream to remote socket (RTSP Proxy?)

My Apologies for the generality of the question. I have tried many things but nothing seems to work. I have a server? (let's call it Server A) that resides in a local area network where there is also an IP-Webcam. That webcam is constantly providing an RTSP feed on the address... let's say... rtsp://192.168.1.50:554/cam.sdp. The camera doesn't have access to the outside world (it must stay in the LAN, and therefore, only has access to server A, no to server B), but server A does. Sadly, Server A doesn't have a public IP, so I can not reach into Server A from anywhere in the world. Server A can go out if it wants but no one can get into Server A... (it's an spoiled brat... too many toys when it was a kid)

Now, there's another server (server B, to be original) in the aforementioned outside world which is a regular web server with its public IP and all. That server allows people to reach into it (not spoiled, very nice... sets the table, does the dishes... that kind of stuff). Both Server A and Server B are my computers and are running Ubuntu 12.04 and some Python applications I designed (Server B is actually running Django, but I don't think that's too relevant). What I mean by this is that I have control over what's going on in both servers. I can install/uninstall packages, I can open ports, close ports... whatever is needed (I can even format them if I want, although I don't think that would help much... or yes... who knows?)

                               _____________                                    _____________
    -----------                |           |                                    |           |   
 __ |         |                |           |                                    |           |     
|  \| WebCam  |================| Server A  |===========|  INTERNET  |===========| Server B  |
|__/|         | ->/cam.sdp  <--|           |----------------- > --------------> *           | 
    |         |                |___________|                                    |___________|
    -----------

The question is: How can I grab the RTSP stream with server A dump it onto a designated socket of server B and open it (with a program able to understand RTSP feeds, such as VLC)?

I'm guessing I need something like an RTSP proxy, maybe? But I don't really know where to start.

Any hint, link... would be appreciated.

Thank you in advance

like image 639
BorrajaX Avatar asked Dec 07 '12 00:12

BorrajaX


2 Answers

I don't know RTSP, but it seems to be a standard TCP-only protocol. Try to run on server A:

ssh -g -R 554:192.168.1.50:554 server_B_hostname

This will open the public port 554 on Server B, and forward it to 192.168.1.50:554 from A's point of view.

Some servers have sshd configured to refuse the ssh -g -R forwarding (for no good reason). If you can, you should check /etc/ssh/sshd_config on Server B and add AllowTcpForwarding yes.

like image 192
Armin Rigo Avatar answered Sep 22 '22 12:09

Armin Rigo


RTSP is a controlling protocol which usually runs on port 554 , but videostreams are port negotiated using SDP, meaning that on handshaking the port for RTP transport (UDP)will be decided and for each transport, port number varies. So perhaps you need to forward a range of ports or fix the transport port to a fixed value.

like image 32
sibendu sankar Das Avatar answered Sep 21 '22 12:09

sibendu sankar Das