1a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber/* 2a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * Copyright (C) 2012 The Android Open Source Project 3a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * 4a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * you may not use this file except in compliance with the License. 6a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * You may obtain a copy of the License at 7a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * 8a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * 10a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * Unless required by applicable law or agreed to in writing, software 11a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * See the License for the specific language governing permissions and 14a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber * limitations under the License. 15a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber */ 16a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 17a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber#ifndef HDCP_API_H_ 18a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 19a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber#define HDCP_API_H_ 20a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 21a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber#include <utils/Errors.h> 22a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 23a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Hubernamespace android { 24a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 25a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huberstruct HDCPModule { 26dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian typedef void (*ObserverFunc)(void *cookie, int msg, int ext1, int ext2); 27a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 28a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // The msg argument in calls to the observer notification function. 29a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber enum { 30a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Sent in response to a call to "HDCPModule::initAsync" once 31a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // initialization has either been successfully completed, 32a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // i.e. the HDCP session is now fully setup (AKE, Locality Check, 33a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // SKE and any authentication with repeaters completed) or failed. 34a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // ext1 should be a suitable error code (status_t), ext2 is 35a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // unused. 36a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCP_INITIALIZATION_COMPLETE, 37dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_INITIALIZATION_FAILED, 38a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 39a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Sent upon completion of a call to "HDCPModule::shutdownAsync". 40a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // ext1 should be a suitable error code, ext2 is unused. 41a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCP_SHUTDOWN_COMPLETE, 42dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_SHUTDOWN_FAILED, 43dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian 44dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_UNAUTHENTICATED_CONNECTION, 45dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_UNAUTHORIZED_CONNECTION, 46dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_REVOKED_CONNECTION, 47dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_TOPOLOGY_EXECEEDED, 48dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCP_UNKNOWN_ERROR, 49a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber }; 50a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 51a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Module can call the notification function to signal completion/failure 52a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // of asynchronous operations (such as initialization) or out of band 53a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // events. 54dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian HDCPModule(void *cookie, ObserverFunc observerNotify) {}; 55a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 56dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian virtual ~HDCPModule() {}; 57a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 58a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Request to setup an HDCP session with the specified host listening 59a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // on the specified port. 60a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual status_t initAsync(const char *host, unsigned port) = 0; 61a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 62a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Request to shutdown the active HDCP session. 63a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual status_t shutdownAsync() = 0; 64a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 65a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Encrypt a data according to the HDCP spec. The data is to be 66a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // encrypted in-place, only size bytes of data should be read/write, 67a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // even if the size is not a multiple of 128 bit (16 bytes). 68a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // This operation is to be synchronous, i.e. this call does not return 69a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // until outData contains size bytes of encrypted data. 70a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // streamCTR will be assigned by the caller (to 0 for the first PES stream, 71a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // 1 for the second and so on) 72a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // inputCTR will be maintained by the callee for each PES stream. 73a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual status_t encrypt( 74a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber const void *inData, size_t size, uint32_t streamCTR, 75a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber uint64_t *outInputCTR, void *outData) = 0; 76a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 77a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huberprivate: 78a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCPModule(const HDCPModule &); 79a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCPModule &operator=(const HDCPModule &); 80a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber}; 81a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 82a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber} // namespace android 83a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 84a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// A shared library exporting the following method should be included to 85a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// support HDCP functionality. The shared library must be called 86a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// "libstagefright_hdcp.so", it will be dynamically loaded into the 87a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// mediaserver process. 88a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huberextern "C" { 89dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian extern android::HDCPModule *createHDCPModule( 90dbaaa38882b8f13c1ff3a0ea352584cdbbbcba72Deva Ramasubramanian void *cookie, android::HDCPModule::ObserverFunc); 91a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber} 92a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 93a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber#endif // HDCP_API_H_ 94a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 95