Real-Time Streaming plugin

The Real-Time Streaming (RTS) plugin adds the ability to consume Wowza Video Real-Time Streaming at Scale (RTS@S) streams, Wowza Video WebRTC streams, and Wowza Streaming Engine WebRTC streams.

Install the plugin

You can include the rts plugin next to the core player:

Copy
Copied
<script src="//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/rts.min.js"></script>
info

If an RTS stream has multiple bitrates and resolutions that you would like to display, you must also load and configure the Quality Selection plugin. The various display options will then appear in a menu within the player.

Configure the plugin

The RTS plugin is a Loader plugin which means it will add a special handler for the source types it handles. Configuration depends on your stream type. See the configuration examples in the following sections.

info

If you're using RTS streams with the Video Track Selection plugin, the Video Track Selection plugin automatically detects and renders the RTS streams.

Wowza Video™ Real-Time Streaming at Scale

If you configure a src with type: "wowza/rts", the RTS plugin connects to Wowza's RTS@S backend and consumes the stream that you configure it to show.

In addition to type, you also need to configure streamName. You will use the Stream Name that you entered when you created the real-time stream in Wowza Video, either through the REST API or in the UI.

The subscriberToken is an optional parameter. If you set a Playback Token by enabling stream security in the RTS@S Wowza Video configuration, you would add it as the subscriberToken.

Info

The Stream Name and Playback Token can be found in the Stream Information section in Wowza Video on the Live Stream informational page that displays after you create an RTS@S stream.

As part of your Wowza Video subscription, your player token is:

Copy
Copied
eyJraWQiOiIwWE44RnRTYkQxblYiLCJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJjIjoie1wiYWNsXCI6MzgsXCJpZFwiOlwiMFhOOEZ0U2JEMW5WXCJ9IiwiaXNzIjoiRmxvd3BsYXllciJ9.wHlyQZ86rIHD8ldgnpiWbmFBmR4zt_3FSj78GMk7lfQ1es7K8y0MuHzbqcJfp0lm6LcUbUkQ5PsazIsAybxivg

Example

Copy
Copied
flowplayer("#player", {
  src: {
    type: "wowza/rts",
    streamName: "myStream",
    subscriberToken: "[your-playback-token]"
  },
  token: "[your-player-token]"
})

Wowza Video WebRTC

You can use WebRTC with Wowza Video through the Wowza Video user interface or REST API.

If you configure a src with type: "wowza/webrtc", the RTS plugin connects to the Wowza Video session of your choice. You must tell the player where your Wowza Video session is hosted and which stream to choose. You can do so by configuring the following properties in the src configuration object.

Property Description
sdpUrl The SDP URL listed on the Overview tab for your WebRTC stream in Wowza Video.
applicationName The value from the Application field on the Overview tab for your WebRTC stream in Wowza Video.
streamName The value from the Stream Name field on the Overview tab for your WebRTC stream in Wowza Video.
token (optional) Refers to the optional token authentication available in Wowza Video. This is different than the top-level product or player token.

As part of your Wowza Video subscription, your player token is:

Copy
Copied
eyJraWQiOiIwWE44RnRTYkQxblYiLCJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJjIjoie1wiYWNsXCI6MzgsXCJpZFwiOlwiMFhOOEZ0U2JEMW5WXCJ9IiwiaXNzIjoiRmxvd3BsYXllciJ9.wHlyQZ86rIHD8ldgnpiWbmFBmR4zt_3FSj78GMk7lfQ1es7K8y0MuHzbqcJfp0lm6LcUbUkQ5PsazIsAybxivg

An example configuration looks like this:

Copy
Copied
flowplayer("#player", {
  src: {
    type: "wowza/webrtc",
    sdpUrl: "wss://zeezzrezrezr.entrypoint.cloud.wowza.com/webrtc-session.json",
    applicationName: "webrtc",
    streamName: "myStream",
    // Optional token for secure streaming
    token: "[your-secure-token]"
  },
  // Top-level product token
  token: "[your-player-token]"
})

Wowza Streaming Engine WebRTC

You can use WebRTC with Wowza Streaming Engine through the Wowza Streaming Engine user interface.

