IWMSAdminArchiveSink::ExpandTemplate

banner art

Previous Next

IWMSAdminArchiveSink::ExpandTemplate

The ExpandTemplate method retrieves the expanded path of the tokenized template.

Syntax

  

Parameters

bstrTemplate

[in] BSTR containing the tokenized template.

pbstrExpandedPath

[out] Pointer to a BSTR containing the expanded path of the template.

Return Values

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

Return code Number Description
E_INVALIDARG 0x80070057 The bstrTemplate parameter or the pbstrExpandedPath parameter is NULL.

Remarks

A template path can contain environment variables and wildcard characters that are replaced with appropriate values when the file is created by the server. Valid wildcard characters used by Windows Media Services are identified in the following table.

  • Note   When the information denoted by the wildcard is not present on the system, the server will substitute an underscore character (_) for it. Also, because a playlist is considered a single presentation unit, time and date wildcards will expand to the same value for all entries in the playlist.
Wildcard character Description
<a> Abbreviated weekday name (three letters).
<A> Full weekday name.
<b> Abbreviated month name (three letters).
<B> Full month name.
<c> Date and time representation appropriate for the locale of the server generating the file.
<d> Day of the month in a two-digit format (01 - 31).
<H> Hour in a 24-hour, two-digit format (00 - 23).
<I> Hour in a 12-hour, two-digit format (01 - 12).
<j> Day of the year in a three-digit format (001 - 366).
<m> Month in a two-digit format (01 - 12).
<M> Minute in a two-digit format (00 - 59).
<N> A four-digit sequence that starts at zero and is incremented every time a new file is added. The counter is reset to zero when the rest of the file name (not including the four-digit sequence) changes in any way.
<P> The 12-hour format AM or PM indicator of the server generating the file.
<S> Seconds in a two-digit format (00 - 59).
<T> The name of the server generating the file.
<U> Week of the year in a two-digit format (00 - 53), with Sunday as the first day of the week.
<V> The name of the publishing point from which content is being archived. If content is being archived from the default publishing point, "[Default]" is inserted in the archive file name. If the publishing point name contains a forward slash (/), the forward slash is replaced with an underscore (_). If the publishing point is renamed, the archive file automatically cycles to reflect the new name.
<w> Day of the week as a decimal number in 1-digit format (0 - 6; Sunday is 0).
<W> Week of the year in a two-digit format (00 - 53), with Monday as the first day of the week.
<x> Date representation for the current locale of the server generating the log file.
<X> Time representation for the current locale of the server generating the log file.
<y> Year without the century in a two-digit format (00 - 99).
<Y> Year with the century in a four-digit format (for example, 1999, 2003).
<z> or <Z> Time zone name or abbreviation. There are no characters if the time zone is unknown.

The following wildcard characters are available for use with archive files only.

Wildcard character Description
<E> Expands to an integer value that starts at one (1) and is incremented every time the archive plug-in creates a new digital media file.
<F> Expands to match the role attribute of a media element in a playlist file. If the media element being archived is not in a playlist file or does not contain a role attribute, this will be replaced by an underscore.
<L> Expands to the last path segment specified by the src attribute of a media element in a playlist file. However, if the media element contains a mediaName attribute, the value of the mediaName attribute will be used instead. The last path segment in the URL includes all of the characters after the last forward slash (/) or backward slash (\). If the last path segment contains a colon (:), the colon and all subsequent characters are removed. For example, if the src attribute references an individual file such as C:\WMPub\WMRoot\Welcome1.asf, the L wildcard character returns the name of the file, "Welcome1.asf". If the src attribute references a remote publishing point, the L wildcard character returns the name of the source file on the origin server. If the src attribute references https://encoder1 in a push or pull scenario, the L wildcard character returns a value of "_".

Example Code

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.

// To access system plug-in interfaces, the
// entire 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        bstrFile;
CComBSTR        bstrExpanded;

// 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;
bstrName = "NewPubPoint";
bstrFile = "https://encoder:port";
hr = pPubPoints->Add(bstrName, WMS_PUBLISHING_POINT_BROADCAST,
                     bstrFile, &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;

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

// Retrieve a pointer to the IWMSPlugin interface
// of the plug-in to be configured.
varIndex = "WMS Archive Data Writer";
hr = pPlugins->get_Item(varIndex, &pPlugin);
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;

// Retrieve the path to content currently being archived.
hr = pAdminArchiveSink->get_ActivePath(&bstrFile);
if (FAILED(hr)) goto EXIT;

// Expand the template path for archived content.
hr = pAdminArchiveSink->get_Path(&bstrFile);
if (FAILED(hr)) goto EXIT;
hr = pAdminArchiveSink->ExpandTemplate(bstrFile, &bstrExpanded);
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