The CKeyStreamDecoder class provides an interface for initializing key stream decoders and process a key stream.
Initializing key stream decoder
The following code segment shows initializing a key stream decoder and querying attributes from the server.
Note: The key stream decoder needs to remain active, to process a key stream.
/* In this code sample, a key stream decoder is created to decode a key stream which is protected by IPSec. Create a protected stream descriptor for IPSec. serverAddr => source connection address (content distributor in real case). This address can be extracted from the SDP (Session Description Protocol). It is assumed that the client has already received this object. clientAddr => target connection address (device in real case). */ CProtectedStreamDesc *protectedStreamDesc = CIpSecProtectedStreamDesc::NewLC(serverAddr, clientAddr); /* The relevant media field for the key stream (CSdpMediaField* keyStreamSDPDesc) is extracted from the SDP (CSdpDocument* sdpDocument). ...... Now create the key stream decoder by using the protected stream descriptor, the key stream media field, and the whole SDP object. */ CKeyStreamDecoder *keyStreamDecoder = CKeyStreamDecoder::NewLC(protectedStreamDesc, keyStreamSDPDesc, sdpDocument); Cleanupstack::PopAndDestroy(protectedStreamDesc); /*If this section of code is reached, the key stream decoder is initialized correctly. If the user has rights to view the stream, the content will be decrypted. */
The following sequence of events occur in the back-end:
In case of an authenticated user of the service, the streaming agent loads the key stream. This creates a key stream decoder object.
The streaming agent starts a new processing task to decrypt the protected stream data. For example, the key processing task for IPSec is to decrypt Short Term Key Message (STKM) received as the key stream, and extract the corresponding cryptographic context.
Querying for protected stream content
Query the streaming agent to get information about the protected stream content, using the created key stream decoder object.
The following code snippet shows an example for querying the playability of the content:
TBool playable = EFalse; keyStreamDecoder->GetAttributeL(ECanPlay, playable); // When the protected key stream receiving has finished or stopped, the key decoder object is destroyed. Cleanupstack::PopAndDestroy(keyStreamDecoder);
Recording protected stream content
The following code snippet shows an example of recording protected streamed content with post-acquisition rights.
// Generate a protected key stream description for IPSec CProtectedStreamDesc *protectedStreamDesc = CIpSecProtectedStreamDesc::NewLC(serverAddr, clientAddr); // Create a key stream decoder CKeyStreamDecoder *keyStreamDecoder = CKeyStreamDecoder::NewLC(protectedStreamDesc, keyStreamSDPDesc, sdpDocument); //Check whether the content is recordable TBool value = EFalse; keyStreamDecoder->GetAttributeL(ECanExport, value); if(!value) { User::Leave(KErrCANotSupported); } /* Get an import handle to record the protected streamed data in 3GPP video format By using the import handle, the streamed content will be recorded as protected together with its post-acquisition Rights Object. After importing, the recorded content is reached according to the restrictions defined in the post-acquisition Rights Object. */ CImportFile* import = keyStreamDecoder->CreateImportSessionLC(_L8("video/3gpp")); TPtr8 decryptedContent; do { // Decrypt the protected streamed content and assign to decryptedContent pointer. import->WriteData(decryptedContent); } while (decryptedContent); // Import has been completed. TFileName fileName; TInt err = import->WriteDataComplete(); while (err == KErrCANewFileHandleRequired) { err = ProvideNewOutputFileL(*import, fileName); if(err == KErrNone) { err = import->WriteDataComplete(); } } User::LeaveIfError(err);
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.