Synchronizing Key Exchange with Data Flow

The key exchange process may begin before all data from the previous key is processed. An example of this would be in the transition from the trailer title set into the main program title set on some movies. There is a flag in the TypeSpecificFlags member of the KSSTREAM_HEADER structure for each data packet. This flag is KS_AM_UseNewCSSKey, which is defined in ksmedia.h. It indicates that the data sample immediately following that header is the first data sample to which the new title key applies.

If the decrypter can process a new key exchange while still using the old key, the DVD decoder minidriver should process the key exchange as it receives the properties. If the decrypter must wait until all movie data requiring the previous key has been processed, then the decrypter holds the SRB for the Set property. The decrypter uses the KS_DVDCOPY_SET_COPY_STATE structure with the parameter KS_DVDCOPYSTATE_INITIALIZE or KS_DVDCOPYSTATE_INITIALIZE_TITLE until it has received the KS_AM_UseNewCSSKey flag on all streams that are connected to it. After that, the DVD decoder minidriver processes all packets received until that point. This prevents using the incorrect key on the data.