blob: 8c5a96746c15511343625ca9cf2ac0c63e457e85 [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 MEDIA_CAS_DEFS_H_
18#define MEDIA_CAS_DEFS_H_
19
20#include <binder/Parcel.h>
21#include <media/cas/CasAPI.h>
22#include <media/cas/DescramblerAPI.h>
23#include <media/stagefright/foundation/ABase.h>
24
25namespace android {
26class IMemory;
27namespace media {
28
29namespace MediaCas {
30class ParcelableCasData : public CasData,
31 public Parcelable {
32public:
33 ParcelableCasData() {}
34 ParcelableCasData(const uint8_t *data, size_t size) :
35 CasData(data, data + size) {}
36 virtual ~ParcelableCasData() {}
37 status_t readFromParcel(const Parcel* parcel) override;
38 status_t writeToParcel(Parcel* parcel) const override;
39
40private:
41 DISALLOW_EVIL_CONSTRUCTORS(ParcelableCasData);
42};
43
44class ParcelableCasPluginDescriptor : public Parcelable {
45public:
46 ParcelableCasPluginDescriptor(int32_t CA_system_id, const char *name)
47 : mCASystemId(CA_system_id), mName(name) {}
48
49 ParcelableCasPluginDescriptor() : mCASystemId(0) {}
50
51 ParcelableCasPluginDescriptor(ParcelableCasPluginDescriptor&& desc) = default;
52
53 virtual ~ParcelableCasPluginDescriptor() {}
54
55 status_t readFromParcel(const Parcel* parcel) override;
56 status_t writeToParcel(Parcel* parcel) const override;
57
58private:
59 int32_t mCASystemId;
60 String16 mName;
61 DISALLOW_EVIL_CONSTRUCTORS(ParcelableCasPluginDescriptor);
62};
63}
64
65namespace MediaDescrambler {
66class DescrambleInfo : public Parcelable {
67public:
68 enum DestinationType {
69 kDestinationTypeVmPointer, // non-secure
70 kDestinationTypeNativeHandle // secure
71 };
72
73 DestinationType dstType;
74 DescramblerPlugin::ScramblingControl scramblingControl;
75 size_t numSubSamples;
76 DescramblerPlugin::SubSample *subSamples;
77 sp<IMemory> srcMem;
78 int32_t srcOffset;
79 void *dstPtr;
80 int32_t dstOffset;
81
82 DescrambleInfo();
83 virtual ~DescrambleInfo();
84 status_t readFromParcel(const Parcel* parcel) override;
85 status_t writeToParcel(Parcel* parcel) const override;
86
87private:
88
89 DISALLOW_EVIL_CONSTRUCTORS(DescrambleInfo);
90};
91}
92
93} // namespace media
94} // namespace android
95
96
97#endif // MEDIA_CAS_DEFS_H_