Home | History | Annotate | Download | only in jni
      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>
     23 #include <media/IDrm.h>
     24 #include <media/IDrmClient.h>
     25 #include <utils/Errors.h>
     26 #include <utils/RefBase.h>
     27 
     28 namespace android {
     29 
     30 struct IDrm;
     31 
     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 {
     40     static bool IsCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType);
     41 
     42     JDrm(JNIEnv *env, jobject thiz, const uint8_t uuid[16]);
     43 
     44     status_t initCheck() const;
     45     sp<IDrm> getDrm() { return mDrm; }
     46 
     47     void notify(DrmPlugin::EventType, int extra, const Parcel *obj);
     48     status_t setListener(const sp<DrmListener>& listener);
     49 
     50 protected:
     51     virtual ~JDrm();
     52 
     53 private:
     54     jweak mObject;
     55     sp<IDrm> mDrm;
     56 
     57     sp<DrmListener> mListener;
     58     Mutex mNotifyLock;
     59     Mutex mLock;
     60 
     61     static sp<IDrm> MakeDrm();
     62     static sp<IDrm> MakeDrm(const uint8_t uuid[16]);
     63 
     64     DISALLOW_EVIL_CONSTRUCTORS(JDrm);
     65 };
     66 
     67 }  // namespace android
     68 
     69 #endif  // _ANDROID_MEDIA_DRM_H_
     70