blob: 1758cdd61b3afa22736f91467f58b07568cf5966 [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/**
46 * Defines DRM Buffer
47 */
48class DrmBuffer {
49public:
50 char* data;
51 int length;
52
53 DrmBuffer() :
54 data(NULL),
55 length(0) {
56 }
57
58 DrmBuffer(char* dataBytes, int dataLength) :
59 data(dataBytes),
60 length(dataLength) {
61 }
62
63};
64
65/**
66 * Defines detailed description of the action
67 */
68class ActionDescription {
69public:
70 ActionDescription(int _outputType, int _configuration) :
71 outputType(_outputType),
72 configuration(_configuration) {
73 }
74
75public:
76 int outputType; /* BLUETOOTH , HDMI*/
77 int configuration; /* RESOLUTION_720_480 , RECORDABLE etc.*/
78};
79
80/**
81 * Defines constants related to DRM types
82 */
83class DrmObjectType {
84private:
85 DrmObjectType();
86
87public:
88 /**
89 * Field specifies the unknown type
90 */
91 static const int UNKNOWN = 0x00;
92 /**
93 * Field specifies the protected content type
94 */
95 static const int CONTENT = 0x01;
96 /**
97 * Field specifies the rights information
98 */
99 static const int RIGHTS_OBJECT = 0x02;
100 /**
101 * Field specifies the trigger information
102 */
103 static const int TRIGGER_OBJECT = 0x03;
104};
105
106/**
107 * Defines constants related to play back
108 */
109class Playback {
110private:
111 Playback();
112
113public:
114 /**
115 * Constant field signifies playback start
116 */
117 static const int START = 0x00;
118 /**
119 * Constant field signifies playback stop
120 */
121 static const int STOP = 0x01;
122 /**
123 * Constant field signifies playback paused
124 */
125 static const int PAUSE = 0x02;
126 /**
127 * Constant field signifies playback resumed
128 */
129 static const int RESUME = 0x03;
130};
131
132/**
133 * Defines actions that can be performed on protected content
134 */
135class Action {
136private:
137 Action();
138
139public:
140 /**
141 * Constant field signifies that the default action
142 */
143 static const int DEFAULT = 0x00;
144 /**
145 * Constant field signifies that the content can be played
146 */
147 static const int PLAY = 0x01;
148 /**
149 * Constant field signifies that the content can be set as ring tone
150 */
151 static const int RINGTONE = 0x02;
152 /**
153 * Constant field signifies that the content can be transfered
154 */
155 static const int TRANSFER = 0x03;
156 /**
157 * Constant field signifies that the content can be set as output
158 */
159 static const int OUTPUT = 0x04;
160 /**
161 * Constant field signifies that preview is allowed
162 */
163 static const int PREVIEW = 0x05;
164 /**
165 * Constant field signifies that the content can be executed
166 */
167 static const int EXECUTE = 0x06;
168 /**
169 * Constant field signifies that the content can displayed
170 */
171 static const int DISPLAY = 0x07;
172};
173
174/**
175 * Defines constants related to status of the rights
176 */
177class RightsStatus {
178private:
179 RightsStatus();
180
181public:
182 /**
183 * Constant field signifies that the rights are valid
184 */
185 static const int RIGHTS_VALID = 0x00;
186 /**
187 * Constant field signifies that the rights are invalid
188 */
189 static const int RIGHTS_INVALID = 0x01;
190 /**
191 * Constant field signifies that the rights are expired for the content
192 */
193 static const int RIGHTS_EXPIRED = 0x02;
194 /**
195 * Constant field signifies that the rights are not acquired for the content
196 */
197 static const int RIGHTS_NOT_ACQUIRED = 0x03;
198};
199
200/**
201 * Defines API set for decryption
202 */
203class DecryptApiType {
204private:
205 DecryptApiType();
206
207public:
208 /**
209 * Decrypt API set for non encrypted content
210 */
211 static const int NON_ENCRYPTED = 0x00;
212 /**
213 * Decrypt API set for ES based DRM
214 */
215 static const int ELEMENTARY_STREAM_BASED = 0x01;
216 /**
217 * POSIX based Decrypt API set for container based DRM
218 */
219 static const int CONTAINER_BASED = 0x02;
Gloria Wang6793a04d62010-10-29 16:44:37 -0700220 /**
221 * Decrypt API for Widevine streams
222 */
223 static const int WV_BASED = 0x3;
aimitakeshid074e302010-07-29 10:12:27 +0900224};
225
226/**
227 * Defines decryption information
228 */
229class DecryptInfo {
230public:
231 /**
232 * size of memory to be allocated to get the decrypted content.
233 */
234 int decryptBufferLength;
235 /**
236 * reserved for future purpose
237 */
238};
239
240/**
241 * Defines decryption handle
242 */
243class DecryptHandle {
244public:
245 /**
246 * Decryption session Handle
247 */
248 int decryptId;
249 /**
250 * Mimetype of the content to be used to select the media extractor
251 * For e.g., "video/mpeg" or "audio/mp3"
252 */
253 String8 mimeType;
254 /**
255 * Defines which decryption pattern should be used to decrypt the given content
256 * DrmFramework provides two different set of decryption APIs.
257 * 1. Decrypt APIs for elementary stream based DRM
258 * (file format is not encrypted but ES is encrypted)
259 * e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format)
260 *
Takeshi Aimidc549d62010-09-20 23:40:41 +0900261 * DecryptApiType::ELEMENTARY_STREAM_BASED
aimitakeshid074e302010-07-29 10:12:27 +0900262 * Decryption API set for ES based DRM
263 * initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit()
264 * 2. Decrypt APIs for container based DRM (file format itself is encrypted)
265 * e.g., OMA DRM (dcf file format)
266 *
Takeshi Aimidc549d62010-09-20 23:40:41 +0900267 * DecryptApiType::CONTAINER_BASED
aimitakeshid074e302010-07-29 10:12:27 +0900268 * POSIX based Decryption API set for container based DRM
269 * pread()
270 */
271 int decryptApiType;
272 /**
273 * Defines the status of the rights like
274 * RIGHTS_VALID, RIGHTS_INVALID, RIGHTS_EXPIRED or RIGHTS_NOT_ACQUIRED
275 */
276 int status;
277 /**
278 * Information required to decrypt content
279 * e.g. size of memory to be allocated to get the decrypted content.
280 */
281 DecryptInfo* decryptInfo;
282
283public:
284 DecryptHandle():
285 decryptId(INVALID_VALUE),
286 mimeType(""),
287 decryptApiType(INVALID_VALUE),
288 status(INVALID_VALUE) {
289
290 }
291
292 bool operator<(const DecryptHandle& handle) const {
293 return (decryptId < handle.decryptId);
294 }
295
296 bool operator==(const DecryptHandle& handle) const {
297 return (decryptId == handle.decryptId);
298 }
299};
300
301};
302
303#endif /* __DRM_FRAMEWORK_COMMON_H__ */
304