video-streamingrtsprtplive555rtsp-client

Demultiplex and proxy for RTSP video stream


I have the problem of having to connect multiple clients to RTSP video stream, without overloading the bandwidth of the original streaming camera. Basically I want something the will maintain only one connection to a RTSP streaming camera/server, but allow N clients to maintain n connections to it:

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

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

I've found one (and ONLY one solution) for this, the Proxy Server component from LIVE555, but it has one show-stopping drawback, for me at least: 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).

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?

(NOTE: I'd prefer a library or something open source because I also have some extra things I'd need to build on top, like maybe temporarily replacing feed with stream of an image placeholder or another "backup" stream when connection drops etc. - but a "just works" appliance is good enough for now, once I solve the proxy-demultiplexing issue the others I can add as separate services.)


Solution

  • I'm not aware of a better solution than the live555 proxy. The only limitation I recall was proxying AMR-NB audio, but I can't recall what the issue was.

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

    The proxyServer is a proxy built on top of the liveMedia code base. Just build your own proxy server on top it. You can use proxyServer as a starting point.

    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).

    It is fairly easy for you to add your own periodic tasks to the single-threaded liveMedia event loop that handles RTSP Server reconnection after camera reboots, network outages, etc. I have used the liveMedia code to handle similar issues before. Just make sure you comply with the LGPL licence requirements.

    Code sample from playCommon.cpp in the live\testProgs directory

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

    where sessionTimerHandler is declared as

    void sessionTimerHandler(void* clientData);
    

    The LiveMedia has basically defined a callback mechanism. Do a search for TaskToken and you'll find lots of further examples in the source code. If you're on Windows, try and find a CMake-based fork of live555 to generate the VS solution. On linux, there are sufficient other tools.

    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?

    You are looking for an RTSP proxy and there is no better one that I'm aware of. There is nothing wrong with your search terms, there are simply not many open source (if any other) around. Not sure if there are commercial variants.

    The live555 code is