Share via


IWMSCacheProxyServerCallback.OnCompareContentInformation (C#)

banner art

Previous Next

IWMSCacheProxyServerCallback.OnCompareContentInformation (C#)

The OnCompareContentInformation method is called by the server to respond when a cache plug-in calls IWMSCacheProxyServer.CompareContentInformation.

Syntax

  

Parameters

lHr

[in] int indicating whether the call to IWMSCacheProxyServer.CompareContentInformation succeeded.

CompareResponse

[in] Member of the WMS_CACHE_VERSION_COMPARE_RESPONSE enumeration type indicating the server response. This must be one of the following values.

Value Description
WMS_CACHE_VERSION_FAIL_TO_CHECK_VERSION There was a problem in checking the version. The cache plug-in should either delete the cached content, or try to compare versions again.
WMS_CACHE_VERSION_CACHE_STALE The content is out of date. The cache plug-in must delete the cached content.
WMS_CACHE_VERSION_CACHE_UP_TO_DATE The content is current. The content can be streamed.

pNewContentInfo

[in] IWMSContext object containing a content description context. The context is associated with the URL passed when the plug-in calls CompareContentInformation.

varContext

[in] object containing a value defined by the plug-in when it called IWMSCacheProxyServer.CompareContentInformation. 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 OnCompareContentInformation.

Return Values

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 IWMSEventLog object 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.

Example Code

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

void IWMSCacheProxyServerCallback.OnCompareContentInformation(
                                 int lHr,
                                 WMS_CACHE_VERSION_COMPARE_RESPONSE CompareResponse,
                                 IWMSContext pNewContentInfo,
                                 object varContext)
{
  try
  {
    IWMSContext pContentInfo= pNewContentInfo;
    // Set the response equal to a cache miss.
    WMS_CACHE_QUERY_RESPONSE Response = WMS_CACHE_QUERY_RESPONSE.WMS_CACHE_QUERY_MISS;

    // Retrieve the user-defined ContentInfo object
    // from the varContext parameter.
    ContentInfo ci = (ContentInfo)varContext;

    // The call to IWMSCacheProxyServer.CompareContentInfo succeeded.
    if(lHr==0)
    {
      switch (CompareResponse)
      {
        // The content has expired. Remove it from the DataSet object.
        case WMS_CACHE_VERSION_COMPARE_RESPONSE.WMS_CACHE_VERSION_CACHE_STALE:
        {
          RemoveEntryFromDatabase(ci,true);
        }
        break;

        // The content is current.
        case WMS_CACHE_VERSION_COMPARE_RESPONSE.WMS_CACHE_VERSION_CACHE_UP_TO_DATE:
        {
          // Broadcast content.
          if((ci.ContentType & 1 )!=0)
          {
            Response = WMS_CACHE_QUERY_RESPONSE.WMS_CACHE_QUERY_HIT_PLAY_BROADCAST;
          }
          // On-demand content.
          else
          {
            Response = WMS_CACHE_QUERY_RESPONSE.WMS_CACHE_QUERY_HIT_PLAY_ON_DEMAND;
          }
          // Update the database with the new information.
          RemoveEntryFromDatabase(ci,false);
          GetContentInfoFromContext(pNewContentInfo,ref ci);
          UpdateTable(ci);

          GetContentInfoContext(ci,out pContentInfo);
        }
        break;

        // The server failed to check version information.
        case WMS_CACHE_VERSION_COMPARE_RESPONSE.WMS_CACHE_VERSION_FAIL_TO_CHECK_VERSION:
        {
        }
        break;

        default:
        break;
      }

      // Specify the cache URL. A basic starting point searches for
      // the :// character sequence in the URL. If this sequence is
      // not found, prefix the URL with file://.
      int nIndex = ci.CacheUrl.IndexOf("://");
      string strCacheUrl = ci.CacheUrl;
      if(nIndex==-1)
      {
        strCacheUrl = string.Format("file://{0}",ci.CacheUrl);
      }

      // Send the response to the server.
      ci.CacheProxyCallback.OnQueryCache(0,
                                         Response,
                                         strCacheUrl,
                                         pContentInfo,
                                         null,
                                         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.

See Also

Previous Next