Android.Media.MediaDrm Class
MediaDrm can be used to obtain keys for decrypting protected media streams, in conjunction with Android.Media.MediaCrypto.

See Also: MediaDrm Members

Syntax

[Android.Runtime.Register("android/media/MediaDrm", DoNotGenerateAcw=true)]
public sealed class MediaDrm : Java.Lang.Object

Remarks

MediaDrm can be used to obtain keys for decrypting protected media streams, in conjunction with Android.Media.MediaCrypto. The MediaDrm APIs are designed to support the ISO/IEC 23001-7: Common Encryption standard, but may also be used to implement other encryption schemes.

Encrypted content is prepared using an encryption server and stored in a content library. The encrypted content is streamed or downloaded from the content library to client devices via content servers. Licenses to view the content are obtained from a License Server.

Keys are requested from the license server using a key request. The key response is delivered to the client app, which provides the response to the MediaDrm API.

A Provisioning server may be required to distribute device-unique credentials to the devices.

Enforcing requirements related to the number of devices that may play content simultaneously can be performed either through key renewal or using the secure stop methods.

The following sequence diagram shows the interactions between the objects involved while playing back encrypted content:

The app first constructs Android.Media.MediaExtractor and Android.Media.MediaCodec objects. It accesses the DRM-scheme-identifying UUID, typically from metadata in the content, and uses this UUID to construct an instance of a MediaDrm object that is able to support the DRM scheme required by the content. Crypto schemes are assigned 16 byte UUIDs. The method MediaDrm.IsCryptoSchemeSupported(Java.Util.UUID) can be used to query if a given scheme is supported on the device.

The app calls MediaDrm.OpenSession to generate a sessionId that will uniquely identify the session in subsequent interactions. The app next uses the MediaDrm object to obtain a key request message and send it to the license server, then provide the server's response to the MediaDrm object.

Once the app has a sessionId, it can construct a MediaCrypto object from the UUID and sessionId. The MediaCrypto object is registered with the MediaCodec in the MediaCodec.Configure(MediaFormat, Android.Views.Surface, Android.Views.Surface, Android.Views.Surface) method to enable the codec to decrypt content.

When the app has constructed Android.Media.MediaExtractor, Android.Media.MediaCodec and Android.Media.MediaCrypto objects, it proceeds to pull samples from the extractor and queue them into the decoder. For encrypted content, the samples returned from the extractor remain encrypted, they are only decrypted when the samples are delivered to the decoder.

Callbacks

Applications should register for informational events in order to be informed of key state updates during playback or streaming. Registration for these events is done via a call to MediaDrm.SetOnEventListener(.IOnEventListener). In order to receive the respective callback associated with this listener, applications are required to create MediaDrm objects on a thread with its own Looper running (main UI thread by default has a Looper running).

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 18