Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.gif)
| Previous | Next |
Receiving a Live Stream
A Windows Media server can be configured to stream live content directly from an encoder source. The encoded content could be anything ranging from a live concert to a direct screen capture of the current computer for tutorial purposes. The live stream can also be archived concurrently with the broadcast to allow for easy rebroadcast. For a broadcast publishing point to stream a live encoding session, the content path must be set to either 'push' or 'pull' from an encoder source.
The following table shows examples of valid paths to live content.
| Content source | Example path |
| Stream pulled from an encoder | https://encoder:port |
| Stream pushed to an encoder | push:* |
The following examples illustrate how to set up a new broadcast publishing point for a live stream.
Visual Basic .NET Example
Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices
' Declare variables.
Dim Server As WMSServer
Dim BCPubPoint As IWMSBroadcastPublishingPoint
Dim Plugin As IWMSPlugin
Try
' Create the WMSServer object.
Server = New WMSServer()
' Add a new broadcast publishing point and set the
' content path to the local encoder.
BCPubPoint = Server.PublishingPoints.Add("LiveBroadcast", _
WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_BROADCAST, _
"https://encoder:port")
' Enable the archive plug-in prior to archiving.
Plugin = BCPubPoint.BroadcastDataSinks.Item("WMS Archive Data Writer")
Plugin.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;
WMSServer Server;
IWMSBroadcastPublishingPoint BCPubPoint;
IWMSPlugin Plugin;
try
{
// Create the WMSServer object.
Server = new WMSServerClass();
// Add a new broadcast publishing point and set the
// content path to the local encoder.
BCPubPoint = (IWMSBroadcastPublishingPoint)Server.PublishingPoints.Add("LiveBroadcast",
WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_BROADCAST,
"https://server_name:8080");
// Enable the archive plug-in prior to archiving.
Plugin = BCPubPoint.BroadcastDataSinks["WMS Archive Data Writer"];
Plugin.Enabled = true;
// Initialize the publishing point and start broadcasting.
BCPubPoint.Start();
// Start archiving the broadcast data locally for rebroadcast.
BCPubPoint.StartArchive();
}
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;
HRESULT hr;
CComBSTR bstrFile;
CComBSTR bstrName;
// 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;
// Set the content path to point to the local encoder.
bstrFile = "Push:*";
bstrName = "LiveBroadcast";
hr = pPubPoints->Add(bstrName, WMS_PUBLISHING_POINT_BROADCAST,
bstrFile, &pPubPoint);
if (FAILED(hr)) goto EXIT;
// TODO: Start your Windows Media Encoder application.
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.
See Also
- IWMSBroadcastPublishingPoint Interface
- IWMSBroadcastPublishingPoint Object (C#)
- IWMSBroadcastPublishingPoint Object (Visual Basic .NET)
- Programming the Server Object Model
| Previous | Next |