IWMSCacheProxyPlugin::PreStuff
Previous | Next |
IWMSCacheProxyPlugin::PreStuff
The PreStuff method fills a cache with content.
Syntax
HRESULT PreStuff( BSTROriginURL,BSTRSourcePath,longlExpiration,longlBandwidth,longlRemoteEventFlags );
Parameters
OriginURL
[in] BSTR that specifies the URL that the client must use to request the content. The cache manager does not require a scheme, such as RTSP, to be specified in the URL. If one is specified, it is ignored. For the cache manager, you need to specify only the server name and the path to the content. Depending on the implementation, a cache plug-in may or may not require a scheme.
SourcePath
[in] BSTR that contains the path to the content. Valid examples are c:\movies\movies.wmv and \\servername\directory\movie.wmv. This is an optional parameter. If no value is specified, the URL in the first parameter is used.
lExpiration
[in] long that contains the expiration value in seconds for the cached content. The default value is –1, which indicates that the content never expires.
lBandwidth
[in] long that contains the bit rate at which the file should be downloaded. The default value is zero, which indicates that content should be downloaded in real time. A value of 0xFFFFFFFF indicates that content should be downloaded as fast as possible.
lRemoteEventFlags
[in] long containing the remote event flags, WMS_CACHE_REMOTE_EVENT_FLAGS, that indicates the remote cache events that should be propagated to the origin server. If these flags are set by this argument and content is prestuffed from a Windows Media server, the values obtained from the Windows Media server will be used. The default value is zero.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
If you use the PreStuff method to fill a cache, a proxy server can start streaming content immediately rather than first downloading it. This minimizes bandwidth. It is an asynchronous call. You can specify a bit rate that is slower than real-time.
For internal events, WMS_EVENT_CACHE_PRESTUFF_COMPLETE is sent on completion of the download to the cache. For WMI events, the PreStuff Complete sub event in the WMS_Cache_Event class is sent on completion of the download.
Example Code
#include <windows.h> #include <atlbase.h> // Includes CComVariant. #include "wmsserver.h" // Declare variables and interfaces. IWMSServer *pServer; IWMSPlugins *pPlugins; IWMSPlugin *pPlugin; IWMSCacheProxyPlugin *pCacheProxyPlugin; HRESULT hr; CComVariant varIndex; 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 an IWMSPlugins interface // that contains cache proxy plug-ins. hr = pServer->get_CacheProxy(&pPlugins); if (FAILED(hr)) goto EXIT; hr = pPlugins->get_Count(&lCount); if (FAILED(hr)) goto EXIT; // Retrieve the IWMSPlugin interface for the // first cache proxy plug-in. varIndex = 0; hr = pPlugins->get_Item(varIndex, &pPlugin); if (FAILED(hr)) goto EXIT; // Retrieve a pointer to the IWMSCacheProxyPlugin interface. hr = pPlugin->QueryInterface(IID_IWMSCacheProxyPlugin, (void **)&pCacheProxyPlugin); if (FAILED(hr)) goto EXIT; // Enable the cache proxy plug-in. hr = pCacheProxyPlugin ->put_Enabled(VARIANT_TRUE); if (FAILED(hr)) goto EXIT; // Prestuff the content cache to decrease the relay // time to the client. bstrOriginURL = SysAllocString(L"https://distribution_server/welcome2.wmv"); hr = pCacheProxyPlugin->PreStuff(bstrOriginURL); 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
Previous | Next |