blob: 726f1ce14663ff5fd35a88ee6ab3a48af3227ab2 [file] [log] [blame]
Chong Zhang9dbe9a52017-01-03 11:35:15 -08001/*
2 * Copyright (C) 2017 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 CAS_IMPL_H_
18#define CAS_IMPL_H_
19
20#include <media/stagefright/foundation/ABase.h>
21#include <android/media/BnCas.h>
22
23namespace android {
24namespace media {
25class ICasListener;
26}
27using namespace media;
28using namespace MediaCas;
29using binder::Status;
Colin Crossb8c35f92017-04-27 16:15:51 -070030struct CasPlugin;
Chong Zhang9dbe9a52017-01-03 11:35:15 -080031class SharedLibrary;
32
33class CasImpl : public BnCas {
34public:
35 CasImpl(const sp<ICasListener> &listener);
36 virtual ~CasImpl();
37
38 static void OnEvent(
39 void *appData,
40 int32_t event,
41 int32_t arg,
42 uint8_t *data,
43 size_t size);
44
45 void init(const sp<SharedLibrary>& library, CasPlugin *plugin);
46 void onEvent(
47 int32_t event,
48 int32_t arg,
49 uint8_t *data,
50 size_t size);
51
52 // ICas inherits
53
54 virtual Status setPrivateData(
55 const CasData& pvtData) override;
56
Chong Zhanga78c1cc2017-03-31 17:36:26 -070057 virtual Status openSession(CasSessionId* _aidl_return) override;
Chong Zhang9dbe9a52017-01-03 11:35:15 -080058
59 virtual Status closeSession(const CasSessionId& sessionId) override;
60
61 virtual Status setSessionPrivateData(
62 const CasSessionId& sessionId,
63 const CasData& pvtData) override;
64
65 virtual Status processEcm(
66 const CasSessionId& sessionId, const ParcelableCasData& ecm) override;
67
68 virtual Status processEmm(const ParcelableCasData& emm) override;
69
70 virtual Status sendEvent(
71 int32_t event, int32_t arg, const ::std::unique_ptr<CasData> &eventData) override;
72
73 virtual Status provision(const String16& provisionString) override;
74
75 virtual Status refreshEntitlements(
76 int32_t refreshType, const ::std::unique_ptr<CasData> &refreshData) override;
77
78 virtual Status release() override;
79
80private:
Chong Zhangb01fb482017-03-23 18:42:51 -070081 struct PluginHolder;
Chong Zhang9dbe9a52017-01-03 11:35:15 -080082 sp<SharedLibrary> mLibrary;
Chong Zhangb01fb482017-03-23 18:42:51 -070083 sp<PluginHolder> mPluginHolder;
Chong Zhang9dbe9a52017-01-03 11:35:15 -080084 sp<ICasListener> mListener;
85
86 DISALLOW_EVIL_CONSTRUCTORS(CasImpl);
87};
88
89} // namespace android
90
91#endif // CAS_IMPL_H_