If you configure a src with type: "wowza/webrtc", the RTS plugin connects to the Wowza Streaming Engine instance of your choice. You must tell the player where your WSE instance is hosted and which stream to choose. You can do so by configuring the following properties in the src configuration object.

Property Description
sdpUrl The Signaling URL or SDP URL in Wowza Streaming Engine contains your StreamLock domain. The StreamLock domain can be found as part of your SSL certificate name.
applicationName The name of the application you set up in Wowza Streaming Engine for WebRTC streams.
streamName The stream name can be found on the Incoming Streams page for the application you created for the stream in Wowza Streaming Engine.
token (optional) Refers to the optional SecureToken available in Wowza Streaming Engine. This is different than the top-level product or player token.

An example configuration looks like this:

Copy
Copied
flowplayer("#player", {
  src: {
    type: "wowza/webrtc",
    sdpUrl: "wss://[your-streamlock-domain].streamlock.net/webrtc-session.json",
    applicationName: "webrtc",
    streamName: "myStream",
    // Optional token for secure streaming
    token: "[your-secure-token]"
  },
  // Top-level product token
  token: "[your-player-token]"
})
info

Update the top-level player token value with the unique token sent to you after buying Wowza Flowplayer as a standalone purchase. Standalone means you didn't purchase the player as part of a Wowza Video subscription. You can use this token value any time you create a player manually for your live stream.

Listen to plugin events

To listen to events for this plugin, use the rts namespace in the player instance. For example, use flowplayer.rts.events to capture an event. The following table describes the object path and events for the RTS plugin.

Event Description
flowplayer.rts.events.STATUS Emitted when the state of the RTS stream changes, for example to Idle or Receiving. For more, see Track RTS status.
flowplayer.rts.events.VIEWER_COUNT Emitted to capture the number of viewers for the RTS live stream in real time. For more, see Get RTS viewer counts.
flowplayer.rts.events.STATS Emitted every five seconds to capture metrics for active Millicast or RTS streams. For more, see Get RTS statistics.

Track RTS event status

When a status event is emitted, you can use the flowplayer.rts.state enumeration to capture state changes for RTS streams. The following properties are available to track.

Property Description
flowplayer.rts.state.Idle Signals the RTS stream has stopped broadcasting, but it's still available.
flowplayer.rts.state.Receiving Signals the RTS stream is starting or that it's already broadcasting.

In the following example, you can see how to setup an event listener on the STATUS event of the player RTS instance.

Copy
Copied
player.on(flowplayer.rts.events.STATUS, (event)=> {
  switch (event.detail.status) {
    case flowplayer.rts.state.Idle: return handleError()
    case flowplayer.rts.state.Receiving: return updateBroadcastUI()
  }
})

The code uses a switch statement to check the status property of the event details. If the streaming status is Idle, the handleError() function is called. With a Receiving status, the updateBroadcastUI() function is called.

Get RTS viewer counts

In the following example, you can set up an event listener for the VIEWER_COUNT event using the on() method provided by the API. This method allows you to listen for specific events related to video playback.

Copy
Copied
video.on(flowplayer.rts.events.VIEWER_COUNT, function(event) {
  // Event is of type "@millicast/sdk/ViewerCount" and extracts viewer count from the event object
  let count = event.viewerCount;
  console.log(count);
});

When you listen to the flowplayer.ads.events.VIEWER_COUNT event, you can extract the number of viewers for the RTS live stream in real time. The function(event) { ... } function is executed when the VIEWER_COUNT event is triggered. The event parameter contains information about the viewer count.

Get RTS statistics (beta)

After you publish an RTS stream, you can use the on() method provided by the API to access the flowplayer.rts.events.STATS event if embedding the player using the CDN. This event emits two properties that provide a unified WebRTC statistics reporting solution for Wowza-based and Millicast RTS streams.

Copy
Copied
player.on(flowplayer.rts.events.STATS, ev => {
  // For all Wowza RTS streams
  ev.detail.stats;
  // If streaming using Millicast RTS streams
  ev.detail.millicastDiagnostic;
});
  • The stats property is exposed by the underlying WebRTC protocol and can be used for all Wowza RTS streams. It relies on the web-webrtc-stats library to parse WebRTS statistics.
  • The millicastDiagnostic property is exposed for Millicast RTS streams. It displays the metrics from this Dolby.io data dictionary .