1 /* 2 * Copyright (C) 2022 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 #include <aidl/android/hardware/cas/BnCas.h> 18 #include <aidl/android/hardware/cas/ICasListener.h> 19 #include <media/stagefright/foundation/ABase.h> 20 21 namespace aidl { 22 namespace android { 23 namespace hardware { 24 namespace cas { 25 26 using namespace ::android; 27 using namespace std; 28 using ndk::ScopedAStatus; 29 30 class CasImpl : public BnCas { 31 public: 32 CasImpl(const shared_ptr<ICasListener>& listener); 33 virtual ~CasImpl(); 34 35 static void OnEvent(void* appData, int32_t event, int32_t arg, uint8_t* data, size_t size); 36 37 static void CallBackExt(void* appData, int32_t event, int32_t arg, uint8_t* data, size_t size, 38 const CasSessionId* sessionId); 39 40 static void StatusUpdate(void* appData, int32_t event, int32_t arg); 41 42 void init(CasPlugin* plugin); 43 void onEvent(int32_t event, int32_t arg, uint8_t* data, size_t size); 44 45 void onEvent(const CasSessionId* sessionId, int32_t event, int32_t arg, uint8_t* data, 46 size_t size); 47 48 void onStatusUpdate(int32_t event, int32_t arg); 49 50 // ICas inherits 51 52 ScopedAStatus setPluginStatusUpdateCallback(); 53 54 virtual ScopedAStatus setPrivateData(const vector<uint8_t>& pvtData) override; 55 56 virtual ScopedAStatus openSessionDefault(vector<uint8_t>* sessionId) override; 57 58 virtual ScopedAStatus openSession(SessionIntent intent, ScramblingMode mode, 59 vector<uint8_t>* sessionId) override; 60 61 virtual ScopedAStatus closeSession(const vector<uint8_t>& sessionId) override; 62 63 virtual ScopedAStatus setSessionPrivateData(const vector<uint8_t>& sessionId, 64 const vector<uint8_t>& pvtData) override; 65 66 virtual ScopedAStatus processEcm(const vector<uint8_t>& sessionId, 67 const vector<uint8_t>& ecm) override; 68 69 virtual ScopedAStatus processEmm(const vector<uint8_t>& emm) override; 70 71 virtual ScopedAStatus sendEvent(int32_t event, int32_t arg, 72 const vector<uint8_t>& eventData) override; 73 74 virtual ScopedAStatus sendSessionEvent(const vector<uint8_t>& sessionId, int32_t event, 75 int32_t arg, const vector<uint8_t>& eventData) override; 76 77 virtual ScopedAStatus provision(const string& provisionString) override; 78 79 virtual ScopedAStatus refreshEntitlements(int32_t refreshType, 80 const vector<uint8_t>& refreshData) override; 81 82 virtual ScopedAStatus release() override; 83 84 private: 85 struct PluginHolder; 86 shared_ptr<CasPlugin> mPluginHolder; 87 shared_ptr<ICasListener> mListener; 88 89 DISALLOW_EVIL_CONSTRUCTORS(CasImpl); 90 }; 91 92 } // namespace cas 93 } // namespace hardware 94 } // namespace android 95 } // namespace aidl 96