blob: 454fc999cd30e4393e99cfecda2dab7d7bb70e01 [file] [log] [blame]
aimitakeshid074e302010-07-29 10:12:27 +09001/*
2 * Copyright (C) 2010 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 __DRM_FRAMEWORK_COMMON_H__
18#define __DRM_FRAMEWORK_COMMON_H__
19
20#include <utils/Vector.h>
21#include <utils/KeyedVector.h>
22#include <utils/String8.h>
23#include <utils/Errors.h>
24
25#define INVALID_VALUE -1
26
27namespace android {
28
29/**
30 * Error code for DRM Frameowrk
31 */
32enum {
33 DRM_ERROR_BASE = -2000,
34
35 DRM_ERROR_UNKNOWN = DRM_ERROR_BASE,
36 DRM_ERROR_LICENSE_EXPIRED = DRM_ERROR_BASE - 1,
37 DRM_ERROR_SESSION_NOT_OPENED = DRM_ERROR_BASE - 2,
38 DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED = DRM_ERROR_BASE - 3,
39 DRM_ERROR_DECRYPT = DRM_ERROR_BASE - 4,
40 DRM_ERROR_CANNOT_HANDLE = DRM_ERROR_BASE - 5,
41
42 DRM_NO_ERROR = NO_ERROR
43};
44
45/**
Gloria Wangee4084b2011-03-21 16:53:14 -070046 * copy control settings used in DecryptHandle::copyControlVector
47 */
48enum DrmCopyControl {
49 DRM_COPY_CONTROL_BASE = 1000,
50 // the key used to set the value for HDCP
51 // if the associated value is 1, then HDCP is required
52 // otherwise, HDCP is not required
53 DRM_COPY_CONTROL_HDCP = DRM_COPY_CONTROL_BASE
54};
55
56/**
aimitakeshid074e302010-07-29 10:12:27 +090057 * Defines DRM Buffer
58 */
59class DrmBuffer {
60public:
61 char* data;
62 int length;
63
64 DrmBuffer() :
65 data(NULL),
66 length(0) {
67 }
68
69 DrmBuffer(char* dataBytes, int dataLength) :
70 data(dataBytes),
71 length(dataLength) {
72 }
73
74};
75
76/**
77 * Defines detailed description of the action
78 */
79class ActionDescription {
80public:
81 ActionDescription(int _outputType, int _configuration) :
82 outputType(_outputType),
83 configuration(_configuration) {
84 }
85
86public:
87 int outputType; /* BLUETOOTH , HDMI*/
88 int configuration; /* RESOLUTION_720_480 , RECORDABLE etc.*/
89};
90
91/**
92 * Defines constants related to DRM types
93 */
94class DrmObjectType {
95private:
96 DrmObjectType();
97
98public:
99 /**
100 * Field specifies the unknown type
101 */
102 static const int UNKNOWN = 0x00;
103 /**
104 * Field specifies the protected content type
105 */
106 static const int CONTENT = 0x01;
107 /**
108 * Field specifies the rights information
109 */
110 static const int RIGHTS_OBJECT = 0x02;
111 /**
112 * Field specifies the trigger information
113 */
114 static const int TRIGGER_OBJECT = 0x03;
115};
116
117/**
118 * Defines constants related to play back
119 */
120class Playback {
121private:
122 Playback();
123
124public:
125 /**
126 * Constant field signifies playback start
127 */
128 static const int START = 0x00;
129 /**
130 * Constant field signifies playback stop
131 */
132 static const int STOP = 0x01;
133 /**
134 * Constant field signifies playback paused
135 */
136 static const int PAUSE = 0x02;
137 /**
138 * Constant field signifies playback resumed
139 */
140 static const int RESUME = 0x03;
141};
142
143/**
144 * Defines actions that can be performed on protected content
145 */
146class Action {
147private:
148 Action();
149
150public:
151 /**
152 * Constant field signifies that the default action
153 */
154 static const int DEFAULT = 0x00;
155 /**
156 * Constant field signifies that the content can be played
157 */
158 static const int PLAY = 0x01;
159 /**
160 * Constant field signifies that the content can be set as ring tone
161 */
162 static const int RINGTONE = 0x02;
163 /**
164 * Constant field signifies that the content can be transfered
165 */
166 static const int TRANSFER = 0x03;
167 /**
168 * Constant field signifies that the content can be set as output
169 */
170 static const int OUTPUT = 0x04;
171 /**
172 * Constant field signifies that preview is allowed
173 */
174 static const int PREVIEW = 0x05;
175 /**
176 * Constant field signifies that the content can be executed
177 */
178 static const int EXECUTE = 0x06;
179 /**
180 * Constant field signifies that the content can displayed
181 */
182 static const int DISPLAY = 0x07;
183};
184
185/**
186 * Defines constants related to status of the rights
187 */
188class RightsStatus {
189private:
190 RightsStatus();
191
192public:
193 /**
194 * Constant field signifies that the rights are valid
195 */
196 static const int RIGHTS_VALID = 0x00;
197 /**
198 * Constant field signifies that the rights are invalid
199 */
200 static const int RIGHTS_INVALID = 0x01;
201 /**
202 * Constant field signifies that the rights are expired for the content
203 */
204 static const int RIGHTS_EXPIRED = 0x02;
205 /**
206 * Constant field signifies that the rights are not acquired for the content
207 */
208 static const int RIGHTS_NOT_ACQUIRED = 0x03;
209};
210
211/**
212 * Defines API set for decryption
213 */
214class DecryptApiType {
215private:
216 DecryptApiType();
217
218public:
219 /**
220 * Decrypt API set for non encrypted content
221 */
222 static const int NON_ENCRYPTED = 0x00;
223 /**
224 * Decrypt API set for ES based DRM
225 */
226 static const int ELEMENTARY_STREAM_BASED = 0x01;
227 /**
228 * POSIX based Decrypt API set for container based DRM
229 */
230 static const int CONTAINER_BASED = 0x02;
Gloria Wang6793a04d62010-10-29 16:44:37 -0700231 /**
232 * Decrypt API for Widevine streams
233 */
234 static const int WV_BASED = 0x3;
aimitakeshid074e302010-07-29 10:12:27 +0900235};
236
237/**
238 * Defines decryption information
239 */
240class DecryptInfo {
241public:
242 /**
243 * size of memory to be allocated to get the decrypted content.
244 */
245 int decryptBufferLength;
246 /**
247 * reserved for future purpose
248 */
249};
250
251/**
252 * Defines decryption handle
253 */
254class DecryptHandle {
255public:
256 /**
257 * Decryption session Handle
258 */
259 int decryptId;
260 /**
261 * Mimetype of the content to be used to select the media extractor
262 * For e.g., "video/mpeg" or "audio/mp3"
263 */
264 String8 mimeType;
265 /**
266 * Defines which decryption pattern should be used to decrypt the given content
267 * DrmFramework provides two different set of decryption APIs.
268 * 1. Decrypt APIs for elementary stream based DRM
269 * (file format is not encrypted but ES is encrypted)
270 * e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format)
271 *
Takeshi Aimidc549d62010-09-20 23:40:41 +0900272 * DecryptApiType::ELEMENTARY_STREAM_BASED
aimitakeshid074e302010-07-29 10:12:27 +0900273 * Decryption API set for ES based DRM
274 * initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit()
275 * 2. Decrypt APIs for container based DRM (file format itself is encrypted)
276 * e.g., OMA DRM (dcf file format)
277 *
Takeshi Aimidc549d62010-09-20 23:40:41 +0900278 * DecryptApiType::CONTAINER_BASED
aimitakeshid074e302010-07-29 10:12:27 +0900279 * POSIX based Decryption API set for container based DRM
280 * pread()
281 */
282 int decryptApiType;
283 /**
284 * Defines the status of the rights like
285 * RIGHTS_VALID, RIGHTS_INVALID, RIGHTS_EXPIRED or RIGHTS_NOT_ACQUIRED
286 */
287 int status;
288 /**
289 * Information required to decrypt content
290 * e.g. size of memory to be allocated to get the decrypted content.
291 */
292 DecryptInfo* decryptInfo;
Gloria Wangee4084b2011-03-21 16:53:14 -0700293 /**
294 * Defines a vector for the copy control settings sent from the DRM plugin
295 * to the player
296 */
297 KeyedVector<DrmCopyControl, int> copyControlVector;
aimitakeshid074e302010-07-29 10:12:27 +0900298
Gloria Wangc4303942011-03-21 17:22:13 -0700299 /**
300 * Defines a vector for any extra data the DRM plugin wants to send
301 * to the native code
302 */
303 KeyedVector<String8, String8> extendedData;
304
aimitakeshid074e302010-07-29 10:12:27 +0900305public:
306 DecryptHandle():
307 decryptId(INVALID_VALUE),
308 mimeType(""),
309 decryptApiType(INVALID_VALUE),
310 status(INVALID_VALUE) {
311
312 }
313
314 bool operator<(const DecryptHandle& handle) const {
315 return (decryptId < handle.decryptId);
316 }
317
318 bool operator==(const DecryptHandle& handle) const {
319 return (decryptId == handle.decryptId);
320 }
321};
322
323};
324
325#endif /* __DRM_FRAMEWORK_COMMON_H__ */
326