Microsoft DirectX 8.1 (C++)

Blocking a Denied Request (C++)

This topic applies to Windows XP Home Edition and Windows XP Professional only.

In this version of Microsoft TV Technologies, the application is responsible for enforcing conditional access, although service providers can also physically scramble the signal.

When a policy adds a denial to the active request, the CA Manager fires an _ICAManagerEvents::RequestDenialAdded event. If the denial is transient, ignore it. Otherwise, block the user from viewing the request; for example, hide the Video Control or place a bitmap over the video window, and mute the volume. Actually stopping or pausing the Video Control is not recommended, because some policies might require information from the program stream.

The first parameter to the RequestDenialAdded event is a pointer to the ICARequest interface. Call the ICARequest::get_Denials method to obtain the denials collection for the request. Then call the ICADenials::get_CountDenied method. This method returns the number of non-transient denials in the collection. Block the request if the count is greater than zero.

When a denial changes state from transient to active, or vice versa, the CA Manager fires an _ICAManagerEvents::DenialStateChanged event. When a policy removes a denial, the CA Manager fires an _ICAManagerEvents::RequestDenialRemoved event. In both cases, check the number of non-transient denials that remain.

The following code example implements a RequestDenialAdded event handler:

// Forward declares:
bool IsRequestDenied(ICARequest *pReq); 
HRESULT ShowBitmap(IMSVidCtl *pVideoControl, WORD nID);

// Event handler:
void __stdcall OnRequestDenied(ICARequest *pReq, ICADenial *pDenial, long cCount)
{
    if (IsRequestDenied(pReq))
    {
        // Put a bitmap over the video window.
        ShowBitmap(m_pVidControl, IDB_DENIED);
    }
}

bool IsRequestDenied(ICARequest *pReq)
{
    bool fDenied = false;
    long cDenied = 0;
    CComPtr<ICADenials> pDenials;
    HRESULT hr = pReq->get_Denials(&pDenials);
    if (SUCCEEDED(hr))
    {
        pDenials->get_CountDenied(&cDenied);
        if (SUCCEEDED(hr))
        {
            fDenied = (cDenied > 0);
        }
    }
    return fDenied;
}

This example assumes that ShowBitmap is a function that places a bitmap image over the video window. For more information, see Mixing an Image Onto the Video Window in C++.