blob: 3c07092aa01f3d3a8741cca49c094ccb2e2a717d [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;
30class CasPlugin;
31class 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
57 virtual Status openSession(
58 int32_t program_number, CasSessionId* _aidl_return) override;
59
60 virtual Status openSessionForStream(
61 int32_t program_number,
62 int32_t elementary_PID,
63 CasSessionId* _aidl_return) override;
64
65 virtual Status closeSession(const CasSessionId& sessionId) override;
66
67 virtual Status setSessionPrivateData(
68 const CasSessionId& sessionId,
69 const CasData& pvtData) override;
70
71 virtual Status processEcm(
72 const CasSessionId& sessionId, const ParcelableCasData& ecm) override;
73
74 virtual Status processEmm(const ParcelableCasData& emm) override;
75
76 virtual Status sendEvent(
77 int32_t event, int32_t arg, const ::std::unique_ptr<CasData> &eventData) override;
78
79 virtual Status provision(const String16& provisionString) override;
80
81 virtual Status refreshEntitlements(
82 int32_t refreshType, const ::std::unique_ptr<CasData> &refreshData) override;
83
84 virtual Status release() override;
85
86private:
Chong Zhangb01fb482017-03-23 18:42:51 -070087 struct PluginHolder;
Chong Zhang9dbe9a52017-01-03 11:35:15 -080088 sp<SharedLibrary> mLibrary;
Chong Zhangb01fb482017-03-23 18:42:51 -070089 sp<PluginHolder> mPluginHolder;
Chong Zhang9dbe9a52017-01-03 11:35:15 -080090 sp<ICasListener> mListener;
91
92 DISALLOW_EVIL_CONSTRUCTORS(CasImpl);
93};
94
95} // namespace android
96
97#endif // CAS_IMPL_H_