From: Hyuk Lee Date: Tue, 27 Jun 2017 05:09:50 +0000 (+0900) Subject: Add the SetAbsoluteVolume internal API for AVRCP controller X-Git-Tag: submit/tizen/20170710.052629~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f31f68cf396a0b62c0ee8349b846d6ea97f201b;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add the SetAbsoluteVolume internal API for AVRCP controller Change-Id: Ie4362694983e5e8d93f3652bcbd68964519ac0f7 Signed-off-by: Hyuk Lee --- diff --git a/include/bluetooth_internal.h b/include/bluetooth_internal.h index 24b080a..1a5de63 100644 --- a/include/bluetooth_internal.h +++ b/include/bluetooth_internal.h @@ -3442,6 +3442,29 @@ int bt_pbap_client_is_connected(const char *address, bool *connected_status); int bt_hid_device_send_custom_event(const char *remote_address, unsigned char report_id, const char *data, unsigned int data_len); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_CONTROL_MODULE + * @brief Sends the volume change request to the remote device. + * @since_tizen 4.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/bluetooth.admin + * @param[in] value The new volume level + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_ENABLED Not enabled + * @retval #BT_ERROR_OPERATION_FAILED Operation failed + * @retval #BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED Remote device is not connected + * @retval #BT_ERROR_PERMISSION_DENIED Permission denied + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The remote device must be connected. + * @see bt_avrcp_target_connection_state_changed_cb() + * @see bt_avrcp_target_initialize() + */ +int bt_avrcp_control_set_absolute_volume(unsigned int value); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE * @brief Creates the Proximity Profile Reporter Role. diff --git a/src/bluetooth-avrcp.c b/src/bluetooth-avrcp.c index c80a197..3a35c51 100644 --- a/src/bluetooth-avrcp.c +++ b/src/bluetooth-avrcp.c @@ -390,6 +390,22 @@ int bt_avrcp_control_send_player_command(bt_avrcp_player_command_e cmd) return error; } +int bt_avrcp_control_set_absolute_volume(unsigned int value) +{ + int error; + + BT_CHECK_AVRCP_CONTROL_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AVRCP_CONTROL_INIT_STATUS(); + error = bluetooth_media_transport_set_property(VOLUME, value); + error = _bt_convert_avrcp_error_code(error); + error = _bt_get_error_code(error); + if (BT_ERROR_NONE != error) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error), error); /* LCOV_EXCL_LINE */ + + return error; +} + int bt_avrcp_control_set_equalizer_state(bt_avrcp_equalizer_state_e state) { int error; diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 5f8fd2b..d5e829c 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -805,6 +805,8 @@ tc_table_t tc_avrcp[] = { , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT}, {"bt_avrcp_control_player_PREV" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV}, + {"bt_avrcp_control_player_SET_ABSOLUTE_VOLUME" + , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME}, {"bt_avrcp_control_player_GET_REPEAT" , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT}, {"bt_avrcp_control_player_SET_REPEAT" @@ -8484,7 +8486,12 @@ int test_input_callback(void *data) TC_PRT("returns %s\n", __bt_get_error_message(ret)); break; } - + case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME: { + static unsigned int volume_level = 1; + ret = bt_avrcp_control_set_absolute_volume(volume_level++); + TC_PRT("returns %s\n", __bt_get_error_message(ret)); + break; + } case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT: { bt_avrcp_repeat_mode_e mode = BT_AVRCP_REPEAT_MODE_GROUP; ret = bt_avrcp_control_get_repeat_mode(&mode); diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index f0529f7..6b28c1c 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -307,6 +307,7 @@ typedef enum { BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_RW, BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_NEXT, BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_PREV, + BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_ABSOLUTE_VOLUME, BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT, BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT, BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE,