Start and stop MediaCaster streams with the Wowza Streaming Engine Java API

MediaCaster provides a way to start and stop RTMP and RTSP/RTP streams on-demand in Wowza Streaming Engine™ media server software, allowing you to re-stream IP camera streams (RTSP/RTP streams), SHOUTcast/Icecast streams, streams from native RTP or MPEG-TS encoders, HLS streams, and RTMP streams.

MediaCaster pulls a stream from a source and makes it available on-demand to all supported player technologies. When the first request is received from a player for a given stream, MediaCaster connects to the source and makes the stream available to the player. When the last player stops watching the stream, MediaCaster waits for a timeout period. If no other players request the stream, the stream is stopped until another request is made.

Note: MediaCaster doesn't work for MPEG-DASH streaming, which requires packetization.
You can use the Wowza Streaming Engine Java API to start and stop MediaCaster streams as part of the IApplicationInstance interface. The utility method
 
IApplicationInstance.startMediaCasterStream(streamName, mediaCasterType);

starts a MediaCaster stream.

The utility method

IApplicationInstance.stopMediaCasterStream(streamName);

stops a MediaCaster stream.

The streamName parameter is the name of the stream you're starting or stopping, including the .stream file extension.

The mediaCasterType parameter defines the type of stream. Valid mediaCasterType values are:

  • liverepeater - Streams pulled using the RTMP protocol or via the WOWZ protocol from another Wowza Streaming Engine instance.
  • rtp -IP camera streams, both RTSP and RTP, and for streams from native RTP and MPEG-TS encoders
     
  • shoutcast - SHOUTcast/Icecast streams
     
  • rtp-record and shoutcast-record - Re-stream and record RTP and SHOUTcast/Icecast streams, respectively.
  • applehls - HLS streams pulled from a live source.
  • mpegtstcp - MPEG-TS streams pulled from a live source over TCP.
  • srt - Accept SRT connections.

Here are some example queries.

Start an RTSP stream named camera.stream:

appInstance.startMediaCasterStream("camera.stream", "rtp");

Stop an RTSP stream named camera.stream:
 
appInstance.stopMediaCasterStream("camera.stream");

Start a SHOUTcast stream named radio.stream:
 
appInstance.startMediaCasterStream("radio.stream", "shoutcast");

Stop a SHOUTcast stream named radio.stream:
 
appInstance.stopMediaCasterStream("radio.stream");

Start an RTMP stream named rtmp.stream from any source that allows RTMP playback:
 
appInstance.startMediaCasterStream("rtmp.stream", "liverepeater");

Stop an RTMP stream named rtmp.stream from any source that allows RTMP playback:
 
appInstance.stopMediaCasterStream("rtmp.stream");