Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 16 | package android.hardware.drm@1.0; |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 17 | |
Jeff Tinker | da002fe | 2017-01-19 14:41:11 -0800 | [diff] [blame] | 18 | import android.hardware.drm@1.0::types; |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * Ref: frameworks/native/include/media/hardware/CryptoAPI.h:CryptoPlugin |
| 22 | * |
| 23 | * ICryptoPlugin is the HAL for vendor-provided crypto plugins. |
| 24 | * It allows crypto sessions to be opened and operated on, to |
| 25 | * load crypto keys for a codec to decrypt protected video content. |
| 26 | */ |
| 27 | interface ICryptoPlugin { |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 28 | /** |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 29 | * Check if the specified mime-type requires a secure decoder |
| 30 | * component. |
| 31 | * |
| 32 | * @param mime The content mime-type |
| 33 | * @return secureRequired must be true only if a secure decoder is required |
| 34 | * for the specified mime-type |
| 35 | */ |
| 36 | requiresSecureDecoderComponent(string mime) |
| 37 | generates(bool secureRequired); |
| 38 | |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 39 | /** |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 40 | * Notify a plugin of the currently configured resolution |
| 41 | * |
| 42 | * @param width - the display resolutions's width |
| 43 | * @param height - the display resolution's height |
| 44 | */ |
| 45 | notifyResolution(uint32_t width, uint32_t height); |
| 46 | |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 47 | /** |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 48 | * Associate a mediadrm session with this crypto session |
| 49 | * |
| 50 | * @param sessionId the MediaDrm session ID to associate with this crypto |
| 51 | * session |
Jeff Tinker | b075caa | 2016-12-06 23:15:20 -0800 | [diff] [blame] | 52 | * @return status the status of the call, status must be |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 53 | * ERROR_DRM_SESSION_NOT_OPENED if the session is not opened, or |
| 54 | * ERROR_DRM_CANNOT_HANDLE if the operation is not supported by the drm |
| 55 | * scheme. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 56 | */ |
| 57 | setMediaDrmSession(vec<uint8_t> sessionId) generates(Status status); |
| 58 | |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 59 | /** |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 60 | * Set a shared memory base for subsequent decrypt operations. The buffer |
| 61 | * base is a hidl_memory which maps shared memory in the HAL module. |
| 62 | * After the shared buffer base is established, the decrypt() method |
| 63 | * receives SharedBuffer instances which specify the buffer address range |
| 64 | * for decrypt source and destination addresses. |
Jeff Tinker | 0b3f41e | 2017-02-16 12:20:30 -0800 | [diff] [blame] | 65 | * |
| 66 | * There can be multiple shared buffers per crypto plugin. The buffers |
| 67 | * are distinguished by the bufferId. |
| 68 | * |
| 69 | * @param base the base IMemory of the memory buffer identified by |
| 70 | * bufferId |
| 71 | * @param bufferId identifies the specific shared buffer for which |
| 72 | * the base is being set. |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 73 | */ |
Jeff Tinker | 0b3f41e | 2017-02-16 12:20:30 -0800 | [diff] [blame] | 74 | setSharedBufferBase(memory base, uint32_t bufferId); |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 77 | * Decrypt an array of subsamples from the source memory buffer to the |
| 78 | * destination memory buffer. |
| 79 | * |
| 80 | * @param secure a flag to indicate if a secure decoder is being used. This |
| 81 | * enables the plugin to configure buffer modes to work consistently with |
| 82 | * a secure decoder. |
| 83 | * @param the keyId for the key that should be used to do the |
| 84 | * the decryption. The keyId refers to a key in the associated |
| 85 | * MediaDrm instance. |
| 86 | * @param iv the initialization vector to use |
| 87 | * @param mode the crypto mode to use |
| 88 | * @param pattern the crypto pattern to use |
| 89 | * @param subSamples a vector of subsamples indicating the number |
| 90 | * of clear and encrypted bytes to process. This allows the decrypt |
| 91 | * call to operate on a range of subsamples in a single call |
| 92 | * @param source the input buffer for the decryption |
Jeff Tinker | 6fdbe86 | 2017-01-11 19:45:23 -0800 | [diff] [blame] | 93 | * @param offset the offset of the first byte of encrypted data from |
| 94 | * the base of the source buffer |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 95 | * @param destination the output buffer for the decryption |
Jeff Tinker | b3a1672 | 2016-12-30 19:03:17 -0800 | [diff] [blame] | 96 | * @return status the status of the call. The status must be OK or one of |
| 97 | * the following errors: ERROR_DRM_NO_LICENSE if no license keys have been |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 98 | * loaded, ERROR_DRM_LICENSE_EXPIRED if the license keys have expired, |
| 99 | * ERROR_DRM_RESOURCE_BUSY if the resources required to perform the |
| 100 | * decryption are not available, ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION |
| 101 | * if required output protections are not active, |
Jeff Tinker | e5fbc46 | 2017-03-14 16:57:15 -0700 | [diff] [blame] | 102 | * ERROR_DRM_SESSION_NOT_OPENED if the decrypt session is not opened, |
| 103 | * ERROR_DRM_DECRYPT if the decrypt operation fails, and |
Jeff Tinker | 35594ec | 2016-12-14 09:55:22 -0800 | [diff] [blame] | 104 | * ERROR_DRM_CANNOT_HANDLE in other failure cases. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 105 | * @return bytesWritten the number of bytes output from the decryption |
Jeff Tinker | 01f0a5a | 2017-01-12 09:22:18 -0800 | [diff] [blame] | 106 | * @return detailedError if the error is a vendor-specific error, the |
| 107 | * vendor's crypto HAL may provide a detailed error string to help |
| 108 | * describe the error. |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 109 | */ |
| 110 | decrypt(bool secure, uint8_t[16] keyId, uint8_t[16] iv, Mode mode, |
| 111 | Pattern pattern, vec<SubSample> subSamples, |
Jeff Tinker | f21cdaf | 2017-01-18 11:49:27 -0800 | [diff] [blame] | 112 | SharedBuffer source, uint64_t offset, DestinationBuffer destination) |
Jeff Tinker | 01f0a5a | 2017-01-12 09:22:18 -0800 | [diff] [blame] | 113 | generates(Status status, uint32_t bytesWritten, string detailedError); |
Jeff Tinker | 53b52fe | 2016-12-01 18:12:56 -0800 | [diff] [blame] | 114 | }; |