blob: 4325c2031319310b7ee29d88de1a49635a944b83 [file] [log] [blame]
Henry Fanga9f93652019-10-11 17:30:15 -07001/*
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 <android/hardware/cas/1.2/ICas.h>
22#include <media/stagefright/foundation/ABase.h>
23
24namespace android {
25struct CasPlugin;
26
27namespace hardware {
28namespace cas {
29namespace V1_1 {
30struct ICasListener;
31namespace implementation {
32
33using ::android::hardware::cas::V1_0::HidlCasData;
34using ::android::hardware::cas::V1_0::HidlCasSessionId;
35using ::android::hardware::cas::V1_0::Status;
36using ::android::hardware::cas::V1_2::ScramblingMode;
37using ::android::hardware::cas::V1_2::SessionIntent;
38using ::android::hardware::cas::V1_2::StatusEvent;
39
40class SharedLibrary;
41
42class CasImpl : public V1_2::ICas {
43 public:
44 CasImpl(const sp<ICasListener>& listener);
45 virtual ~CasImpl();
46
47 static void OnEvent(void* appData, int32_t event, int32_t arg, uint8_t* data, size_t size);
48
49 static void CallBackExt(void* appData, int32_t event, int32_t arg, uint8_t* data, size_t size,
50 const CasSessionId* sessionId);
51
52 static void StatusUpdate(void* appData, int32_t event, int32_t arg);
53
54 void init(const sp<SharedLibrary>& library, CasPlugin* plugin);
55 void onEvent(int32_t event, int32_t arg, uint8_t* data, size_t size);
56
57 void onEvent(const CasSessionId* sessionId, int32_t event, int32_t arg, uint8_t* data,
58 size_t size);
59
60 void onStatusUpdate(int32_t event, int32_t arg);
61
62 // ICas inherits
63
64 Return<Status> setPluginStatusUpdateCallback();
65
66 virtual Return<Status> setPrivateData(const HidlCasData& pvtData) override;
67
68 virtual Return<void> openSession(openSession_cb _hidl_cb) override;
69
70 virtual Return<void> openSession_1_2(const SessionIntent intent, const ScramblingMode mode,
71 openSession_1_2_cb _hidl_cb) override;
72
73 virtual Return<Status> closeSession(const HidlCasSessionId& sessionId) override;
74
75 virtual Return<Status> setSessionPrivateData(const HidlCasSessionId& sessionId,
76 const HidlCasData& pvtData) override;
77
78 virtual Return<Status> processEcm(const HidlCasSessionId& sessionId,
79 const HidlCasData& ecm) override;
80
81 virtual Return<Status> processEmm(const HidlCasData& emm) override;
82
83 virtual Return<Status> sendEvent(int32_t event, int32_t arg,
84 const HidlCasData& eventData) override;
85
86 virtual Return<Status> sendSessionEvent(const HidlCasSessionId& sessionId, int32_t event,
87 int32_t arg, const HidlCasData& eventData) override;
88
89 virtual Return<Status> provision(const hidl_string& provisionString) override;
90
91 virtual Return<Status> refreshEntitlements(int32_t refreshType,
92 const HidlCasData& refreshData) override;
93
94 virtual Return<Status> release() override;
95
96 private:
97 struct PluginHolder;
98 sp<SharedLibrary> mLibrary;
99 std::shared_ptr<CasPlugin> mPluginHolder;
100 sp<ICasListener> mListener;
101
102 DISALLOW_EVIL_CONSTRUCTORS(CasImpl);
103};
104
105} // namespace implementation
106} // namespace V1_1
107} // namespace cas
108} // namespace hardware
109} // namespace android
110
111#endif // ANDROID_HARDWARE_CAS_V1_1_CAS_IMPL_H_