Home | History | Annotate | Download | only in default
      1 /*
      2  * Copyright (C) 2019 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_HARDWARE_CAS_V1_1_CAS_IMPL_H_
     18 #define ANDROID_HARDWARE_CAS_V1_1_CAS_IMPL_H_
     19 
     20 #include <android/hardware/cas/1.1/ICas.h>
     21 #include <media/stagefright/foundation/ABase.h>
     22 
     23 namespace android {
     24 struct CasPlugin;
     25 
     26 namespace hardware {
     27 namespace cas {
     28 namespace V1_1 {
     29 struct ICasListener;
     30 namespace implementation {
     31 
     32 using ::android::hardware::cas::V1_0::HidlCasData;
     33 using ::android::hardware::cas::V1_0::HidlCasSessionId;
     34 using ::android::hardware::cas::V1_0::Status;
     35 
     36 class SharedLibrary;
     37 
     38 class CasImpl : public ICas {
     39    public:
     40     CasImpl(const sp<ICasListener>& listener);
     41     virtual ~CasImpl();
     42 
     43     static void OnEvent(void* appData, int32_t event, int32_t arg, uint8_t* data, size_t size);
     44 
     45     static void CallBackExt(void* appData, int32_t event, int32_t arg, uint8_t* data, size_t size,
     46                             const CasSessionId* sessionId);
     47 
     48     void init(const sp<SharedLibrary>& library, CasPlugin* plugin);
     49     void onEvent(int32_t event, int32_t arg, uint8_t* data, size_t size);
     50 
     51     void onEvent(const CasSessionId* sessionId, int32_t event, int32_t arg, uint8_t* data,
     52                  size_t size);
     53 
     54     // ICas inherits
     55 
     56     virtual Return<Status> setPrivateData(const HidlCasData& pvtData) override;
     57 
     58     virtual Return<void> openSession(openSession_cb _hidl_cb) override;
     59 
     60     virtual Return<Status> closeSession(const HidlCasSessionId& sessionId) override;
     61 
     62     virtual Return<Status> setSessionPrivateData(const HidlCasSessionId& sessionId,
     63                                                  const HidlCasData& pvtData) override;
     64 
     65     virtual Return<Status> processEcm(const HidlCasSessionId& sessionId,
     66                                       const HidlCasData& ecm) override;
     67 
     68     virtual Return<Status> processEmm(const HidlCasData& emm) override;
     69 
     70     virtual Return<Status> sendEvent(int32_t event, int32_t arg,
     71                                      const HidlCasData& eventData) override;
     72 
     73     virtual Return<Status> sendSessionEvent(const HidlCasSessionId& sessionId, int32_t event,
     74                                             int32_t arg, const HidlCasData& eventData) override;
     75 
     76     virtual Return<Status> provision(const hidl_string& provisionString) override;
     77 
     78     virtual Return<Status> refreshEntitlements(int32_t refreshType,
     79                                                const HidlCasData& refreshData) override;
     80 
     81     virtual Return<Status> release() override;
     82 
     83    private:
     84     struct PluginHolder;
     85     sp<SharedLibrary> mLibrary;
     86     std::shared_ptr<CasPlugin> mPluginHolder;
     87     sp<ICasListener> mListener;
     88 
     89     DISALLOW_EVIL_CONSTRUCTORS(CasImpl);
     90 };
     91 
     92 }  // namespace implementation
     93 }  // namespace V1_1
     94 }  // namespace cas
     95 }  // namespace hardware
     96 }  // namespace android
     97 
     98 #endif  // ANDROID_HARDWARE_CAS_V1_1_CAS_IMPL_H_
     99