1fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/* 2fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Copyright (C) 2010 The Android Open Source Project 3fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 4fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Licensed under the Apache License, Version 2.0 (the "License"); 5fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * you may not use this file except in compliance with the License. 6fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * You may obtain a copy of the License at 7fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 8fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * http://www.apache.org/licenses/LICENSE-2.0 9fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 10fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Unless required by applicable law or agreed to in writing, software 11fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * distributed under the License is distributed on an "AS IS" BASIS, 12fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * See the License for the specific language governing permissions and 14fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * limitations under the License. 15fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 16fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 17fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifndef __FWDLOCKENGINE_H__ 18fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#define __FWDLOCKENGINE_H__ 19fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 20fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmEngineBase.h> 21fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmConstraints.h> 22fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmRights.h> 23fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmInfo.h> 24fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmInfoStatus.h> 25fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmConvertedStatus.h> 26fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmInfoRequest.h> 27fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmSupportInfo.h> 28fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <DrmInfoEvent.h> 29fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 30fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include "SessionMap.h" 31fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include "FwdLockConv.h" 32fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 33fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheranamespace android { 34fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 35fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 36fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Forward Lock Engine class. 37fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 38fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraclass FwdLockEngine : public android::DrmEngineBase { 39fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 40fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherapublic: 41fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera FwdLockEngine(); 42fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera virtual ~FwdLockEngine(); 43fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 44fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraprotected: 45fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 46fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Get constraint information associated with input content. 47fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 48fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 49fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path of the protected content 50fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param action Actions defined such as, 51fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Action::DEFAULT, Action::PLAY, etc 52fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return DrmConstraints 53fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * key-value pairs of constraint are embedded in it 54fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @note 55fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * In case of error, return NULL 56fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 57fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmConstraints* onGetConstraints(int uniqueId, const String8* path, int action); 58fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 59fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 60fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Get metadata information associated with input content. 61fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 62fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 63fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path of the protected content 64fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return DrmMetadata 65fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * For Forward Lock engine, it returns an empty object 66fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @note 67fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * In case of error, returns NULL 68fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 69fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmMetadata* onGetMetadata(int uniqueId, const String8* path); 70fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 71fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 72fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Initialize plug-in. 73fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 74fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 75fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 76fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 77fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 78fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onInitialize(int uniqueId); 79fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 80fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 81fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Register a callback to be invoked when the caller required to 82fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * receive necessary information. 83fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 84fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 85fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param infoListener Listener 86fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 87fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 88fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 89fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onSetOnInfoListener(int uniqueId, const IDrmEngine::OnInfoListener* infoListener); 90fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 91fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 92fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Terminate the plug-in and release resources bound to it. 93fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 94fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 95fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 96fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 97fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 98fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onTerminate(int uniqueId); 99fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 100fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 101fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Get whether the given content can be handled by this plugin or not. 102fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 103fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 104fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path to the protected object 105fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return bool 106fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns true if this plugin can handle , false in case of not able to handle 107fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 108fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherabool onCanHandle(int uniqueId, const String8& path); 109fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 110fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 111fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Processes the given DRM information as appropriate for its type. 112fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Not used for Forward Lock Engine. 113fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 114fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 115fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param drmInfo Information that needs to be processed 116fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return DrmInfoStatus 117fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * instance as a result of processing given input 118fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 119fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo); 120fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 121fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 122fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Save DRM rights to specified rights path 123fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * and make association with content path. 124fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 125fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 126fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param drmRights DrmRights to be saved 127fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param rightsPath File path where rights to be saved 128fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param contentPath File path where content was saved 129fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 130fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 131fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 132fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onSaveRights(int uniqueId, 133fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const DrmRights& drmRights, 134fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const String8& rightsPath, 135fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const String8& contentPath); 136fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 137fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 138fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Retrieves necessary information for registration, unregistration or rights 139fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * acquisition information. 140fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 141fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 142fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param drmInfoRequest Request information to retrieve drmInfo 143fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return DrmInfo 144fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * instance as a result of processing given input 145fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 146fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmInfo* onAcquireDrmInfo(int uniqueId, 147fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const DrmInfoRequest* drmInfoRequest); 148fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 149fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 150fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Retrieves the mime type embedded inside the original content. 151fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 152fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 153bf5b3b29e31b293313788d7464cfb258ac0da803James Dong * @param path Path of the conent or null. 154bf5b3b29e31b293313788d7464cfb258ac0da803James Dong * @param fd descriptor of the protected content as a file source 155fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return String8 156fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns mime-type of the original content, such as "video/mpeg" 157fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 158bf5b3b29e31b293313788d7464cfb258ac0da803James DongString8 onGetOriginalMimeType(int uniqueId, const String8& path, int fd); 159fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 160fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 161fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Retrieves the type of the protected object (content, rights, etc..) 162fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * using specified path or mimetype. At least one parameter should be non null 163fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * to retrieve DRM object type. 164fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 165fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 166fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path of the content or null. 167fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param mimeType Mime type of the content or null. 168fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return type of the DRM content, 169fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * such as DrmObjectType::CONTENT, DrmObjectType::RIGHTS_OBJECT 170fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 171fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraint onGetDrmObjectType(int uniqueId, 172fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const String8& path, 173fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const String8& mimeType); 174fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 175fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 176fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Check whether the given content has valid rights or not. 177fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 178fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 179fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path of the protected content 180fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param action Action to perform (Action::DEFAULT, Action::PLAY, etc) 181fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return the status of the rights for the protected content, 182fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * such as RightsStatus::RIGHTS_VALID, RightsStatus::RIGHTS_EXPIRED, etc. 183fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 184fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraint onCheckRightsStatus(int uniqueId, 185fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const String8& path, 186fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int action); 187fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 188fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 189fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Consumes the rights for a content. 190fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * If the reserve parameter is true the rights are reserved until the same 191fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * application calls this api again with the reserve parameter set to false. 192fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 193fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 194fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 195fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param action Action to perform. (Action::DEFAULT, Action::PLAY, etc) 196fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param reserve True if the rights should be reserved. 197fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 198fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 199fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 200fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onConsumeRights(int uniqueId, 201fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 202fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int action, 203fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera bool reserve); 204fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 205fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 206fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Informs the DRM Engine about the playback actions performed on the DRM files. 207fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 208fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 209fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 210fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE) 211fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param position Position in the file (in milliseconds) where the start occurs. 212fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Only valid together with Playback::START. 213fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 214fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 215fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 216fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifdef USE_64BIT_DRM_API 217fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onSetPlaybackStatus(int uniqueId, 218fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 219fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int playbackStatus, 220fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int64_t position); 221fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#else 222fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onSetPlaybackStatus(int uniqueId, 223fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 224fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int playbackStatus, 225fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int position); 226fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif 227fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 228fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 229fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Validates whether an action on the DRM content is allowed or not. 230fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 231fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 232fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path of the protected content 233fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param action Action to validate (Action::PLAY, Action::TRANSFER, etc) 234fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param description Detailed description of the action 235fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return true if the action is allowed. 236fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 237fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherabool onValidateAction(int uniqueId, 238fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const String8& path, 239fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int action, 240fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const ActionDescription& description); 241fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 242fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 243fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Removes the rights associated with the given protected content. 244fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Not used for Forward Lock Engine. 245fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 246fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 247fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param path Path of the protected content 248fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 249fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 250fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 251fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onRemoveRights(int uniqueId, const String8& path); 252fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 253fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 254fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Removes all the rights information of each plug-in associated with 255fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM framework. Will be used in master reset but does nothing for 256fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Forward Lock Engine. 257fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 258fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 259fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 260fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 261fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 262fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onRemoveAllRights(int uniqueId); 263fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 264fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 265fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Starts the Forward Lock file conversion session. 266fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Each time the application tries to download a new DRM file 267fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * which needs to be converted, then the application has to 268fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * begin with calling this API. The convertId is used as the conversion session key 269fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * and must not be the same for different convert sessions. 270fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 271fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 272fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param convertId Handle for the convert session 273fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 274fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 275fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 276fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onOpenConvertSession(int uniqueId, int convertId); 277fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 278fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 279fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Accepts and converts the input data which is part of DRM file. 280fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * The resultant converted data and the status is returned in the DrmConvertedInfo 281fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * object. This method will be called each time there is a new block 282fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * of data received by the application. 283fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 284fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 285fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param convertId Handle for the convert session 286fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param inputData Input Data which need to be converted 287fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return Return object contains the status of the data conversion, 288fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * the output converted data and offset. In this case the 289fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * application will ignore the offset information. 290fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 291fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmConvertedStatus* onConvertData(int uniqueId, 292fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int convertId, 293fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const DrmBuffer* inputData); 294fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 295fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 296fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Closes the convert session in case of data supply completed or error occurred. 297fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Upon successful conversion of the complete data, it returns signature calculated over 298fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * the entire data used over a conversion session. This signature must be copied to the offset 299fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * mentioned in the DrmConvertedStatus. Signature is used for data integrity protection. 300fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 301fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 302fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param convertId Handle for the convert session 303fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return Return object contains the status of the data conversion, 304fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * the header and body signature data. It also informs 305fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * the application about the file offset at which this 306fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * signature data should be written. 307fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 308fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmConvertedStatus* onCloseConvertSession(int uniqueId, int convertId); 309fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 310fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 311fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns the information about the Drm Engine capabilities which includes 312fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * supported MimeTypes and file suffixes. 313fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 314fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 315fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return DrmSupportInfo 316fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * instance which holds the capabilities of a plug-in 317fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 318fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraDrmSupportInfo* onGetSupportInfo(int uniqueId); 319fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 320fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 321fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Open the decrypt session to decrypt the given protected content. 322fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 323fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 324fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the current decryption session 325fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param fd File descriptor of the protected content to be decrypted 326fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param offset Start position of the content 327fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param length The length of the protected content 328fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return 329fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success 330fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 331fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifdef USE_64BIT_DRM_API 332fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onOpenDecryptSession(int uniqueId, 333fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 334fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int fd, off64_t offset, off64_t length); 335fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#else 336fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onOpenDecryptSession(int uniqueId, 337fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 338fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int fd, int offset, int length); 339fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif 340fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 341fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 342fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Open the decrypt session to decrypt the given protected content. 343fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 344fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 345fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the current decryption session 346fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uri Path of the protected content to be decrypted 347fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return 348fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success 349fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 350fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onOpenDecryptSession(int uniqueId, 351fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 352fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const char* uri); 353fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 354fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 355fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Close the decrypt session for the given handle. 356fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 357fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 358fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 359fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 360fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure 361fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 362fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onCloseDecryptSession(int uniqueId, 363fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle); 364fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 365fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 366fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Initialize decryption for the given unit of the protected content. 367fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 368fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 369fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 370fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptUnitId ID which specifies decryption unit, such as track ID 371fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param headerInfo Information for initializing decryption of this decrypUnit 372fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return 373fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success 374fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 375fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onInitializeDecryptUnit(int uniqueId, 376fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 377fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int decryptUnitId, 378fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const DrmBuffer* headerInfo); 379fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 380fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 381fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Decrypt the protected content buffers for the given unit. 382fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * This method will be called any number of times, based on number of 383fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * encrypted streams received from application. 384fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 385fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 386fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 387fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptUnitId ID which specifies decryption unit, such as track ID 388fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param encBuffer Encrypted data block 389fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decBuffer Decrypted data block 390fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 391fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns the error code for this API 392fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED 393fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED, 394fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_DECRYPT for failure. 395fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 396fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onDecrypt(int uniqueId, 397fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 398fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int decryptUnitId, 399fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const DrmBuffer* encBuffer, 400fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DrmBuffer** decBuffer); 401fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 402fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 403fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Decrypt the protected content buffers for the given unit. 404fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * This method will be called any number of times, based on number of 405fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * encrypted streams received from application. 406fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 407fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 408fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptId Handle for the decryption session 409fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptUnitId ID Specifies decryption unit, such as track ID 410fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param encBuffer Encrypted data block 411fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decBuffer Decrypted data block 412fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param IV Optional buffer 413fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return status_t 414fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Returns the error code for this API 415fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED 416fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED, 417fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_DECRYPT for failure. 418fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 419fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, 420fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int decryptUnitId, const DrmBuffer* encBuffer, 421fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DrmBuffer** decBuffer, DrmBuffer* IV); 422fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 423fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 424fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Finalize decryption for the given unit of the protected content. 425fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 426fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 427fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 428fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptUnitId ID Specifies decryption unit, such as track ID 429fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return 430fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success 431fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 432fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatus_t onFinalizeDecryptUnit(int uniqueId, 433fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 434fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int decryptUnitId); 435fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 436fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 437fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Reads the specified number of bytes from an open DRM file. 438fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 439fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 440fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 441fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param buffer Reference to the buffer that should receive the read data. 442fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param numBytes Number of bytes to read. 443fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 444fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return Number of bytes read. 445fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @retval -1 Failure. 446fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 447fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherassize_t onRead(int uniqueId, 448fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 449fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera void* pBuffer, 450fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int numBytes); 451fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 452fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 453fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Updates the file position within an open DRM file. 454fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 455fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 456fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 457fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param offset Offset with which to update the file position. 458fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param whence One of SEEK_SET, SEEK_CUR, and SEEK_END. 459fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * These constants are defined in unistd.h. 460fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 461fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return New file position. 462fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @retval ((off_t)-1) Failure. 463fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 464fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifdef USE_64BIT_DRM_API 465fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraoff64_t onLseek(int uniqueId, 466fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 467fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera off64_t offset, 468fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int whence); 469fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#else 470fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraoff_t onLseek(int uniqueId, 471fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 472fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera off_t offset, 473fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int whence); 474fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif 475fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 476fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 477fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Reads the specified number of bytes from an open DRM file. 478fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 479fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param uniqueId Unique identifier for a session 480fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param decryptHandle Handle for the decryption session 481fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param buffer Reference to the buffer that should receive the read data. 482fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param numBytes Number of bytes to read. 483fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param offset Offset with which to update the file position. 484fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 485fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return Number of bytes read. Returns -1 for Failure. 486fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 487fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifdef USE_64BIT_DRM_API 488fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherassize_t onPread(int uniqueId, 489fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 490fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera void* buffer, 491fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera ssize_t numBytes, 492fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera off64_t offset); 493fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#else 494fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherassize_t onPread(int uniqueId, 495fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecryptHandle* decryptHandle, 496fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera void* buffer, 497fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera ssize_t numBytes, 498fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera off_t offset); 499fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif 500fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 501fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraprivate: 502fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 503bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static const String8 Description; 504bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static const String8 FileSuffixes[]; 505bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static const String8 MimeTypes[]; 506bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static bool IsFileSuffixSupported(const String8& suffix); 507bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static bool IsMimeTypeSupported(const String8& mime); 508bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static void AddSupportedMimeTypes(DrmSupportInfo *info); 509bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong static void AddSupportedFileSuffixes(DrmSupportInfo *info); 510bd2f13ddbe7a9e7550205f6b53880329e09b9457James Dong 511fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 512fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Session Class for Forward Lock Conversion. An object of this class is created 513fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * for every conversion. 514fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 515fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraclass ConvertSession { 516fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera public : 517fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int uniqueId; 518fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera FwdLockConv_Output_t output; 519fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 520fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera ConvertSession() { 521fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera uniqueId = 0; 522fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera memset(&output, 0, sizeof(FwdLockConv_Output_t)); 523fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera } 524fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 525fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera virtual ~ConvertSession() {} 526fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera}; 527fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 528fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 529fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Session Class for Forward Lock decoder. An object of this class is created 530fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * for every decoding session. 531fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 532fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraclass DecodeSession { 533fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera public : 534fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera int fileDesc; 535fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera off_t offset; 536fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 537fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera DecodeSession() { 538fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera fileDesc = -1; 539fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera offset = 0; 540fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera } 541fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 5428c0164ca98bcc76f3656fb1078033bffd4a387deChih-Hung Hsieh explicit DecodeSession(int fd) { 543fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera fileDesc = fd; 544fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera offset = 0; 545fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera } 546fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 547fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera virtual ~DecodeSession() {} 548fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera}; 549fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 550fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 551fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Session Map Tables for Conversion and Decoding of forward lock files. 552fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 553fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraSessionMap<ConvertSession*> convertSessionMap; 554fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat DalbeheraSessionMap<DecodeSession*> decodeSessionMap; 555fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 556fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** 557fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * Converts the error code from Forward Lock Converter to DrmConvertStatus error code. 558fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 559fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @param Forward Lock Converter error code 560fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * 561fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * @return Status code from DrmConvertStatus. 562fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 563fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherastatic int getConvertedStatus(FwdLockConv_Status_t status); 564fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera}; 565fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 566fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera}; 567fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 568fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif /* __FWDLOCKENGINE_H__ */ 569