Creating and Initializing a DRM Writer

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The following steps are required to initialize an ASF writer object for importing encrypted media samples in Windows Media DRM.

  1. Follow steps 1 to 4 of Importing License and Key Material.
  2. Create and initialize an ASF writer object using the appropriate Windows Media DRM key material. For more information, see Enabling DRM Support.
  3. Set each of the following attributes by calling IWMDRMWriter::SetDRMAttribute:
    • DRM_HeaderSignPrivKey
    • DRM_V1LicenseAcqURL
    • DRM_KeyID
    • DRM_LicenseAcqURL
  4. If a licensed version of Windows Media Rights Manager is not installed on the computer running your software, then the following four attributes must also be set:
    • DRM_LASignatureRootCert
    • DRM_LASignatureCert
    • DRM_LASignatureLicSrvCert
    • DRM_LASignaturePrivKey
    • Application for the necessary encryption certificates can be completed by filling out the Windows Media Licensing Agreement (WMLA) online.
  5. Create a session key and fill out a WMDRM_IMPORT_SESSION_KEY structure. The session key will be used for encrypting a content key. For an example, see Create Session Key Example.
  6. Create a content key from a random RC4 initialization vector, and fill out a WMDRM_IMPORT_CONTENT_KEY structure. The content key is used for encrypting the media samples. For an example, see Create Content Key Example.
  7. Encrypt the content key with the session key, using RC4 encryption.
  8. Extract the machine certificate collection key. For an example, see Get Machine Certificate Example.
  9. Encrypt the session key with the public key extracted from the certificate.
  10. Fill out a WMDRM_IMPORT_INIT_STRUCT structure.
  11. Call the IWMDRMWriter3::SetProtectStreamSamples method to notify the SDK that samples coming into the writer are already protected and should be sent directly to the Windows Media DRM client for import.
  12. Call IWMWriter::BeginWriting.

The remaining steps for creating a DRM-protected file are documented in the Windows Media Format SDK Programming Guide. For more information, see Creating Protected Files.

The next step is to iterate through each media sample, encrypt it, and pass it to the writer object. For more information, see the Encrypting and Importing Media Samples.

Attributes

DRM Import