IWMSCacheProxyCallback::OnQueryCacheMissPolicy

banner art

Previous Next

IWMSCacheProxyCallback::OnQueryCacheMissPolicy

The OnQueryCacheMissPolicy method is called by the cache plug-in to respond when the server calls IWMSCacheProxy::QueryCacheMissPolicy.

Syntax

  HRESULT OnQueryCacheMissPolicy(
  
  HRESULT
  
  hr
  ,
  WMS_CACHE_QUERY_MISS_RESPONSE  CacheMissPolicy,
BSTRbstrUrl,
  IWMSProxyContext*  pProxyContext,
  IWMSContext*  pContentInfo, VARIANTvarContext);

Parameters

hr

[in] HRESULT indicating whether the call to IWMSCacheProxy::QueryCacheMissPolicy was successful.

CacheMissPolicy

[in] Member of the WMS_CACHE_QUERY_MISS_RESPONSE enumeration type identifying the cache-miss policy of the plug-in. This must be one of the following values.

Value Description
WMS_CACHE_QUERY_MISS_SKIP The cache proxy plug-in indicates that it will not process the request. The server queries the next plug-in.
WMS_CACHE_QUERY_MISS_DISCONNECT The cache proxy plug-in indicates that it will not process the request and that no other plug-in can process it. This forces the server to disconnect the client.
WMS_CACHE_QUERY_MISS_REDIRECT The cache proxy plug-in indicates that the server must redirect the client to an alternate URL specified by the plug-in. The server does not query the remaining plug-ins.
WMS_CACHE_QUERY_MISS_REDIRECT_TO_PROXY The cache proxy plug-in indicates that the server must redirect the client to an alternate cache proxy server specified by the plug-in. The client requests the same URL, but through a different proxy.
WMS_CACHE_QUERY_MISS_PLAY_BROADCAST The cache proxy plug-in directs that the stream be proxied to the client that requested it and shared to other clients that request it.
WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND The cache proxy plug-in directs that the stream be proxied only to the client that requested it. This can also be used to indicate that a broadcast stream must be sent to a single client.
WMS_CACHE_QUERY_MISS_FORWARD_REQUEST The cache proxy plug-in directs that the stream be forwarded to an upstream origin server specified by the requested URL. This response is only valid if the server has called QueryCache and specified either WMS_CACHE_QUERY_GET_CONTENT_INFO or WMS_CACHE_QUERY_CACHE_EVENT.
WMS_CACHE_QUERY_MISS_PROCESS_REQUEST The cache proxy plug-in indicates that it will process the client request. If the server has called QueryCache and specified WMS_CACHE_QUERY_GET_CONTENT_INFO, the plug-in supplies the content information BLOB. If the server has specified WMS_CACHE_QUERY_CACHE_EVENT, the plug-in enables the server to receive the event notice as if it is the origin server. The server can log and process the event.

bstrUrl

[in] BSTR containing the URL.

pProxyContext

[in, optional] Pointer to an IWMSProxyContext interface that enables the server to retrieve client credentials and the name and port number of the proxy server that handles the client request.

pContentInfo

Pointer to an IWMSContext interface containing content information.

varContext

[in] VARIANT containing a value defined by the server to identify which call to IWMSCacheProxy::QueryCacheMissPolicy the plug-in is responding to when it calls OnQueryCacheMissPolicy. The plug-in must pass this value back unaltered.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_INVALIDARG 0x80070057 The VarContext parameter does not contain a pointer to an IUnknown interface.
E_INVALIDARG 0x80070057 The bstrUrl parameter is NULL.
E_INVALIDARG 0x80070057 The plug-in returned WMS_CACHE_QUERY_MISS_DISCONNECT, WMS_CACHE_QUERY_MISS_REDIRECT_TO_PROXY, or WMS_CACHE_QUERY_MISS_REDIRECT when the server called QueryCache and specified WMS_CACHE_QUERY_LOCAL_EVENT.
E_INVALIDARG 0x80070057 The plug-in returned WMS_CACHE_QUERY_MISS_PLAY_BROADCAST or WMS_CACHE_QUERY_MISS_PLAY_ON_DEMAND when the server called QueryCache and specified WMS_CACHE_QUERY_GET_CONTENT_INFO or WMS_CACHE_QUERY_LOCAL_EVENT.
E_INVALIDARG 0x80070057 The plug-in returned WMS_CACHE_QUERY_MISS_FORWARD_REQUEST when the server called QueryCache and specified WMS_CACHE_QUERY_OPEN.
E_INVALIDARG 0x80070057 The plug-in returned WMS_CACHE_QUERY_MISS_PROCESS_REQUEST when the server called QueryCache and specified WMS_CACHE_QUERY_OPEN.

Example Code

HRESULT STDMETHODCALLTYPE 
CCachePlugin::QueryCacheMissPolicy( BSTR bstrOriginUrl,
                                    IWMSContext *pUserContext,
                                    IWMSCommandContext *pCommandContext,
                                    IWMSContext *pPresentationContext,
                                    IUnknown *pCachePluginContext,
                                    long QueryType, 
                                    IWMSCacheProxyCallback *pCallback,
                                    VARIANT varContext
                                    )
{
    CComVariant varContext2;
    COpState *pOpState = NULL;
    CComBSTR bstrUrl;
    LPWSTR pszHostName = NULL;
    LPWSTR pszPath = NULL;
    HRESULT hr = S_OK;

    // The proxy is configured as a reverse proxy.
    // Instruct the server to skip this plug-in.
    if( QueryType & WMS_CACHE_QUERY_REVERSE_PROXY )
    {
        hr = pCallback->OnQueryCacheMissPolicy( 
                            S_OK,
                            WMS_CACHE_QUERY_MISS_SKIP,
                            NULL,
                            NULL,
                            NULL,
                            varContext );
        return( hr );
    }

    // The downstream proxy has either raised an event or
    // requested information about content it has cached.
    // Forward the request to an upstream server.
    if( ( QueryType & WMS_CACHE_QUERY_CACHE_EVENT ) || 
        ( QueryType & WMS_CACHE_QUERY_GET_CONTENT_INFO ) )
    {
        hr = pCallback->OnQueryCacheMissPolicy( 
                S_OK,
                WMS_CACHE_QUERY_MISS_FORWARD_REQUEST,
                NULL,
                this,
                NULL,
                varContext );         
        return( hr );
    }

    // Set up the plug-in to perform protocol rollover.
    // Create an instance of a COpState class and retrieve a
    // pointer to it. The COpState class is user-defined and 
    // contains various data members, including an array of 
    // rollover protocols supported by this plug-in. 
    pOpState = new COpState;
    pOpState->m_Op = COpState::OP_QUERY_CACHE_MISS_POLICY;
    pOpState->m_bstrOriginUrl = bstrOriginUrl;
    pOpState->m_pPresentationContext = pPresentationContext;
    pOpState->m_pCacheProxyCallback = pCallback;
    pOpState->m_varContext = varContext;
    pOpState->m_pPresentationContext->AddRef();
    pOpState->m_pCacheProxyCallback->AddRef();

    // Start the protocol rollover process by initializing 
    // an index into an array of protocols supported by this plug-in, 
    // such as HTTP and RTSP.
    pOpState->m_dwProtocolIndex = -1;
    V_VT( &varContext2 ) = VT_UNKNOWN;
    V_UNKNOWN( &varContext2 ) = (IUnknown *) pOpState;

    // Initiate protocol rollover by calling OnGetContentInformation().
    // You must implement the OnGetContentInformation() method.
    OnGetContentInformation( NS_E_CONNECTION_FAILURE, NULL, varContext2 );

    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