HDCPAPI.h revision a8fc772b5b13e359fa73d5867c0f617b8eae4a41
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 { 26a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber typedef void (*ObserverFunc)(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, 37a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 38a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Sent upon completion of a call to "HDCPModule::shutdownAsync". 39a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // ext1 should be a suitable error code, ext2 is unused. 40a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCP_SHUTDOWN_COMPLETE, 41a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber }; 42a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 43a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Module can call the notification function to signal completion/failure 44a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // of asynchronous operations (such as initialization) or out of band 45a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // events. 46a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCPModule(ObserverFunc observerNotify); 47a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 48a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual ~HDCPModule(); 49a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 50a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Request to setup an HDCP session with the specified host listening 51a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // on the specified port. 52a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual status_t initAsync(const char *host, unsigned port) = 0; 53a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 54a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Request to shutdown the active HDCP session. 55a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual status_t shutdownAsync() = 0; 56a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 57a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // Encrypt a data according to the HDCP spec. The data is to be 58a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // encrypted in-place, only size bytes of data should be read/write, 59a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // even if the size is not a multiple of 128 bit (16 bytes). 60a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // This operation is to be synchronous, i.e. this call does not return 61a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // until outData contains size bytes of encrypted data. 62a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // streamCTR will be assigned by the caller (to 0 for the first PES stream, 63a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // 1 for the second and so on) 64a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber // inputCTR will be maintained by the callee for each PES stream. 65a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber virtual status_t encrypt( 66a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber const void *inData, size_t size, uint32_t streamCTR, 67a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber uint64_t *outInputCTR, void *outData) = 0; 68a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 69a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huberprivate: 70a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCPModule(const HDCPModule &); 71a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber HDCPModule &operator=(const HDCPModule &); 72a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber}; 73a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 74a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber} // namespace android 75a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 76a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// A shared library exporting the following method should be included to 77a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// support HDCP functionality. The shared library must be called 78a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// "libstagefright_hdcp.so", it will be dynamically loaded into the 79a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber// mediaserver process. 80a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huberextern "C" { 81a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber extern android::HDCPModule *createHDCPModule(); 82a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber} 83a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 84a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber#endif // HDCP_API_H_ 85a8fc772b5b13e359fa73d5867c0f617b8eae4a41Andreas Huber 86