Merge tizen_next codes into tizen branch
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / audio / avrcp / bt-service-avrcp-ctrl.c
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:  Nilesh Trimbake <t.shripati@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <sys/socket.h>
23 #include <sys/errno.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <vconf.h>
27
28 #include "oal-hardware.h"
29 #include "oal-device-mgr.h"
30 #include <oal-manager.h>
31 #include <oal-avrcp-ct.h>
32
33 #include <bt-service-avrcp-ctrl.h>
34 #include <bluetooth-media-control.h>
35 #include <bt-service-event.h>
36
37 static int __media_prop_to_oal_type(int type)
38 {
39         int oal_type;
40
41         switch (type) {
42         case EQUALIZER:
43                 oal_type = OAL_EQUALIZER;
44                 break;
45         case SHUFFLE:
46                 oal_type = OAL_SHUFFLE;
47                 break;
48         case REPEAT:
49                 oal_type = OAL_REPEAT;
50                 break;
51         case SCAN:
52                 oal_type = OAL_SCAN;
53                 break;
54         case POSITION:
55                 oal_type = OAL_PLAY_POSITION;
56                 break;
57         case STATUS:
58                 oal_type = OAL_PLAY_STATUS;
59                 break;
60         default:
61                 BT_ERR("Unknown type: %d", type);
62                 oal_type = -1;
63         }
64
65         return oal_type;
66 }
67
68 static int __oal_type_to_media_prop(int oal_type)
69 {
70         int type;
71
72         switch (oal_type) {
73         case OAL_EQUALIZER:
74                 type = EQUALIZER;
75                 break;
76         case OAL_SHUFFLE:
77                 type = SHUFFLE;
78                 break;
79         case OAL_REPEAT:
80                 type = REPEAT;
81                 break;
82         case OAL_SCAN:
83                 type = SCAN;
84                 break;
85         case OAL_PLAY_POSITION:
86                 type = POSITION;
87                 break;
88         case OAL_PLAY_STATUS:
89                 type = STATUS;
90                 break;
91         default:
92                 BT_ERR("Unknown type: %d", oal_type);
93                 type = -1;
94         }
95
96         return type;
97 }
98
99 int _bt_avrcp_connect_remote_target(bluetooth_device_address_t *device_address)
100 {
101         oal_status_t status = OAL_STATUS_SUCCESS;
102         int result = BLUETOOTH_ERROR_NONE;
103         BT_INFO("+");
104
105         status = avrcp_ct_connect((bt_address_t*)device_address);
106         if (status != OAL_STATUS_SUCCESS) {
107                 BT_ERR("Connection could not be established, err: [%d]", status);
108                 result = BLUETOOTH_ERROR_INTERNAL;
109         }
110         return result;
111 }
112
113 int _bt_avrcp_disconnect_remote_target(bluetooth_device_address_t *device_address)
114 {
115         oal_status_t status = OAL_STATUS_SUCCESS;
116         int result = BLUETOOTH_ERROR_NONE;
117         BT_INFO("+");
118
119         status = avrcp_ct_disconnect((bt_address_t*)device_address);
120         if (status != OAL_STATUS_SUCCESS) {
121                 BT_ERR("DisConnection err: [%d]", status);
122                 result = BLUETOOTH_ERROR_INTERNAL;
123         }
124         return result;
125 }
126
127 int _bt_avrcp_control_cmd(int type)
128 {
129         char connected_address[BT_ADDRESS_STRING_SIZE + 1];
130         gboolean connected;
131         bluetooth_device_address_t device_address;
132         oal_status_t status = OAL_STATUS_SUCCESS;
133         int result = BLUETOOTH_ERROR_NONE;
134         BT_INFO("+");
135
136         connected = _bt_is_headset_type_connected(BT_AVRCP, connected_address);
137
138         if (connected) {
139                 _bt_convert_addr_string_to_type(device_address.addr,
140                                 connected_address);
141                 switch (type) {
142                 case RC_PASS_CMD_PLAY:
143                         status = avrcp_ct_play((bt_address_t*)&device_address);
144                         break;
145                 case RC_PASS_CMD_PAUSE:
146                         status = avrcp_ct_pause((bt_address_t*)&device_address);
147                         break;
148                 case RC_PASS_CMD_STOP:
149                         status = avrcp_ct_stop((bt_address_t*)&device_address);
150                         break;
151                 case RC_PASS_CMD_NEXT:
152                         status = avrcp_ct_next_track((bt_address_t*)&device_address);
153                         break;
154                 case RC_PASS_CMD_PREVIOUS:
155                         status = avrcp_ct_prev_track((bt_address_t*)&device_address);
156                         break;
157                 case RC_PASS_CMD_PRESS_FAST_FORWARD:
158                         status = avrcp_ct_fforward((bt_address_t*)&device_address, PRESS_STATE);
159                         break;
160                 case RC_PASS_CMD_RELEASE_FAST_FORWARD:
161                         status = avrcp_ct_fforward((bt_address_t*)&device_address, RELEASE_STATE);
162                         break;
163                 case RC_PASS_CMD_PRESS_REWIND:
164                         status = avrcp_ct_rewind((bt_address_t*)&device_address, PRESS_STATE);
165                         break;
166                 case RC_PASS_CMD_RELEASE_REWIND:
167                         status = avrcp_ct_rewind((bt_address_t*)&device_address, RELEASE_STATE);
168                         break;
169                 default:
170                         break;
171                 }
172
173                 if (status != OAL_STATUS_SUCCESS) {
174                         BT_ERR("Send pass through command err: [%d]", status);
175                         result = BLUETOOTH_ERROR_INTERNAL;
176                 }
177         } else {
178                 BT_ERR("Device is not connected:");
179                 return BLUETOOTH_ERROR_NOT_CONNECTED;
180         }
181
182         return result;
183 }
184
185 int _bt_avrcp_control_set_property(int type, unsigned int value)
186 {
187         char connected_address[BT_ADDRESS_STRING_SIZE + 1];
188         gboolean connected;
189         bluetooth_device_address_t device_address;
190         oal_status_t status = OAL_STATUS_SUCCESS;
191         int result = BLUETOOTH_ERROR_NONE;
192         BT_INFO("+");
193         connected = _bt_is_headset_type_connected(BT_AVRCP, connected_address);
194
195         if (connected) {
196                 int oal_type;
197
198                 oal_type = __media_prop_to_oal_type(type);
199                 retv_if(0 > oal_type, BLUETOOTH_ERROR_INVALID_PARAM);
200
201                 _bt_convert_addr_string_to_type(device_address.addr,
202                                 connected_address);
203                 status = avrcp_ct_set_property((bt_address_t*)&device_address,
204                                 oal_type, value);
205                 if (status != OAL_STATUS_SUCCESS) {
206                         BT_ERR("Set peoperty err: [%d]", status);
207                         result = BLUETOOTH_ERROR_INTERNAL;
208                 }
209         } else {
210                 BT_ERR("Device is not connected:");
211                 return BLUETOOTH_ERROR_NOT_CONNECTED;
212         }
213         return result;
214 }
215
216 int _bt_avrcp_control_get_property(int type)
217 {
218         char connected_address[BT_ADDRESS_STRING_SIZE + 1];
219         gboolean connected;
220         bt_address_t device_address;
221         oal_status_t status = OAL_STATUS_SUCCESS;
222         int result = BLUETOOTH_ERROR_NONE;
223         BT_INFO("+");
224         connected = _bt_is_headset_type_connected(BT_AVRCP, connected_address);
225
226         if (connected) {
227                 avrcp_ct_player_property_type_t oal_type;
228
229                 _bt_convert_addr_string_to_type(
230                                 device_address.addr,
231                                 connected_address);
232                 if (type == STATUS) {
233                         status = avrcp_ct_get_play_status(&device_address);
234                         if (status != OAL_STATUS_SUCCESS) {
235                                 BT_ERR("Get play status err: [%d]", status);
236                                 result = BLUETOOTH_ERROR_INTERNAL;
237                         }
238                 } else {
239                         oal_type = __media_prop_to_oal_type(type);
240                         retv_if(0 > oal_type, BLUETOOTH_ERROR_INVALID_PARAM);
241
242                         status = avrcp_ct_get_property(&device_address, oal_type);
243                         if (status != OAL_STATUS_SUCCESS) {
244                                 BT_ERR("Get peoperty err: [%d]", status);
245                                 result = BLUETOOTH_ERROR_INTERNAL;
246                         }
247                 }
248         } else {
249                 BT_ERR("Device is not connected:");
250                 return BLUETOOTH_ERROR_NOT_CONNECTED;
251         }
252         return result;
253 }
254
255 int _bt_avrcp_control_get_track_info(void)
256 {
257         char connected_address[BT_ADDRESS_STRING_SIZE + 1];
258         gboolean connected;
259         bluetooth_device_address_t device_address;
260         oal_status_t status = OAL_STATUS_SUCCESS;
261         int result = BLUETOOTH_ERROR_NONE;
262         BT_INFO("+");
263         connected = _bt_is_headset_type_connected(BT_AVRCP, connected_address);
264
265         if (connected) {
266                 _bt_convert_addr_string_to_type(
267                                 device_address.addr,
268                                 connected_address);
269
270                 status = avrcp_ct_get_media_attribute((bt_address_t*)&device_address);
271                 if (status != OAL_STATUS_SUCCESS) {
272                         BT_ERR("Get track info err: [%d]", status);
273                         result = BLUETOOTH_ERROR_INTERNAL;
274                 }
275         } else {
276                 BT_ERR("Device is not connected:");
277                 return BLUETOOTH_ERROR_NOT_CONNECTED;
278         }
279         return result;
280 }
281
282 static void __bt_reply_avrcp_ct_connection_pending_request(bluetooth_device_address_t *address)
283 {
284         BT_DBG("+");
285         char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
286         int result = BLUETOOTH_ERROR_NONE;
287         bluetooth_device_address_t device_address;
288         GArray *out_param;
289         invocation_info_t *req_info;
290         memcpy(device_address.addr, address->addr, BLUETOOTH_ADDRESS_LENGTH);
291         _bt_convert_addr_type_to_string(addr, address->addr);
292
293         req_info = _bt_get_request_info_data(BT_AVRCP_CONTROL_CONNECT, addr);
294         if (NULL == req_info) {
295                 BT_INFO("AVRCP CT Connect request not found or possibly already replied");
296                 return;
297         } else {
298                 BT_INFO("AVRCP CT Connect request found for [%s]", addr);
299         }
300
301         out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
302         g_array_append_vals(out_param, addr, BT_ADDRESS_STRING_SIZE);
303         _bt_service_method_return(req_info->context,
304                         out_param, result);
305         g_array_free(out_param, TRUE);
306         g_free(req_info->user_data);
307         _bt_free_info_from_invocation_list(req_info);
308 }
309
310 static void __bt_handle_avrcp_target_connected_state(bluetooth_device_address_t *address)
311 {
312         char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
313         GVariant *param;
314         int result = BLUETOOTH_ERROR_NONE;
315         ret_if(NULL == address);
316         BT_INFO("+");
317
318         _bt_convert_addr_type_to_string(addr, address->addr);
319         BT_INFO("Address of connected device [%s]", addr);
320
321         /* Add data from the connected list */
322         _bt_add_headset_to_list(BT_AVRCP, BT_STATE_CONNECTED, addr);
323
324         /* Replay to avrcp cotroller connect */
325         __bt_reply_avrcp_ct_connection_pending_request(address);
326
327         /* Send AVRCP(TARGET Role) connected event to Application */
328         param = g_variant_new("(is)", result, addr);
329         _bt_send_event(BT_AVRCP_CONTROL_EVENT, BLUETOOTH_EVENT_AVRCP_CONNECTED, param);
330
331         BT_INFO("-");
332 }
333
334 static void __bt_reply_avrcp_ct_disconnection_pending_request(bluetooth_device_address_t *address)
335 {
336         char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
337         int result = BLUETOOTH_ERROR_NONE;
338         GArray *out_param;
339         invocation_info_t *req_info;
340
341         BT_DBG("+");
342         _bt_convert_addr_type_to_string(addr, address->addr);
343
344         req_info = _bt_get_request_info_data(BT_AVRCP_CONTROL_DISCONNECT, addr);
345         if (NULL == req_info) {
346                 BT_INFO("AVRCP CT Disconnect request not found or possibly already replied");
347                 return;
348         } else {
349                 BT_INFO("AVRCP CT Disconnect request found for [%s]", addr);
350         }
351
352         out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
353         g_array_append_vals(out_param, addr, BT_ADDRESS_STRING_SIZE);
354         _bt_service_method_return(req_info->context,
355                         out_param, result);
356         g_array_free(out_param, TRUE);
357         g_free(req_info->user_data);
358         _bt_free_info_from_invocation_list(req_info);
359 }
360
361 static void __bt_avrcp_ct_reply_pending_requests(void)
362 {
363         BT_INFO("+");
364         int result = BLUETOOTH_ERROR_INTERNAL;
365         GArray *out_param;
366         invocation_info_t *req_info;
367         GSList *l;
368
369         for (l = _bt_get_invocation_list(); l != NULL;) {
370                 req_info = l->data;
371                 l = g_slist_next(l);
372
373                 if (req_info == NULL)
374                         continue;
375
376                 /* Create out param */
377                 out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
378
379                 BT_INFO("service_function: [0x%X]", req_info->service_function);
380                 switch (req_info->service_function) {
381                 case BT_AVRCP_GET_TRACK_INFO:
382                 case BT_AVRCP_CONTROL_GET_PROPERTY: {
383                         _bt_service_method_return(req_info->context, out_param, result);
384                         break;
385                 }
386                 default:
387                         break;
388                 }
389                 _bt_free_info_from_invocation_list(req_info);
390                 g_array_free(out_param, TRUE);
391         }
392         BT_INFO("-");
393 }
394
395 static void __bt_handle_avrcp_target_disconnected_state(bluetooth_device_address_t *address)
396 {
397         char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
398         GVariant *param;
399         int result = BLUETOOTH_ERROR_NONE;
400         ret_if(NULL == address);
401         BT_INFO("+");
402
403         _bt_convert_addr_type_to_string(addr, address->addr);
404         BT_INFO("Address of disconnected device [%s]", addr);
405
406         /* Remove data from the connected list */
407         _bt_remove_headset_from_list(BT_AVRCP, addr);
408
409         /* Reply to avrcp cotroller connect */
410         __bt_reply_avrcp_ct_disconnection_pending_request(address);
411
412         /* Reply AVRCP CT pending requests */
413         __bt_avrcp_ct_reply_pending_requests();
414
415         /* Send AVRCP(TARGET Role) disconnected event to Application */
416         param = g_variant_new("(is)", result, addr);
417         _bt_send_event(BT_AVRCP_CONTROL_EVENT, BLUETOOTH_EVENT_AVRCP_DISCONNECTED, param);
418
419         BT_INFO("-");
420 }
421
422 static int __bt_oal_to_bt_event(int oal_event)
423 {
424         int ret = 0;
425
426         switch (oal_event) {
427         case OAL_EVENT_AVRCP_CT_EQUALIZER_STATUS:
428                 ret = BLUETOOTH_EVENT_AVRCP_CONTROL_EQUALIZER_STATUS;
429                 break;
430         case OAL_EVENT_AVRCP_CT_REPEAT_STATUS:
431                 ret = BLUETOOTH_EVENT_AVRCP_CONTROL_REPEAT_STATUS;
432                 break;
433         case OAL_EVENT_AVRCP_CT_SHUFFLE_STATUS:
434                 ret = BLUETOOTH_EVENT_AVRCP_CONTROL_SHUFFLE_STATUS;
435                 break;
436         case OAL_EVENT_AVRCP_CT_SCAN_STATUS:
437                 ret = BLUETOOTH_EVENT_AVRCP_CONTROL_SCAN_STATUS;
438                 break;
439         case OAL_EVENT_AVRCP_CT_NOTIF_PLAY_POS_CHANGED:
440                 ret = BLUETOOTH_EVENT_AVRCP_SONG_POSITION_STATUS;
441                 break;
442         case OAL_EVENT_AVRCP_CT_NOTIF_PLAY_STATUS_CHANGED:
443                 ret = BLUETOOTH_EVENT_AVRCP_PLAY_STATUS_CHANGED;
444                 break;
445         default:
446                 break;
447         }
448         return ret;
449 }
450
451 static void __bt_handle_avrcp_target_player_property(unsigned int property_value, int oal_event)
452 {
453         GVariant *param;
454         BT_INFO("+");
455         /* Send AVRCP Target player property event to Application */
456         param = g_variant_new("(u)", property_value);
457         _bt_send_event(BT_AVRCP_CONTROL_EVENT,
458                         __bt_oal_to_bt_event(oal_event), param);
459 }
460
461 static void __bt_handle_avrcp_track_info_changed(event_avrcp_ct_media_info_t* metadata)
462 {
463         GVariant *param;
464         unsigned int total_track = 0;
465         unsigned int track_number = 0;
466         unsigned int playing_time = 0;
467
468         BT_INFO("+");
469
470         total_track = (unsigned int)(metadata->total_track);
471         track_number = (unsigned int)(metadata->track_number);
472         playing_time = (unsigned int)(metadata->playing_time);
473         /* Send AVRCP Target player track info changed event to application*/
474         param = g_variant_new("(ssssuuu)",
475                         metadata->title_info,
476                         metadata->artist_info,
477                         metadata->album_info,
478                         metadata->genre_info,
479                         total_track,
480                         track_number,
481                         playing_time);
482
483         BT_INFO("Total_track: %u, track_number: %u, playing_time: %u",
484                         total_track, track_number, playing_time);
485         _bt_send_event(BT_AVRCP_CONTROL_EVENT,
486                         BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED, param);
487 }
488
489 static invocation_info_t* __bt_get_request_info(int service_function)
490 {
491         GSList *l;
492         invocation_info_t *req_info = NULL;
493
494         BT_DBG("+");
495         /* Get method invocation context */
496         for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
497                 req_info = l->data;
498                 if (req_info == NULL || req_info->service_function != service_function)
499                         continue;
500                 return req_info;
501         }
502         return NULL;
503 }
504
505 static void __bt_handle_avrcp_track_info(event_avrcp_ct_media_info_t* metadata)
506 {
507         media_metadata_t meta_data;
508         invocation_info_t *req_info = NULL;
509         GArray *out_param = NULL;
510         int result = BLUETOOTH_ERROR_NONE;
511
512         req_info = __bt_get_request_info(BT_AVRCP_GET_TRACK_INFO);
513         ret_if(NULL == req_info);
514
515         memset(&meta_data, 0x00, sizeof(media_metadata_t));
516
517         memcpy(&meta_data.title, &metadata->title_info,
518                         strlen((char *)metadata->title_info));
519         meta_data.title[strlen((char *)metadata->title_info)] = '\0';
520
521         memcpy(&meta_data.artist, &metadata->artist_info,
522                         strlen((char *)metadata->artist_info));
523         meta_data.artist[strlen((char *)metadata->artist_info)] = '\0';
524
525         memcpy(&meta_data.album, &metadata->album_info,
526                         strlen((char *)metadata->album_info));
527         meta_data.album[strlen((char *)metadata->album_info)] = '\0';
528
529         memcpy(&meta_data.genre, &metadata->genre_info,
530                         strlen((char *)metadata->genre_info));
531         meta_data.genre[strlen((char *)metadata->genre_info)] = '\0';
532
533         meta_data.total_tracks = metadata->total_track;
534         meta_data.number = metadata->track_number;
535         meta_data.duration = metadata->playing_time;
536
537         out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
538         g_array_append_vals(out_param, &meta_data, sizeof(media_metadata_t));
539
540         _bt_service_method_return(req_info->context, out_param, result);
541         g_array_free(out_param, TRUE);
542         _bt_free_info_from_invocation_list(req_info);
543 }
544
545 static void __bt_handle_avrcp_pass_cmd_res(avrcp_ct_pass_cmd_t *pass_cmd)
546 {
547         BT_INFO(" Send Command Response [%d]", pass_cmd->key_code);
548 }
549
550 static void __bt_handle_avrcp_player_setting_res(avrcp_ct_playersetting_t *player_setting_res)
551 {
552         BT_INFO("Set Property Response [%d]", player_setting_res->accepted);
553 }
554
555 static void __bt_handle_avrcp_get_property_res_event(avrcp_ct_player_property_type_t oal_type, int value)
556 {
557         invocation_info_t *req_info = NULL;
558         GArray *out_param = NULL;
559         int result = BLUETOOTH_ERROR_NONE;
560         int prop_type;
561         int type;
562         GSList *l;
563
564         BT_DBG("+");
565
566         prop_type = __oal_type_to_media_prop(oal_type);
567         ret_if(0 > prop_type);
568
569         out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
570         g_array_append_vals(out_param, &value, sizeof(value));
571
572         /* Find and reply to all get requests for prop_type */
573         for (l = _bt_get_invocation_list(); l != NULL;) {
574                 req_info = l->data;
575                 l = g_slist_next(l);
576
577                 if (req_info == NULL)
578                         continue;
579
580                 type = *((int *)req_info->user_data);
581                 if (req_info->service_function != BT_AVRCP_CONTROL_GET_PROPERTY
582                                 || type != prop_type)
583                         continue;
584
585                 BT_INFO("Request found");
586                 _bt_service_method_return(req_info->context, out_param, result);
587                 g_free(req_info->user_data);
588                 _bt_free_info_from_invocation_list(req_info);
589         }
590
591         g_array_free(out_param, TRUE);
592         BT_DBG("-");
593 }
594
595 void _bt_avrcp_ctrl_event_handler(int oal_event, gpointer event_data)
596 {
597         BT_INFO("+");
598         bluetooth_device_address_t* bd_addr;
599
600         switch (oal_event) {
601         case OAL_EVENT_AVRCP_CT_CONNECTED: {
602                 BT_INFO("AVRCP Controller Profile connected..");
603                 bd_addr = (bluetooth_device_address_t*)event_data;
604                 __bt_handle_avrcp_target_connected_state(bd_addr);
605                 break;
606         }
607         case OAL_EVENT_AVRCP_CT_DISCONNECTED: {
608                 BT_INFO("AVRCP Controller Profile dissconnected..");
609                 bd_addr = (bluetooth_device_address_t*)event_data;
610                 __bt_handle_avrcp_target_disconnected_state(bd_addr);
611                 break;
612         }
613         case OAL_EVENT_AVRCP_CT_EQUALIZER_STATUS:
614         case OAL_EVENT_AVRCP_CT_REPEAT_STATUS:
615         case OAL_EVENT_AVRCP_CT_SHUFFLE_STATUS:
616         case OAL_EVENT_AVRCP_CT_SCAN_STATUS: {
617                 avrcp_ct_property_value_t* property_val;
618                 property_val = (avrcp_ct_property_value_t*)event_data;
619                 __bt_handle_avrcp_target_player_property(property_val->value, oal_event);
620                 break;
621         }
622         case OAL_EVENT_AVRCP_CT_NOTIF_PLAY_STATUS_CHANGED:{
623                 event_notif_avrcp_ct_notif_info_t* play_status_val;
624                 play_status_val = (event_notif_avrcp_ct_notif_info_t*)event_data;
625                 __bt_handle_avrcp_target_player_property(play_status_val->play_status, oal_event);
626                 break;
627         }
628         case OAL_EVENT_AVRCP_CT_NOTIF_PLAY_POS_CHANGED: {
629                 event_notif_avrcp_ct_notif_info_t* play_position;
630                 play_position = (event_notif_avrcp_ct_notif_info_t*)event_data;
631                 __bt_handle_avrcp_target_player_property(play_position->song_pos, oal_event);
632                 break;
633         }
634         case OAL_EVENT_AVRCP_CT_NOTIF_TRACK_CHANGE: {
635                 BT_INFO("AVRCP Controller Track Changed event..");
636                 event_avrcp_ct_media_info_t* metadata = event_data;
637
638                 __bt_handle_avrcp_track_info_changed(metadata);
639                 break;
640         }
641         case OAL_EVENT_AVRCP_CT_MEDIA_INFO: {
642                 BT_INFO("AVRCP Controller Track Info event..");
643                 event_avrcp_ct_media_info_t* metadata;
644
645                 metadata = (event_avrcp_ct_media_info_t*)event_data;
646                 __bt_handle_avrcp_track_info(metadata);
647                 break;
648         }
649         case OAL_EVENT_AVRCP_CT_GET_PROPERTY_RES: {
650                 BT_INFO("AVRCP Controller Get Property response event..");
651                 avrcp_ct_property_value_t *property = (avrcp_ct_property_value_t *)event_data;
652                 __bt_handle_avrcp_get_property_res_event(property->type, property->value);
653                 break;
654         }
655         case OAL_EVENT_AVRCP_CT_PLAY_STATUS: {
656                 BT_INFO("AVRCP Controller Get Play status response event..");
657                 event_avrcp_ct_play_status_t *play_status_info = (event_avrcp_ct_play_status_t *)event_data;
658                 __bt_handle_avrcp_get_property_res_event(OAL_PLAY_STATUS, play_status_info->play_status);
659                 break;
660         }
661         case OAL_EVENT_AVRCP_CT_PASS_CMD_RES: {
662                 BT_INFO("AVRCP Controller Pass Command Res");
663                 avrcp_ct_pass_cmd_t *pass_cmd;
664
665                 pass_cmd = (avrcp_ct_pass_cmd_t *)event_data;
666                 __bt_handle_avrcp_pass_cmd_res(pass_cmd);
667                 break;
668         }
669         case OAL_EVENT_AVRCP_CT_PLAYER_SETTING_RES: {
670                 BT_INFO("AVRCP Player setting response");
671                 avrcp_ct_playersetting_t *player_setting_res;
672
673                 player_setting_res = (avrcp_ct_playersetting_t *)event_data;
674                 __bt_handle_avrcp_player_setting_res(player_setting_res);
675                 break;
676         }
677         default:
678                 BT_INFO("Invalid Event = %d", oal_event);
679                 break;
680         }
681
682         BT_INFO("-");
683 }