Support in AVRCPT controller commands for multiple controllers 15/198515/2
authorAvichal <avichal.a@samsung.com>
Fri, 25 Jan 2019 05:45:31 +0000 (14:45 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 30 Jan 2019 01:09:23 +0000 (10:09 +0900)
Change-Id: I8e913da0bfa6e118c640603d588a9e88b1e08297
Signed-off-by: Avichal <avichal.a@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-api/bt-avrcp.c
bt-api/bt-common.c
bt-service-adaptation/services/audio/avrcp/bt-service-avrcp-ctrl.c
bt-service-adaptation/services/audio/bt-service-audio.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/include/bt-service-audio-common.h
bt-service-adaptation/services/include/bt-service-avrcp-ctrl.h
include/bluetooth-media-control.h
include/bt-internal-types.h

index d0fa661..9c6ba9a 100644 (file)
@@ -392,6 +392,35 @@ BT_EXPORT_API int bluetooth_media_control_command(
        return result;
 }
 
+BT_EXPORT_API int bluetooth_media_control_command_to_dest(
+                                               media_player_control_cmd type,
+                                               bluetooth_device_address_t *remote_address)
+{
+       int result;
+
+       BT_CHECK_ENABLED(return);
+
+#ifdef TIZEN_FEATURE_BT_DPM
+       if (_bt_check_dpm(BT_DPM_AVRCP, NULL) == BT_DPM_RESTRICTED) {
+               BT_ERR("Not allow to use AVRCP profile");
+               return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+       }
+#endif
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, &type, sizeof(int));
+       g_array_append_vals(in_param2, remote_address,
+                                               sizeof(bluetooth_device_address_t));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_AVRCP_HANDLE_CONTROL_TO_DEST,
+               in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 BT_EXPORT_API int bluetooth_media_control_set_property(
                                                media_player_property_type type,
                                                unsigned int value)
index 23e9ab3..97f1be5 100644 (file)
@@ -555,6 +555,7 @@ const char *_bt_convert_service_function_to_string(int function)
                {BT_AVRCP_TARGET_CONNECT, "BT_AVRCP_TARGET_CONNECT"},
                {BT_AVRCP_TARGET_DISCONNECT, "BT_AVRCP_TARGET_DISCONNECT"},
                {BT_AVRCP_HANDLE_CONTROL, "BT_AVRCP_HANDLE_CONTROL"},
+               {BT_AVRCP_HANDLE_CONTROL_TO_DEST, "BT_AVRCP_HANDLE_CONTROL_TO_DEST"},
                {BT_AVRCP_CONTROL_SET_PROPERTY, "BT_AVRCP_CONTROL_SET_PROPERTY"},
                {BT_AVRCP_CONTROL_GET_PROPERTY, "BT_AVRCP_CONTROL_GET_PROPERTY"},
                {BT_AVRCP_GET_TRACK_INFO, "BT_AVRCP_GET_TRACK_INFO"},
index 39d41d7..afc2517 100644 (file)
@@ -188,6 +188,70 @@ int _bt_avrcp_control_cmd(int type)
        return result;
 }
 
+int _bt_avrcp_control_cmd_to_dest(int type, bluetooth_device_address_t *device_address)
+{
+       char connected_address[BT_ADDRESS_STRING_SIZE + 1];
+       gboolean connected;
+       oal_status_t status = OAL_STATUS_SUCCESS;
+       int result = BLUETOOTH_ERROR_NONE;
+       BT_INFO("+");
+
+       _bt_convert_addr_type_to_string(connected_address, device_address->addr);
+
+       connected = _bt_is_headset_address_type_connected(BT_AVRCP,
+                                                               (const char *)connected_address);
+
+       if (connected) {
+               switch (type) {
+               case RC_PASS_CMD_PLAY:
+                       status = avrcp_ct_play((bt_address_t*)device_address);
+                       break;
+               case RC_PASS_CMD_PAUSE:
+                       status = avrcp_ct_pause((bt_address_t*)device_address);
+                       break;
+               case RC_PASS_CMD_STOP:
+                       status = avrcp_ct_stop((bt_address_t*)device_address);
+                       break;
+               case RC_PASS_CMD_NEXT:
+                       status = avrcp_ct_next_track((bt_address_t*)device_address);
+                       break;
+               case RC_PASS_CMD_PREVIOUS:
+                       status = avrcp_ct_prev_track((bt_address_t*)device_address);
+                       break;
+               case RC_PASS_CMD_PRESS_FAST_FORWARD:
+                       status = avrcp_ct_fforward((bt_address_t*)device_address, PRESS_STATE);
+                       break;
+               case RC_PASS_CMD_RELEASE_FAST_FORWARD:
+                       status = avrcp_ct_fforward((bt_address_t*)device_address, RELEASE_STATE);
+                       break;
+               case RC_PASS_CMD_PRESS_REWIND:
+                       status = avrcp_ct_rewind((bt_address_t*)device_address, PRESS_STATE);
+                       break;
+               case RC_PASS_CMD_RELEASE_REWIND:
+                       status = avrcp_ct_rewind((bt_address_t*)device_address, RELEASE_STATE);
+                       break;
+               case RC_PASS_CMD_VOLUME_UP:
+                       status = avrcp_ct_volume_up((bt_address_t*)device_address);
+                       break;
+               case RC_PASS_CMD_VOLUME_DOWN:
+                       status = avrcp_ct_volume_down((bt_address_t*)device_address);
+                       break;
+               default:
+                       break;
+               }
+
+               if (status != OAL_STATUS_SUCCESS) {
+                       BT_ERR("Send pass through command err: [%d]", status);
+                       result = BLUETOOTH_ERROR_INTERNAL;
+               }
+       } else {
+               BT_ERR("Device is not connected:");
+               return BLUETOOTH_ERROR_NOT_CONNECTED;
+       }
+
+       return result;
+}
+
 int _bt_avrcp_control_set_property(int type, unsigned int value)
 {
        char connected_address[BT_ADDRESS_STRING_SIZE + 1];
index 6d5922e..17b2ade 100644 (file)
@@ -179,6 +179,25 @@ gboolean _bt_is_headset_type_connected(int type, char *address)
        return FALSE;
 }
 
