How to do one-to-many video broadcast?

You can do one-to-many live video broadcast by having the broadcaster user publish live camera view and microphone to a media stream, and all other listeners play that media stream from the media server. Please see How to work with media server? on details of installing and configuring a media server. For illustrations in this section we assume that you have a media server running on 192.1.2.3 and that has an application called myapp which allows you to record a media stream. Thus, your media server application should be reachable at "rtmp://192.1.2.3/myapp". In real deployment you will use the real host name or IP address of your media server.

The one-to-many video broadcast requires all the listeners to know the media server URL to connect to and the stream name to listen and play. The broadcaster user picks a stream name, say, "myrant", and sets the src property of his VideoIO application to enable publish as "rtmp://192.1.2.3/myapp?publish=myrant". The broadcaster informs the listeners about the src URL. A listener who wants to listen to this broadcast, replaces the publish with play and assigns the src property of her VideoIO to "rtmp://192.1.2.3/myapp?play=myrant". The broadcaster can stop the stream by setting src to null or "". Similarly a listener can stop by setting src to null or "".

In a broadcast session, the broadcaster user is publishing his stream whereas other listeners are playing his stream. Thus the remaining challenge is to convey the desired stream URL to the listeners. In practice, people use variety of methods ranging from CGI web service or static web sites to list all the broadcast URLs, or announcing via email or Jabber service. Whatever mechanism you decide will become the broadcast announcement service of your system. In our tutorial we will assume that these information is sent out-of-band to the individuals, e.g., over instant messenging or email.

Information: Typically a media server allows any number of play instances for a stream name, but only one publish instance within a URL scope. Hence, the stream name must be chosen carefully by the broadcaster user to avoid conflict with other broadcasters.

The user interface for broadcaster will typically be different than that of the listener. A broadcaster will typically have a VideoIO instance and perhaps a text-based feedback from the listeners. A listener will typically have a listing of all the broadcast sessions, an ability to join a session, and a VideoIO instance when he joins a session. Additionally, there may be a text-based input box to allow sending questions or feedback to the broadcaster.

The following user interface embeds a VideoIO instance which can be used by broadcaster as well as listener. To try the demonstration, open this page in multiple browser instances. You can try on different machines or the same machine. On the first browser instance, select "publish" in the drop-down box to act as a broadcaster, before clicking on the set button. On other browser instances, keep the default "play" in the drop-down box and click on the set button to act as listeners. If you are running media server on a different host than 192.1.2.3, change the URL's IP address in all text input boxes.


? =

The source code for this is similar to earlier examples. You can also right-click and select "View Page Source" or equivalent menu option to see the source code.

Summary

In summary, you can use the src property with URL parameter containing publish for broadcast user's stream and play for listener user's stream. The recording and playing properties control the current state of whether your video is transmitted or whether remote video is played.

This tutorial is just the begining of how to do one-to-many video broadcast. The VideoIO API is so simple that just setting the src property allows you to accomplish several use cases. There are several other properties that affect behavior of a call, e.g., you can control the camera quality or sound mute. Additionally, you can build other advanced user interface controls in JavaScript similar to how VideoIO's control panel shows in Flash.