1 /*
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 ANDROID_HARDWARE_CAS_V1_0_DESCRAMBLER_IMPL_H_
18 #define ANDROID_HARDWARE_CAS_V1_0_DESCRAMBLER_IMPL_H_
19 
20 #include <media/stagefright/foundation/ABase.h>
21 #include <android/hardware/cas/native/1.0/IDescrambler.h>
22 
23 namespace android {
24 struct DescramblerPlugin;
25 using namespace hardware::cas::native::V1_0;
26 
27 namespace hardware {
28 namespace cas {
29 namespace V1_0 {
30 namespace implementation {
31 
32 class SharedLibrary;
33 
34 class DescramblerImpl : public IDescrambler {
35 public:
36     DescramblerImpl(const sp<SharedLibrary>& library, DescramblerPlugin *plugin);
37     virtual ~DescramblerImpl();
38 
39     virtual Return<Status> setMediaCasSession(
40             const HidlCasSessionId& sessionId) override;
41 
42     virtual Return<bool> requiresSecureDecoderComponent(
43             const hidl_string& mime) override;
44 
45     virtual Return<void> descramble(
46             ScramblingControl scramblingControl,
47             const hidl_vec<SubSample>& subSamples,
48             const SharedBuffer& srcBuffer,
49             uint64_t srcOffset,
50             const DestinationBuffer& dstBuffer,
51             uint64_t dstOffset,
52             descramble_cb _hidl_cb) override;
53 
54     virtual Return<Status> release() override;
55 
56 private:
57     sp<SharedLibrary> mLibrary;
58     std::shared_ptr<DescramblerPlugin> mPluginHolder;
59 
60     DISALLOW_EVIL_CONSTRUCTORS(DescramblerImpl);
61 };
62 
63 } // namespace implementation
64 } // namespace V1_0
65 } // namespace cas
66 } // namespace hardware
67 } // namespace android
68 
69 #endif // ANDROID_HARDWARE_CAS_V1_0_DESCRAMBLER_IMPL_H_
70