Share via


IWMSCacheProxyPlugin.PreStuff (C#)

banner art

Previous Next

IWMSCacheProxyPlugin.PreStuff (C#)

The PreStuff method fills a cache with content.

Syntax

  IWMSCachePlugin
  .PreStuff(
  string  strOriginURL, 
  string  strSourcePath, 
  int  lExpiration, 
 int  lBitRate, 
  int  lRemoteEventFlags
);

Parameters

strOriginURL

[in] string specifying 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.

strSourcePath

[in] string 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 first parameter is used.

lExpiration

[in] int containing the expiration value in seconds for the cached content. The default value is –1, which indicates that the content never expires.

lBitRate

[in] int containing 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] int containing the remote event flags, WMS_CACHE_REMOTE_EVENT_FLAGS, indicating 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

This method does not return a value.

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. A slower than real-time bit rate can be specified.

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

using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;

// Declare variables.
WMSServer                   Server;
IWMSCacheProxyPlugin        CacheProxyPlugin;
IWMSPlugins                 Plugins;

string                      strOriginURL;

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

    // Retrieve the IWMSPlugins object
    // containing cache proxy plug-ins.
    Plugins = Server.CacheProxy;

    // Retrieve the IWMSCacheProxyPlugin object.
    CacheProxyPlugin = (IWMSCacheProxyPlugin)Plugins[0];

    // Prestuff the content cache to decrease the relay
    // time to the client.
    strOriginURL = "https://distribution_server/welcome1.wmv";
    CacheProxyPlugin.PreStuff(strOriginURL, NULL, -1, 0, 0);
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

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

See Also

Previous Next