Configuring a Broadcast Publishing Point
Previous | Next |
Configuring a Broadcast Publishing Point
Broadcast publishing points enable you to deliver specific stream content to clients through the use of playlist files or live encoding. By using the IWMSBroadcastPublishingPoint object, you can configure publishing points to deliver content from various sources, including remote servers and local files.
The following table shows examples of valid paths to various types of publishing point content.
Content source | Example path |
Media file | file://C:\wmpub\wmroot\movie.wmv
file://\\server\directory\movie.wmv |
Playlist file | file://C:\wmpub\wmroot\playlist.wsx
file://\\server\directory\playlist.wsx |
Stream from an encoder | https://encoder:port |
Stream pushed to an encoder | push:* |
Stream from a publishing point on a local or remote server | rtsp://server/pubpoint
https://server/pubpoint |
Stream from a station or publishing point on a version 4.1 server | https://server/stationname
https://server/pubpoint |
Media file or playlist on a local or remote server | rtsp://server/pubpoint/movie.wmv |
Playlist file from a Web server | https://server/playlist.asp
https://server/playlist.wsx |
Directory of files | file://C:\wmpub\wmroot\directory |
The following code examples illustrate how to create and configure a broadcast publishing point.
Visual Basic .NET Example
Imports Microsoft.WindowsMediaServices.Interop Imports System.Runtime.InteropServices ' Declare variables. Dim Server As WMSServer Dim BCPubPoint As IWMSBroadcastPublishingPoint Dim Playlist As IWMSPlaylist Dim Plugins As IWMSPlugins Dim Plugin As IWMSPlugin Dim lCount As Long Try ' Create the WMSServer object. Server = New WMSServer() ' Add a new broadcast publishing point. BCPubPoint = Server.PublishingPoints.Add("NewPubPoint", _ WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_BROADCAST, _ "rtsp://server/pubpoint/movie.wmv") ' Set the publishing point to start broadcasting when ' the first client connects. BCPubPoint.AllowClientToStartAndStop = True ' Set the publishing point to allow splitting the stream. BCPubPoint.AllowStreamSplitting = True BCPubPoint.AnnouncementStreamFormats.Add("c:\wmpub\wmroot\content_clip1.wmv") ' Retrieve an IWMSPlugins object containing ' broadcast data sink plug-in information. Plugins = BCPubPoint.BroadcastDataSinks ' Prepare the publishing point for announcement and ' create an NSC file to be used for client connection. BCPubPoint.Announce() BCPubPoint.AnnounceToNSCFile("c:\wmpub\wmroot\pubpoint.nsc") ' If the publishing point is currently stopped, start ' it and retrieve the shared playlist file. If BCPubPoint.BroadcastStatus = WMS_BROADCAST_PUBLISHING_POINT_STATUS.WMS_BROADCAST_PUBLISHING_POINT_STOPPED Then BCPubPoint.Start() Playlist = BCPubPoint.SharedPlaylist ' If the publishing point is currently running, retrieve the ' amount of time it has been broadcasting and then stop it. ElseIf BCPubPoint.BroadcastStatus & WMS_BROADCAST_PUBLISHING_POINT_STATUS.WMS_BROADCAST_PUBLISHING_POINT_STARTED Then lCount = BCPubPoint.UpTime BCPubPoint.Stop() End If ' Set the buffer setting to minimize propagation latency. BCPubPoint.BufferSetting = WMS_BUFFER_SETTING.WMS_BUFFER_SETTING_MINIMIZE_PROPAGATION_LATENCY ' Export the publishing point configuration to an ' XML file. BCPubPoint.ExportXML("c:\wmpub\wmroot\pubpoint.xml") Catch errCom As COMException ' TODO: Handle COM exceptions. Catch err As Exception ' TODO: Exception handler goes here. Finally ' TODO: Clean-up code goes here. End Try
C# Example
using Microsoft.WindowsMediaServices.Interop; using System.Runtime.InteropServices; //Declare variables WMSServer Server; IWMSBroadcastPublishingPoint BCPubPoint; IWMSPlaylist Playlist; IWMSPlugins Plugins; IWMSPlugin plugin; long lCount; try { // Create the WMSServer object. Server = new WMSServerClass(); // Add a new broadcast publishing point. BCPubPoint = (IWMSBroadcastPublishingPoint)Server.PublishingPoints.Add("NewPubPoint", WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_BROADCAST, "rtsp://server/pubpoint/movie.wmv"); // Set the publishing point to start broadcasting when // the first client connects. BCPubPoint.AllowClientToStartAndStop = true; // Set the publishing point to allow splitting the stream. BCPubPoint.AllowStreamSplitting = true; BCPubPoint.AnnouncementStreamFormats.Add("c:\\wmpub\\wmroot\\content_clip1.wmv"); // Retrieve an IWMSPlugins object containing // broadcast data sink plug-in information. Plugins = BCPubPoint.BroadcastDataSinks; // If the publishing point is currently stopped, start // it and retrieve the shared playlist file. if (BCPubPoint.BroadcastStatus == WMS_BROADCAST_PUBLISHING_POINT_STATUS.WMS_BROADCAST_PUBLISHING_POINT_STOPPED) { BCPubPoint.Start(); Playlist = BCPubPoint.SharedPlaylist; } // If the publishing point is currently running, retrieve the // amount of time it has been broadcasting and then stop it. else if ((BCPubPoint.BroadcastStatus & WMS_BROADCAST_PUBLISHING_POINT_STATUS.WMS_BROADCAST_PUBLISHING_POINT_STARTED) != 0) { lCount = BCPubPoint.UpTime; BCPubPoint.Stop(); } // Set the buffer setting to minimize propagation latency. BCPubPoint.BufferSetting = WMS_BUFFER_SETTING.WMS_BUFFER_SETTING_MINIMIZE_PROPAGATION_LATENCY; // Export the publishing point configuration to an // XML file. BCPubPoint.ExportXML("c:\\wmpub\\wmroot\\pubpoint.xml"); } catch (COMException comExc) { // TODO: Handle COM exceptions. } catch (Exception exc) { // TODO: Exception handler goes here. } finally { // TODO: Clean-up code goes here. }
C++ Example
#include <windows.h> #include <atlbase.h> // Includes CComBSTR. #include "wmsserver.h" // Declare variables and interfaces. IWMSServer *pServer; IWMSPublishingPoints *pPubPoints; IWMSPublishingPoint *pPubPoint; IWMSBroadcastPublishingPoint *pBCPubPoint; IWMSAnnouncementStreamFormats *pAnnounceStreamFormats; IWMSPlaylist *pPlaylist; IWMSPlugins *pPlugins; HRESULT hr; CComBSTR bstrFile; CComBSTR bstrName; long lCount; // Initialize the COM library and retrieve a pointer // to an IWMSServer interface. hr = CoInitialize(NULL); hr = CoCreateInstance(CLSID_WMSServer, NULL, CLSCTX_ALL, IID_IWMSServer, (void **)&pServer); if (FAILED(hr)) goto EXIT; // Retrieve a pointer to the IWMSPublishingPoints // interface and add a new broadcast publishing point. hr = pServer->get_PublishingPoints(&pPubPoints); if (FAILED(hr)) goto EXIT; bstrName = "NewPubPoint"; bstrFile = "https://encoder:port"; hr = pPubPoints->Add(bstrName, WMS_PUBLISHING_POINT_BROADCAST, bstrFile, &pPubPoint); if (FAILED(hr)) goto EXIT; // Query the IWMSBroadcastPublishingPoint interface from // the newly created publishing point. hr = pPubPoint->QueryInterface(IID_IWMSBroadcastPublishingPoint, (void **)&pBCPubPoint); if (FAILED(hr)) goto EXIT; // Retrieve a pointer to the IWMSAnnouncementStreamFormats // interface. hr = pBCPubPoint->get_AnnouncementStreamFormats(&pAnnounceStreamFormats); if (FAILED(hr)) goto EXIT; // Set the publishing point to start broadcasting when // the first client connects. hr = pBCPubPoint->put_AllowClientToStartAndStop(VARIANT_TRUE); if (FAILED(hr)) goto EXIT; // Set the publishing point to allow splitting the stream. hr = pBCPubPoint->put_AllowStreamSplitting(VARIANT_TRUE); if (FAILED(hr)) goto EXIT; // Retrieve the current status of the publishing point. // The status is reported as the result of a bitwise OR // of any of the designated values. WMS_BROADCAST_PUBLISHING_POINT_STATUS ppsStatus; hr = pBCPubPoint->get_BroadcastStatus(&ppsStatus); if (FAILED(hr)) goto EXIT; // If the publishing point is currently stopped, start // it and retrieve the shared playlist file. if (ppsStatus == WMS_BROADCAST_PUBLISHING_POINT_STOPPED) { hr = pBCPubPoint->Start(); if (FAILED(hr)) goto EXIT; hr = pBCPubPoint->get_SharedPlaylist(&pPlaylist); if (FAILED(hr)) goto EXIT; } // If the publishing point is currently running, retrieve the // amount of time it has been broadcasting and then stop it. if (ppsStatus & WMS_BROADCAST_PUBLISHING_POINT_STARTED) { hr = pBCPubPoint->get_UpTime(&lCount); if (FAILED(hr)) goto EXIT; hr = pBCPubPoint->Stop(); if (FAILED(hr)) goto EXIT; } // Set the buffer setting to minimize propagation latency. hr = pBCPubPoint->put_BufferSetting( WMS_BUFFER_SETTING_MINIMIZE_PROPAGATION_LATENCY); if (FAILED(hr)) goto EXIT; // Retrieve a pointer to an IWMSPlugins interface // containing broadcast data sink plug-in information. hr = pBCPubPoint->get_BroadcastDataSinks(&pPlugins); if (FAILED(hr)) goto EXIT; // Export the publishing point configuration to an // XML file. bstrFile = "c:\\wmpub\\wmroot\\pubpoint.xml"; hr = pBCPubPoint->ExportXML(bstrFile); if (FAILED(hr)) goto EXIT; // Prepare the publishing point for announcement and // create an NSC file to be used for client connection. hr = pBCPubPoint->Announce(); if (FAILED(hr)) goto EXIT; bstrFile = "c:\\wmpub\\wmroot\\pubpoint.nsc"; hr = pBCPubPoint->AnnounceToNSCFile(bstrFile, VARIANT_TRUE); if (FAILED(hr)) goto EXIT; EXIT: // TODO: Release temporary COM objects and uninitialize COM.
See Also (General)
See Also (Visual Basic .NET)
- IWMSBroadcastPublishingPoint Object (Visual Basic .NET)
- IWMSPublishingPoint Object (Visual Basic .NET)
See Also (C#)
See Also (C++)
Previous | Next |