Add the SetAbsoluteVolume internal API for AVRCP controller 51/135851/1
authorHyuk Lee <hyuk0512.lee@samsung.com>
Tue, 27 Jun 2017 05:09:50 +0000 (14:09 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Tue, 27 Jun 2017 05:09:50 +0000 (14:09 +0900)
Change-Id: Ie4362694983e5e8d93f3652bcbd68964519ac0f7
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
include/bluetooth_internal.h
src/bluetooth-avrcp.c
test/bt_unit_test.c
test/bt_unit_test.h

index 24b080a8675ca7e9a06574ac4f73e0c75198622e..1a5de63a55f11a0152f9a09b42803c99beb17b17 100644 (file)
@@ -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.
index c80a19705e796f02a8cfc8615cf8c6c0b28b0604..3a35c51130f2704a6f9c819aa809289d83a3462f 100644 (file)
@@ -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;
index 5f8fd2bb86e6471a2ac1423533733e72d40942de..d5e829c77c4b45ae765c554f135a81f618df07ad 100644 (file)
@@ -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);
index f0529f779986104ff0550b90f514c6e77cbc2d9f..6b28c1c3bdf5322ee9561f9a297d3d332fcf32ce 100644 (file)
@@ -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,