blob: 18aee9e45701ab72763744da08daf0af0fe2a691 [file] [log] [blame]
Henry Fang3e3cbb72019-01-31 22:46:57 +00001/*
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
23namespace android {
24struct CasPlugin;
25
26namespace hardware {
27namespace cas {
28namespace V1_1 {
29struct ICasListener;
30namespace implementation {
31
32using ::android::hardware::cas::V1_0::HidlCasData;
33using ::android::hardware::cas::V1_0::HidlCasSessionId;
34using ::android::hardware::cas::V1_0::Status;
35
36class SharedLibrary;
37
38class 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_