MediaDrm.java revision 3ed38266c1647c6219ae5ad89cb3f867cf66caaa
1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.media;
18
19import android.media.MediaDrmException;
20import java.lang.ref.WeakReference;
21import java.util.UUID;
22import java.util.HashMap;
23import java.util.List;
24import android.os.Handler;
25import android.os.Looper;
26import android.os.Message;
27import android.os.Bundle;
28import android.os.Parcel;
29import android.util.Log;
30
31/**
32 * MediaDrm can be used to obtain keys for decrypting protected media streams, in
33 * conjunction with {@link android.media.MediaCrypto}.  The MediaDrm APIs
34 * are designed to support the ISO/IEC 23001-7: Common Encryption standard, but
35 * may also be used to implement other encryption schemes.
36 * <p>
37 * Encrypted content is prepared using an encryption server and stored in a content
38 * library. The encrypted content is streamed or downloaded from the content library to
39 * client devices via content servers.  Licenses to view the content are obtained from
40 * a License Server.
41 * <p>
42 * <p><img src="../../../images/mediadrm_overview.png"
43 *      alt="MediaDrm Overview diagram"
44 *      border="0" /></p>
45 * <p>
46 * Keys are requested from the license server using a key request. The key
47 * response is delivered to the client app, which provides the response to the
48 * MediaDrm API.
49 * <p>
50 * A Provisioning server may be required to distribute device-unique credentials to
51 * the devices.
52 * <p>
53 * Enforcing requirements related to the number of devices that may play content
54 * simultaneously can be performed either through key renewal or using the secure
55 * stop methods.
56 * <p>
57 * The following sequence diagram shows the interactions between the objects
58 * involved while playing back encrypted content:
59 * <p>
60 * <p><img src="../../../images/mediadrm_decryption_sequence.png"
61 *         alt="MediaDrm Overview diagram"
62 *         border="0" /></p>
63 * <p>
64 * The app first constructs {@link android.media.MediaExtractor} and
65 * {@link android.media.MediaCodec} objects. It accesses the DRM-scheme-identifying UUID,
66 * typically from metadata in the content, and uses this UUID to construct an instance
67 * of a MediaDrm object that is able to support the DRM scheme required by the content.
68 * Crypto schemes are assigned 16 byte UUIDs.  The method {@link #isCryptoSchemeSupported}
69 * can be used to query if a given scheme is supported on the device.
70 * <p>
71 * The app calls {@link #openSession} to generate a sessionId that will uniquely identify
72 * the session in subsequent interactions. The app next uses the MediaDrm object to
73 * obtain a key request message and send it to the license server, then provide
74 * the server's response to the MediaDrm object.
75 * <p>
76 * Once the app has a sessionId, it can construct a MediaCrypto object from the UUID and
77 * sessionId.  The MediaCrypto object is registered with the MediaCodec in the
78 * {@link MediaCodec.#configure} method to enable the codec to decrypt content.
79 * <p>
80 * When the app has constructed {@link android.media.MediaExtractor},
81 * {@link android.media.MediaCodec} and {@link android.media.MediaCrypto} objects,
82 * it proceeds to pull samples from the extractor and queue them into the decoder.  For
83 * encrypted content, the samples returned from the extractor remain encrypted, they
84 * are only decrypted when the samples are delivered to the decoder.
85 * <p>
86 * <a name="Callbacks"></a>
87 * <h3>Callbacks</h3>
88 * <p>Applications should register for informational events in order
89 * to be informed of key state updates during playback or streaming.
90 * Registration for these events is done via a call to
91 * {@link #setOnEventListener}. In order to receive the respective
92 * callback associated with this listener, applications are required to create
93 * MediaDrm objects on a thread with its own Looper running (main UI
94 * thread by default has a Looper running).
95 */
96public final class MediaDrm {
97
98    private final static String TAG = "MediaDrm";
99
100    private EventHandler mEventHandler;
101    private OnEventListener mOnEventListener;
102
103    private int mNativeContext;
104
105    /**
106     * Query if the given scheme identified by its UUID is supported on
107     * this device.
108     * @param uuid The UUID of the crypto scheme.
109     */
110    public static final boolean isCryptoSchemeSupported(UUID uuid) {
111        return isCryptoSchemeSupportedNative(getByteArrayFromUUID(uuid));
112    }
113
114    private static final byte[] getByteArrayFromUUID(UUID uuid) {
115        long msb = uuid.getMostSignificantBits();
116        long lsb = uuid.getLeastSignificantBits();
117
118        byte[] uuidBytes = new byte[16];
119        for (int i = 0; i < 8; ++i) {
120            uuidBytes[i] = (byte)(msb >>> (8 * (7 - i)));
121            uuidBytes[8 + i] = (byte)(lsb >>> (8 * (7 - i)));
122        }
123
124        return uuidBytes;
125    }
126
127    private static final native boolean isCryptoSchemeSupportedNative(byte[] uuid);
128
129    /**
130     * Instantiate a MediaDrm object
131     *
132     * @param uuid The UUID of the crypto scheme.
133     *
134     * @throws UnsupportedSchemeException if the device does not support the
135     * specified scheme UUID
136     */
137    public MediaDrm(UUID uuid) throws UnsupportedSchemeException {
138        Looper looper;
139        if ((looper = Looper.myLooper()) != null) {
140            mEventHandler = new EventHandler(this, looper);
141        } else if ((looper = Looper.getMainLooper()) != null) {
142            mEventHandler = new EventHandler(this, looper);
143        } else {
144            mEventHandler = null;
145        }
146
147        /* Native setup requires a weak reference to our object.
148         * It's easier to create it here than in C++.
149         */
150        native_setup(new WeakReference<MediaDrm>(this),
151                     getByteArrayFromUUID(uuid));
152    }
153
154    /**
155     * Register a callback to be invoked when an event occurs
156     *
157     * @param listener the callback that will be run
158     */
159    public void setOnEventListener(OnEventListener listener)
160    {
161        mOnEventListener = listener;
162    }
163
164    /**
165     * Interface definition for a callback to be invoked when a drm event
166     * occurs
167     */
168    public interface OnEventListener
169    {
170        /**
171         * Called when an event occurs that requires the app to be notified
172         *
173         * @param md the MediaDrm object on which the event occurred
174         * @param sessionId the DRM session ID on which the event occurred
175         * @param event indicates the event type
176         * @param extra an secondary error code
177         * @param data optional byte array of data that may be associated with the event
178         */
179        void onEvent(MediaDrm md, byte[] sessionId, int event, int extra, byte[] data);
180    }
181
182    /**
183     * This event type indicates that the app needs to request a certificate from
184     * the provisioning server.  The request message data is obtained using
185     * {@link #getProvisionRequest}
186     */
187    public static final int EVENT_PROVISION_REQUIRED = 1;
188
189    /**
190     * This event type indicates that the app needs to request keys from a license
191     * server.  The request message data is obtained using {@link #getKeyRequest}.
192     */
193    public static final int EVENT_KEY_REQUIRED = 2;
194
195    /**
196     * This event type indicates that the licensed usage duration for keys in a session
197     * has expired.  The keys are no longer valid.
198     */
199    public static final int EVENT_KEY_EXPIRED = 3;
200
201    /**
202     * This event may indicate some specific vendor-defined condition, see your
203     * DRM provider documentation for details
204     */
205    public static final int EVENT_VENDOR_DEFINED = 4;
206
207    private static final int DRM_EVENT = 200;
208
209    private class EventHandler extends Handler
210    {
211        private MediaDrm mMediaDrm;
212
213        public EventHandler(MediaDrm md, Looper looper) {
214            super(looper);
215            mMediaDrm = md;
216        }
217
218        @Override
219        public void handleMessage(Message msg) {
220            if (mMediaDrm.mNativeContext == 0) {
221                Log.w(TAG, "MediaDrm went away with unhandled events");
222                return;
223            }
224            switch(msg.what) {
225
226            case DRM_EVENT:
227                Log.i(TAG, "Drm event (" + msg.arg1 + "," + msg.arg2 + ")");
228
229                if (mOnEventListener != null) {
230                    if (msg.obj != null && msg.obj instanceof Parcel) {
231                        Parcel parcel = (Parcel)msg.obj;
232                        byte[] sessionId = parcel.createByteArray();
233                        if (sessionId.length == 0) {
234                            sessionId = null;
235                        }
236                        byte[] data = parcel.createByteArray();
237                        if (data.length == 0) {
238                            data = null;
239                        }
240                        mOnEventListener.onEvent(mMediaDrm, sessionId, msg.arg1, msg.arg2, data);
241                    }
242                }
243                return;
244
245            default:
246                Log.e(TAG, "Unknown message type " + msg.what);
247                return;
248            }
249        }
250    }
251
252    /*
253     * This method is called from native code when an event occurs.  This method
254     * just uses the EventHandler system to post the event back to the main app thread.
255     * We use a weak reference to the original MediaPlayer object so that the native
256     * code is safe from the object disappearing from underneath it.  (This is
257     * the cookie passed to native_setup().)
258     */
259    private static void postEventFromNative(Object mediadrm_ref,
260                                            int eventType, int extra, Object obj)
261    {
262        MediaDrm md = (MediaDrm)((WeakReference)mediadrm_ref).get();
263        if (md == null) {
264            return;
265        }
266        if (md.mEventHandler != null) {
267            Message m = md.mEventHandler.obtainMessage(DRM_EVENT, eventType, extra, obj);
268            md.mEventHandler.sendMessage(m);
269        }
270    }
271
272    /**
273     * Open a new session with the MediaDrm object.  A session ID is returned.
274     *
275     * @throws NotProvisionedException if provisioning is needed
276     * @throws ResourceBusyException if required resources are in use
277     */
278    public native byte[] openSession() throws NotProvisionedException;
279
280    /**
281     * Close a session on the MediaDrm object that was previously opened
282     * with {@link #openSession}.
283     */
284    public native void closeSession(byte[] sessionId);
285
286    /**
287     * This key request type species that the keys will be for online use, they will
288     * not be saved to the device for subsequent use when the device is not connected
289     * to a network.
290     */
291    public static final int KEY_TYPE_STREAMING = 1;
292
293    /**
294     * This key request type specifies that the keys will be for offline use, they
295     * will be saved to the device for use when the device is not connected to a network.
296     */
297    public static final int KEY_TYPE_OFFLINE = 2;
298
299    /**
300     * This key request type specifies that previously saved offline keys should be released.
301     */
302    public static final int KEY_TYPE_RELEASE = 3;
303
304    /**
305     * Contains the opaque data an app uses to request keys from a license server
306     */
307    public final static class KeyRequest {
308        KeyRequest() {}
309
310        /**
311         * Get the opaque message data
312         */
313        public byte[] getData() { return mData; }
314
315        /**
316         * Get the default URL to use when sending the key request message to a
317         * server, if known.  The app may prefer to use a different license
318         * server URL from other sources.
319         */
320        public String getDefaultUrl() { return mDefaultUrl; }
321
322        private byte[] mData;
323        private String mDefaultUrl;
324    };
325
326    /**
327     * A key request/response exchange occurs between the app and a license server
328     * to obtain or release keys used to decrypt encrypted content.
329     * <p>
330     * getKeyRequest() is used to obtain an opaque key request byte array that is
331     * delivered to the license server.  The opaque key request byte array is returned
332     * in KeyRequest.data.  The recommended URL to deliver the key request to is
333     * returned in KeyRequest.defaultUrl.
334     * <p>
335     * After the app has received the key request response from the server,
336     * it should deliver to the response to the DRM engine plugin using the method
337     * {@link #provideKeyResponse}.
338     *
339     * @param scope may be a sessionId or a keySetId, depending on the specified keyType.
340     * When the keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE,
341     * scope should be set to the sessionId the keys will be provided to.  When the keyType
342     * is KEY_TYPE_RELEASE, scope should be set to the keySetId of the keys
343     * being released. Releasing keys from a device invalidates them for all sessions.
344     * @param init container-specific data, its meaning is interpreted based on the
345     * mime type provided in the mimeType parameter.  It could contain, for example,
346     * the content ID, key ID or other data obtained from the content metadata that is
347     * required in generating the key request. init may be null when keyType is
348     * KEY_TYPE_RELEASE.
349     * @param mimeType identifies the mime type of the content
350     * @param keyType specifes the type of the request. The request may be to acquire
351     * keys for streaming or offline content, or to release previously acquired
352     * keys, which are identified by a keySetId.
353     * @param optionalParameters are included in the key request message to
354     * allow a client application to provide additional message parameters to the server.
355     *
356     * @throws NotProvisionedException if reprovisioning is needed, due to a
357     * problem with the certifcate
358     */
359    public native KeyRequest getKeyRequest(byte[] scope, byte[] init,
360                                           String mimeType, int keyType,
361                                           HashMap<String, String> optionalParameters)
362        throws NotProvisionedException;
363
364
365    /**
366     * A key response is received from the license server by the app, then it is
367     * provided to the DRM engine plugin using provideKeyResponse.  When the
368     * response is for an offline key request, a keySetId is returned that can be
369     * used to later restore the keys to a new session with the method
370     * {@link #restoreKeys}.
371     * When the response is for a streaming or release request, null is returned.
372     *
373     * @param scope may be a sessionId or keySetId depending on the type of the
374     * response.  Scope should be set to the sessionId when the response is for either
375     * streaming or offline key requests.  Scope should be set to the keySetId when
376     * the response is for a release request.
377     * @param response the byte array response from the server
378     *
379     * @throws NotProvisionedException if the response indicates that
380     * reprovisioning is required
381     * @throws DeniedByServerException if the response indicates that the
382     * server rejected the request
383     * @throws ResourceBusyException if required resources are in use
384     */
385    public native byte[] provideKeyResponse(byte[] scope, byte[] response)
386        throws NotProvisionedException, DeniedByServerException;
387
388
389    /**
390     * Restore persisted offline keys into a new session.  keySetId identifies the
391     * keys to load, obtained from a prior call to {@link #provideKeyResponse}.
392     *
393     * @param sessionId the session ID for the DRM session
394     * @param keySetId identifies the saved key set to restore
395     */
396    public native void restoreKeys(byte[] sessionId, byte[] keySetId);
397
398    /**
399     * Remove the current keys from a session.
400     *
401     * @param sessionId the session ID for the DRM session
402     */
403    public native void removeKeys(byte[] sessionId);
404
405    /**
406     * Request an informative description of the key status for the session.  The status is
407     * in the form of {name, value} pairs.  Since DRM license policies vary by vendor,
408     * the specific status field names are determined by each DRM vendor.  Refer to your
409     * DRM provider documentation for definitions of the field names for a particular
410     * DRM engine plugin.
411     *
412     * @param sessionId the session ID for the DRM session
413     */
414    public native HashMap<String, String> queryKeyStatus(byte[] sessionId);
415
416    /**
417     * Contains the opaque data an app uses to request a certificate from a provisioning
418     * server
419     */
420    public final static class ProvisionRequest {
421        ProvisionRequest() {}
422
423        /**
424         * Get the opaque message data
425         */
426        public byte[] getData() { return mData; }
427
428        /**
429         * Get the default URL to use when sending the provision request
430         * message to a server, if known. The app may prefer to use a different
431         * provisioning server URL obtained from other sources.
432         */
433        public String getDefaultUrl() { return mDefaultUrl; }
434
435        private byte[] mData;
436        private String mDefaultUrl;
437    }
438
439    /**
440     * A provision request/response exchange occurs between the app and a provisioning
441     * server to retrieve a device certificate.  If provisionining is required, the
442     * EVENT_PROVISION_REQUIRED event will be sent to the event handler.
443     * getProvisionRequest is used to obtain the opaque provision request byte array that
444     * should be delivered to the provisioning server. The provision request byte array
445     * is returned in ProvisionRequest.data. The recommended URL to deliver the provision
446     * request to is returned in ProvisionRequest.defaultUrl.
447     */
448    public native ProvisionRequest getProvisionRequest();
449
450    /**
451     * After a provision response is received by the app, it is provided to the DRM
452     * engine plugin using this method.
453     *
454     * @param response the opaque provisioning response byte array to provide to the
455     * DRM engine plugin.
456     *
457     * @throws DeniedByServerException if the response indicates that the
458     * server rejected the request
459     */
460    public native void provideProvisionResponse(byte[] response)
461        throws DeniedByServerException;
462
463    /**
464     * A means of enforcing limits on the number of concurrent streams per subscriber
465     * across devices is provided via SecureStop. This is achieved by securely
466     * monitoring the lifetime of sessions.
467     * <p>
468     * Information from the server related to the current playback session is written
469     * to persistent storage on the device when each MediaCrypto object is created.
470     * <p>
471     * In the normal case, playback will be completed, the session destroyed and the
472     * Secure Stops will be queried. The app queries secure stops and forwards the
473     * secure stop message to the server which verifies the signature and notifies the
474     * server side database that the session destruction has been confirmed. The persisted
475     * record on the client is only removed after positive confirmation that the server
476     * received the message using releaseSecureStops().
477     */
478    public native List<byte[]> getSecureStops();
479
480
481    /**
482     * Process the SecureStop server response message ssRelease.  After authenticating
483     * the message, remove the SecureStops identified in the response.
484     *
485     * @param ssRelease the server response indicating which secure stops to release
486     */
487    public native void releaseSecureStops(byte[] ssRelease);
488
489
490    /**
491     * String property name: identifies the maker of the DRM engine plugin
492     */
493    public static final String PROPERTY_VENDOR = "vendor";
494
495    /**
496     * String property name: identifies the version of the DRM engine plugin
497     */
498    public static final String PROPERTY_VERSION = "version";
499
500    /**
501     * String property name: describes the DRM engine plugin
502     */
503    public static final String PROPERTY_DESCRIPTION = "description";
504
505    /**
506     * String property name: a comma-separated list of cipher and mac algorithms
507     * supported by CryptoSession.  The list may be empty if the DRM engine
508     * plugin does not support CryptoSession operations.
509     */
510    public static final String PROPERTY_ALGORITHMS = "algorithms";
511
512    /**
513     * Read a DRM engine plugin String property value, given the property name string.
514     * <p>
515     * Standard fields names are:
516     * {@link #PROPERTY_VENDOR}, {@link #PROPERTY_VERSION},
517     * {@link #PROPERTY_DESCRIPTION}, {@link #PROPERTY_ALGORITHMS}
518     */
519    public native String getPropertyString(String propertyName);
520
521
522    /**
523     * Byte array property name: the device unique identifier is established during
524     * device provisioning and provides a means of uniquely identifying each device.
525     */
526    public static final String PROPERTY_DEVICE_UNIQUE_ID = "deviceUniqueId";
527
528    /**
529     * Read a DRM engine plugin byte array property value, given the property name string.
530     * <p>
531     * Standard fields names are {@link #PROPERTY_DEVICE_UNIQUE_ID}
532     */
533    public native byte[] getPropertyByteArray(String propertyName);
534
535
536    /**
537     * Set a DRM engine plugin String property value.
538     */
539    public native void setPropertyString(String propertyName, String value);
540
541    /**
542     * Set a DRM engine plugin byte array property value.
543     */
544    public native void setPropertyByteArray(String propertyName, byte[] value);
545
546
547    private static final native void setCipherAlgorithmNative(MediaDrm drm, byte[] sessionId,
548                                                              String algorithm);
549
550    private static final native void setMacAlgorithmNative(MediaDrm drm, byte[] sessionId,
551                                                           String algorithm);
552
553    private static final native byte[] encryptNative(MediaDrm drm, byte[] sessionId,
554                                                     byte[] keyId, byte[] input, byte[] iv);
555
556    private static final native byte[] decryptNative(MediaDrm drm, byte[] sessionId,
557                                                     byte[] keyId, byte[] input, byte[] iv);
558
559    private static final native byte[] signNative(MediaDrm drm, byte[] sessionId,
560                                                  byte[] keyId, byte[] message);
561
562    private static final native boolean verifyNative(MediaDrm drm, byte[] sessionId,
563                                                     byte[] keyId, byte[] message,
564                                                     byte[] signature);
565
566    /**
567     * In addition to supporting decryption of DASH Common Encrypted Media, the
568     * MediaDrm APIs provide the ability to securely deliver session keys from
569     * an operator's session key server to a client device, based on the factory-installed
570     * root of trust, and then perform encrypt, decrypt, sign and verify operations
571     * with the session key on arbitrary user data.
572     * <p>
573     * The CryptoSession class implements generic encrypt/decrypt/sign/verify methods
574     * based on the established session keys.  These keys are exchanged using the
575     * getKeyRequest/provideKeyResponse methods.
576     * <p>
577     * Applications of this capability could include securing various types of
578     * purchased or private content, such as applications, books and other media,
579     * photos or media delivery protocols.
580     * <p>
581     * Operators can create session key servers that are functionally similar to a
582     * license key server, except that instead of receiving license key requests and
583     * providing encrypted content keys which are used specifically to decrypt A/V media
584     * content, the session key server receives session key requests and provides
585     * encrypted session keys which can be used for general purpose crypto operations.
586     * <p>
587     * A CryptoSession is obtained using {@link #getCryptoSession}
588     */
589    public final class CryptoSession {
590        private MediaDrm mDrm;
591        private byte[] mSessionId;
592
593        CryptoSession(MediaDrm drm, byte[] sessionId,
594                      String cipherAlgorithm, String macAlgorithm)
595        {
596            mSessionId = sessionId;
597            mDrm = drm;
598            setCipherAlgorithmNative(drm, sessionId, cipherAlgorithm);
599            setMacAlgorithmNative(drm, sessionId, macAlgorithm);
600        }
601
602        /**
603         * Encrypt data using the CryptoSession's cipher algorithm
604         *
605         * @param keyid specifies which key to use
606         * @param input the data to encrypt
607         * @param iv the initialization vector to use for the cipher
608         */
609        public byte[] encrypt(byte[] keyid, byte[] input, byte[] iv) {
610            return encryptNative(mDrm, mSessionId, keyid, input, iv);
611        }
612
613        /**
614         * Decrypt data using the CryptoSessions's cipher algorithm
615         *
616         * @param keyid specifies which key to use
617         * @param input the data to encrypt
618         * @param iv the initialization vector to use for the cipher
619         */
620        public byte[] decrypt(byte[] keyid, byte[] input, byte[] iv) {
621            return decryptNative(mDrm, mSessionId, keyid, input, iv);
622        }
623
624        /**
625         * Sign data using the CryptoSessions's mac algorithm.
626         *
627         * @param keyid specifies which key to use
628         * @param message the data for which a signature is to be computed
629         */
630        public byte[] sign(byte[] keyid, byte[] message) {
631            return signNative(mDrm, mSessionId, keyid, message);
632        }
633
634        /**
635         * Verify a signature using the CryptoSessions's mac algorithm. Return true
636         * if the signatures match, false if they do no.
637         *
638         * @param keyid specifies which key to use
639         * @param message the data to verify
640         * @param signature the reference signature which will be compared with the
641         *        computed signature
642         */
643        public boolean verify(byte[] keyid, byte[] message, byte[] signature) {
644            return verifyNative(mDrm, mSessionId, keyid, message, signature);
645        }
646    };
647
648    /**
649     * Obtain a CryptoSession object which can be used to encrypt, decrypt,
650     * sign and verify messages or data using the session keys established
651     * for the session using methods {@link #getKeyRequest} and
652     * {@link #provideKeyResponse} using a session key server.
653     *
654     * @param sessionId the session ID for the session containing keys
655     * to be used for encrypt, decrypt, sign and/or verify
656     * @param cipherAlgorithm the algorithm to use for encryption and
657     * decryption ciphers. The algorithm string conforms to JCA Standard
658     * Names for Cipher Transforms and is case insensitive.  For example
659     * "AES/CBC/NoPadding".
660     * @param macAlgorithm the algorithm to use for sign and verify
661     * The algorithm string conforms to JCA Standard Names for Mac
662     * Algorithms and is case insensitive.  For example "HmacSHA256".
663     * <p>
664     * The list of supported algorithms for a DRM engine plugin can be obtained
665     * using the method {@link #getPropertyString} with the property name
666     * "algorithms".
667     */
668    public CryptoSession getCryptoSession(byte[] sessionId,
669                                          String cipherAlgorithm,
670                                          String macAlgorithm)
671    {
672        return new CryptoSession(this, sessionId, cipherAlgorithm, macAlgorithm);
673    }
674
675    @Override
676    protected void finalize() {
677        native_finalize();
678    }
679
680    public native final void release();
681    private static native final void native_init();
682
683    private native final void native_setup(Object mediadrm_this, byte[] uuid);
684
685    private native final void native_finalize();
686
687    static {
688        System.loadLibrary("media_jni");
689        native_init();
690    }
691}
692