Configuring an On-Demand Publishing Point
On-demand publishing points allow each client to request different content by specifying a file or playlist, a directory, or by using wildcard characters. On-demand publishing points let clients decide what content to stream and when to stream it; the client can start and stop the streaming at will. The IWMSOnDemandPublishingPoint object is used to create an on-demand publishing point.
The following examples illustrate how to create and configure an on-demand publishing point.
Visual Basic .NET Example
Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices
' Declare variables.
Dim Server As WMSServer
Dim ODPubPoint As IWMSOnDemandPublishingPoint
Try
' Create the WMSServer object.
Server = New WMSServer()
' Add a new on-demand publishing point.
ODPubPoint = Server.PublishingPoints.Add("NewPubPoint", _
WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_ON_DEMAND, _
"c:\wmpub\wmroot\")
' Set the publishing point to enable content to be
' cached before sending it to a client.
ODPubPoint.AllowContentCaching = True
' Set the publishing point to prevent client access
' to files by using wildcard characters (for example, *.asf).
ODPubPoint.EnableClientWildcardDirectoryAccess = False
' Set the publishing point to prevent clients from
' downloading and storing server content locally.
ODPubPoint.EnableDownload = False
' Set the client content download rate to unlimited.
ODPubPoint.DownloadBandwidth = 0
' Export the publishing point configuration to an
' XML file.
ODPubPoint.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;
WMSServer Server;
IWMSOnDemandPublishingPoint ODPubPoint;
try
{
// Create the WMSServer object.
Server = new WMSServerClass();
// Add a new on-demand publishing point.
ODPubPoint = (IWMSOnDemandPublishingPoint)Server.PublishingPoints.Add("NewPubPoint",
WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_ON_DEMAND,
"c:\\wmpub\\wmroot\\");
// Set the publishing point to enable content to be
// cached before sending it to a client.
ODPubPoint.AllowContentCaching = true;
// Set the publishing point to prevent client access
// to files by using wildcard characters (for example, *.asf).
ODPubPoint.EnableClientWildcardDirectoryAccess = false;
// Set the publishing point to prevent clients from
// downloading and storing server content locally.
ODPubPoint.EnableDownload = false;
// Set the client content download rate to unlimited.
ODPubPoint.DownloadBandwidth = 0;
// Export the publishing point configuration to an
// XML file.
ODPubPoint.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;
IWMSOnDemandPublishingPoint *pODPubPoint;
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 on-demand publishing point.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
bstrName = "NewPubPoint";
bstrFile = "c:\\wmpub\\wmroot\\";
hr = pPubPoints->Add(bstrName, WMS_PUBLISHING_POINT_ON_DEMAND,
bstrFile, &pPubPoint);
if (FAILED(hr)) goto EXIT;
// Query the IWMSOnDemandPublishingPoint interface from
// the newly created publishing point.
hr = pPubPoint->QueryInterface(IID_IWMSOnDemandPublishingPoint,
(void **)&pODPubPoint);
if (FAILED(hr)) goto EXIT;
// Set the publishing point to allow content to be
// cached before sending it to a client.
hr = pODPubPoint->put_AllowContentCaching(VARIANT_TRUE);
if (FAILED(hr)) goto EXIT;
// Set the publishing point to prevent client access
// to files by using wildcard characters(for example, *.asf).
hr = pODPubPoint->put_EnableClientWildcardDirectoryAccess(VARIANT_FALSE);
if (FAILED(hr)) goto EXIT;
// Set the publishing point to prevent clients from
// downloading and storing server content locally.
hr = pODPubPoint->put_EnableDownload(VARIANT_FALSE);
if (FAILED(hr)) goto EXIT;
// Set the client content download rate to unlimited.
hr = pODPubPoint->put_DownloadBandwidth(0);
if (FAILED(hr)) goto EXIT;
// Export the publishing point configuration to an
// XML file.
bstrFile = "c:\\wmpub\\wmroot\\pubpoint.xml";
hr = pODPubPoint->ExportXML(bstrFile);
if (FAILED(hr)) goto EXIT;
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.
See Also (General)
See Also (Visual Basic .NET)
IWMSOnDemandPublishingPointIWMSOnDemandPublishingPoint Object (Visual Basic .NET)
IWMSPublishingPointIWMSPublishingPoint Object (Visual Basic .NET)
See Also (C#)
IWMSOnDemandPublishingPointIWMSOnDemandPublishingPoint Object (C#)
IWMSPublishingPointIWMSPublishingPoint Object (C#)
See Also (C++)
IWMSOnDemandPublishingPointIWMSOnDemandPublishingPoint Interface
IWMSPublishingPointIWMSPublishingPoint Interface