Andreas Huber | 9bd5a93 | 2012-08-29 11:34:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | */ |
| 16 | |
| 17 | #include <binder/IInterface.h> |
| 18 | #include <media/hardware/HDCPAPI.h> |
| 19 | #include <media/stagefright/foundation/ABase.h> |
| 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | struct IHDCPObserver : public IInterface { |
| 24 | DECLARE_META_INTERFACE(HDCPObserver); |
| 25 | |
| 26 | virtual void notify( |
| 27 | int msg, int ext1, int ext2, const Parcel *obj) = 0; |
| 28 | |
| 29 | private: |
| 30 | DISALLOW_EVIL_CONSTRUCTORS(IHDCPObserver); |
| 31 | }; |
| 32 | |
| 33 | struct IHDCP : public IInterface { |
| 34 | DECLARE_META_INTERFACE(HDCP); |
| 35 | |
| 36 | // Called to specify the observer that receives asynchronous notifications |
| 37 | // from the HDCP implementation to signal completion/failure of asynchronous |
| 38 | // operations (such as initialization) or out of band events. |
| 39 | virtual status_t setObserver(const sp<IHDCPObserver> &observer) = 0; |
| 40 | |
| 41 | // Request to setup an HDCP session with the specified host listening |
| 42 | // on the specified port. |
| 43 | virtual status_t initAsync(const char *host, unsigned port) = 0; |
| 44 | |
| 45 | // Request to shutdown the active HDCP session. |
| 46 | virtual status_t shutdownAsync() = 0; |
| 47 | |
Andreas Huber | 279dcd8 | 2013-01-30 10:41:25 -0800 | [diff] [blame] | 48 | // ENCRYPTION only: |
| 49 | // Encrypt data according to the HDCP spec. "size" bytes of data are |
| 50 | // available at "inData" (virtual address), "size" may not be a multiple |
| 51 | // of 128 bits (16 bytes). An equal number of encrypted bytes should be |
| 52 | // written to the buffer at "outData" (virtual address). |
Andreas Huber | 9bd5a93 | 2012-08-29 11:34:22 -0700 | [diff] [blame] | 53 | // This operation is to be synchronous, i.e. this call does not return |
| 54 | // until outData contains size bytes of encrypted data. |
| 55 | // streamCTR will be assigned by the caller (to 0 for the first PES stream, |
| 56 | // 1 for the second and so on) |
Andreas Huber | 279dcd8 | 2013-01-30 10:41:25 -0800 | [diff] [blame] | 57 | // inputCTR _will_be_maintained_by_the_callee_ for each PES stream. |
Andreas Huber | 9bd5a93 | 2012-08-29 11:34:22 -0700 | [diff] [blame] | 58 | virtual status_t encrypt( |
| 59 | const void *inData, size_t size, uint32_t streamCTR, |
| 60 | uint64_t *outInputCTR, void *outData) = 0; |
| 61 | |
Andreas Huber | 279dcd8 | 2013-01-30 10:41:25 -0800 | [diff] [blame] | 62 | // DECRYPTION only: |
| 63 | // Decrypt data according to the HDCP spec. |
| 64 | // "size" bytes of encrypted data are available at "inData" |
| 65 | // (virtual address), "size" may not be a multiple of 128 bits (16 bytes). |
| 66 | // An equal number of decrypted bytes should be written to the buffer |
| 67 | // at "outData" (virtual address). |
| 68 | // This operation is to be synchronous, i.e. this call does not return |
| 69 | // until outData contains size bytes of decrypted data. |
| 70 | // Both streamCTR and inputCTR will be provided by the caller. |
| 71 | virtual status_t decrypt( |
| 72 | const void *inData, size_t size, |
| 73 | uint32_t streamCTR, uint64_t inputCTR, |
| 74 | void *outData) = 0; |
| 75 | |
Andreas Huber | 9bd5a93 | 2012-08-29 11:34:22 -0700 | [diff] [blame] | 76 | private: |
| 77 | DISALLOW_EVIL_CONSTRUCTORS(IHDCP); |
| 78 | }; |
| 79 | |
| 80 | struct BnHDCPObserver : public BnInterface<IHDCPObserver> { |
| 81 | virtual status_t onTransact( |
| 82 | uint32_t code, const Parcel &data, Parcel *reply, |
| 83 | uint32_t flags = 0); |
| 84 | }; |
| 85 | |
| 86 | struct BnHDCP : public BnInterface<IHDCP> { |
| 87 | virtual status_t onTransact( |
| 88 | uint32_t code, const Parcel &data, Parcel *reply, |
| 89 | uint32_t flags = 0); |
| 90 | }; |
| 91 | |
| 92 | } // namespace android |
| 93 | |
| 94 | |