1*4d7e907cSAndroid Build Coastguard Worker/** 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 17*4d7e907cSAndroid Build Coastguard Worker 18*4d7e907cSAndroid Build Coastguard Workerimport @1.0::IDrmPlugin; 19*4d7e907cSAndroid Build Coastguard Workerimport @1.0::IDrmPluginListener; 20*4d7e907cSAndroid Build Coastguard Workerimport @1.0::KeyedVector; 21*4d7e907cSAndroid Build Coastguard Workerimport @1.0::KeyType; 22*4d7e907cSAndroid Build Coastguard Workerimport @1.0::Status; 23*4d7e907cSAndroid Build Coastguard Workerimport @1.1::DrmMetricGroup; 24*4d7e907cSAndroid Build Coastguard Workerimport @1.1::HdcpLevel; 25*4d7e907cSAndroid Build Coastguard Workerimport @1.1::KeyRequestType; 26*4d7e907cSAndroid Build Coastguard Workerimport @1.0::SecureStopId; 27*4d7e907cSAndroid Build Coastguard Workerimport @1.1::SecureStopRelease; 28*4d7e907cSAndroid Build Coastguard Workerimport @1.1::SecurityLevel; 29*4d7e907cSAndroid Build Coastguard Workerimport @1.0::SessionId; 30*4d7e907cSAndroid Build Coastguard Worker 31*4d7e907cSAndroid Build Coastguard Worker/** 32*4d7e907cSAndroid Build Coastguard Worker * IDrmPlugin is used to interact with a specific drm plugin that was created by 33*4d7e907cSAndroid Build Coastguard Worker * IDrm::createPlugin. A drm plugin provides methods for obtaining drm keys that 34*4d7e907cSAndroid Build Coastguard Worker * may be used by a codec to decrypt protected video content. 35*4d7e907cSAndroid Build Coastguard Worker */ 36*4d7e907cSAndroid Build Coastguard Workerinterface IDrmPlugin extends @1.0::IDrmPlugin { 37*4d7e907cSAndroid Build Coastguard Worker /** 38*4d7e907cSAndroid Build Coastguard Worker * Open a new session at a requested security level. The security level 39*4d7e907cSAndroid Build Coastguard Worker * represents the robustness of the device's DRM implementation. By default, 40*4d7e907cSAndroid Build Coastguard Worker * sessions are opened at the native security level of the device which is 41*4d7e907cSAndroid Build Coastguard Worker * the maximum level that can be supported. Overriding the security level is 42*4d7e907cSAndroid Build Coastguard Worker * necessary when the decrypted frames need to be manipulated, such as for 43*4d7e907cSAndroid Build Coastguard Worker * image compositing. The security level parameter must be equal to or lower 44*4d7e907cSAndroid Build Coastguard Worker * than the native level. If the requested level is not supported, the next 45*4d7e907cSAndroid Build Coastguard Worker * lower supported security level must be set. The level can be queried 46*4d7e907cSAndroid Build Coastguard Worker * using {@link #getSecurityLevel}. A session ID is returned. When the 47*4d7e907cSAndroid Build Coastguard Worker * [email protected] openSession is called, which has no securityLevel parameter, the 48*4d7e907cSAndroid Build Coastguard Worker * security level is defaulted to the native security level of the device. 49*4d7e907cSAndroid Build Coastguard Worker * 50*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 51*4d7e907cSAndroid Build Coastguard Worker * the following errors: ERROR_DRM_NOT_PROVISIONED if the device 52*4d7e907cSAndroid Build Coastguard Worker * requires provisioning before it can open a session, 53*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_RESOURCE_BUSY if there are insufficent resources available 54*4d7e907cSAndroid Build Coastguard Worker * to open a session, ERROR_DRM_CANNOT_HANDLE if the requested security 55*4d7e907cSAndroid Build Coastguard Worker * level is higher than the native level or lower than the lowest 56*4d7e907cSAndroid Build Coastguard Worker * supported level or if openSession is not supported at the time of 57*4d7e907cSAndroid Build Coastguard Worker * the call, or ERROR_DRM_INVALID_STATE if the HAL is in a state where 58*4d7e907cSAndroid Build Coastguard Worker * a session cannot be opened. 59*4d7e907cSAndroid Build Coastguard Worker * @param level the requested security level 60*4d7e907cSAndroid Build Coastguard Worker * @return sessionId the session ID for the newly opened session 61*4d7e907cSAndroid Build Coastguard Worker */ 62*4d7e907cSAndroid Build Coastguard Worker openSession_1_1(SecurityLevel securityLevel) generates (Status status, 63*4d7e907cSAndroid Build Coastguard Worker SessionId sessionId); 64*4d7e907cSAndroid Build Coastguard Worker 65*4d7e907cSAndroid Build Coastguard Worker /** 66*4d7e907cSAndroid Build Coastguard Worker * A key request/response exchange occurs between the app and a License 67*4d7e907cSAndroid Build Coastguard Worker * Server to obtain the keys required to decrypt the content. 68*4d7e907cSAndroid Build Coastguard Worker * getKeyRequest_1_1() is used to obtain an opaque key request blob that is 69*4d7e907cSAndroid Build Coastguard Worker * delivered to the license server. 70*4d7e907cSAndroid Build Coastguard Worker * 71*4d7e907cSAndroid Build Coastguard Worker * getKeyRequest_1_1() only differs from getKeyRequest() in that additional 72*4d7e907cSAndroid Build Coastguard Worker * values are returned in 1.1::KeyRequestType as compared to 73*4d7e907cSAndroid Build Coastguard Worker * 1.0::KeyRequestType 74*4d7e907cSAndroid Build Coastguard Worker * 75*4d7e907cSAndroid Build Coastguard Worker * @param scope may be a sessionId or a keySetId, depending on the 76*4d7e907cSAndroid Build Coastguard Worker * specified keyType. When the keyType is OFFLINE or STREAMING, 77*4d7e907cSAndroid Build Coastguard Worker * scope should be set to the sessionId the keys will be provided 78*4d7e907cSAndroid Build Coastguard Worker * to. When the keyType is RELEASE, scope should be set to the 79*4d7e907cSAndroid Build Coastguard Worker * keySetId of the keys being released. 80*4d7e907cSAndroid Build Coastguard Worker * @param initData container-specific data, its meaning is interpreted 81*4d7e907cSAndroid Build Coastguard Worker * based on the mime type provided in the mimeType parameter. 82*4d7e907cSAndroid Build Coastguard Worker * It could contain, for example, the content ID, key ID or 83*4d7e907cSAndroid Build Coastguard Worker * other data obtained from the content metadata that is 84*4d7e907cSAndroid Build Coastguard Worker * required to generate the key request. initData may be empty 85*4d7e907cSAndroid Build Coastguard Worker * when keyType is RELEASE. 86*4d7e907cSAndroid Build Coastguard Worker * @param mimeType identifies the mime type of the content 87*4d7e907cSAndroid Build Coastguard Worker * @param keyType specifies if the keys are to be used for streaming, 88*4d7e907cSAndroid Build Coastguard Worker * offline or a release 89*4d7e907cSAndroid Build Coastguard Worker * @param optionalParameters included in the key request message to 90*4d7e907cSAndroid Build Coastguard Worker * allow a client application to provide additional message 91*4d7e907cSAndroid Build Coastguard Worker * parameters to the server. 92*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 93*4d7e907cSAndroid Build Coastguard Worker * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the 94*4d7e907cSAndroid Build Coastguard Worker * session is not opened, ERROR_DRM_NOT_PROVISIONED if the device 95*4d7e907cSAndroid Build Coastguard Worker * requires provisioning before it can generate a key request, 96*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_CANNOT_HANDLE if getKeyRequest is not supported 97*4d7e907cSAndroid Build Coastguard Worker * at the time of the call, BAD_VALUE if any parameters are 98*4d7e907cSAndroid Build Coastguard Worker * invalid or ERROR_DRM_INVALID_STATE if the HAL is in a 99*4d7e907cSAndroid Build Coastguard Worker * state where a key request cannot be generated. 100*4d7e907cSAndroid Build Coastguard Worker * @return request if successful, the opaque key request blob is returned 101*4d7e907cSAndroid Build Coastguard Worker * @return requestType indicates type information about the returned 102*4d7e907cSAndroid Build Coastguard Worker * request. The type may be one of INITIAL, RENEWAL, RELEASE, 103*4d7e907cSAndroid Build Coastguard Worker * NONE or UPDATE. An INITIAL request is the first key request 104*4d7e907cSAndroid Build Coastguard Worker * for a license. RENEWAL is a subsequent key request used to 105*4d7e907cSAndroid Build Coastguard Worker * refresh the keys in a license. RELEASE corresponds to a 106*4d7e907cSAndroid Build Coastguard Worker * keyType of RELEASE, which indicates keys are being released. 107*4d7e907cSAndroid Build Coastguard Worker * NONE indicates that no request is needed because the keys are 108*4d7e907cSAndroid Build Coastguard Worker * already loaded. UPDATE indicates that the keys need to be 109*4d7e907cSAndroid Build Coastguard Worker * refetched after the initial license request. 110*4d7e907cSAndroid Build Coastguard Worker * @return defaultUrl the URL that the request may be sent to, if 111*4d7e907cSAndroid Build Coastguard Worker * provided by the drm HAL. The app may choose to override this URL. 112*4d7e907cSAndroid Build Coastguard Worker */ 113*4d7e907cSAndroid Build Coastguard Worker getKeyRequest_1_1(vec<uint8_t> scope, vec<uint8_t> initData, 114*4d7e907cSAndroid Build Coastguard Worker string mimeType, KeyType keyType, KeyedVector optionalParameters) 115*4d7e907cSAndroid Build Coastguard Worker generates (Status status, vec<uint8_t> request, 116*4d7e907cSAndroid Build Coastguard Worker KeyRequestType requestType, string defaultUrl); 117*4d7e907cSAndroid Build Coastguard Worker 118*4d7e907cSAndroid Build Coastguard Worker /** 119*4d7e907cSAndroid Build Coastguard Worker * Return the currently negotiated and max supported HDCP levels. 120*4d7e907cSAndroid Build Coastguard Worker * 121*4d7e907cSAndroid Build Coastguard Worker * The current level is based on the display(s) the device is connected to. 122*4d7e907cSAndroid Build Coastguard Worker * If multiple HDCP-capable displays are simultaneously connected to 123*4d7e907cSAndroid Build Coastguard Worker * separate interfaces, this method returns the lowest negotiated HDCP level 124*4d7e907cSAndroid Build Coastguard Worker * of all interfaces. 125*4d7e907cSAndroid Build Coastguard Worker * 126*4d7e907cSAndroid Build Coastguard Worker * The maximum HDCP level is the highest level that can potentially be 127*4d7e907cSAndroid Build Coastguard Worker * negotiated. It is a constant for any device, i.e. it does not depend on 128*4d7e907cSAndroid Build Coastguard Worker * downstream receiving devices that could be connected. For example, if 129*4d7e907cSAndroid Build Coastguard Worker * the device has HDCP 1.x keys and is capable of negotiating HDCP 1.x, but 130*4d7e907cSAndroid Build Coastguard Worker * does not have HDCP 2.x keys, then the maximum HDCP capability would be 131*4d7e907cSAndroid Build Coastguard Worker * reported as 1.x. If multiple HDCP-capable interfaces are present, it 132*4d7e907cSAndroid Build Coastguard Worker * indicates the highest of the maximum HDCP levels of all interfaces. 133*4d7e907cSAndroid Build Coastguard Worker * 134*4d7e907cSAndroid Build Coastguard Worker * This method should only be used for informational purposes, not for 135*4d7e907cSAndroid Build Coastguard Worker * enforcing compliance with HDCP requirements. Trusted enforcement of HDCP 136*4d7e907cSAndroid Build Coastguard Worker * policies must be handled by the DRM system. 137*4d7e907cSAndroid Build Coastguard Worker * 138*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or 139*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the HDCP 140*4d7e907cSAndroid Build Coastguard Worker * level cannot be queried. 141*4d7e907cSAndroid Build Coastguard Worker * @return connectedLevel the lowest HDCP level for any connected 142*4d7e907cSAndroid Build Coastguard Worker * displays 143*4d7e907cSAndroid Build Coastguard Worker * @return maxLevel the highest HDCP level that can be supported 144*4d7e907cSAndroid Build Coastguard Worker * by the device 145*4d7e907cSAndroid Build Coastguard Worker */ 146*4d7e907cSAndroid Build Coastguard Worker getHdcpLevels() generates (Status status, HdcpLevel connectedLevel, 147*4d7e907cSAndroid Build Coastguard Worker HdcpLevel maxLevel); 148*4d7e907cSAndroid Build Coastguard Worker 149*4d7e907cSAndroid Build Coastguard Worker /** 150*4d7e907cSAndroid Build Coastguard Worker * Return the current number of open sessions and the maximum number of 151*4d7e907cSAndroid Build Coastguard Worker * sessions that may be opened simultaneosly among all DRM instances for the 152*4d7e907cSAndroid Build Coastguard Worker * active DRM scheme. 153*4d7e907cSAndroid Build Coastguard Worker * 154*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or 155*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where number of 156*4d7e907cSAndroid Build Coastguard Worker * sessions cannot be queried. 157*4d7e907cSAndroid Build Coastguard Worker * @return currentSessions the number of currently opened sessions 158*4d7e907cSAndroid Build Coastguard Worker * @return maxSessions the maximum number of sessions that the device 159*4d7e907cSAndroid Build Coastguard Worker * can support 160*4d7e907cSAndroid Build Coastguard Worker */ 161*4d7e907cSAndroid Build Coastguard Worker getNumberOfSessions() generates (Status status, uint32_t currentSessions, 162*4d7e907cSAndroid Build Coastguard Worker uint32_t maxSessions); 163*4d7e907cSAndroid Build Coastguard Worker 164*4d7e907cSAndroid Build Coastguard Worker /** 165*4d7e907cSAndroid Build Coastguard Worker * Return the current security level of a session. A session has an initial 166*4d7e907cSAndroid Build Coastguard Worker * security level determined by the robustness of the DRM system's 167*4d7e907cSAndroid Build Coastguard Worker * implementation on the device. 168*4d7e907cSAndroid Build Coastguard Worker * 169*4d7e907cSAndroid Build Coastguard Worker * @param sessionId the session id the call applies to 170*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 171*4d7e907cSAndroid Build Coastguard Worker * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the 172*4d7e907cSAndroid Build Coastguard Worker * session is not opened, BAD_VALUE if the sessionId is invalid or 173*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the 174*4d7e907cSAndroid Build Coastguard Worker * security level cannot be queried. 175*4d7e907cSAndroid Build Coastguard Worker * @return level the current security level for the session 176*4d7e907cSAndroid Build Coastguard Worker */ 177*4d7e907cSAndroid Build Coastguard Worker getSecurityLevel(vec<uint8_t> sessionId) generates(Status status, 178*4d7e907cSAndroid Build Coastguard Worker SecurityLevel level); 179*4d7e907cSAndroid Build Coastguard Worker 180*4d7e907cSAndroid Build Coastguard Worker /** 181*4d7e907cSAndroid Build Coastguard Worker * Returns the plugin-specific metrics. Multiple metric groups may be 182*4d7e907cSAndroid Build Coastguard Worker * returned in one call to getMetrics(). The scope and definition of the 183*4d7e907cSAndroid Build Coastguard Worker * metrics is defined by the plugin. 184*4d7e907cSAndroid Build Coastguard Worker * 185*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or 186*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the metrics are not available to be 187*4d7e907cSAndroid Build Coastguard Worker * returned. 188*4d7e907cSAndroid Build Coastguard Worker * @return metric_groups the collection of metric groups provided by the 189*4d7e907cSAndroid Build Coastguard Worker * plugin. 190*4d7e907cSAndroid Build Coastguard Worker */ 191*4d7e907cSAndroid Build Coastguard Worker getMetrics() generates (Status status, vec<DrmMetricGroup> metric_groups); 192*4d7e907cSAndroid Build Coastguard Worker 193*4d7e907cSAndroid Build Coastguard Worker /** 194*4d7e907cSAndroid Build Coastguard Worker * Get the IDs of all secure stops on the device 195*4d7e907cSAndroid Build Coastguard Worker * 196*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or 197*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop 198*4d7e907cSAndroid Build Coastguard Worker * IDs cannot be returned. 199*4d7e907cSAndroid Build Coastguard Worker * @return secureStopIds a list of the IDs 200*4d7e907cSAndroid Build Coastguard Worker */ 201*4d7e907cSAndroid Build Coastguard Worker getSecureStopIds() generates 202*4d7e907cSAndroid Build Coastguard Worker (Status status, vec<SecureStopId> secureStopIds); 203*4d7e907cSAndroid Build Coastguard Worker 204*4d7e907cSAndroid Build Coastguard Worker /** 205*4d7e907cSAndroid Build Coastguard Worker * Release secure stops given a release message from the key server 206*4d7e907cSAndroid Build Coastguard Worker * 207*4d7e907cSAndroid Build Coastguard Worker * @param ssRelease the secure stop release message identifying one or more 208*4d7e907cSAndroid Build Coastguard Worker * secure stops to release. ssRelease is opaque, it is passed directly from 209*4d7e907cSAndroid Build Coastguard Worker * a DRM license server through the app and media framework to the vendor 210*4d7e907cSAndroid Build Coastguard Worker * HAL module. The format and content of ssRelease must be defined by the 211*4d7e907cSAndroid Build Coastguard Worker * DRM scheme being implemented according to this HAL. The DRM scheme 212*4d7e907cSAndroid Build Coastguard Worker * can be identified by its UUID which can be queried using 213*4d7e907cSAndroid Build Coastguard Worker * IDrmFactory::isCryptoSchemeSupported. 214*4d7e907cSAndroid Build Coastguard Worker * 215*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 216*4d7e907cSAndroid Build Coastguard Worker * the following errors: BAD_VALUE if ssRelease is invalid or 217*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop 218*4d7e907cSAndroid Build Coastguard Worker * cannot be released. 219*4d7e907cSAndroid Build Coastguard Worker */ 220*4d7e907cSAndroid Build Coastguard Worker releaseSecureStops(SecureStopRelease ssRelease) generates (Status status); 221*4d7e907cSAndroid Build Coastguard Worker 222*4d7e907cSAndroid Build Coastguard Worker /** 223*4d7e907cSAndroid Build Coastguard Worker * Remove a secure stop given its secure stop ID, without requiring 224*4d7e907cSAndroid Build Coastguard Worker * a secure stop release response message from the key server. 225*4d7e907cSAndroid Build Coastguard Worker * 226*4d7e907cSAndroid Build Coastguard Worker * @param secureStopId the ID of the secure stop to release. 227*4d7e907cSAndroid Build Coastguard Worker * 228*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 229*4d7e907cSAndroid Build Coastguard Worker * the following errors: BAD_VALUE if the secureStopId is invalid or 230*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure stop 231*4d7e907cSAndroid Build Coastguard Worker * cannot be released. 232*4d7e907cSAndroid Build Coastguard Worker */ 233*4d7e907cSAndroid Build Coastguard Worker removeSecureStop(SecureStopId secureStopId) generates (Status status); 234*4d7e907cSAndroid Build Coastguard Worker 235*4d7e907cSAndroid Build Coastguard Worker /** 236*4d7e907cSAndroid Build Coastguard Worker * Remove all secure stops on the device without requiring a secure 237*4d7e907cSAndroid Build Coastguard Worker * stop release response message from the key server. 238*4d7e907cSAndroid Build Coastguard Worker * 239*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or 240*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the secure 241*4d7e907cSAndroid Build Coastguard Worker * stops cannot be removed. 242*4d7e907cSAndroid Build Coastguard Worker */ 243*4d7e907cSAndroid Build Coastguard Worker removeAllSecureStops() generates (Status status); 244*4d7e907cSAndroid Build Coastguard Worker}; 245