IHDCP.h revision 308bcaa44e578279e61be32b572fdb0b11b1e4c7
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#include <ui/GraphicBuffer.h> 21 22namespace android { 23 24struct IHDCPObserver : public IInterface { 25 DECLARE_META_INTERFACE(HDCPObserver); 26 27 virtual void notify( 28 int msg, int ext1, int ext2, const Parcel *obj) = 0; 29 30private: 31 DISALLOW_EVIL_CONSTRUCTORS(IHDCPObserver); 32}; 33 34struct IHDCP : public IInterface { 35 DECLARE_META_INTERFACE(HDCP); 36 37 // Called to specify the observer that receives asynchronous notifications 38 // from the HDCP implementation to signal completion/failure of asynchronous 39 // operations (such as initialization) or out of band events. 40 virtual status_t setObserver(const sp<IHDCPObserver> &observer) = 0; 41 42 // Request to setup an HDCP session with the specified host listening 43 // on the specified port. 44 virtual status_t initAsync(const char *host, unsigned port) = 0; 45 46 // Request to shutdown the active HDCP session. 47 virtual status_t shutdownAsync() = 0; 48 49 // ENCRYPTION only: 50 // Encrypt data according to the HDCP spec. "size" bytes of data are 51 // available at "inData" (virtual address), "size" may not be a multiple 52 // of 128 bits (16 bytes). An equal number of encrypted bytes should be 53 // written to the buffer at "outData" (virtual address). 54 // This operation is to be synchronous, i.e. this call does not return 55 // until outData contains size bytes of encrypted data. 56 // streamCTR will be assigned by the caller (to 0 for the first PES stream, 57 // 1 for the second and so on) 58 // inputCTR _will_be_maintained_by_the_callee_ for each PES stream. 59 virtual status_t encrypt( 60 const void *inData, size_t size, uint32_t streamCTR, 61 uint64_t *outInputCTR, void *outData) = 0; 62 63 // Encrypt data according to the HDCP spec. "size" bytes of data starting 64 // at location "offset" are available in "buffer" (buffer handle). "size" 65 // may not be a multiple of 128 bits (16 bytes). An equal number of 66 // encrypted bytes should be written to the buffer at "outData" (virtual 67 // address). This operation is to be synchronous, i.e. this call does not 68 // return until outData contains size bytes of encrypted data. 69 // streamCTR will be assigned by the caller (to 0 for the first PES stream, 70 // 1 for the second and so on) 71 // inputCTR _will_be_maintained_by_the_callee_ for each PES stream. 72 virtual status_t encryptNative( 73 const sp<GraphicBuffer> &graphicBuffer, 74 size_t offset, size_t size, uint32_t streamCTR, 75 uint64_t *outInputCTR, void *outData) = 0; 76 77 // DECRYPTION only: 78 // Decrypt data according to the HDCP spec. 79 // "size" bytes of encrypted data are available at "inData" 80 // (virtual address), "size" may not be a multiple of 128 bits (16 bytes). 81 // An equal number of decrypted bytes should be written to the buffer 82 // at "outData" (virtual address). 83 // This operation is to be synchronous, i.e. this call does not return 84 // until outData contains size bytes of decrypted data. 85 // Both streamCTR and inputCTR will be provided by the caller. 86 virtual status_t decrypt( 87 const void *inData, size_t size, 88 uint32_t streamCTR, uint64_t inputCTR, 89 void *outData) = 0; 90 91private: 92 DISALLOW_EVIL_CONSTRUCTORS(IHDCP); 93}; 94 95struct BnHDCPObserver : public BnInterface<IHDCPObserver> { 96 virtual status_t onTransact( 97 uint32_t code, const Parcel &data, Parcel *reply, 98 uint32_t flags = 0); 99}; 100 101struct BnHDCP : public BnInterface<IHDCP> { 102 virtual status_t onTransact( 103 uint32_t code, const Parcel &data, Parcel *reply, 104 uint32_t flags = 0); 105}; 106 107} // namespace android 108 109 110