2

I am writing a proxy for an application that uses RTSP for streaming video content. It basically works as follows:

  • The application (server) makes an RTSP stream available on localhost port 8554.
  • A client wishing to connect to this stream connects to my proxy on localhost port 8553.
  • My proxy connects to the RTSP stream (server) on localhost port 8554 and passes the network traffic (bytes) along between client and server. (I don't inspect packets at all, I simply read the bytes on the one stream and pass those bytes along to the other stream.)

Since RTSP uses both TCP and UDP communication, I will have to have listeners for both protocols on the proxy, however, I have not yet got to implementing the UDP part. At the moment I am simply working on TCP which essentially handles the "handshaking" to start the video transfer. The actual video transfer over UDP will be my next step.

Now for my question: I am successfully passing messages ("OPTIONS", "DESCRIBE", "SETUP, etc.) along with the proxy. The problem is that the content of the messages itself contains some information about the streaming server. Specifically, when the server responds to the client's "DESCRIBE" request, it returns amongst others:

Content-Base: rtsp://127.0.0.1:8554/nurv/

Before passing it along to the client, I need to change this on the proxy to:

Content-Base: rtsp://127.0.0.1:8553/nurv/

because at the moment, when the client issues the subsequent "SETUP" request, it requests:

SETUP rtsp://127.0.0.1:8554/nurv/track1 RTSP/1.0

which means that for the actual streaming it bypasses my proxy on port 8553 and connects directly to the stream on 8554.

How can I modify the messages on the proxy so that references to the actual server (i.e. 127.0.0.1:8554) get replaced by references to the proxy (i.e. 127.0.0.1:8553)? Obviously it isn't optimal to do a string search through each message being passed through the proxy since that would mean unpacking and inspecting each message before repacking and sending on.

4

1 回答 1

1

我已经解决了这个问题。由于 RTSP 协议的 TCP 连接通常只包含控制消息,因此此处传递的消息数量并不多(如果是开始播放的简单请求,则每侧 5 或 6 个,最后,结束它)。大流量将通过 UDP 连接处理。

因此,如果我对通过 TCP 发送的消息进行解包、操作和重新打包,它不会导致大的性能问题。所以我只是阅读了软件包,根据需要替换了必要的 IP 地址,仅此而已。我还需要这样做来读取客户端和服务器协商的 UDP 端口,以便我的代理可以介于两者之间。由于 TCP 上的流量很低,我可以做到这一点。

于 2013-05-15T09:11:05.687 回答