michael@0: /* michael@0: * Copyright (C) 2010 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef __DRM_FRAMEWORK_COMMON_H__ michael@0: #define __DRM_FRAMEWORK_COMMON_H__ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #define INVALID_VALUE -1 michael@0: michael@0: namespace android { michael@0: michael@0: /** michael@0: * Error code for DRM Frameowrk michael@0: */ michael@0: enum { michael@0: // The following constant values should be in sync with michael@0: // media/stagefright/MediaErrors.h michael@0: ERROR_BASE = -2000, michael@0: michael@0: DRM_ERROR_UNKNOWN = ERROR_BASE, michael@0: DRM_ERROR_NO_LICENSE = ERROR_BASE - 1, michael@0: DRM_ERROR_LICENSE_EXPIRED = ERROR_BASE - 2, michael@0: DRM_ERROR_SESSION_NOT_OPENED = ERROR_BASE - 3, michael@0: DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED = ERROR_BASE - 4, michael@0: DRM_ERROR_DECRYPT = ERROR_BASE - 5, michael@0: DRM_ERROR_CANNOT_HANDLE = ERROR_BASE - 6, michael@0: DRM_ERROR_TAMPER_DETECTED = ERROR_BASE - 7, michael@0: michael@0: DRM_NO_ERROR = NO_ERROR michael@0: }; michael@0: michael@0: /** michael@0: * copy control settings used in DecryptHandle::copyControlVector michael@0: */ michael@0: enum DrmCopyControl { michael@0: DRM_COPY_CONTROL_BASE = 1000, michael@0: // the key used to set the value for HDCP michael@0: // if the associated value is 1, then HDCP is required michael@0: // otherwise, HDCP is not required michael@0: DRM_COPY_CONTROL_HDCP = DRM_COPY_CONTROL_BASE michael@0: }; michael@0: michael@0: /** michael@0: * Defines DRM Buffer michael@0: */ michael@0: class DrmBuffer { michael@0: public: michael@0: char* data; michael@0: int length; michael@0: michael@0: DrmBuffer() : michael@0: data(NULL), michael@0: length(0) { michael@0: } michael@0: michael@0: DrmBuffer(char* dataBytes, int dataLength) : michael@0: data(dataBytes), michael@0: length(dataLength) { michael@0: } michael@0: michael@0: }; michael@0: michael@0: /** michael@0: * Defines detailed description of the action michael@0: */ michael@0: class ActionDescription { michael@0: public: michael@0: ActionDescription(int _outputType, int _configuration) : michael@0: outputType(_outputType), michael@0: configuration(_configuration) { michael@0: } michael@0: michael@0: public: michael@0: int outputType; /* BLUETOOTH , HDMI*/ michael@0: int configuration; /* RESOLUTION_720_480 , RECORDABLE etc.*/ michael@0: }; michael@0: michael@0: /** michael@0: * Defines constants related to DRM types michael@0: */ michael@0: class DrmObjectType { michael@0: private: michael@0: DrmObjectType(); michael@0: michael@0: public: michael@0: /** michael@0: * Field specifies the unknown type michael@0: */ michael@0: static const int UNKNOWN = 0x00; michael@0: /** michael@0: * Field specifies the protected content type michael@0: */ michael@0: static const int CONTENT = 0x01; michael@0: /** michael@0: * Field specifies the rights information michael@0: */ michael@0: static const int RIGHTS_OBJECT = 0x02; michael@0: /** michael@0: * Field specifies the trigger information michael@0: */ michael@0: static const int TRIGGER_OBJECT = 0x03; michael@0: }; michael@0: michael@0: /** michael@0: * Defines constants related to play back michael@0: */ michael@0: class Playback { michael@0: private: michael@0: Playback(); michael@0: michael@0: public: michael@0: /** michael@0: * Constant field signifies playback start michael@0: */ michael@0: static const int START = 0x00; michael@0: /** michael@0: * Constant field signifies playback stop michael@0: */ michael@0: static const int STOP = 0x01; michael@0: /** michael@0: * Constant field signifies playback paused michael@0: */ michael@0: static const int PAUSE = 0x02; michael@0: /** michael@0: * Constant field signifies playback resumed michael@0: */ michael@0: static const int RESUME = 0x03; michael@0: }; michael@0: michael@0: /** michael@0: * Defines actions that can be performed on protected content michael@0: */ michael@0: class Action { michael@0: private: michael@0: Action(); michael@0: michael@0: public: michael@0: /** michael@0: * Constant field signifies that the default action michael@0: */ michael@0: static const int DEFAULT = 0x00; michael@0: /** michael@0: * Constant field signifies that the content can be played michael@0: */ michael@0: static const int PLAY = 0x01; michael@0: /** michael@0: * Constant field signifies that the content can be set as ring tone michael@0: */ michael@0: static const int RINGTONE = 0x02; michael@0: /** michael@0: * Constant field signifies that the content can be transfered michael@0: */ michael@0: static const int TRANSFER = 0x03; michael@0: /** michael@0: * Constant field signifies that the content can be set as output michael@0: */ michael@0: static const int OUTPUT = 0x04; michael@0: /** michael@0: * Constant field signifies that preview is allowed michael@0: */ michael@0: static const int PREVIEW = 0x05; michael@0: /** michael@0: * Constant field signifies that the content can be executed michael@0: */ michael@0: static const int EXECUTE = 0x06; michael@0: /** michael@0: * Constant field signifies that the content can displayed michael@0: */ michael@0: static const int DISPLAY = 0x07; michael@0: }; michael@0: michael@0: /** michael@0: * Defines constants related to status of the rights michael@0: */ michael@0: class RightsStatus { michael@0: private: michael@0: RightsStatus(); michael@0: michael@0: public: michael@0: /** michael@0: * Constant field signifies that the rights are valid michael@0: */ michael@0: static const int RIGHTS_VALID = 0x00; michael@0: /** michael@0: * Constant field signifies that the rights are invalid michael@0: */ michael@0: static const int RIGHTS_INVALID = 0x01; michael@0: /** michael@0: * Constant field signifies that the rights are expired for the content michael@0: */ michael@0: static const int RIGHTS_EXPIRED = 0x02; michael@0: /** michael@0: * Constant field signifies that the rights are not acquired for the content michael@0: */ michael@0: static const int RIGHTS_NOT_ACQUIRED = 0x03; michael@0: }; michael@0: michael@0: /** michael@0: * Defines API set for decryption michael@0: */ michael@0: class DecryptApiType { michael@0: private: michael@0: DecryptApiType(); michael@0: michael@0: public: michael@0: /** michael@0: * Decrypt API set for non encrypted content michael@0: */ michael@0: static const int NON_ENCRYPTED = 0x00; michael@0: /** michael@0: * Decrypt API set for ES based DRM michael@0: */ michael@0: static const int ELEMENTARY_STREAM_BASED = 0x01; michael@0: /** michael@0: * POSIX based Decrypt API set for container based DRM michael@0: */ michael@0: static const int CONTAINER_BASED = 0x02; michael@0: /** michael@0: * Decrypt API for Widevine streams michael@0: */ michael@0: static const int WV_BASED = 0x3; michael@0: }; michael@0: michael@0: /** michael@0: * Defines decryption information michael@0: */ michael@0: class DecryptInfo { michael@0: public: michael@0: /** michael@0: * size of memory to be allocated to get the decrypted content. michael@0: */ michael@0: int decryptBufferLength; michael@0: /** michael@0: * reserved for future purpose michael@0: */ michael@0: }; michael@0: michael@0: /** michael@0: * Defines decryption handle michael@0: */ michael@0: class DecryptHandle : public RefBase { michael@0: public: michael@0: /** michael@0: * Decryption session Handle michael@0: */ michael@0: int decryptId; michael@0: /** michael@0: * Mimetype of the content to be used to select the media extractor michael@0: * For e.g., "video/mpeg" or "audio/mp3" michael@0: */ michael@0: String8 mimeType; michael@0: /** michael@0: * Defines which decryption pattern should be used to decrypt the given content michael@0: * DrmFramework provides two different set of decryption APIs. michael@0: * 1. Decrypt APIs for elementary stream based DRM michael@0: * (file format is not encrypted but ES is encrypted) michael@0: * e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format) michael@0: * michael@0: * DecryptApiType::ELEMENTARY_STREAM_BASED michael@0: * Decryption API set for ES based DRM michael@0: * initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit() michael@0: * 2. Decrypt APIs for container based DRM (file format itself is encrypted) michael@0: * e.g., OMA DRM (dcf file format) michael@0: * michael@0: * DecryptApiType::CONTAINER_BASED michael@0: * POSIX based Decryption API set for container based DRM michael@0: * pread() michael@0: */ michael@0: int decryptApiType; michael@0: /** michael@0: * Defines the status of the rights like michael@0: * RIGHTS_VALID, RIGHTS_INVALID, RIGHTS_EXPIRED or RIGHTS_NOT_ACQUIRED michael@0: */ michael@0: int status; michael@0: /** michael@0: * Information required to decrypt content michael@0: * e.g. size of memory to be allocated to get the decrypted content. michael@0: */ michael@0: DecryptInfo* decryptInfo; michael@0: /** michael@0: * Defines a vector for the copy control settings sent from the DRM plugin michael@0: * to the player michael@0: */ michael@0: KeyedVector copyControlVector; michael@0: michael@0: /** michael@0: * Defines a vector for any extra data the DRM plugin wants to send michael@0: * to the native code michael@0: */ michael@0: KeyedVector extendedData; michael@0: michael@0: public: michael@0: DecryptHandle(): michael@0: decryptId(INVALID_VALUE), michael@0: mimeType(""), michael@0: decryptApiType(INVALID_VALUE), michael@0: status(INVALID_VALUE), michael@0: decryptInfo(NULL) { michael@0: michael@0: } michael@0: michael@0: ~DecryptHandle() { michael@0: delete decryptInfo; decryptInfo = NULL; michael@0: } michael@0: michael@0: bool operator<(const DecryptHandle& handle) const { michael@0: return (decryptId < handle.decryptId); michael@0: } michael@0: michael@0: bool operator==(const DecryptHandle& handle) const { michael@0: return (decryptId == handle.decryptId); michael@0: } michael@0: }; michael@0: michael@0: }; michael@0: michael@0: #endif /* __DRM_FRAMEWORK_COMMON_H__ */ michael@0: