blob: b9356f30bae8c76ab86186590225ed02369e7639 [file] [log] [blame]
Jeff Tinker8a0c80f2013-02-08 10:20:44 -08001/*
2 * Copyright 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
17#ifndef _ANDROID_MEDIA_DRM_H_
18#define _ANDROID_MEDIA_DRM_H_
19
20#include "jni.h"
21
22#include <media/stagefright/foundation/ABase.h>
Jeff Tinker54cfbd62013-04-02 13:14:59 -070023#include <media/IDrm.h>
24#include <media/IDrmClient.h>
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080025#include <utils/Errors.h>
26#include <utils/RefBase.h>
27
28namespace android {
29
30struct IDrm;
31
Jeff Tinker54cfbd62013-04-02 13:14:59 -070032class DrmListener: virtual public RefBase
33{
34public:
35 virtual void notify(DrmPlugin::EventType eventType, int extra,
36 const Parcel *obj) = 0;
37};
38
39struct JDrm : public BnDrmClient {
Jeff Tinker7cda4912013-08-21 11:52:34 -070040 static bool IsCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType);
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080041
Edwin Wong4d1d84e2017-01-04 09:37:49 -080042 JDrm(JNIEnv *env, jobject thiz, const uint8_t uuid[16], const String8 &appPackageName);
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080043
44 status_t initCheck() const;
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080045 sp<IDrm> getDrm() { return mDrm; }
46
Jeff Tinker54cfbd62013-04-02 13:14:59 -070047 void notify(DrmPlugin::EventType, int extra, const Parcel *obj);
48 status_t setListener(const sp<DrmListener>& listener);
49
Jeff Tinker600071c2014-04-11 16:11:15 -070050 void disconnect();
51
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080052protected:
53 virtual ~JDrm();
54
55private:
56 jweak mObject;
57 sp<IDrm> mDrm;
58
Jeff Tinker54cfbd62013-04-02 13:14:59 -070059 sp<DrmListener> mListener;
60 Mutex mNotifyLock;
61 Mutex mLock;
62
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080063 static sp<IDrm> MakeDrm();
Edwin Wong4d1d84e2017-01-04 09:37:49 -080064 static sp<IDrm> MakeDrm(const uint8_t uuid[16], const String8 &appPackageName);
Jeff Tinker8a0c80f2013-02-08 10:20:44 -080065
66 DISALLOW_EVIL_CONSTRUCTORS(JDrm);
67};
68
69} // namespace android
70
71#endif // _ANDROID_MEDIA_DRM_H_