IWMSBroadcastPublishingPoint.AnnounceToNSCStream (C#)

banner art

Previous Next

IWMSBroadcastPublishingPoint.AnnounceToNSCStream (C#)

The AnnounceToNSCStream method retrieves an UCOMIStream object containing a file stream that can be used by a client to receive and render a broadcast.

  • Note   This method is available only on Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; and Windows Server 2008.

Syntax

  UCOMIStream = IWMSBroadcastPublishingPoint
  .AnnounceToNSCStream();

Parameters

This method takes no parameters.

Return Values

This method returns an UCOMIStream object containing the NSC file stream.

Remarks

Players cannot connect directly to a server to render a multicast stream. Therefore, to obtain the information required to receive a multicast broadcast, you must use the AnnounceToNSCStream or AnnounceToNSCFile method to provide players the necessary information. This stream contains a multicast address, a port number, a rollover URL, source content headers, and so on.

Before calling the AnnounceToNSCStream method, you must add the names of all of the media files included in the multicast to the IWMSAnnouncementStreamFormats Object (C#) collection and call the IWMSBroadcastPublishingPoint.Announce (C#) method.

Example Code

using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
using System.Text;

// Declare variables.
WMSServer                       Server;
IWMSBroadcastPublishingPoint    BCPubPoint;
IWMSPublishingPoints            PubPoints;
IWMSPublishingPoint             PubPoint;
Decoder                         Dec = Encoding.UTF8.GetDecoder();
UCOMIStream                     oStream;
STATSTG                         StreamStats;
byte[]                          Bytes;
char[]                          Chars;
int                             iChars;

try {
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Retrieve the IWMSPublishingPoints object.
    PubPoints = Server.PublishingPoints;

    // Retrieve each publishing point and retrieve the
    // IWMSBroadcastPublishingPoint object.
    for (int i = 0; i < PubPoints.Count; i++)
    {
        PubPoint = PubPoints[i];

        if (PubPoint.Type == 
            WMS_PUBLISHING_POINT_TYPE.WMS_PUBLISHING_POINT_TYPE_BROADCAST)
        {
            BCPubPoint = (IWMSBroadcastPublishingPoint)PubPoint;

            // Retrieve the announcement file that clients can use
            // to connect to the publishing point.
            BCPubPoint.Announce();
            oStream = (UCOMIStream)BCPubPoint.AnnounceToNSCStream();

            oStream.Stat(out StreamStats, 0);

            Bytes = (byte[])Array.CreateInstance(typeof(byte),
                                                (int)StreamStats.cbSize);
            oStream.Read(Bytes, (int)StreamStats.cbSize, (IntPtr)null);
            iChars = Dec.GetCharCount(Bytes, 0, (int)StreamStats.cbSize);
            Chars = (char[])Array.CreateInstance(typeof(char), iChars);
            iChars = Dec.GetChars(Bytes, 0, (int)StreamStats.cbSize,
                                  Chars, 0);
            string strBuf = new string(Chars, 0, (int)StreamStats.cbSize);
            break;
        }
    }
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next