• How to use the Wowza Streaming Engine Java API to start and stop MediaCaster streams

    MediaCaster provides a way to start and stop RTMP and RTSP/RTP streams on-demand in Wowza Streaming Engine™ live streaming software, allowing you to re-stream IP camera streams (RTSP/RTP streams), SHOUTcast/Icecast streams, streams from native RTP or MPEG-TS encoders, and RTMP streams from another Wowza media server. 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 Adobe HDS, Apple HLS, Microsoft Smooth Streaming, or MPEG-DASH streaming, which require packetization.
    You can use the Wowza Streaming Engine Server-Side 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 mediaCasterType parameter defines the type of stream. Valid mediaCasterType values are:

    • liverepeater - RTMP streams pulled from another Wowza media server

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

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

    For example:

    Start an RTSP stream whose name is camera.stream

    appInstance.startMediaCasterStream("camera.stream", "rtp");
    Stop an RTSP stream whose name is camera.stream

    appInstance.stopMediaCasterStream("camera.stream", "rtp");
    Start a SHOUTcast stream whose name is radio.stream

    appInstance.startMediaCasterStream("radio.stream", "shoutcast");
    Stop a SHOUTcast stream whose name is radio.stream

    appInstance.stopMediaCasterStream("radio.stream", "shoutcast");
    Start an RTMP stream named rtmp.stream from another Wowza media server

    appInstance.startMediaCasterStream("rtmp.stream", "liverepeater");
    Stop an RTMP stream named rtmp.stream from another Wowza media server

    appInstance.stopMediaCasterStream("rtmp.stream", "liverepeater");

    Originally Published: 10-03-2010.
    Updated: For Wowza Streaming Engine on 12-29-2016.

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