RTSP 视频流的解复用和代理

Demultiplex and proxy for RTSP video stream

我遇到的问题是必须将多个客户端连接到 RTSP 视频流,而不会使原始流媒体摄像机的带宽过载。基本上我想要的东西将只保持一个到 RTSP 流的连接 camera/server,但允许 N 个客户端保持 n 个连接:

                                             +--->[RTSP client 1]
[input RT(S)P stream]--->[? magic thing ?]---+--->[RTSP client 2]
                                             +--->[...]
                                             +--->[RTSP client N]

什么软件可以做到这一点,and/or有哪些库可以让我自己破解 ti?

我为此找到了一个(而且只有一个解决方案),即 Proxy Server component from LIVE555,但它有一个令人难以接受的缺点,至少对我而言:它无法处理随机断开连接并完全暂停输入流(这是一个要求,这需要与非常糟糕的相机一起工作,RT(S)P的实现可能有错误,偶尔会重新启动,并且连接非常不稳定 - 想想3G 连接每 10 - 15 分钟断开一次,可能持续 1-2 秒)。

我想知道 也许我正在搜索错误的东西,这个过程的名称错误,关键字错误等,因为我只找到了一个可用的软件,即 LIVE555 Proxy - 至少有人能为我指明正确的方向以找到解决方案吗?

(注意:我更喜欢库或开源的东西,因为我还需要在上面构建一些额外的东西,比如可能暂时用图像占位符流或其他 "backup" 连接断开时流式传输等 - 但 "just works" 设备现在已经足够好了,一旦我解决了代理多路分解问题,我就可以将其他设备添加为单独的服务。)

我不知道有比 live555 代理更好的解决方案。我记得的唯一限制是代理 AMR-NB 音频,但我不记得是什么问题了。

What software can do this, and/or what libraries are there that I can use to hack ti together myself?

proxyServer 是建立在 liveMedia 代码库之上的代理。只需在其上构建您自己的代理服务器即可。您可以使用 proxyServer 作为起点。

it cannot handle randomly disconnecting and pausing of input stream well at all (and this is a requirement, this needs to work with really crappy cameras, with possibly buggy implementation of RT(S)P, which occasionally reboot, and pretty flaky connectivity - think 3G connection down every 10 - 15 min for maybe 1-2 sec).

您可以很容易地将自己的周期性任务添加到单线程 liveMedia 事件循环中,该事件循环处理 RTSP 服务器在相机重启、网络中断等情况下重新连接。我之前使用 liveMedia 代码来处理类似的问题.只要确保您符合 LGPL 许可要求即可。

来自 live\testProgs 目录 playCommon.cpp 的代码示例

    int64_t uSecsToDelay = (int64_t)(secondsToDelay*1000000.0);
    sessionTimerTask = env->taskScheduler().scheduleDelayedTask(uSecsToDelay, (TaskFunc*)sessionTimerHandler, (void*)NULL);

其中 sessionTimerHandler 声明为

void sessionTimerHandler(void* clientData);

LiveMedia基本定义了回调机制。搜索 TaskToken,您会在源代码中找到更多示例。如果您在 Windows,请尝试找到基于 CMake 的 live555 分支来生成 VS 解决方案。在 linux 上,还有足够的其他工具。

I'm wondering that maybe I'm searching for the wrong thing, wrong name for this process, wrong keywords etc. since I've only found one usable software for this, namely LIVE555 Proxy - can someone at least point me in the right direction for finding a solution to this?

您正在寻找 RTSP 代理,据我所知没有更好的代理了。您的搜索词没有任何问题,周围根本没有多少开源(如果有的话)。不确定是否有商业变体。

live555密码为

  • 开源 (LGPL)
  • 跨平台
  • 经过反复测试(许多问题已被 live555 的各个用户 found/fixed 解决)
  • 积极维护
  • 扩展起来相当简单
  • 通过邮件列表提供支持。 Ross Finlayson(live555 的作者)对邮寄列表上发布的合理查询有相当快的响应时间。发帖时不要使用您的 Gmail 地址:-)