Merge "Mesh: Fix issues in Mesh Model Subscrition" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-avrcp-tg.c
index de9df0d..31e0795 100644 (file)
@@ -105,32 +105,32 @@ static notif_t registered_notifications;
 static const btrc_interface_t *avrcp_api;
 
 static btrc_callbacks_t sBluetoothAvrcpCallbacks = {
-       sizeof(sBluetoothAvrcpCallbacks),
+       .size = sizeof(sBluetoothAvrcpCallbacks),
 #ifdef TIZEN_BT_HAL
-       cb_connection_state,
+       .connection_state_cb = cb_connection_state,
 #endif
-       cb_avrcp_remote_features,
-       cb_avrcp_get_play_status,
-       NULL, /* cb_avrcp_list_player_app_attr, */
-       NULL, /* cb_avrcp_list_player_app_values, */
-       NULL, /* cb_avrcp_get_player_app_value, */
-       NULL, /* cb_avrcp_get_player_app_attrs_text, */
-       NULL, /* cb_avrcp_get_player_app_values_text, */
-       cb_avrcp_set_player_app_value,
-       cb_avrcp_get_element_attr,
-       cb_avrcp_register_notification,
-       cb_avrcp_volume_change,
-       cb_avrcp_delay_change,
-       cb_avrcp_passthrough_command,
-       NULL, /* cb_avrcp_set_addressed_player, */
-       NULL, /* cb_avrcp_set_browsed_player, */
-       NULL, /* cb_avrcp_get_folder_items, */
-       NULL, /* cb_avrcp_change_path, */
-       NULL, /* cb_avrcp_get_item_attr, */
-       NULL, /* cb_avrcp_play_item, */
-       NULL, /* cb_avrcp_get_total_num_of_items, */
-       NULL, /* cb_avrcp_search, */
-       NULL, /* cb_avrcp_add_to_now_playing, */
+       .remote_features_cb = cb_avrcp_remote_features,
+       .get_play_status_cb = cb_avrcp_get_play_status,
+       .list_player_app_attr_cb = NULL,
+       .list_player_app_values_cb = NULL,
+       .get_player_app_value_cb = NULL,
+       .get_player_app_attrs_text_cb = NULL,
+       .get_player_app_values_text_cb = NULL,
+       .set_player_app_value_cb = cb_avrcp_set_player_app_value,
+       .get_element_attr_cb = cb_avrcp_get_element_attr,
+       .register_notification_cb = cb_avrcp_register_notification,
+       .volume_change_cb = cb_avrcp_volume_change,
+       .delay_change_cb = cb_avrcp_delay_change,
+       .passthrough_cmd_cb = cb_avrcp_passthrough_command,
+       .set_addressed_player_cb = NULL,
+       .set_browsed_player_cb = NULL,
+       .get_folder_items_cb = NULL,
+       .change_path_cb = NULL,
+       .get_item_attr_cb = NULL,
+       .play_item_cb = NULL,
+       .get_total_num_of_items_cb = NULL,
+       .search_cb = NULL,
+       .add_to_now_playing_cb = NULL,
 };
 
 static void send_pos_changed(void)
@@ -453,41 +453,14 @@ oal_status_t avrcp_set_property(int type, unsigned int value)
        }
        case AVRCP_STATUS:
                if (value != player_setting.status) {
-                       btrc_play_status_t play_status = player_setting.status;
-
                        player_setting.status = (value == STATUS_ERROR) ? BTRC_PLAYSTATE_ERROR : value;
 
                        if (registered_notifications.play_status) {
-                               gboolean is_timer = FALSE;
-
                                response.play_status = player_setting.status;
                                ret = avrcp_api->register_notification_rsp(BTRC_EVT_PLAY_STATUS_CHANGED,
                                                BTRC_NOTIFICATION_TYPE_CHANGED, &response);
                                if (ret != BT_STATUS_SUCCESS)
                                        BT_ERR("Notif send failed: %s", status2string(ret));
-
-                               /* Check if old and new status value are changed from NOT PLAYING to PLAYING */
-                               switch (play_status) {
-                               case BTRC_PLAYSTATE_ERROR:      /* Intentional fall-through */
-                               case BTRC_PLAYSTATE_STOPPED:    /* Intentional fall-through */
-                               case BTRC_PLAYSTATE_PAUSED:     /* Intentional fall-through */
-                                       if (STATUS_PLAYING == value ||
-                                                       STATUS_REVERSE_SEEK == value ||
-                                                       STATUS_FORWARD_SEEK == value) {
-                                               BT_INFO("Play status changed from stopped to playing");
-                                               is_timer = TRUE;
-                                       }
-                                       break;
-                               default:
-                                       is_timer = FALSE;
-                               }
-
-                               if (is_timer) {
-                                       BT_DBG("Player is playing mode, start sending pos change notifications");
-                                       remove_pos_timer();
-                                       send_pos_timer = g_timeout_add(registered_notifications.interval * 1000,
-                                                       send_pos_timeout, NULL);
-                               }
                        }
                }
                break;
@@ -506,6 +479,61 @@ oal_status_t avrcp_set_property(int type, unsigned int value)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t avrcp_tg_set_volume(bt_address_t *rem_addr, unsigned int volume)
+{
+       int result = OAL_STATUS_SUCCESS;
+       bt_status_t status;
+       bdstr_t bdstr;
+
+       API_TRACE();
+
+       CHECK_OAL_AVRCP_ENABLED();
+       OAL_CHECK_PARAMETER(rem_addr, return);
+
+       BT_INFO("BT Audio Address: %s", bdt_bd2str(rem_addr, &bdstr));
+
+#ifdef TIZEN_BT_HAL
+       status = avrcp_api->set_volume((bt_bdaddr_t *)rem_addr, volume);
+       if ((status != BT_STATUS_SUCCESS) && (status != BT_STATUS_DONE)) {
+               BT_ERR("set volume failed, err: %s", status2string(status));;
+               result = convert_to_oal_status(status);
+       }
+#else
+       BT_INFO("Not Supported");
+       result = OAL_STATUS_NOT_SUPPORT;
+#endif
+
+       return result;
+}
+
+oal_status_t avrcp_tg_get_volume(bt_address_t *rem_addr, unsigned int *volume)
+{
+       int result = OAL_STATUS_SUCCESS;
+       bt_status_t status;
+       bdstr_t bdstr;
+
+       API_TRACE();
+
+       CHECK_OAL_AVRCP_ENABLED();
+       OAL_CHECK_PARAMETER(rem_addr, return);
+
+       BT_INFO("BT Audio Address: %s", bdt_bd2str(rem_addr, &bdstr));
+
+#ifdef TIZEN_BT_HAL
+       status = avrcp_api->get_volume((bt_bdaddr_t *)rem_addr, volume);
+       if ((status != BT_STATUS_SUCCESS) && (status != BT_STATUS_DONE)) {
+               BT_ERR("set volume failed, err: %s", status2string(status));;
+               result = convert_to_oal_status(status);
+       }
+#else
+       BT_INFO("Not Supported");
+       result = OAL_STATUS_NOT_SUPPORT;
+#endif
+
+       return result;
+}
+
+
 #ifdef TIZEN_BT_HAL
 static void cb_connection_state(bt_bdaddr_t* bd_addr, btrc_connection_state_t state)
 {