Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

python - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...