Condividi tramite


COPPSequenceStart function

The sample COPPSequenceStart function sets the current video session to protected mode.

Syntax

HRESULT COPPSequenceStart(
  _In_ COPP_DeviceData    pThis,
  _In_ DXVA_COPPSignature *pSeqStartInfo
);

Parameters

pThis [in]

  • Pointer to the COPP DirectX VA device object.

pSeqStartInfo [in]

  • Supplies a pointer to a DXVA_COPPSignature structure that contains information about the start sequence.

Return value

Returns zero (S_OK or DD_OK) if successful; otherwise, returns an error code.

Remarks

A COPP DirectX VA device should provide the graphics hardware certificate to the VMR before receiving a call to its COPPSequenceStart function. That is, the COPPKeyExchange function should be called before COPPSequenceStart. If COPPSequenceStart is called before COPPKeyExchange, COPPSequenceStart should return E_UNEXPECTED.

After providing the graphics hardware certificate, the COPP DirectX VA device should receive only one call to its COPPSequenceStart function. If the COPP DirectX VA device receives another COPPSequenceStart call, it should return E_UNEXPECTED.

The COPPSequenceStart function receives a populated DXVA_COPPSignature structure that contains a start sequence, which consists of the following items concatenated together:

  • 128-bit random number generated by the driver and returned through a call to the driver's COPPKeyExchange function
  • 128-bit random data integrity session key
  • 32-bit random starting status sequence number
  • 32-bit random starting command sequence number

The start sequence is encrypted by using the public key of the graphic hardware.

Mapping RenderMoComp to COPPSequenceStart

The sample COPPSequenceStart function maps directly to a call to the RenderMoComp member of the DD_MOTIONCOMPCALLBACKS structure. The RenderMoComp member points to the display driver-supplied DdMoCompRender callback function that references the DD_RENDERMOCOMPDATA structure.

The RenderMoComp callback function is called without the display driver-supplied BeginMoCompFrame or EndMoCompFrame function being called first.

The DD_RENDERMOCOMPDATA structure is filled as follows.

Member Value
dwNumBuffers Zero.
lpBufferInfo NULL.
dwFunction DXVA_COPPSequenceStartFnCode constant (defined in dxva.h).
lpInputData Pointer to a DXVA_COPPSignature structure.
lpOutputData NULL.

Example Code

The following code provides an example of how you can implement your COPPSequenceStart function:

HRESULT
COPP_RSADecryptData(
    const BYTE* lpPrivateKey,
    DXVA_COPPSignature* pOutput,
    DXVA_COPPSignature* pInput
    )
{
    DWORD dwLen = sizeof(DXVA_COPPSignature);
    return RSADecPrivate(lpPrivateKey, (const BYTE *)pInput,
                         sizeof(DXVA_COPPSignature), (BYTE*) pOutput, &dwLen);
}

HRESULT
COPPSequenceStart(
    COPP_DeviceData* pThis,
    DXVA_COPPSignature* pSeqStartInfo
    )
{
    if (pThis->m_COPPDevState == COPP_KEY_EXCHANGED) {
        BYTE* pByte;
        DXVA_COPPSignature Decrypted;
        GUID rGraphicsDriver;
        HRESULT hr;
        COPP_RSADecryptData(PrivateKey, &Decrypted, pSeqStartInfo);
        pByte = (BYTE*)&Decrypted;
        memcpy(&rGraphicsDriver, pByte, sizeof(DWORD));
        pByte += sizeof(DWORD);
        memcpy(&pThis->m_KDI, pByte, sizeof(GUID));
        pByte += sizeof(GUID);
        memcpy(&pThis->m_StatusSeqNumber, pByte, sizeof(DWORD));
        pByte += sizeof(DWORD);
        memcpy(&pThis->m_CmdSeqNumber, pByte, sizeof(DWORD));
        pByte += sizeof(DWORD);
        hr = SetKey(&pThis->m_AesHelper, (BYTE*)&pThis->m_KDI, sizeof(GUID));
        if (hr != S_OK) {
            return hr;
        }
        if (!IsEqualGUID(&rGraphicsDriver, &pThis->m_rGraphicsDriver)) {
            return E_UNEXPECTED;
        }
        pThis->m_COPPDevState = COPP_SESSION_ACTIVE;
    }
    else {
        return E_UNEXPECTED;
    }
    return NO_ERROR;
}

Requirements

Target platform Version
Desktop This function applies only to Windows Server 2003 with SP1 and later, and Windows XP with SP2 and later.