+
+gboolean _bt_is_headset_address_type_connected(int type, const char *address)
+{
+       GList *node;
+
+       node = g_list_first(g_connected_list);
+       while (node != NULL) {
+               bt_connected_headset_data_t *connected_device = node->data;
+
+               if (connected_device && (connected_device->type & type)) {
+                       if (memcmp(connected_device->device_address, address, 19) == 0)
+                               return TRUE;
+               }
+
+               node = g_list_next(node);
+       }
+       return FALSE;
+}
+
 static void __bt_set_headset_disconnection_type(const char *address)
 {
        bt_connected_headset_data_t *connected_device;
index 70f1b0a..2bcb912 100644 (file)
@@ -1633,6 +1633,17 @@ int __bt_bluez_request(int function_name,
                result = _bt_avrcp_control_cmd(key_code);
                break;
        }
+       case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
+               int key_code;
+               bluetooth_device_address_t address = { { 0 } };
+
+               __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
+               break;
+       }
        case BT_AVRCP_CONTROL_SET_PROPERTY: {
                int type;
                unsigned int value;
@@ -3789,7 +3800,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_AVRCP_CONTROL_GET_PROPERTY:
        case BT_AVRCP_GET_TRACK_INFO:
        case BT_AVRCP_TRANSPORT_SET_PROPERTY:
-
+       case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
 
        case BT_SET_CONTENT_PROTECT:
        case BT_BOND_DEVICE_BY_TYPE:
index ebf5261..41ceaff 100644 (file)
@@ -106,6 +106,8 @@ void _bt_audio_check_pending_connect(char *address);
 
 gboolean _bt_is_headset_type_connected(int type, char *address);
 
+gboolean _bt_is_headset_address_type_connected(int type, const char *address);
+
 void _bt_add_headset_to_list(int type, int status, const char *address);
 
 void _bt_remove_service_search_request(char *address);
index 18d1c6a..30d4a3c 100644 (file)
@@ -67,6 +67,8 @@ int _bt_avrcp_disconnect_remote_target(bluetooth_device_address_t *address);
 
 int _bt_avrcp_control_cmd(int type);
 
+int _bt_avrcp_control_cmd_to_dest(int type, bluetooth_device_address_t *address);
+
 int _bt_avrcp_control_set_property(int type, unsigned int value);
 
 int _bt_avrcp_transport_set_property(int type, unsigned int value);
index d1932cd..fee7914 100755 (executable)
@@ -303,6 +303,18 @@ int bluetooth_media_target_disconnect(bluetooth_device_address_t *remote_address
 int bluetooth_media_control_command(media_player_control_cmd type);
 
 /**
+ * @brief      The function bluetooth_media_control_command_to_dest is called to send
+ *     the  AVRCP Control command like Play, Pause, FF, Rewind to the specific target device.
+ *
+ * @param[in]  type    media_player_control_cmd.
+ * @param[in]  remote_address  Bluetooth device address.
+ * @return     int     Zero on Success or reason for error if any.
+ *
+ */
+int bluetooth_media_control_command_to_dest(media_player_control_cmd type,
+                                       bluetooth_device_address_t *remote_address);
+
+/**
  * @fn int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value)
  * @brief Notifies the remote bluetooth target with change in music control settings
  *
index 6601c22..b3a0f03 100644 (file)
@@ -265,6 +265,7 @@ typedef enum {
        BT_AVRCP_TARGET_CONNECT,
        BT_AVRCP_TARGET_DISCONNECT,
        BT_AVRCP_HANDLE_CONTROL,
+       BT_AVRCP_HANDLE_CONTROL_TO_DEST,
        BT_AVRCP_CONTROL_SET_PROPERTY,
        BT_AVRCP_CONTROL_GET_PROPERTY,
        BT_AVRCP_GET_TRACK_INFO,