Start native RTP and MPEG-TS streams with the Wowza Streaming Engine Java API

When using the rtp-live and rtp-live-record stream types in Wowza Streaming Engine™ media server software, 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 Wowza Streaming Engine Java API to acquire and release the stream.

To start publishing/recording:

MediaCasterStreamMap mediaCasterMap = appInstance.getMediaCasterStreams();
MediaCasterStreamItem mediaCasterItem = mediaCasterMap.acquire(streamName);

To stop publishing/recording (unless there are connected clients, in which case it will continue):


mediaCasterItem.release();

If you're using StreamType rtp-live, 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).