IWMSCacheProxyServerCallback::OnGetContentInformation

banner art

Previous Next

IWMSCacheProxyServerCallback::OnGetContentInformation

The OnGetContentInformation method is called by the server to respond when a cache plug-in calls IWMSCacheProxyServer::GetContentInformation.

Syntax

  HRESULT OnGetContentInformation(
  
  HRESULT
  
  hr
  ,
  
  IWMSContext*
  
  pContentInfo
  ,
  
  VARIANT
  
  varContext
  
  );

Parameters

hr

[in] HRESULT indicating whether the call to IWMSCacheProxyServer::GetContentInformation succeeded.

pContentInfo

[in] Pointer to an IWMSContext interface 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.

varContext

[in] VARIANT 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 Values

If the method succeeds, the plug-in must return S_OK. To report an error, the plug-in can return any HRESULT other than S_OK. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. 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 interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving 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 Code

HRESULT STDMETHODCALLTYPE 
CCachePlugin::OnGetContentInfo(
                    long lHr,
                    IWMSContext *pContentInfo,
                    VARIANT varContext
                    )
{
    HRESULT returnHr = (HRESULT) lHr;
    HRESULT hr = S_OK;   
    long lContentType;
   
    // Quit if the call to GetContentInformation() failed .
    if( FAILED( returnHr ) )
    {
            hr = returnHr;
            goto exit;
    }

    // If the plug-in called GetContentInformation() because the
    // requested content was not cached, the plug-in must
    // determine a cache-miss policy based on the content 
    // information sent by the server.
    // You can define a local variable that contains the reason
    // why the plug-in called GetContentInformation().
    if (m_OpState == OP_CACHE_MISS)
    {
        // pContentInfo is a pointer to a context sent by the server.
        // The context contains information about the digital media
        // requested by the client.
        hr = pContentInfo->GetLongValue( 
                     WMS_CACHE_CONTENT_INFORMATION_CONTENT_TYPE,
                     WMS_CACHE_CONTENT_INFORMATION_CONTENT_TYPE_ID,
                     (long *) &lContentType,
                     0 );

            if( WMS_CACHE_CONTENT_TYPE_PLAYLIST & lContentType ) 
            {
                // TODO: Process the playlist content type.
            }
            else if( WMS_CACHE_CONTENT_TYPE_BROADCAST & lContentType )
            {
                // TODO: Process the broadcast content type.
            }
            else
            {
                // TODO: Process the on-demand content type.
            }
        }

    // The plug-in can also call GetContentInformation()if a 
    // client requested that the cache be prestuffed. The plug-in
    // must use information about the content to determine whether
    // the content can be downloaded.
    if (m_OpState == OP_ADD_ITEM)
    {
        BOOL fDownload = FALSE;
        hr = pContentInfo->GetAndQueryIUnknownValue( 
               WMS_CACHE_CONTENT_INFORMATION_DATA_CONTAINER_VERSION,
               WMS_CACHE_CONTENT_INFORMATION_DATA_CONTAINER_VERSION_ID,
               IID_IWMSDataContainerVersion,
               (IUnknown **) &pContentVersion,
               0 );

        hr = pContentVersion->GetCacheFlags((long*) &dwCacheFlags);
        // TODO: Use the cache flags to determine whether content 
        // can be downloaded and, if so, download the content.
    }
    return S_OK;
}

Requirements

Header: streamcache.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Previous Next