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 d0fa6619a7e407d1c41c227aee8c5d483d500c78..9c6ba9a30a2b75bb488846266dcca7b742db254e 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 23e9ab313a137e373d0b5a60b2a1b3514248c2ca..97f1be52132505fda28ea35401d687364d5e3e4e 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 39d41d7f33368de7d13b1ed537802fe1fbb2b735..afc2517f8fefd75f2ed8b6995853ddad422c99b7 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 6d5922e4a98c3a48dc0439ed6541894ca18cbb1e..17b2ade13dd78cad44949280a57579b2c475c7c7 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 70f1b0a5b889cd2290e4f2086e388f6cd3d321f5..2bcb912530ee49479d53c82cb9b4cfe294b2bb71 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 ebf52617afb9cf8e0a46d6684f9c6a883e93b3e5..41ceaffcded715ffde908432f6de9c590320dbf2 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 18d1c6a3c3cd0309e85070f60fddb606a61aa5d7..30d4a3c96790aa211323dfb38446030e663caad8 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 d1932cd041ebaa374513ee5a63a049182e3f90e6..fee791438f9f56d918ea5626e45a5d7667891472 100755 (executable)
@@ -302,6 +302,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 6601c22a4343fad7ca3ec245fb9c485eb99048dc..b3a0f03d062efe3a80313ce8826c78085e1fa20f 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,