MediaCrypto.java revision 2952c5d03c26aec8f2aa2d69f20b47a7cc8f39e1
1/*
2 * Copyright (C) 2012 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
19/**
20 * MediaCrypto class can be used in conjunction with {@link android.media.MediaCodec}
21 * to decode encrypted media data.
22 *
23 * Crypto schemes are assigned 16 byte UUIDs,
24 * the method {@link #isCryptoSchemeSupported} can be used to query if a given
25 * scheme is supported on the device.
26 *
27*/
28public final class MediaCrypto {
29    /** Query if the given scheme identified by its UUID is supported on
30      * this device.
31      * @param uuid The UUID of the crypto scheme.
32    */
33    public static final native boolean isCryptoSchemeSupported(byte[] uuid);
34
35    /** Instantiate a MediaCrypto object using opaque, crypto scheme specific
36      * data.
37      * @param uuid The UUID of the crypto scheme.
38      * @param initData Opaque initialization data specific to the crypto scheme.
39    */
40    public MediaCrypto(byte[] uuid, byte[] initData) throws RuntimeException {
41        native_setup(uuid, initData);
42    }
43
44    /** Query if the crypto scheme requires the use of a secure decoder
45      * to decode data of the given mime type.
46      * @param mime The mime type of the media data
47    */
48    public final native boolean requiresSecureDecoderComponent(String mime);
49
50    @Override
51    protected void finalize() {
52        native_finalize();
53    }
54
55    public native final void release();
56    private static native final void native_init();
57    private native final void native_setup(byte[] uuid, byte[] initData);
58    private native final void native_finalize();
59
60    static {
61        System.loadLibrary("media_jni");
62        native_init();
63    }
64
65    private int mNativeContext;
66}
67