blob: 352561ecbb005c8317b8a3c738101ef2f4c17df2 [file] [log] [blame]
Andreas Huber1b19c9d2012-08-29 11:34:22 -07001/*
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>
Chong Zhang308bcaa2013-05-03 21:54:17 -070020#include <ui/GraphicBuffer.h>
Andreas Huber1b19c9d2012-08-29 11:34:22 -070021
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
Chong Zhangec3acca2013-09-03 14:35:37 -070049 // Returns the capability bitmask of this HDCP session.
50 // Possible return values (please refer to HDCAPAPI.h):
51 // HDCP_CAPS_ENCRYPT: mandatory, meaning the HDCP module can encrypt
52 // from an input byte-array buffer to an output byte-array buffer
53 // HDCP_CAPS_ENCRYPT_NATIVE: the HDCP module supports encryption from
54 // a native buffer to an output byte-array buffer. The format of the
55 // input native buffer is specific to vendor's encoder implementation.
56 // It is the same format as that used by the encoder when
57 // "storeMetaDataInBuffers" extension is enabled on its output port.
58 virtual uint32_t getCaps() = 0;
59
Andreas Hubera6a88d92013-01-30 10:41:25 -080060 // ENCRYPTION only:
61 // Encrypt data according to the HDCP spec. "size" bytes of data are
62 // available at "inData" (virtual address), "size" may not be a multiple
63 // of 128 bits (16 bytes). An equal number of encrypted bytes should be
64 // written to the buffer at "outData" (virtual address).
Andreas Huber1b19c9d2012-08-29 11:34:22 -070065 // This operation is to be synchronous, i.e. this call does not return
66 // until outData contains size bytes of encrypted data.
67 // streamCTR will be assigned by the caller (to 0 for the first PES stream,
68 // 1 for the second and so on)
Andreas Hubera6a88d92013-01-30 10:41:25 -080069 // inputCTR _will_be_maintained_by_the_callee_ for each PES stream.
Andreas Huber1b19c9d2012-08-29 11:34:22 -070070 virtual status_t encrypt(
71 const void *inData, size_t size, uint32_t streamCTR,
72 uint64_t *outInputCTR, void *outData) = 0;
73
Chong Zhang308bcaa2013-05-03 21:54:17 -070074 // Encrypt data according to the HDCP spec. "size" bytes of data starting
75 // at location "offset" are available in "buffer" (buffer handle). "size"
76 // may not be a multiple of 128 bits (16 bytes). An equal number of
77 // encrypted bytes should be written to the buffer at "outData" (virtual
78 // address). This operation is to be synchronous, i.e. this call does not
79 // return until outData contains size bytes of encrypted data.
80 // streamCTR will be assigned by the caller (to 0 for the first PES stream,
81 // 1 for the second and so on)
82 // inputCTR _will_be_maintained_by_the_callee_ for each PES stream.
83 virtual status_t encryptNative(
84 const sp<GraphicBuffer> &graphicBuffer,
85 size_t offset, size_t size, uint32_t streamCTR,
86 uint64_t *outInputCTR, void *outData) = 0;
87
Andreas Hubera6a88d92013-01-30 10:41:25 -080088 // DECRYPTION only:
89 // Decrypt data according to the HDCP spec.
90 // "size" bytes of encrypted data are available at "inData"
91 // (virtual address), "size" may not be a multiple of 128 bits (16 bytes).
92 // An equal number of decrypted bytes should be written to the buffer
93 // at "outData" (virtual address).
94 // This operation is to be synchronous, i.e. this call does not return
95 // until outData contains size bytes of decrypted data.
96 // Both streamCTR and inputCTR will be provided by the caller.
97 virtual status_t decrypt(
98 const void *inData, size_t size,
99 uint32_t streamCTR, uint64_t inputCTR,
100 void *outData) = 0;
101
Andreas Huber1b19c9d2012-08-29 11:34:22 -0700102private:
103 DISALLOW_EVIL_CONSTRUCTORS(IHDCP);
104};
105
106struct BnHDCPObserver : public BnInterface<IHDCPObserver> {
107 virtual status_t onTransact(
108 uint32_t code, const Parcel &data, Parcel *reply,
109 uint32_t flags = 0);
110};
111
112struct BnHDCP : public BnInterface<IHDCP> {
113 virtual status_t onTransact(
114 uint32_t code, const Parcel &data, Parcel *reply,
115 uint32_t flags = 0);
116};
117
118} // namespace android
119
120