Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Tinker | 54cfbd6 | 2013-04-02 13:14:59 -0700 | [diff] [blame] | 23 | #include <media/IDrm.h> |
| 24 | #include <media/IDrmClient.h> |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 25 | #include <utils/Errors.h> |
| 26 | #include <utils/RefBase.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | struct IDrm; |
| 31 | |
Jeff Tinker | 54cfbd6 | 2013-04-02 13:14:59 -0700 | [diff] [blame] | 32 | class DrmListener: virtual public RefBase |
| 33 | { |
| 34 | public: |
| 35 | virtual void notify(DrmPlugin::EventType eventType, int extra, |
| 36 | const Parcel *obj) = 0; |
| 37 | }; |
| 38 | |
| 39 | struct JDrm : public BnDrmClient { |
Jeff Tinker | 5de2e90 | 2019-01-25 23:09:36 -0800 | [diff] [blame] | 40 | static status_t IsCryptoSchemeSupported(const uint8_t uuid[16], |
| 41 | const String8 &mimeType, |
| 42 | DrmPlugin::SecurityLevel level, |
| 43 | bool *isSupported); |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 44 | |
Edwin Wong | 4d1d84e | 2017-01-04 09:37:49 -0800 | [diff] [blame] | 45 | JDrm(JNIEnv *env, jobject thiz, const uint8_t uuid[16], const String8 &appPackageName); |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 46 | |
| 47 | status_t initCheck() const; |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 48 | sp<IDrm> getDrm() { return mDrm; } |
| 49 | |
Jeff Tinker | 54cfbd6 | 2013-04-02 13:14:59 -0700 | [diff] [blame] | 50 | void notify(DrmPlugin::EventType, int extra, const Parcel *obj); |
| 51 | status_t setListener(const sp<DrmListener>& listener); |
| 52 | |
Jeff Tinker | 600071c | 2014-04-11 16:11:15 -0700 | [diff] [blame] | 53 | void disconnect(); |
| 54 | |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 55 | protected: |
| 56 | virtual ~JDrm(); |
| 57 | |
| 58 | private: |
| 59 | jweak mObject; |
| 60 | sp<IDrm> mDrm; |
| 61 | |
Jeff Tinker | 54cfbd6 | 2013-04-02 13:14:59 -0700 | [diff] [blame] | 62 | sp<DrmListener> mListener; |
| 63 | Mutex mNotifyLock; |
| 64 | Mutex mLock; |
| 65 | |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 66 | static sp<IDrm> MakeDrm(); |
Edwin Wong | 4d1d84e | 2017-01-04 09:37:49 -0800 | [diff] [blame] | 67 | static sp<IDrm> MakeDrm(const uint8_t uuid[16], const String8 &appPackageName); |
Jeff Tinker | 8a0c80f | 2013-02-08 10:20:44 -0800 | [diff] [blame] | 68 | |
| 69 | DISALLOW_EVIL_CONSTRUCTORS(JDrm); |
| 70 | }; |
| 71 | |
| 72 | } // namespace android |
| 73 | |
| 74 | #endif // _ANDROID_MEDIA_DRM_H_ |