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.
The OnGetContentInformation method is called by the server to respond when a cache plug-in calls IWMSCacheProxyServer::GetContentInformation.
void IWMSCacheProxyServerCallback.OnGetContentInformation(
int lHr,
IWMSContext pContentInfo,
object varContext
);
Arguments
[in] int indicating whether the call to IWMSCacheProxyServer.GetContentInformation succeeded. |
|
[in] IWMSContextIWMSContext Object (C#) containing a Cache Content Information Context. The context includes a variable named WMS_CACHE_CONTENT_INFORMATION_CONTENT_TYPE, which can be zero to indicate on-demand content, or one of the values in the following table, or a bitwise OR of both values. |
Value |
Description |
|---|---|
WMS_CACHE_CONTENT_TYPE_BROADCAST |
The content is a broadcast. |
WMS_CACHE_CONTENT_TYPE_PLAYLIST |
The content is a playlist. |
[in] object containing a value defined by the plug-in when it called IWMSCacheProxyServer.GetContentInformation. For example, your plug-in can use this parameter to persist state information. The server does not alter this value and passes it back when calling OnGetContentInformation. |
Return Value
This method does not return a value. To report an error, the plug-in can throw a COMException object to the server. If the plug-in uses the IWMSEventLogIWMSEventLog Object (C#) to log error information, it is recommended that it throw NS_E_PLUGIN_ERROR_REPORTED (0xC00D157D). Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog object to send custom error information to the Windows Event Viewer, throwing NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about plug-in error information, see Identifying Plug-in Errors.
Remarks
Cache proxy plug-ins generally call GetContentInformation when performing any of the following operations:
Rolling over to a different protocol
Establishing a cache-miss policy
Processing a prestuff request
In each case, the plug-in must get more information about the content before it can proceed. For example, to establish a cache-miss policy, the plug-in must determine whether the content is a broadcast, a playlist, or on demand. Also, before prestuffing content, it must determine whether the content can be cached.
Example
using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
void IWMSCacheProxyServerCallback.OnGetContentInformation(
int lHr,
IWMSContext pContentInfo,
object varContext
)
{
try
{
int nFlag=0;
bool bAddCacheItem = false;
int nRetHr = lHr;
// Retrieve the user-defined ContentInfo object from the
// varContext parameter.
ContentInfo ci = (ContentInfo)varContext;
// If this function is called from AddCacheItem(), lExpiration
// will not be zero, and you can call DownloadContent().
if(ci.lExpiration!=0)
{
bAddCacheItem=true;
lHr=0;
}
// Download the content if the server indicates that your
// plug-in's call to GetContentInformation() succeeded.
if(lHr==0)
{
// Call a user-defined function, GetContentInfoFromContext(),
// to retrieve cache content information from the pContentInfo
// parameter. The context contains a reference to an
// IWMSDataContainerVersion object that the plug-in can use
// to retrieve content information.
GetContentInfoFromContext(pContentInfo, ref ci);
// Determine whether the content can be downloaded.
nFlag = ci.CacheFlags & (int)WMS_DATA_CONTAINER_VERSION_CACHE_FLAGS.WMS_DATA_CONTAINER_VERSION_ALLOW_PROXY_CACHING;
if((nFlag!=0)||(bAddCacheItem))
{
// Identify a cache URL.
if((!bAddCacheItem)||(bAddCacheItem && (ci.CacheUrl==null)))
{
ci.CacheUrl = "c:\\WMSCache\\test";
}
// Call a user-defined function, IsDownloadInProgress(), to
// determine whether there is a download in progress.
if(!IsDownloadInProgress(ci))
{
// If there is no current download, call a user-defined
// function, AddForDownload(), to add cache content
// information to the DataSet object.
AddForDownload(ci);
// Download the content.
CacheProxyServer.DownloadContent(ci.OriginUrl,
ci.CacheUrl,
0,0,0,0,
this,
null,
this,
ci);
}
else
{
// Debugging is already in progress.
}
}
// If the content is a broadcast, do not download it, but
// store the content information in the DataSet with an empty
// cache URL.
if((ci.ContentType & 1)!=0)
{
UpdateTable(ci);
}
}
// The server returned E_ACCESSDENIED in response to the
// plug-in's call to GetContentInformation().
else
{
if(lHr==-2147024891)
nRetHr=0;
}
// Determine whether stream splitting is allowed.
WMS_CACHE_QUERY_MISS_RESPONSE MissResponse = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND;
nFlag = ci.CacheFlags & (int)WMS_DATA_CONTAINER_VERSION_CACHE_FLAGS.WMS_DATA_CONTAINER_VERSION_ALLOW_STREAM_SPLITTING;
// If the stream can be split, broadcast the content.
// Otherwise, play the content on demand.
if(nFlag!=0)
{
MissResponse = WMS_CACHE_QUERY_MISS_RESPONSE.WMS_CACHE_QUERY_MISS_PLAY_BROADCAST;
}
// Request that the server proxy the content on demand.
if(ci.CacheProxyCallback!=null)
{
ci.CacheProxyCallback.OnQueryCacheMissPolicy((int)nRetHr,MissResponse
,ci.OriginUrl,null,pContentInfo,ci.varContext);
}
}
catch(Exception e)
{
throw new COMException();
}
return;
}
Requirements
Reference: Add a reference to Microsoft.WindowsMediaServices.
Namespace: Microsoft.WindowsMediaServices.Interop.
Assembly: Microsoft.WindowsMediaServices.dll.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.