Share via


IWMSAdminArchiveSink::StartRecord

banner art

Previous Next

IWMSAdminArchiveSink::StartRecord

The StartRecord method starts the archiving process.

Syntax

  HRESULT StartRecord();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_UNEXPECTED 0x8000FFFF The WMS Archive Data Writer plug-in cannot be found.

Remarks

If the publishing point is stopped, the StartRecord method does not start it. You must therefore call IWMSBroadcastPublishingPoint::Start before calling StartRecord. Alternately, you can call IWMSBroadcastPublishingPoint::StartArchive to start both the publishing point and the archiving process.

The server does not raise a WMS_Publishing_Point_Event Class event when you call the StartRecord method.

Example Code

#include <windows.h>
#include <atlbase.h>

// To access system plug-in interfaces, the
// type library must be imported as shown.
#import "WMSServerTypeLib.dll" no_namespace named_guids \
                               raw_interfaces_only

// Declare variables and interfaces.
IWMSServer                    *pServer;
IWMSPublishingPoints          *pPubPoints;
IWMSPublishingPoint           *pPubPoint;
IWMSBroadcastPublishingPoint  *pBCPubPoint;
IWMSPlugins                   *pPlugins;
IWMSPlugin                    *pPlugin;
IDispatch                     *pDispatch;
IWMSAdminArchiveSink          *pAdminArchiveSink;

HRESULT         hr;
CComVariant     varIndex;
CComBSTR        bstrName;
CComBSTR        bstrPath;
CComBSTR        bstrTemplate;
VARIANT_BOOL    bEnabled = VARIANT_FALSE;

// 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 retrieve the sample broadcast
// publishing point.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
varIndex = "Sample_Broadcast";
hr = pPubPoints->get_Item(varIndex, &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;

// Stop the publishing point.
hr = pBCPubPoint->Stop();
if (FAILED(hr)) goto EXIT;

// Specify the publishing point path.
bstrPath = "C:\\WMPub\\WMRoot\\Serverside_Playlist.wsx";
hr = pBCPubPoint->put_Path(bstrPath);
if (FAILED(hr)) goto EXIT;

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

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

// Make sure the plug-in is enabled.
hr = pPlugin->get_Enabled(&bEnabled);
if (FAILED(hr)) goto EXIT;
if (! bEnabled)
{
    hr = pPlugin->put_Enabled(VARIANT_TRUE);
    if (FAILED(hr)) goto EXIT;
}

// Retrieve a pointer to the custom interface
// of the plug-in.
hr = pPlugin->get_CustomInterface(&pDispatch);
if (FAILED(hr)) goto EXIT;

// Query the specific administration interface
// for the plug-in.
hr = pDispatch->QueryInterface(IID_IWMSAdminArchiveSink,
                              (void **)&pAdminArchiveSink);
if (FAILED(hr)) goto EXIT;

// Turn off the automatic start property.
hr = pAdminArchiveSink->put_AutoStart(VARIANT_FALSE);
if (FAILED(hr)) goto EXIT;

// Specify the archive path template.
bstrTemplate = "%SystemDrive%\\WMPub\\WMArchive\\<V>\\Archive_<Y><m><d>.wmv";
hr = pAdminArchiveSink->put_Path(bstrTemplate);
if (FAILED(hr)) goto EXIT;

// Restart the publishing point and begin archiving.
hr = pBCPubPoint->Start();
if (SUCCEEDED(hr))
{
    hr = pAdminArchiveSink->StartRecord();
    if (FAILED(hr)) goto EXIT;
}

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

Requirements

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next