1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/omx-plugin/include/ics/drm/drm_framework_common.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,336 @@ 1.4 +/* 1.5 + * Copyright (C) 2010 The Android Open Source Project 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * Unless required by applicable law or agreed to in writing, software 1.14 + * distributed under the License is distributed on an "AS IS" BASIS, 1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.16 + * See the License for the specific language governing permissions and 1.17 + * limitations under the License. 1.18 + */ 1.19 + 1.20 +#ifndef __DRM_FRAMEWORK_COMMON_H__ 1.21 +#define __DRM_FRAMEWORK_COMMON_H__ 1.22 + 1.23 +#include <utils/Vector.h> 1.24 +#include <utils/KeyedVector.h> 1.25 +#include <utils/RefBase.h> 1.26 +#include <utils/String8.h> 1.27 +#include <utils/Errors.h> 1.28 + 1.29 +#define INVALID_VALUE -1 1.30 + 1.31 +namespace android { 1.32 + 1.33 +/** 1.34 + * Error code for DRM Frameowrk 1.35 + */ 1.36 +enum { 1.37 + // The following constant values should be in sync with 1.38 + // media/stagefright/MediaErrors.h 1.39 + ERROR_BASE = -2000, 1.40 + 1.41 + DRM_ERROR_UNKNOWN = ERROR_BASE, 1.42 + DRM_ERROR_NO_LICENSE = ERROR_BASE - 1, 1.43 + DRM_ERROR_LICENSE_EXPIRED = ERROR_BASE - 2, 1.44 + DRM_ERROR_SESSION_NOT_OPENED = ERROR_BASE - 3, 1.45 + DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED = ERROR_BASE - 4, 1.46 + DRM_ERROR_DECRYPT = ERROR_BASE - 5, 1.47 + DRM_ERROR_CANNOT_HANDLE = ERROR_BASE - 6, 1.48 + DRM_ERROR_TAMPER_DETECTED = ERROR_BASE - 7, 1.49 + 1.50 + DRM_NO_ERROR = NO_ERROR 1.51 +}; 1.52 + 1.53 +/** 1.54 + * copy control settings used in DecryptHandle::copyControlVector 1.55 + */ 1.56 +enum DrmCopyControl { 1.57 + DRM_COPY_CONTROL_BASE = 1000, 1.58 + // the key used to set the value for HDCP 1.59 + // if the associated value is 1, then HDCP is required 1.60 + // otherwise, HDCP is not required 1.61 + DRM_COPY_CONTROL_HDCP = DRM_COPY_CONTROL_BASE 1.62 +}; 1.63 + 1.64 +/** 1.65 + * Defines DRM Buffer 1.66 + */ 1.67 +class DrmBuffer { 1.68 +public: 1.69 + char* data; 1.70 + int length; 1.71 + 1.72 + DrmBuffer() : 1.73 + data(NULL), 1.74 + length(0) { 1.75 + } 1.76 + 1.77 + DrmBuffer(char* dataBytes, int dataLength) : 1.78 + data(dataBytes), 1.79 + length(dataLength) { 1.80 + } 1.81 + 1.82 +}; 1.83 + 1.84 +/** 1.85 + * Defines detailed description of the action 1.86 + */ 1.87 +class ActionDescription { 1.88 +public: 1.89 + ActionDescription(int _outputType, int _configuration) : 1.90 + outputType(_outputType), 1.91 + configuration(_configuration) { 1.92 + } 1.93 + 1.94 +public: 1.95 + int outputType; /* BLUETOOTH , HDMI*/ 1.96 + int configuration; /* RESOLUTION_720_480 , RECORDABLE etc.*/ 1.97 +}; 1.98 + 1.99 +/** 1.100 + * Defines constants related to DRM types 1.101 + */ 1.102 +class DrmObjectType { 1.103 +private: 1.104 + DrmObjectType(); 1.105 + 1.106 +public: 1.107 + /** 1.108 + * Field specifies the unknown type 1.109 + */ 1.110 + static const int UNKNOWN = 0x00; 1.111 + /** 1.112 + * Field specifies the protected content type 1.113 + */ 1.114 + static const int CONTENT = 0x01; 1.115 + /** 1.116 + * Field specifies the rights information 1.117 + */ 1.118 + static const int RIGHTS_OBJECT = 0x02; 1.119 + /** 1.120 + * Field specifies the trigger information 1.121 + */ 1.122 + static const int TRIGGER_OBJECT = 0x03; 1.123 +}; 1.124 + 1.125 +/** 1.126 + * Defines constants related to play back 1.127 + */ 1.128 +class Playback { 1.129 +private: 1.130 + Playback(); 1.131 + 1.132 +public: 1.133 + /** 1.134 + * Constant field signifies playback start 1.135 + */ 1.136 + static const int START = 0x00; 1.137 + /** 1.138 + * Constant field signifies playback stop 1.139 + */ 1.140 + static const int STOP = 0x01; 1.141 + /** 1.142 + * Constant field signifies playback paused 1.143 + */ 1.144 + static const int PAUSE = 0x02; 1.145 + /** 1.146 + * Constant field signifies playback resumed 1.147 + */ 1.148 + static const int RESUME = 0x03; 1.149 +}; 1.150 + 1.151 +/** 1.152 + * Defines actions that can be performed on protected content 1.153 + */ 1.154 +class Action { 1.155 +private: 1.156 + Action(); 1.157 + 1.158 +public: 1.159 + /** 1.160 + * Constant field signifies that the default action 1.161 + */ 1.162 + static const int DEFAULT = 0x00; 1.163 + /** 1.164 + * Constant field signifies that the content can be played 1.165 + */ 1.166 + static const int PLAY = 0x01; 1.167 + /** 1.168 + * Constant field signifies that the content can be set as ring tone 1.169 + */ 1.170 + static const int RINGTONE = 0x02; 1.171 + /** 1.172 + * Constant field signifies that the content can be transfered 1.173 + */ 1.174 + static const int TRANSFER = 0x03; 1.175 + /** 1.176 + * Constant field signifies that the content can be set as output 1.177 + */ 1.178 + static const int OUTPUT = 0x04; 1.179 + /** 1.180 + * Constant field signifies that preview is allowed 1.181 + */ 1.182 + static const int PREVIEW = 0x05; 1.183 + /** 1.184 + * Constant field signifies that the content can be executed 1.185 + */ 1.186 + static const int EXECUTE = 0x06; 1.187 + /** 1.188 + * Constant field signifies that the content can displayed 1.189 + */ 1.190 + static const int DISPLAY = 0x07; 1.191 +}; 1.192 + 1.193 +/** 1.194 + * Defines constants related to status of the rights 1.195 + */ 1.196 +class RightsStatus { 1.197 +private: 1.198 + RightsStatus(); 1.199 + 1.200 +public: 1.201 + /** 1.202 + * Constant field signifies that the rights are valid 1.203 + */ 1.204 + static const int RIGHTS_VALID = 0x00; 1.205 + /** 1.206 + * Constant field signifies that the rights are invalid 1.207 + */ 1.208 + static const int RIGHTS_INVALID = 0x01; 1.209 + /** 1.210 + * Constant field signifies that the rights are expired for the content 1.211 + */ 1.212 + static const int RIGHTS_EXPIRED = 0x02; 1.213 + /** 1.214 + * Constant field signifies that the rights are not acquired for the content 1.215 + */ 1.216 + static const int RIGHTS_NOT_ACQUIRED = 0x03; 1.217 +}; 1.218 + 1.219 +/** 1.220 + * Defines API set for decryption 1.221 + */ 1.222 +class DecryptApiType { 1.223 +private: 1.224 + DecryptApiType(); 1.225 + 1.226 +public: 1.227 + /** 1.228 + * Decrypt API set for non encrypted content 1.229 + */ 1.230 + static const int NON_ENCRYPTED = 0x00; 1.231 + /** 1.232 + * Decrypt API set for ES based DRM 1.233 + */ 1.234 + static const int ELEMENTARY_STREAM_BASED = 0x01; 1.235 + /** 1.236 + * POSIX based Decrypt API set for container based DRM 1.237 + */ 1.238 + static const int CONTAINER_BASED = 0x02; 1.239 + /** 1.240 + * Decrypt API for Widevine streams 1.241 + */ 1.242 + static const int WV_BASED = 0x3; 1.243 +}; 1.244 + 1.245 +/** 1.246 + * Defines decryption information 1.247 + */ 1.248 +class DecryptInfo { 1.249 +public: 1.250 + /** 1.251 + * size of memory to be allocated to get the decrypted content. 1.252 + */ 1.253 + int decryptBufferLength; 1.254 + /** 1.255 + * reserved for future purpose 1.256 + */ 1.257 +}; 1.258 + 1.259 +/** 1.260 + * Defines decryption handle 1.261 + */ 1.262 +class DecryptHandle : public RefBase { 1.263 +public: 1.264 + /** 1.265 + * Decryption session Handle 1.266 + */ 1.267 + int decryptId; 1.268 + /** 1.269 + * Mimetype of the content to be used to select the media extractor 1.270 + * For e.g., "video/mpeg" or "audio/mp3" 1.271 + */ 1.272 + String8 mimeType; 1.273 + /** 1.274 + * Defines which decryption pattern should be used to decrypt the given content 1.275 + * DrmFramework provides two different set of decryption APIs. 1.276 + * 1. Decrypt APIs for elementary stream based DRM 1.277 + * (file format is not encrypted but ES is encrypted) 1.278 + * e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format) 1.279 + * 1.280 + * DecryptApiType::ELEMENTARY_STREAM_BASED 1.281 + * Decryption API set for ES based DRM 1.282 + * initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit() 1.283 + * 2. Decrypt APIs for container based DRM (file format itself is encrypted) 1.284 + * e.g., OMA DRM (dcf file format) 1.285 + * 1.286 + * DecryptApiType::CONTAINER_BASED 1.287 + * POSIX based Decryption API set for container based DRM 1.288 + * pread() 1.289 + */ 1.290 + int decryptApiType; 1.291 + /** 1.292 + * Defines the status of the rights like 1.293 + * RIGHTS_VALID, RIGHTS_INVALID, RIGHTS_EXPIRED or RIGHTS_NOT_ACQUIRED 1.294 + */ 1.295 + int status; 1.296 + /** 1.297 + * Information required to decrypt content 1.298 + * e.g. size of memory to be allocated to get the decrypted content. 1.299 + */ 1.300 + DecryptInfo* decryptInfo; 1.301 + /** 1.302 + * Defines a vector for the copy control settings sent from the DRM plugin 1.303 + * to the player 1.304 + */ 1.305 + KeyedVector<DrmCopyControl, int> copyControlVector; 1.306 + 1.307 + /** 1.308 + * Defines a vector for any extra data the DRM plugin wants to send 1.309 + * to the native code 1.310 + */ 1.311 + KeyedVector<String8, String8> extendedData; 1.312 + 1.313 +public: 1.314 + DecryptHandle(): 1.315 + decryptId(INVALID_VALUE), 1.316 + mimeType(""), 1.317 + decryptApiType(INVALID_VALUE), 1.318 + status(INVALID_VALUE), 1.319 + decryptInfo(NULL) { 1.320 + 1.321 + } 1.322 + 1.323 + ~DecryptHandle() { 1.324 + delete decryptInfo; decryptInfo = NULL; 1.325 + } 1.326 + 1.327 + bool operator<(const DecryptHandle& handle) const { 1.328 + return (decryptId < handle.decryptId); 1.329 + } 1.330 + 1.331 + bool operator==(const DecryptHandle& handle) const { 1.332 + return (decryptId == handle.decryptId); 1.333 + } 1.334 +}; 1.335 + 1.336 +}; 1.337 + 1.338 +#endif /* __DRM_FRAMEWORK_COMMON_H__ */ 1.339 +