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 |
IWMSAnnouncementStreamFormats::Add
The Add method adds a URL or a file path to the IWMSAnnouncementStreamFormats collection.
- Note This method is available only on Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition, and Windows Server 2008.
Syntax
HRESULT Add( VARIANT varFileName );
Parameters
varFileName
[in] VARIANT containing the URL or file path. Valid file names include those with an .asd extension.
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 | bstrFileName is an invalid argument. This can be returned if bstrFileName points to a directory or a playlist file. |
| ERROR_FILE_NOT_FOUND | 0x00000002 | The data source plug-in was not able to find the indicated file. This error is returned by the WMS File Data Source plug-in, but other plug-ins could return different error codes. |
| ERROR_PATH_NOT_FOUND | 0x00000003 | The path indicated by bstrFileName was not found. |
| NS_E_SOURCE_PLUGIN_NOT_FOUND | 0xC00D157EL | The server was not able to find an enabled data source plug-in to access the indicated file. |
Remarks
The Add method also parses the associated media file to extract stream format information. The IWMSBroadcastPublishingPoint::Announce method then updates the server configuration with that information. The IWMSBroadcastPublishingPoint::AnnounceToNSCFile method retrieves the stream format information from the server configuration and uses it to create a file that a client can use to receive and render a multicast broadcast.
If a file path is added, it must identify a Windows Media file, a multicast configuration (.nsc) file, or a stream format file from Windows Media Encoder. If a URL is added, it must identify a single source such as a live Windows Media Encoder stream or a Windows Media file on an upstream server. However, it is not recommended that you specify a server-side playlist. The format added to the collection will be that represented by only the first entry in the playlist.
Example Code
#include <windows.h>
#include <atlbase.h> // Includes CComBSTR and CComVariant.
#include "wmsserver.h"
// Declare variables and interfaces.
IWMSServer *pServer;
IWMSPublishingPoints *pPubPoints;
IWMSPublishingPoint *pPubPoint;
IWMSBroadcastPublishingPoint *pBCPubPoint;
IWMSAnnouncementStreamFormats *pAnnounceStreamFormats;
HRESULT hr;
CComVariant varIndex;
CComVariant varFile;
long lCount;
// 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 number of publishing points.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
hr = pPubPoints->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;
// Retrieve each publishing point and query the
// IWMSBroadcastPublishingPoint interface.
for (long x = 0; x < lCount; x++)
{
varIndex = x;
hr = pPubPoints->get_Item(varIndex, &pPubPoint);
if (FAILED(hr)) goto EXIT;
hr = pPubPoint->QueryInterface(IID_IWMSBroadcastPublishingPoint,
(void **)&pBCPubPoint);
if (FAILED(hr)) goto EXIT;
// Release temporary COM objects.
pPubPoint->Release();
if (SUCCEEDED(hr))
break;
}
// Retrieve a pointer to the IWMSAnnouncementStreamFormats
// interface.
hr = pBCPubPoint->get_AnnouncementStreamFormats(&pAnnounceStreamFormats);
if (FAILED(hr)) goto EXIT;
// Add a file to the IWMSAnnoucementStreamFormats
// interface for multicast broadcasting.
varFile = "file://c:\\wmpub\\wmroot\\welcome2.asd";
hr = pAnnounceStreamFormats->Add(varFile);
if (FAILED(hr)) goto EXIT;
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.
Requirements
Header: wmsserver.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003 family, Windows Server 2008 family.
See Also
- IWMSAnnouncementStreamFormats Interface
- IWMSAnnouncementStreamFormats::Remove
- IWMSBroadcastPublishingPoint::Announce
- IWMSBroadcastPublishingPoint::AnnounceToNSCFile
| Previous | Next |