From: Haesu Gwon Date: Thu, 15 May 2025 09:28:34 +0000 (+0900) Subject: [HALACR-41] Add HDCP encrypt API X-Git-Tag: accepted/tizen/unified/20250610.081807~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31a008c564d168c2e5fe56107f47c87615c4030b;p=platform%2Fhal%2Fapi%2Fdrm.git [HALACR-41] Add HDCP encrypt API - Add new HDCP encrypt API [Version] 1.0.1 [Issue Type] New feature Change-Id: I629b25f5b2e1257701c404ea93bc37559b29af3d --- diff --git a/CMakeLists.txt b/CMakeLists.txt index edd516b..de5d3f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,4 +49,3 @@ INSTALL(DIRECTORY include/ DESTINATION include/hal INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) ADD_SUBDIRECTORY(tests) - diff --git a/include/hal-drm-interface-1.h b/include/hal-drm-interface-1.h index 4415fd8..f4634fe 100644 --- a/include/hal-drm-interface-1.h +++ b/include/hal-drm-interface-1.h @@ -173,33 +173,35 @@ typedef enum */ typedef struct _hal_backend_drm_funcs { /** Initializes DRM HAL backend handle */ - hal_drm_error_e (*init)(void **drm_handle); + int (*init)(void **drm_handle); /** Deinitializes DRM HAL backend handle */ - hal_drm_error_e (*deinit)(void *drm_handle); + int (*deinit)(void *drm_handle); /** Sets the various command and value */ - hal_drm_error_e (*set_command)(void *drm_handle, hal_drm_command_e command, void *value); + int (*set_command)(void *drm_handle, hal_drm_command_e command, void *value); /** Gets the current value of command */ - hal_drm_error_e (*get_command)(void *drm_handle, hal_drm_command_e command, void **value); + int (*get_command)(void *drm_handle, hal_drm_command_e command, void **value); /** Sets a set of commands */ - hal_drm_error_e (*set_batch_command)(void *drm_handle, hal_drm_batch_command_control_s *batch_command, hal_drm_command_e *error_command); + int (*set_batch_command)(void *drm_handle, hal_drm_batch_command_control_s *batch_command, hal_drm_command_e *error_command); /** Opens HDCP */ - hal_drm_error_e (*hdcp_open)(void *drm_handle, hal_drm_hdcp_device_type_e type, hal_drm_hdcp_protocol_version_e version); + int (*hdcp_open)(void *drm_handle, hal_drm_hdcp_device_type_e type, hal_drm_hdcp_protocol_version_e version); /** Closes HDCP */ - hal_drm_error_e (*hdcp_close)(void *drm_handle); + int (*hdcp_close)(void *drm_handle); /** Starts HDCP receiver */ - hal_drm_error_e (*hdcp_start_receiver)(void *drm_handle, uint32_t socket_port, uint32_t *hdcp_id); + int (*hdcp_start_receiver)(void *drm_handle, uint32_t socket_port, uint32_t *hdcp_id); /** Stops HDCP receiver */ - hal_drm_error_e (*hdcp_stop_receiver)(void *drm_handle, uint32_t hdcp_id); + int (*hdcp_stop_receiver)(void *drm_handle, uint32_t hdcp_id); /** Starts HDCP transmitter */ - hal_drm_error_e (*hdcp_start_transmitter)(void *drm_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id); + int (*hdcp_start_transmitter)(void *drm_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id); /** Stops HDCP transmitter */ - hal_drm_error_e (*hdcp_stop_transmitter)(void *drm_handle, uint32_t hdcp_id); + int (*hdcp_stop_transmitter)(void *drm_handle, uint32_t hdcp_id); /** Allocates hdcp output buffer */ - hal_drm_error_e (*hdcp_allocate_output_buffer)(void *drm_handle, uint32_t size, bool is_secure, hal_drm_buffer_s *buffer); + int (*hdcp_allocate_output_buffer)(void *drm_handle, uint32_t size, bool is_secure, hal_drm_buffer_s *buffer); /** Releases hdcp output buffer */ - hal_drm_error_e (*hdcp_release_output_buffer)(void *drm_handle, hal_drm_buffer_s *buffer); + int (*hdcp_release_output_buffer)(void *drm_handle, hal_drm_buffer_s *buffer); /** Decrypts HDCP data */ - hal_drm_error_e (*hdcp_decrypt)(void *drm_handle, hal_drm_buffer_s *input, void *decrypt_info, hal_drm_buffer_s *output); + int (*hdcp_decrypt)(void *drm_handle, hal_drm_buffer_s *input, void *decrypt_info, hal_drm_buffer_s *output); + /** Encrypts HDCP data */ + int (*hdcp_encrypt)(void *drm_handle, hal_drm_buffer_s *input, uint32_t hdcp_id, void *encrypt_info, hal_drm_buffer_s *output); } hal_backend_drm_funcs; /** diff --git a/include/hal-drm.h b/include/hal-drm.h index 02a4131..7988556 100644 --- a/include/hal-drm.h +++ b/include/hal-drm.h @@ -48,7 +48,7 @@ extern "C" { * @post If it succeeds, the DRM state will be #HAL_DRM_STATE_INITIALIZED. * @see hal_drm_deinit() */ -hal_drm_error_e hal_drm_init(void **drm_handle); +int hal_drm_init(void **drm_handle); /** * @brief Deinitializes handle of DRM HAL. @@ -61,7 +61,7 @@ hal_drm_error_e hal_drm_init(void **drm_handle); * @post If it succeeds, the DRM state will be #HAL_DRM_STATE_NONE. * @see hal_drm_init() */ -hal_drm_error_e hal_drm_deinit(void *drm_handle); +int hal_drm_deinit(void *drm_handle); /** * @brief Gets the state of DRM. @@ -74,7 +74,7 @@ hal_drm_error_e hal_drm_deinit(void *drm_handle); * @retval #HAL_DRM_ERROR_NOT_IMPLEMENTED The feature is not implemented * @pre The DRM state must be set to #HAL_DRM_STATE_INITIALIZED. */ -hal_drm_error_e hal_drm_get_state(void *drm_handle, hal_drm_state_e *state); +int hal_drm_get_state(void *drm_handle, hal_drm_state_e *state); /** * @brief Sets the various command and value to control DRM. @@ -91,7 +91,7 @@ hal_drm_error_e hal_drm_get_state(void *drm_handle, hal_drm_state_e *state); * @pre The DRM state must be set to #HAL_DRM_STATE_INITIALIZED. * @see hal_drm_get_command() */ -hal_drm_error_e hal_drm_set_command(void *drm_handle, hal_drm_command_e command, void *value); +int hal_drm_set_command(void *drm_handle, hal_drm_command_e command, void *value); /** * @brief Gets the current value of command. @@ -109,7 +109,7 @@ hal_drm_error_e hal_drm_set_command(void *drm_handle, hal_drm_command_e command, * @pre The DRM state must be set to #HAL_DRM_STATE_INITIALIZED. * @see hal_drm_set_command() */ -hal_drm_error_e hal_drm_get_command(void *drm_handle, hal_drm_command_e command, void **value); +int hal_drm_get_command(void *drm_handle, hal_drm_command_e command, void **value); /** * @brief Sets a set of commands. @@ -127,7 +127,7 @@ hal_drm_error_e hal_drm_get_command(void *drm_handle, hal_drm_command_e command, * @see hal_drm_set_command() * @see hal_drm_get_command() */ -hal_drm_error_e hal_drm_set_batch_command(void *drm_handle, hal_drm_batch_command_control_s *batch_command, hal_drm_command_e *error_command); +int hal_drm_set_batch_command(void *drm_handle, hal_drm_batch_command_control_s *batch_command, hal_drm_command_e *error_command); /** * @brief Opens HDCP. @@ -143,7 +143,7 @@ hal_drm_error_e hal_drm_set_batch_command(void *drm_handle, hal_drm_batch_comman * @post If it succeeds, the DRM state will be #HAL_DRM_STATE_HDCP_OPENED. * @see hal_drm_hdcp_close() */ -hal_drm_error_e hal_drm_hdcp_open(void *drm_handle, hal_drm_hdcp_device_type_e type, hal_drm_hdcp_protocol_version_e version); +int hal_drm_hdcp_open(void *drm_handle, hal_drm_hdcp_device_type_e type, hal_drm_hdcp_protocol_version_e version); /** * @brief Closes HDCP. @@ -157,7 +157,7 @@ hal_drm_error_e hal_drm_hdcp_open(void *drm_handle, hal_drm_hdcp_device_type_e t * @post If it succeeds, the DRM state will be #HAL_DRM_STATE_INITIALIZED. * @see hal_drm_hdcp_open() */ -hal_drm_error_e hal_drm_hdcp_close(void *drm_handle); +int hal_drm_hdcp_close(void *drm_handle); /** * @brief Starts HDCP receiver. @@ -172,7 +172,7 @@ hal_drm_error_e hal_drm_hdcp_close(void *drm_handle); * @pre The DRM state must be set to #HAL_DRM_STATE_HDCP_OPENED. * @see hal_drm_hdcp_stop_receiver() */ -hal_drm_error_e hal_drm_hdcp_start_receiver(void *drm_handle, uint32_t socket_port, uint32_t *hdcp_id); +int hal_drm_hdcp_start_receiver(void *drm_handle, uint32_t socket_port, uint32_t *hdcp_id); /** * @brief Stops HDCP receiver. @@ -186,7 +186,7 @@ hal_drm_error_e hal_drm_hdcp_start_receiver(void *drm_handle, uint32_t socket_po * @pre The DRM state must be set to #HAL_DRM_STATE_HDCP_OPENED. * @see hal_drm_hdcp_start_receiver() */ -hal_drm_error_e hal_drm_hdcp_stop_receiver(void *drm_handle, uint32_t hdcp_id); +int hal_drm_hdcp_stop_receiver(void *drm_handle, uint32_t hdcp_id); /** * @brief Starts HDCP transmitter. @@ -202,7 +202,7 @@ hal_drm_error_e hal_drm_hdcp_stop_receiver(void *drm_handle, uint32_t hdcp_id); * @pre The DRM state must be set to #HAL_DRM_STATE_HDCP_OPENED. * @see hal_drm_hdcp_stop_transmitter() */ -hal_drm_error_e hal_drm_hdcp_start_transmitter(void *drm_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id); +int hal_drm_hdcp_start_transmitter(void *drm_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id); /** * @brief Stops HDCP transmitter. @@ -216,7 +216,7 @@ hal_drm_error_e hal_drm_hdcp_start_transmitter(void *drm_handle, const char *soc * @pre The DRM state must be set to #HAL_DRM_STATE_HDCP_OPENED. * @see hal_drm_hdcp_start_transmitter() */ -hal_drm_error_e hal_drm_hdcp_stop_transmitter(void *drm_handle, uint32_t hdcp_id); +int hal_drm_hdcp_stop_transmitter(void *drm_handle, uint32_t hdcp_id); /** * @brief Allocates HDCP output buffer. @@ -234,7 +234,7 @@ hal_drm_error_e hal_drm_hdcp_stop_transmitter(void *drm_handle, uint32_t hdcp_id * @see hal_drm_hdcp_release_output_buffer() * @see hal_drm_hdcp_decrypt() */ -hal_drm_error_e hal_drm_hdcp_allocate_output_buffer(void *drm_handle, uint32_t size, bool is_secure, hal_drm_buffer_s *buffer); +int hal_drm_hdcp_allocate_output_buffer(void *drm_handle, uint32_t size, bool is_secure, hal_drm_buffer_s *buffer); /** * @brief Releases HDCP output buffer. @@ -250,7 +250,7 @@ hal_drm_error_e hal_drm_hdcp_allocate_output_buffer(void *drm_handle, uint32_t s * @see hal_drm_hdcp_allocate_output_buffer() * @see hal_drm_hdcp_decrypt() */ -hal_drm_error_e hal_drm_hdcp_release_output_buffer(void *drm_handle, hal_drm_buffer_s *buffer); +int hal_drm_hdcp_release_output_buffer(void *drm_handle, hal_drm_buffer_s *buffer); /** * @brief Decrypts HDCP data. @@ -268,7 +268,27 @@ hal_drm_error_e hal_drm_hdcp_release_output_buffer(void *drm_handle, hal_drm_buf * @see hal_drm_hdcp_allocate_output_buffer() * @see hal_drm_hdcp_release_output_buffer() */ -hal_drm_error_e hal_drm_hdcp_decrypt(void *drm_handle, hal_drm_buffer_s *input, void *decrypt_info, hal_drm_buffer_s *output); +int hal_drm_hdcp_decrypt(void *drm_handle, hal_drm_buffer_s *input, void *decrypt_info, hal_drm_buffer_s *output); + +/** + * @brief Encrypts HDCP data to send. + * @since HAL_MODULE_DRM 1.0 + * @param[in] drm_handle The handle to the DRM HAL + * @param[in] input The input buffer to encrypt + * @param[in] hdcp_id The hdcp id + * @param[in] encrypt_info The encryption information + * @param[out] output The encrypted output buffer + * @return @c 0 on success, otherwise a negative error value + * @retval #HAL_DRM_ERROR_NONE Successful + * @retval #HAL_DRM_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #HAL_DRM_ERROR_INTERNAL Internal error + * @retval #HAL_DRM_ERROR_NOT_IMPLEMENTED The feature is not implemented + * @pre The DRM state must be set to #HAL_DRM_STATE_HDCP_OPENED. + * @see hal_drm_hdcp_allocate_output_buffer() + * @see hal_drm_hdcp_release_output_buffer() + */ +int hal_drm_hdcp_encrypt(void *drm_handle, hal_drm_buffer_s *input, uint32_t hdcp_id, void *encrypt_info, hal_drm_buffer_s *output); + /** * @} */ diff --git a/packaging/hal-api-drm.spec b/packaging/hal-api-drm.spec index f2e51dd..bcaa8d9 100644 --- a/packaging/hal-api-drm.spec +++ b/packaging/hal-api-drm.spec @@ -3,7 +3,7 @@ ### main package ######### Name: %{name} Summary: %{name} interface -Version: 1.0.0 +Version: 1.0.1 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/src/hal-api-drm.c b/src/hal-api-drm.c index ec8a119..3ca89ed 100644 --- a/src/hal-api-drm.c +++ b/src/hal-api-drm.c @@ -94,7 +94,7 @@ static int hal_drm_exit_backend(void *data, void *user_data) return 0; } -hal_drm_error_e hal_drm_init(void **drm_handle) +int hal_drm_init(void **drm_handle) { HAL_DRM_RETURN_IF_NULL(drm_handle, HAL_DRM_ERROR_INVALID_PARAMETER); @@ -146,7 +146,7 @@ __HAL_INIT_FAILED: return HAL_DRM_ERROR_INTERNAL; } -hal_drm_error_e hal_drm_deinit(void *drm_handle) +int hal_drm_deinit(void *drm_handle) { int ret = 0; hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -155,7 +155,7 @@ hal_drm_error_e hal_drm_deinit(void *drm_handle) HAL_DRM_RETURN_IF_NULL(handle->funcs, HAL_DRM_ERROR_INVALID_PARAMETER); HAL_DRM_RETURN_IF_NULL(handle->funcs->deinit, HAL_DRM_ERROR_NOT_IMPLEMENTED); - SLOGI("start"); + SLOGI("start handle=%p", drm_handle); AUTOCLEAN_LOCKER(&handle->lock); @@ -174,13 +174,14 @@ hal_drm_error_e hal_drm_deinit(void *drm_handle) g_mutex_clear(&handle->lock); g_free(handle); + handle = NULL; SLOGI("done"); return HAL_DRM_ERROR_NONE; } -hal_drm_error_e hal_drm_get_state(void *drm_handle, hal_drm_state_e *state) +int hal_drm_get_state(void *drm_handle, hal_drm_state_e *state) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -196,7 +197,7 @@ hal_drm_error_e hal_drm_get_state(void *drm_handle, hal_drm_state_e *state) return HAL_DRM_ERROR_NONE; } -hal_drm_error_e hal_drm_set_command(void *drm_handle, hal_drm_command_e command, void *value) +int hal_drm_set_command(void *drm_handle, hal_drm_command_e command, void *value) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -215,7 +216,7 @@ hal_drm_error_e hal_drm_set_command(void *drm_handle, hal_drm_command_e command, return handle->funcs->set_command(handle->backend, command, value); } -hal_drm_error_e hal_drm_get_command(void *drm_handle, hal_drm_command_e command, void **value) +int hal_drm_get_command(void *drm_handle, hal_drm_command_e command, void **value) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -234,7 +235,7 @@ hal_drm_error_e hal_drm_get_command(void *drm_handle, hal_drm_command_e command, return handle->funcs->get_command(handle->backend, command, value); } -hal_drm_error_e hal_drm_set_batch_command(void *drm_handle, hal_drm_batch_command_control_s *batch_command, hal_drm_command_e *error_command) +int hal_drm_set_batch_command(void *drm_handle, hal_drm_batch_command_control_s *batch_command, hal_drm_command_e *error_command) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -253,7 +254,7 @@ hal_drm_error_e hal_drm_set_batch_command(void *drm_handle, hal_drm_batch_comman return handle->funcs->set_batch_command(handle->backend, batch_command, error_command); } -hal_drm_error_e hal_drm_hdcp_open(void *drm_handle, hal_drm_hdcp_device_type_e type, hal_drm_hdcp_protocol_version_e version) +int hal_drm_hdcp_open(void *drm_handle, hal_drm_hdcp_device_type_e type, hal_drm_hdcp_protocol_version_e version) { int ret = 0; hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -279,7 +280,7 @@ hal_drm_error_e hal_drm_hdcp_open(void *drm_handle, hal_drm_hdcp_device_type_e t return ret; } -hal_drm_error_e hal_drm_hdcp_close(void *drm_handle) +int hal_drm_hdcp_close(void *drm_handle) { int ret = 0; hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -299,7 +300,7 @@ hal_drm_error_e hal_drm_hdcp_close(void *drm_handle) return ret; } -hal_drm_error_e hal_drm_hdcp_start_receiver(void *drm_handle, uint32_t socket_port, uint32_t *hdcp_id) +int hal_drm_hdcp_start_receiver(void *drm_handle, uint32_t socket_port, uint32_t *hdcp_id) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -315,7 +316,7 @@ hal_drm_error_e hal_drm_hdcp_start_receiver(void *drm_handle, uint32_t socket_po return handle->funcs->hdcp_start_receiver(handle->backend, socket_port, hdcp_id); } -hal_drm_error_e hal_drm_hdcp_stop_receiver(void *drm_handle, uint32_t hdcp_id) +int hal_drm_hdcp_stop_receiver(void *drm_handle, uint32_t hdcp_id) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -330,7 +331,7 @@ hal_drm_error_e hal_drm_hdcp_stop_receiver(void *drm_handle, uint32_t hdcp_id) return handle->funcs->hdcp_stop_receiver(handle->backend, hdcp_id); } -hal_drm_error_e hal_drm_hdcp_start_transmitter(void *drm_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id) +int hal_drm_hdcp_start_transmitter(void *drm_handle, const char *socket_ip, uint32_t socket_port, uint32_t *hdcp_id) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -347,7 +348,7 @@ hal_drm_error_e hal_drm_hdcp_start_transmitter(void *drm_handle, const char *soc return handle->funcs->hdcp_start_transmitter(handle->backend, socket_ip, socket_port, hdcp_id); } -hal_drm_error_e hal_drm_hdcp_stop_transmitter(void *drm_handle, uint32_t hdcp_id) +int hal_drm_hdcp_stop_transmitter(void *drm_handle, uint32_t hdcp_id) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -362,7 +363,7 @@ hal_drm_error_e hal_drm_hdcp_stop_transmitter(void *drm_handle, uint32_t hdcp_id return handle->funcs->hdcp_stop_transmitter(handle->backend, hdcp_id); } -hal_drm_error_e hal_drm_hdcp_allocate_output_buffer(void *drm_handle, uint32_t size, bool is_secure, hal_drm_buffer_s *buffer) +int hal_drm_hdcp_allocate_output_buffer(void *drm_handle, uint32_t size, bool is_secure, hal_drm_buffer_s *buffer) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -378,7 +379,7 @@ hal_drm_error_e hal_drm_hdcp_allocate_output_buffer(void *drm_handle, uint32_t s return handle->funcs->hdcp_allocate_output_buffer(handle->backend, size, is_secure, buffer); } -hal_drm_error_e hal_drm_hdcp_release_output_buffer(void *drm_handle, hal_drm_buffer_s *buffer) +int hal_drm_hdcp_release_output_buffer(void *drm_handle, hal_drm_buffer_s *buffer) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -394,7 +395,7 @@ hal_drm_error_e hal_drm_hdcp_release_output_buffer(void *drm_handle, hal_drm_buf return handle->funcs->hdcp_release_output_buffer(handle->backend, buffer); } -hal_drm_error_e hal_drm_hdcp_decrypt(void *drm_handle, hal_drm_buffer_s *input, void *decrypt_info, hal_drm_buffer_s *output) +int hal_drm_hdcp_decrypt(void *drm_handle, hal_drm_buffer_s *input, void *decrypt_info, hal_drm_buffer_s *output) { hal_drm_s *handle = (hal_drm_s *)drm_handle; @@ -404,11 +405,27 @@ hal_drm_error_e hal_drm_hdcp_decrypt(void *drm_handle, hal_drm_buffer_s *input, HAL_DRM_RETURN_IF_NULL(input, HAL_DRM_ERROR_INVALID_PARAMETER); HAL_DRM_RETURN_IF_NULL(output, HAL_DRM_ERROR_INVALID_PARAMETER); - // If decrypt_info is NULL, it means that it's not encrypted data. - AUTOCLEAN_LOCKER(&handle->lock); HAL_DRM_CHECK_STATE(handle->state, HAL_DRM_STATE_HDCP_OPENED); return handle->funcs->hdcp_decrypt(handle->backend, input, decrypt_info, output); -} \ No newline at end of file +} + +int hal_drm_hdcp_encrypt(void *drm_handle, hal_drm_buffer_s *input, uint32_t hdcp_id, void *encrypt_info, hal_drm_buffer_s *output) +{ + hal_drm_s *handle = (hal_drm_s *)drm_handle; + + HAL_DRM_RETURN_IF_NULL(handle, HAL_DRM_ERROR_INVALID_PARAMETER); + HAL_DRM_RETURN_IF_NULL(handle->funcs, HAL_DRM_ERROR_INVALID_PARAMETER); + HAL_DRM_RETURN_IF_NULL(handle->funcs->hdcp_encrypt, HAL_DRM_ERROR_NOT_IMPLEMENTED); + HAL_DRM_RETURN_IF_NULL(input, HAL_DRM_ERROR_INVALID_PARAMETER); + HAL_DRM_RETURN_IF_NULL(encrypt_info, HAL_DRM_ERROR_INVALID_PARAMETER); + HAL_DRM_RETURN_IF_NULL(output, HAL_DRM_ERROR_INVALID_PARAMETER); + + AUTOCLEAN_LOCKER(&handle->lock); + + HAL_DRM_CHECK_STATE(handle->state, HAL_DRM_STATE_HDCP_OPENED); + + return handle->funcs->hdcp_encrypt(handle->backend, input, hdcp_id, encrypt_info, output); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c3afbba..bee8aad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,4 +19,3 @@ SET_TARGET_PROPERTIES(${HAL_DRM_TEST} PROPERTIES COMPILE_FLAGS "-fPIE") SET_TARGET_PROPERTIES(${HAL_DRM_TEST} PROPERTIES LINK_FLAGS "-pie") INSTALL(TARGETS ${HAL_DRM_TEST} DESTINATION ${EXEC_PREFIX}/hal/) - diff --git a/tests/drm_hal_test.cpp b/tests/drm_hal_test.cpp index a4c3c46..3148f9c 100644 --- a/tests/drm_hal_test.cpp +++ b/tests/drm_hal_test.cpp @@ -24,7 +24,7 @@ #include #include -static int ret; +static int gRet; static void *gHalHandle; static const char *gSocketIp = "192.168.0.1"; static int gPortIp = 100; @@ -37,20 +37,20 @@ class DrmHalTest : public testing::Test public: virtual void SetUp() { - ret = hal_drm_init(&gHalHandle); - if (ret == HAL_DRM_ERROR_NONE) { + gRet = hal_drm_init(&gHalHandle); + if (gRet == HAL_DRM_ERROR_NONE) { std::cout << "DRM HAL init - handle: " << gHalHandle << std::endl; return; } - std::cout << "DRM HAL init failed " << ret << std::endl; + std::cout << "DRM HAL init failed " << gRet << std::endl; } virtual void TearDown() { if (gHalHandle) { std::cout << "DRM HAL deinit - handle: " << gHalHandle << std::endl; - ret = hal_drm_deinit(gHalHandle); + gRet = hal_drm_deinit(gHalHandle); gHalHandle = nullptr; } } @@ -89,8 +89,8 @@ TEST_F(DrmHalTest, InitP) */ TEST_F(DrmHalTest, InitN) { - ret = hal_drm_init(nullptr); - EXPECT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_init(nullptr); + EXPECT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); } /** @@ -110,14 +110,14 @@ TEST_F(DrmHalTest, DeinitP) { void *hal_handle = nullptr; - ret = hal_drm_init(&hal_handle); + gRet = hal_drm_init(&hal_handle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); ASSERT_NE(hal_handle, nullptr); if (hal_handle) { - ret = hal_drm_deinit(hal_handle); - EXPECT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_deinit(hal_handle); + EXPECT_EQ(gRet, HAL_DRM_ERROR_NONE); hal_handle = nullptr; } } @@ -137,8 +137,8 @@ TEST_F(DrmHalTest, DeinitP) */ TEST_F(DrmHalTest, DeinitN) { - ret = hal_drm_deinit(nullptr); - EXPECT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_deinit(nullptr); + EXPECT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); } /** @@ -161,14 +161,14 @@ TEST_F(DrmHalTest, DrmSetBatchCommandP) batch_command.custom.name = "custom_command_name"; batch_command.custom.value = (void*)10; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_set_batch_command(gHalHandle, &batch_command, nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_set_batch_command(gHalHandle, &batch_command, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -191,17 +191,17 @@ TEST_F(DrmHalTest, DrmSetBatchCommandN) batch_command.custom.name = "custom_command_name"; batch_command.custom.value = (void*)10; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_set_batch_command(nullptr, &batch_command, nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_set_batch_command(nullptr, &batch_command, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_set_batch_command(gHalHandle, nullptr, nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_set_batch_command(gHalHandle, nullptr, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -219,8 +219,8 @@ TEST_F(DrmHalTest, DrmSetBatchCommandN) */ TEST_F(DrmHalTest, HdcpOpenP) { - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -238,11 +238,11 @@ TEST_F(DrmHalTest, HdcpOpenP) */ TEST_F(DrmHalTest, HdcpCloseP) { - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -260,8 +260,8 @@ TEST_F(DrmHalTest, HdcpCloseP) */ TEST_F(DrmHalTest, HdcpCloseN1) { - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_STATE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_STATE); } /** @@ -279,11 +279,11 @@ TEST_F(DrmHalTest, HdcpCloseN1) */ TEST_F(DrmHalTest, HdcpCloseN2) { - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_close(nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); } /** @@ -303,14 +303,14 @@ TEST_F(DrmHalTest, HdcpStartReceiverP) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -330,8 +330,8 @@ TEST_F(DrmHalTest, HdcpStartReceiverN1) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_STATE); + gRet = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_STATE); } /** @@ -351,17 +351,17 @@ TEST_F(DrmHalTest, HdcpStartReceiverN2) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_receiver(nullptr, 100, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_start_receiver(nullptr, 100, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_start_receiver(gHalHandle, 100, nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_start_receiver(gHalHandle, 100, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -381,17 +381,17 @@ TEST_F(DrmHalTest, HdcpStopReceiverP) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_receiver(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_receiver(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -411,8 +411,8 @@ TEST_F(DrmHalTest, HdcpStopReceiverN1) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_stop_receiver(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_STATE); + gRet = hal_drm_hdcp_stop_receiver(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_STATE); } /** @@ -432,17 +432,17 @@ TEST_F(DrmHalTest, HdcpStopReceiverN2) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_receiver(gHalHandle, 100, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_receiver(nullptr, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_stop_receiver(nullptr, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -462,14 +462,14 @@ TEST_F(DrmHalTest, HdcpStartTransmitterP) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -489,8 +489,8 @@ TEST_F(DrmHalTest, HdcpStartTransmitterN1) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_STATE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_STATE); } /** @@ -510,14 +510,14 @@ TEST_F(DrmHalTest, HdcpStartTransmitterN2) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(nullptr, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_start_transmitter(nullptr, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -537,17 +537,17 @@ TEST_F(DrmHalTest, HdcpStopTransmitterP) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -567,8 +567,8 @@ TEST_F(DrmHalTest, HdcpStopTransmitterN1) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_STATE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_STATE); } /** @@ -588,17 +588,17 @@ TEST_F(DrmHalTest, HdcpStopTransmitterN2) { uint32_t hdcp_id = 0; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_transmitter(nullptr, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_stop_transmitter(nullptr, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -619,20 +619,20 @@ TEST_F(DrmHalTest, HdcpAllocateBufferP) uint32_t hdcp_id = 0; hal_drm_buffer_s output; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -653,23 +653,23 @@ TEST_F(DrmHalTest, HdcpAllocateBufferN) uint32_t hdcp_id = 0; hal_drm_buffer_s output; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_allocate_output_buffer(nullptr, 1000, false, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_allocate_output_buffer(nullptr, 1000, false, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -690,23 +690,23 @@ TEST_F(DrmHalTest, HdcpReleaseBufferP) uint32_t hdcp_id = 0; hal_drm_buffer_s output; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_release_output_buffer(gHalHandle, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_release_output_buffer(gHalHandle, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -727,26 +727,26 @@ TEST_F(DrmHalTest, HdcpReleaseBufferN) uint32_t hdcp_id = 0; hal_drm_buffer_s output; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_release_output_buffer(nullptr, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_release_output_buffer(nullptr, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_release_output_buffer(gHalHandle, nullptr); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_release_output_buffer(gHalHandle, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -755,10 +755,10 @@ TEST_F(DrmHalTest, HdcpReleaseBufferN) * @author SR(haesu.gwon) * @reviewer SR(gilbok) * @type auto - * @description Positive, Stop HDCP transmitter - * @apicovered hal_drm_hdcp_stop_transmitter - * @passcase when hal_drm_hdcp_stop_transmitter returns HAL_DRM_ERROR_NONE - * @failcase when hal_drm_hdcp_stop_transmitter does not return HAL_DRM_ERROR_NONE + * @description Positive, Decrypt HDCP data + * @apicovered hal_drm_hdcp_decrypt + * @passcase when hal_drm_hdcp_decrypt returns HAL_DRM_ERROR_NONE + * @failcase when hal_drm_hdcp_decrypt does not return HAL_DRM_ERROR_NONE * @precondition None * @postcondition None */ @@ -768,24 +768,24 @@ TEST_F(DrmHalTest, HdcpDecryptP) hal_drm_buffer_s input, output; uint32_t decrypt_info; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); input.size = 100; - ret = hal_drm_hdcp_decrypt(gHalHandle, &input, (void *)&decrypt_info, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_decrypt(gHalHandle, &input, (void *)&decrypt_info, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } /** @@ -794,10 +794,10 @@ TEST_F(DrmHalTest, HdcpDecryptP) * @author SR(haesu.gwon) * @reviewer SR(gilbok) * @type auto - * @description Negative, Stop HDCP transmitter - * @apicovered hal_drm_hdcp_stop_transmitter - * @passcase when hal_drm_hdcp_stop_transmitter returns HAL_DRM_ERROR_INVALID_STATE - * @failcase when hal_drm_hdcp_stop_transmitter does not return HAL_DRM_ERROR_INVALID_STATE + * @description Negative, Decrypt HDCP data + * @apicovered hal_drm_hdcp_decrypt + * @passcase when hal_drm_hdcp_decrypt returns HAL_DRM_ERROR_INVALID_PARAMETER + * @failcase when hal_drm_hdcp_decrypt does not return HAL_DRM_ERROR_INVALID_PARAMETER * @precondition None * @postcondition None */ @@ -807,20 +807,101 @@ TEST_F(DrmHalTest, HdcpDecryptN1) hal_drm_buffer_s output; int decrypt_info; - ret = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_decrypt(gHalHandle, nullptr, (void *)&decrypt_info, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); + + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); +} + +/** + * @testcase HdcpEncryptP + * @since HAL_MODULE_DRM 1.0 + * @author SR(haesu.gwon) + * @reviewer SR(gilbok) + * @type auto + * @description Positive, Encrypt HDCP data + * @apicovered hal_drm_hdcp_encrypt + * @passcase when hal_drm_hdcp_encrypt returns HAL_DRM_ERROR_NONE + * @failcase when hal_drm_hdcp_encrypt does not return HAL_DRM_ERROR_NONE + * @precondition None + * @postcondition None + */ +TEST_F(DrmHalTest, HdcpEncryptP) +{ + uint32_t hdcp_id = 0; + hal_drm_buffer_s input, output; + uint32_t encrypt_info; + + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_allocate_output_buffer(gHalHandle, 1000, false, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + input.size = 100; + gRet = hal_drm_hdcp_encrypt(gHalHandle, &input, hdcp_id, (void *)&encrypt_info, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); +} + +/** + * @testcase HdcpEncryptN1 + * @since HAL_MODULE_DRM 1.0 + * @author SR(haesu.gwon) + * @reviewer SR(gilbok) + * @type auto + * @description Negative, Encrypt HDCP data + * @apicovered hal_drm_hdcp_encrypt + * @passcase when hal_drm_hdcp_encrypt returns HAL_DRM_ERROR_INVALID_PARAMETER + * @failcase when hal_drm_hdcp_encrypt does not return HAL_DRM_ERROR_INVALID_PARAMETER + * @precondition None + * @postcondition None + */ +TEST_F(DrmHalTest, HdcpEncryptN1) +{ + uint32_t hdcp_id = 0; + hal_drm_buffer_s input, output; + uint32_t encrypt_info; + input.size = 100; + + gRet = hal_drm_hdcp_open(gHalHandle, HAL_DRM_HDCP_DEVICE_RECEIVER, HAL_DRM_HDCP_VERSION_2_0); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); + + gRet = hal_drm_hdcp_encrypt(gHalHandle, nullptr, hdcp_id, (void *)&encrypt_info, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_start_transmitter(gHalHandle, gSocketIp, gPortIp, &hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_encrypt(gHalHandle, &input, hdcp_id, nullptr, &output); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_decrypt(gHalHandle, nullptr, (void *)&decrypt_info, &output); - ASSERT_EQ(ret, HAL_DRM_ERROR_INVALID_PARAMETER); + gRet = hal_drm_hdcp_encrypt(gHalHandle, &input, hdcp_id, (void *)&encrypt_info, nullptr); + ASSERT_EQ(gRet, HAL_DRM_ERROR_INVALID_PARAMETER); - ret = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_stop_transmitter(gHalHandle, hdcp_id); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); - ret = hal_drm_hdcp_close(gHalHandle); - ASSERT_EQ(ret, HAL_DRM_ERROR_NONE); + gRet = hal_drm_hdcp_close(gHalHandle); + ASSERT_EQ(gRet, HAL_DRM_ERROR_NONE); } int main(int argc, char **argv)