• How to MediaCaster API to start native RTP and MPEG-TS streams

    When using the rtp-live and rtp-live-record stream types, Native RTP and MPEG-TS streams are started and stopped on demand based on client's viewing the stream. The publishing process is started the first time a client tries to view a stream and stops 60 seconds after the last client has stopped viewing the stream. If you want to control when the stream is started and be sure it remains running, you can use the MediaCaster API to acquire and release the stream. The code looks like this:

    To start publishing/recording:
    MediaCasterStreamMap mediaCasterMap = appInstance.getMediaCasterStreams();
    MediaCasterStreamItem mediaCasterItem = mediaCasterMap.acquire(streamName);

    To stop publishing/recording (unless there are connected clients, then it will continue):
    mediaCasterItem.release();
    If you're using StreamType rtp-live, you should change to live so that Flash clients can't start the stream until it's started by your process.

    The acquire call will start the publishing/recording process if it's not already started and will keep it going even if all clients stop viewing the stream. The release call will remove the stream lock. If no clients are currently viewing the stream, then it will be unloaded. If clients are viewing the stream, it will follow the normal rules. You must have matching calls to acquire and release for the system to work properly (equal number of calls to acquire and release).


    If you're having problems or want to discuss this article, post in our forum.