Add the inhouse APIs for AVRCP control volume up / down 83/164183/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 18 Dec 2017 01:35:10 +0000 (10:35 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 18 Dec 2017 01:35:10 +0000 (10:35 +0900)
Change-Id: Ia5bd9eff0d389215a75005629d9a243a68a7caf1
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/bluetooth_internal.h
src/bluetooth-avrcp.c
test/bt_unit_test.c
test/bt_unit_test.h

index c7d261fca91ae63bc830c17ec3b8757114c54cd5..94515125284572983d110ddf316abf57dd01f510 100644 (file)
@@ -3525,6 +3525,50 @@ int bt_hid_device_send_custom_event(const char *remote_address,
  */
 int bt_avrcp_control_set_absolute_volume(unsigned int value);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_CONTROL_MODULE
+ * @brief  Sends the volume up request to the remote device.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/bluetooth.admin
+ * @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_control_connect()
+ * @see bt_avrcp_control_initialize()
+ */
+int bt_avrcp_control_increase_volume(void);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_CONTROL_MODULE
+ * @brief  Sends the volume down request to the remote device.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/bluetooth.admin
+ * @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_control_connect()
+ * @see bt_avrcp_control_initialize()
+ */
+int bt_avrcp_control_decrease_volume(void);
+
 /**
  * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE
  * @brief Creates the Proximity Profile Reporter Role.
index 3a35c51130f2704a6f9c819aa809289d83a3462f..fef8a3fb1d4ab8d7f0d885b02c147242ec0077bb 100644 (file)
@@ -406,6 +406,38 @@ int bt_avrcp_control_set_absolute_volume(unsigned int value)
        return error;
 }
 
+int bt_avrcp_control_increase_volume(void)
+{
+       int error;
+
+       BT_CHECK_AVRCP_CONTROL_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_AVRCP_CONTROL_INIT_STATUS();
+       error = bluetooth_media_control_command(VOLUME_UP);
+       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_decrease_volume(void)
+{
+       int error;
+
+       BT_CHECK_AVRCP_CONTROL_SUPPORT();
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_AVRCP_CONTROL_INIT_STATUS();
+       error = bluetooth_media_control_command(VOLUME_DOWN);
+       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 24130231a1e0c2701bc18284e5095031cc2bc94b..5f08b735551424058f5933f64d3a5c5502773a22 100644 (file)
@@ -811,6 +811,10 @@ tc_table_t tc_avrcp[] = {
                , 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_VOLUME_UP"
+               , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP},
+       {"bt_avrcp_control_player_VOLUME_DOWN"
+               , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN},
        {"bt_avrcp_control_player_GET_REPEAT"
                , BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT},
        {"bt_avrcp_control_player_SET_REPEAT"
@@ -9050,6 +9054,16 @@ int test_input_callback(void *data)
                        TC_PRT("returns %s\n", __bt_get_error_message(ret));
                        break;
                        }
+               case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_UP: {
+                       ret = bt_avrcp_control_increase_volume();
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+                       }
+               case BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN: {
+                       ret = bt_avrcp_control_decrease_volume();
+                       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 a30a2ad453262304f7c395997c0c1368721efe20..887e3e94b4375fdfb0ddf525f3acd7b90ead383b 100644 (file)
@@ -316,6 +316,8 @@ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA,
        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_VOLUME_UP,
+       BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_VOLUME_DOWN,
        BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_REPEAT,
        BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_SET_REPEAT,
        BT_UNIT_TEST_FUNCTION_AVRCP_CONTROL_GET_SHUFFLE,