Creating an On-Demand Multicast with the SDK

You can set up and start a multicast using the NetShow SDK instead of the NetShow administrative application. This section outlines the steps needed to set up a basic multicast to distribute content on demand, using only the SDK. The following examples are written from the perspective of doing local administration.

Instantiate the Station Manager Object

Create an instance of the station manager object. The following code is straight HTML code, so it should not be within a SCRIPT section.

<OBJECT ID="MCM" HEIGHT=1 WIDTH=1
   CLASSID="CLSID:B00464B3-67D4-11D0-A464-00C04FC29CFB">
</OBJECT>

Connect to the NetShow Server

Open a connection to the NetShow server. In this example, the new station manager object is called MCM. It connects to a NetShow server running on the same computer where the script is being run. However, as long as the Station Manager Control is installed locally, you can also connect to a remote computer that is running the NetShow server.

MCM.Connect "LocalHost"

Create a New Station

You create a station for the multicast using the Open method.. In this example the first parameter for the Open method specifies a station named My Station. The second parameter specifies that all administrative clients on the NetShow server will have full read, write, and delete permissions. The Open method returns a Channel object, which can be referred to by the variable MyStation.

Set MyStation = MCM.Channels.Open( "My Station", 7 )

Set Station Properties

Once you have a station to work with, you set the properties you need. The following properties must be set before you can multicast over the station. Many of the optional descriptive properties have not been set in this example, but if you do want to set them, this is where you can do it.

Note: When you set the IPAddress and Port properties, ensure that the values don't duplicate those of an existing station. It can be difficult to track down duplicate multicast servers.

MyStation.MulticastAddress = "238.8.217.46"
MyStation.Port = 13767

Specify Delivery Options

You must also specify if the multicast is intended for distribution to other servers, for viewing in a player, or both. In this example, the distribution mode has been set to allow the multicast to be viewed in a player.

MyStation.DeliveryMode = MCM_DM_SESSIONLESS_3PH

Create a Station Format

The station must contain at least one station format to tell players how to render the content in the multicast. The station format is contained in a ChannelFormat object. In this example, the .asf file used as the multicast source is also used to specify the station format:

MyStation.ChannelFormats.Add "c:\ASFRoot\welcome.asf", _
   3MCM_ASF_CH_FORMAT_FILE

Create an NSC File

When you have your station set up, you need to export it into an .nsc file that is posted for easy access by a client. In this example, the .nsc file is written into the home folder of a Web server on the local computer. The second parameter specifies that an old file with the same name can be overwritten.

MyStation.WriteNSC "c:\inetpub\wwwroot\mynsc.nsc", "True"

Create a Stream

Now that the station has been created, you create a stream to play within it. Use the Open method to create a stream. In this example, the new stream is given the name "MyStream", with a unicast URL as its source. You must specify the access rights clients can have to the stream. The enumeration for access right is defined as MCM_PA_READ, MCM_PA_WRITE, MCM_PA_DELETE, and MCM_PA_ALL.

Set MyStream = MCM.Streams.Open ("mms://astrid/welcome.asf", "MyStream", MCM_PA_READ)

Activate the Stream

Once you have a valid station and stream, you need to associate the stream with the station by activating it. A station can have only one active stream. If you have several streams, you can switch among them while the station multicasts. Clients listening to the station will receive content from the active stream, but cannot select which stream is active. That is up to you. In this case, we have only one stream to set as the active stream.

MyStation.SetActiveStream MyStream

Start the Multicast

All that is left to do is start the stream. In this example, we will start the stream at the beginning by specifying an opening position of zero milliseconds past the start of the file.

MyStream.Start 0

Playing the Multicast

Now your stream is being multicasted. A client on a subnet that receives the multicast can now connect and play the multicast.

© 1996-1998 Microsoft Corporation. All rights reserved.