Partager via


Splitting a Stream

Stream splitting allows content from a broadcast publishing point to be distributed from a cache proxy server to multiple clients. When stream splitting is enabled, a cache proxy server can make one connection to the origin server to request content and then copy the content to multiple client connections. If stream splitting is disabled however, each client connection requires a separate connection from the cache proxy server to the origin server. Because stream splitting requires fewer direct connections to the origin server, a large amount of bandwidth can be conserved by enabling this feature.

The following examples illustrate how to enable stream splitting on a broadcast publishing point.

Visual Basic .NET Example

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

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

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

    ' Create the IWMSPublishingPoints object.
    PubPoints = Server.PublishingPoints

    ' Retrieve the publishing point.  
    BCPubPoint = PubPoints.Item("My Broadcast PubPoint")

    ' Set the publishing point to allow stream splitting.
    BCPubPoint.AllowStreamSplitting = True

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;
int i;

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

    // Retrieve the Broadcast Publishing Point
    for (i=0; i< Server.PublishingPoints.Count; i++)
    {
        if ("My Broadcast PubPoint" == Server.PublishingPoints[i].Name)
        {
            BCPubPoint = (IWMSBroadcastPublishingPoint)Server.PublishingPoints[i];

           // Set the publishing point to allow stream splitting.
           BCPubPoint.AllowStreamSplitting = true;
           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 CComVariant.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer                    *pServer;
IWMSPublishingPoints          *pPubPoints;
IWMSPublishingPoint           *pPubPoint;
IWMSBroadcastPublishingPoint  *pBCPubPoint;

HRESULT         hr;
CComVariant     varIndex;

// 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 the publishing point and query the
// IWMSBroadcastPublishingPoint interface.
varIndex = "My Broadcast PubPoint";
hr = pPubPoints->get_Item(varIndex, &pPubPoint);
if (FAILED(hr)) goto EXIT;
hr = pPubPoint->QueryInterface(IID_IWMSBroadcastPublishingPoint,
                              (void **)&pBCPubPoint);
if (FAILED(hr)) goto EXIT;

// Set the publishing point to allow stream splitting.
hr = pBCPubPoint->put_AllowStreamSplitting(VARIANT_TRUE);
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

Programming the Server Object Model