Share via


Starting Your New Broadcast Publishing Point

After everything has been configured, you are ready to begin publishing your content. If you are broadcasting live content, you may even want to archive your stream for rebroadcast at a later date. The following examples show you how to start your new broadcast publishing point and begin archiving your streamed content.

Visual Basic .NET Example

Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices

' Declare variables.
Dim Server As WMSServer
Dim BCPubPoint As IWMSBroadcastPublishingPoint

Try
    ' Create the WMSServer object.
    Server = New WMSServer()

    ' Retrieve a broadcast publishing point.
    BCPubPoint = Server.PublishingPoints.item ("NewPubPointVI")

    ' Enable the archiving plug-in.
    BCPubPoint.BroadcastDataSinks.Item("WMS Archive Data Writer").Enabled = True

    ' Initialize the publishing point and start broadcasting.
    BCPubPoint.Start()

    ' Start archiving the broadcast data locally for rebroadcast.
    BCPubPoint.StartArchive()

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;

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

    // Retrieve a broadcast publishing point.
    BCPubPoint = 
(IWMSBroadcastPublishingPoint)Server.PublishingPoints["NewPubPointIV"];

    // Retrieve the plug-in to be configured.
    for (int i = 0; i< BCPubPoint.BroadcastDataSinks.Count; i++)
    {
        if ("WMS Archive Data Writer" == 
                                BCPubPoint.BroadcastDataSinks[i].Name)
        {
            BCPubPoint.BroadcastDataSinks[i].Enabled = true;

            // Initialize the publishing point and start broadcasting.
            BCPubPoint.Start();

            // Start archiving the boradcast data locally for rebroadcast.
            BCPubPoint.StartArchive();
            break;
        }
    }
}
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;
IWMSPlugins                   *pPlugins;
IWMSPlugin                    *pPlugin;

HRESULT                       hr;
CComVariant                   varIndex;
CComVariant                   varName;

// 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.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to a publishing point.
varName = L"NewPubPoint";
hr = pPubPoints->get_Item(varName, &pPubPoint);
if (FAILED(hr)) goto EXIT;

// Query the IWMSBroadcastPublishingPoint interface from
// the publishing point.
hr = pPubPoint->QueryInterface(IID_IWMSBroadcastPublishingPoint,
                              (void **)&pBCPubPoint);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the collection of
// data sink plug-ins.
hr = pBCPubPoint->get_BroadcastDataSinks(&pPlugins);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the archiving plug-in.
varIndex = "WMS Archive Data Writer";
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;

// Enable the archiving plug-in.
hr = pPlugin->put_Enabled(VARIANT_TRUE);
if (FAILED(hr)) goto EXIT;

// Initialize the publishing point and start broadcasting.
hr = pBCPubPoint->Start();
if (FAILED(hr)) goto EXIT;

// Start archiving the broadcast data locally for rebroadcast.
hr = pBCPubPoint->StartArchive();
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Reference

IWMSBroadcastPublishingPoint Interface

IWMSBroadcastPublishingPoint Object (C#)

IWMSBroadcastPublishingPoint Object (Visual Basic .NET)

Concepts

Publishing Broadcast Content