33 #if defined(USE_BLUEZ5)
34 #include <bluetooth/bluetooth.h>
36 #include <bluetooth/audio/a2dp-codecs.h>
37 #if defined(USE_BLUEZ4)
38 #include <bluetooth/audio/ipc.h>
42 #include "btrCore_logger.h"
45 #include "btrCore_avMedia.h"
47 #include "btrCore_bt_ifce.h"
51 #define MIN_BITPOOL SBC_MIN_BITPOOL
54 #define MAX_BITPOOL SBC_MAX_BITPOOL
60 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
61 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
64 #if defined(USE_BLUEZ4)
67 #define BTR_SBC_CHANNEL_MODE_MONO BT_A2DP_CHANNEL_MODE_MONO
68 #define BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL BT_A2DP_CHANNEL_MODE_DUAL_CHANNEL
69 #define BTR_SBC_CHANNEL_MODE_STEREO BT_A2DP_CHANNEL_MODE_STEREO
70 #define BTR_SBC_CHANNEL_MODE_JOINT_STEREO BT_A2DP_CHANNEL_MODE_JOINT_STEREO
72 #define BTR_SBC_SAMPLING_FREQ_16000 BT_SBC_SAMPLING_FREQ_16000
73 #define BTR_SBC_SAMPLING_FREQ_32000 BT_SBC_SAMPLING_FREQ_32000
74 #define BTR_SBC_SAMPLING_FREQ_44100 BT_SBC_SAMPLING_FREQ_44100
75 #define BTR_SBC_SAMPLING_FREQ_48000 BT_SBC_SAMPLING_FREQ_48000
77 #define BTR_SBC_ALLOCATION_SNR BT_A2DP_ALLOCATION_SNR
78 #define BTR_SBC_ALLOCATION_LOUDNESS BT_A2DP_ALLOCATION_LOUDNESS
80 #define BTR_SBC_SUBBANDS_4 BT_A2DP_SUBBANDS_4
81 #define BTR_SBC_SUBBANDS_8 BT_A2DP_SUBBANDS_8
83 #define BTR_SBC_BLOCK_LENGTH_4 BT_A2DP_BLOCK_LENGTH_4
84 #define BTR_SBC_BLOCK_LENGTH_8 BT_A2DP_BLOCK_LENGTH_8
85 #define BTR_SBC_BLOCK_LENGTH_12 BT_A2DP_BLOCK_LENGTH_12
87 #define BTR_SBC_BLOCK_LENGTH_16 BT_A2DP_BLOCK_LENGTH_16
89 #elif defined(USE_BLUEZ5)
92 #define BTR_SBC_CHANNEL_MODE_MONO SBC_CHANNEL_MODE_MONO
93 #define BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL SBC_CHANNEL_MODE_DUAL_CHANNEL
94 #define BTR_SBC_CHANNEL_MODE_STEREO SBC_CHANNEL_MODE_STEREO
95 #define BTR_SBC_CHANNEL_MODE_JOINT_STEREO SBC_CHANNEL_MODE_JOINT_STEREO
97 #define BTR_SBC_SAMPLING_FREQ_16000 SBC_SAMPLING_FREQ_16000
98 #define BTR_SBC_SAMPLING_FREQ_32000 SBC_SAMPLING_FREQ_32000
99 #define BTR_SBC_SAMPLING_FREQ_44100 SBC_SAMPLING_FREQ_44100
100 #define BTR_SBC_SAMPLING_FREQ_48000 SBC_SAMPLING_FREQ_48000
102 #define BTR_SBC_ALLOCATION_SNR SBC_ALLOCATION_SNR
103 #define BTR_SBC_ALLOCATION_LOUDNESS SBC_ALLOCATION_LOUDNESS
105 #define BTR_SBC_SUBBANDS_4 SBC_SUBBANDS_4
106 #define BTR_SBC_SUBBANDS_8 SBC_SUBBANDS_8
108 #define BTR_SBC_BLOCK_LENGTH_4 SBC_BLOCK_LENGTH_4
109 #define BTR_SBC_BLOCK_LENGTH_8 SBC_BLOCK_LENGTH_8
110 #define BTR_SBC_BLOCK_LENGTH_12 SBC_BLOCK_LENGTH_12
111 #define BTR_SBC_BLOCK_LENGTH_16 SBC_BLOCK_LENGTH_16
114 #define MIN_BITPOOL SBC_MIN_BITPOOL
118 #define MAX_BITPOOL SBC_MAX_BITPOOL
121 #if defined(AAC_SUPPORTED)
124 #define BTR_MPEG_CHANNEL_MODE_MONO MPEG_CHANNEL_MODE_MONO
125 #define BTR_MPEG_CHANNEL_MODE_DUAL_CHANNEL MPEG_CHANNEL_MODE_DUAL_CHANNEL
126 #define BTR_MPEG_CHANNEL_MODE_STEREO MPEG_CHANNEL_MODE_STEREO
127 #define BTR_MPEG_CHANNEL_MODE_JOINT_STEREO MPEG_CHANNEL_MODE_JOINT_STEREO
129 #define BTR_MPEG_LAYER_MP1 MPEG_LAYER_MP1
130 #define BTR_MPEG_LAYER_MP2 MPEG_LAYER_MP2
131 #define BTR_MPEG_LAYER_MP3 MPEG_LAYER_MP3
133 #define BTR_MPEG_SAMPLING_FREQ_16000 MPEG_SAMPLING_FREQ_16000
134 #define BTR_MPEG_SAMPLING_FREQ_22050 MPEG_SAMPLING_FREQ_22050
135 #define BTR_MPEG_SAMPLING_FREQ_24000 MPEG_SAMPLING_FREQ_24000
136 #define BTR_MPEG_SAMPLING_FREQ_32000 MPEG_SAMPLING_FREQ_32000
137 #define BTR_MPEG_SAMPLING_FREQ_44100 MPEG_SAMPLING_FREQ_44100
138 #define BTR_MPEG_SAMPLING_FREQ_48000 MPEG_SAMPLING_FREQ_48000
140 #define BTR_MPEG_BIT_RATE_VBR MPEG_BIT_RATE_VBR
141 #define BTR_MPEG_BIT_RATE_320000 MPEG_BIT_RATE_320000
142 #define BTR_MPEG_BIT_RATE_256000 MPEG_BIT_RATE_256000
143 #define BTR_MPEG_BIT_RATE_224000 MPEG_BIT_RATE_224000
144 #define BTR_MPEG_BIT_RATE_192000 MPEG_BIT_RATE_192000
145 #define BTR_MPEG_BIT_RATE_160000 MPEG_BIT_RATE_160000
146 #define BTR_MPEG_BIT_RATE_128000 MPEG_BIT_RATE_128000
147 #define BTR_MPEG_BIT_RATE_112000 MPEG_BIT_RATE_112000
148 #define BTR_MPEG_BIT_RATE_96000 MPEG_BIT_RATE_96000
149 #define BTR_MPEG_BIT_RATE_80000 MPEG_BIT_RATE_80000
150 #define BTR_MPEG_BIT_RATE_64000 MPEG_BIT_RATE_64000
151 #define BTR_MPEG_BIT_RATE_56000 MPEG_BIT_RATE_56000
152 #define BTR_MPEG_BIT_RATE_48000 MPEG_BIT_RATE_48000
153 #define BTR_MPEG_BIT_RATE_40000 MPEG_BIT_RATE_40000
154 #define BTR_MPEG_BIT_RATE_32000 MPEG_BIT_RATE_32000
155 #define BTR_MPEG_BIT_RATE_FREE MPEG_BIT_RATE_FREE
158 #define BTR_AAC_OT_MPEG2_AAC_LC AAC_OBJECT_TYPE_MPEG2_AAC_LC
159 #define BTR_AAC_OT_MPEG4_AAC_LC AAC_OBJECT_TYPE_MPEG4_AAC_LC
160 #define BTR_AAC_OT_MPEG4_AAC_LTP AAC_OBJECT_TYPE_MPEG4_AAC_LTP
161 #define BTR_AAC_OT_MPEG4_AAC_SCA AAC_OBJECT_TYPE_MPEG4_AAC_SCA
163 #define BTR_AAC_SAMPLING_FREQ_8000 AAC_SAMPLING_FREQ_8000
164 #define BTR_AAC_SAMPLING_FREQ_11025 AAC_SAMPLING_FREQ_11025
165 #define BTR_AAC_SAMPLING_FREQ_12000 AAC_SAMPLING_FREQ_12000
166 #define BTR_AAC_SAMPLING_FREQ_16000 AAC_SAMPLING_FREQ_16000
167 #define BTR_AAC_SAMPLING_FREQ_22050 AAC_SAMPLING_FREQ_22050
168 #define BTR_AAC_SAMPLING_FREQ_24000 AAC_SAMPLING_FREQ_24000
169 #define BTR_AAC_SAMPLING_FREQ_32000 AAC_SAMPLING_FREQ_32000
170 #define BTR_AAC_SAMPLING_FREQ_44100 AAC_SAMPLING_FREQ_44100
171 #define BTR_AAC_SAMPLING_FREQ_48000 AAC_SAMPLING_FREQ_48000
172 #define BTR_AAC_SAMPLING_FREQ_64000 AAC_SAMPLING_FREQ_64000
173 #define BTR_AAC_SAMPLING_FREQ_88200 AAC_SAMPLING_FREQ_88200
174 #define BTR_AAC_SAMPLING_FREQ_96000 AAC_SAMPLING_FREQ_96000
176 #define BTR_AAC_CHANNELS_1 AAC_CHANNELS_1
177 #define BTR_AAC_CHANNELS_2 AAC_CHANNELS_2
179 #define BTR_AAC_SET_BITRATE AAC_SET_BITRATE
180 #define BTR_AAC_SET_FREQ AAC_SET_FREQUENCY
181 #define BTR_AAC_GET_BITRATE AAC_GET_BITRATE
182 #define BTR_AAC_GET_FREQ AAC_GET_FREQUENCY
188 #define BTR_SBC_HIGH_BITRATE_BITPOOL 51
189 #define BTR_SBC_MED_BITRATE_BITPOOL 33
190 #define BTR_SBC_LOW_BITRATE_BITPOOL 19
192 #define BTR_SBC_DEFAULT_BITRATE_BITPOOL BTR_SBC_HIGH_BITRATE_BITPOOL
194 #define BTR_MEDIA_INVALID_ID 0xFFFFFFFFFFFFFFFF
195 #define BTR_MEDIA_PLAYLIST_ID 0x8000000000000000
196 #define BTR_MEDIA_BROWSER_ID 0x0
199 typedef enum _enBTRCoreAVMTransportPathState {
200 enAVMTransportStConnected,
201 enAVMTransportStToBeConnected,
202 enAVMTransportStDisconnected
203 } enBTRCoreAVMTransportPathState;
205 typedef enum _eBTRCoreAVMediaPlayerType {
206 eBTRCoreAVMPTypAudio,
207 eBTRCoreAVMPTypVideo,
208 eBTRCoreAVMPTypAudioBroadcasting,
209 eBTRCoreAVMPTypVideoBroadcasting,
210 eBTRCoreAVMPTypUnknown
211 } eBTRCoreAVMediaPlayerType;
213 typedef enum _eBTRCoreAVMediaPlayerSubtype {
214 eBTRCoreAVMPSbTypAudioBook,
215 eBTRCoreAVMPSbTypPodcast,
216 eBTRCoreAVMPSbTypUnknown
217 } eBTRCoreAVMediaPlayerSubtype;
220 typedef enum _eBTRCoreAVMediaItemFilterAtt {
221 eBTRcoreAVMFilterAttTitle,
222 eBTRcoreAVMFilterAttArtist,
223 eBTRcoreAVMFilterAttAlbum,
224 eBTRcoreAVMFilterAttGenre,
225 eBTRcoreAVMFilterAttNumberOfTracks,
226 eBTRcoreAVMFilterAttTrackNumber,
227 eBTRcoreAVMFilterAttDuration,
228 eBTRcoreAVMFilterAttUnknown
229 } eBTRCoreAVMediaItemFilterAtt;
232 unsigned int ui32AVMediaFolderFilterStartIndex;
233 unsigned int ui32AVMediaFolderFilterEndIndex;
234 unsigned char mediaItemFilterAttFlag;
238 void* pvAVMediaParentItem;
239 unsigned char bIsMediaItemPlayable;
240 char pcAVMediaItemPath[BTRCORE_MAX_STR_LEN];
241 char pcAVMediaItemName[BTRCORE_MAX_STR_LEN];
242 unsigned int ui32AVMediaNumberOfItems;
243 tBTRCoreAVMediaElementId ui32AVMediaItemId;
244 eBTRCoreAVMElementType eMediaItemType;
253 char m_mediaPlayerName[BTRCORE_MAX_STR_LEN];
254 eBTRCoreAVMediaPlayerType eAVMediaPlayerType;
255 eBTRCoreAVMediaPlayerSubtype eAVMediaPlayerSubtype;
256 enBTRCoreAVMediaCtrl eAVMediaPlayerEqualizer;
257 enBTRCoreAVMediaCtrl eAVMediaPlayerShuffle;
258 enBTRCoreAVMediaCtrl eAVMediaPlayerRepeat;
259 enBTRCoreAVMediaCtrl eAVMediaPlayerScan;
260 unsigned int m_mediaPlayerPosition;
261 unsigned char m_mediaPlayerBrowsable;
262 unsigned char m_mediaPlayerSearchable;
263 unsigned char m_mediaTrackChanged;
264 eBTRCoreAVMediaStatusUpdate eAVMediaStatusUpdate;
272 int iBTMediaDefSampFreqPref;
273 eBTRCoreAVMType eAVMediaTypeOut;
274 eBTRCoreAVMType eAVMediaTypeIn;
275 void* pstBTMediaConfigOut;
276 void* pstBTMediaConfigIn;
277 char* pcAVMediaTransportPathOut;
278 char* pcAVMediaTransportPathIn;
280 unsigned char ui8AVMediaTransportVolume;
282 enBTRCoreAVMTransportPathState eAVMTState;
284 char* pcAVMediaPlayerPath;
285 char* pcAVMediaControlPath;
286 unsigned char bAVMediaPlayerConnected;
290 unsigned int ui32AVMediaBrowserItemCount;
293 unsigned int ui32AVMediaPlayListItemCount;
296 fPtr_BTRCore_AVMediaStatusUpdateCb fpcBBTRCoreAVMediaStatusUpdate;
297 void* pcBMediaStatusUserData;
299 GThread* pMediaPollingThread;
301 eBTRCoreAVMediaStatusUpdate eAVMediaStPrev;
302 tBTRCoreAVMediaElementId SelectedaBtrAVMediaItemId;
309 void* apvAVMUserData;
310 const char* apcAVMDevAddress;
314 static uint8_t btrCore_AVMedia_GetA2DPDefaultBitpool (uint8_t au8SamplingFreq, uint8_t au8AudioChannelsMode);
320 static eBTRCoreAVMElementType btrCore_AVMedia_MapFolderTypeToElementType (enBTMediaFolderType aeMediaFolderType);
323 static void* btrCore_AVMedia_PlaybackPositionPolling (
void* arg);
326 static int btrCore_AVMedia_NegotiateMediaCb (
void* apBtMediaCapsInput,
void** appBtMediaCapsOutput,
enBTDeviceType aenBTDeviceType,
enBTMediaType aenBTMediaType,
void* apUserData);
327 static int btrCore_AVMedia_TransportPathCb (
const char* apBtMediaTransportPath,
const char* apBtMediaUuid,
void* apBtMediaCaps,
enBTDeviceType aenBTDeviceType,
enBTMediaType aenBTMediaType,
void* apUserData);
328 static int btrCore_AVMedia_MediaPlayerPathCb (
const char* apcBTMediaPlayerPath,
void* apUserData);
330 static int btrCore_AVMedia_MediaBrowserUpdateCb (
stBTMediaBrowserUpdate* apstBtMediaBrUpdate,
unsigned char ucItemScope,
const char* apcBtDevAddr,
void* apUserData);
336 #if 0 // if zerod for reference
338 btrCore_AVMedia_GetA2DPDefaultBitpool (
339 uint8_t au8SamplingFreq,
340 uint8_t au8AudioChannelsMode
342 switch (au8SamplingFreq) {
343 case BTR_SBC_SAMPLING_FREQ_16000:
344 case BTR_SBC_SAMPLING_FREQ_32000:
347 case BTR_SBC_SAMPLING_FREQ_44100:
348 switch (au8AudioChannelsMode) {
349 case BTR_SBC_CHANNEL_MODE_MONO:
350 case BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL:
353 case BTR_SBC_CHANNEL_MODE_STEREO:
354 case BTR_SBC_CHANNEL_MODE_JOINT_STEREO:
358 BTRCORELOG_ERROR (
"Invalid A2DP channels mode %u\n", au8AudioChannelsMode);
361 case BTR_SBC_SAMPLING_FREQ_48000:
362 switch (au8AudioChannelsMode) {
363 case BTR_SBC_CHANNEL_MODE_MONO:
364 case BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL:
367 case BTR_SBC_CHANNEL_MODE_STEREO:
368 case BTR_SBC_CHANNEL_MODE_JOINT_STEREO:
372 BTRCORELOG_ERROR (
"Invalid A2DP channels mode %u\n", au8AudioChannelsMode);
376 BTRCORELOG_ERROR (
"Invalid Bluetooth SBC sampling freq %u\n", au8SamplingFreq);
382 btrCore_AVMedia_GetA2DPDefaultBitpool (
383 uint8_t au8SamplingFreq,
384 uint8_t au8AudioChannelsMode
386 switch (au8SamplingFreq) {
387 case BTR_SBC_SAMPLING_FREQ_16000:
388 case BTR_SBC_SAMPLING_FREQ_32000:
389 return BTR_SBC_DEFAULT_BITRATE_BITPOOL;
391 case BTR_SBC_SAMPLING_FREQ_44100:
392 switch (au8AudioChannelsMode) {
393 case BTR_SBC_CHANNEL_MODE_MONO:
394 case BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL:
397 case BTR_SBC_CHANNEL_MODE_STEREO:
398 case BTR_SBC_CHANNEL_MODE_JOINT_STEREO:
399 return BTR_SBC_DEFAULT_BITRATE_BITPOOL;
402 BTRCORELOG_ERROR (
"Invalid A2DP channels mode %u\n", au8AudioChannelsMode);
403 return BTR_SBC_DEFAULT_BITRATE_BITPOOL;
405 case BTR_SBC_SAMPLING_FREQ_48000:
406 switch (au8AudioChannelsMode) {
407 case BTR_SBC_CHANNEL_MODE_MONO:
408 case BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL:
411 case BTR_SBC_CHANNEL_MODE_STEREO:
412 case BTR_SBC_CHANNEL_MODE_JOINT_STEREO:
413 return BTR_SBC_DEFAULT_BITRATE_BITPOOL;
416 BTRCORELOG_ERROR (
"Invalid A2DP channels mode %u\n", au8AudioChannelsMode);
417 return BTR_SBC_DEFAULT_BITRATE_BITPOOL;
420 BTRCORELOG_ERROR (
"Invalid Bluetooth SBC sampling freq %u\n", au8SamplingFreq);
421 return BTR_SBC_DEFAULT_BITRATE_BITPOOL;
427 btrCore_AVMedia_AllocateBrowserMemory (
434 if (!apstlhBTRCoreAVM || !apstBrowserNew) {
435 BTRCORELOG_ERROR (
"Invalid Args!\n");
440 BTRCORELOG_ERROR (
"Memory Allocation Failed !\n");
448 BTRCORELOG_DEBUG (
"Reallocating subItem from %u to %u\n", apstBrowser->ui32AVMediaNumberOfItems, apstBrowser->ui32AVMediaNumberOfItems+1);
449 if ((apstBrowser->pstAVMediaSubItems = (
stBTRCoreAVMediaItem**) realloc (apstBrowser->pstAVMediaSubItems,
451 apstBrowser->pstAVMediaSubItems[apstBrowser->ui32AVMediaNumberOfItems -1] = *apstBrowserNew;
455 BTRCORELOG_ERROR (
"Memory Re-allocation Failed !\n");
467 btrCore_AVMedia_DeallocateBrowserMemory (
474 if (!apstBrowser || !(*apstBrowser)) {
475 BTRCORELOG_ERROR (
"Invalid Args!\n");
479 if ((ptr = (*apstBrowser)->pvAVMediaParentItem)) {
480 if (ptr->pstAVMediaSubItems[ptr->ui32AVMediaNumberOfItems -1]->ui32AVMediaItemId != (*apstBrowser)->ui32AVMediaItemId) {
481 memcpy (*apstBrowser, ptr->pstAVMediaSubItems[ptr->ui32AVMediaNumberOfItems -1],
sizeof(
stBTRCoreAVMediaItem));
482 *apstBrowser = ptr->pstAVMediaSubItems[ptr->ui32AVMediaNumberOfItems -1];
487 free ((
void*)(*apstBrowser));
489 if ((*apstBrowser = ptr)) {
490 BTRCORELOG_DEBUG (
"Reallocating subItem from %u to %u\n", ptr->ui32AVMediaNumberOfItems, ptr->ui32AVMediaNumberOfItems-1);
493 if (!ptr->pstAVMediaSubItems && ptr->ui32AVMediaNumberOfItems) {
494 BTRCORELOG_ERROR (
"Memory Re-allocation Failed !\n");
509 btrCore_AVMedia_DeallocateUnhandledBrowserMemory (
511 const char* apcBtDevAddr,
514 unsigned int ui32ArrayIdx[10] = {0};
515 unsigned int ui8LoopIdx = 0;
519 if (!apstMedItem || !(*apstMedItem) || !apstlhBTRCoreAVM) {
521 BTRCORELOG_ERROR (
"Invalid Args!\n");
525 BTRCORELOG_WARN (
"!!!Clearing Off unhandled AV Media Browser memory\n");
526 apstBrowser = *apstMedItem;
528 while (apstBrowser) {
530 if (apstBrowser->ui32AVMediaNumberOfItems) {
531 if (!apstBrowser->bIsMediaItemPlayable && apstBrowser->pstAVMediaSubItems) {
532 if (0 < apstBrowser->ui32AVMediaNumberOfItems - ui32ArrayIdx[ui8LoopIdx]) {
533 if (apstBrowser->pstAVMediaSubItems[apstBrowser->ui32AVMediaNumberOfItems -ui32ArrayIdx[ui8LoopIdx] -1]) {
535 apstBrowser = (ptr = apstBrowser)->pstAVMediaSubItems[apstBrowser->ui32AVMediaNumberOfItems -ui32ArrayIdx[ui8LoopIdx] -1];
536 ptr->pstAVMediaSubItems[ptr->ui32AVMediaNumberOfItems -ui32ArrayIdx[ui8LoopIdx] -1] = NULL;
538 if (!(ptr->ui32AVMediaNumberOfItems -ui32ArrayIdx[ui8LoopIdx] -1)) {
539 BTRCORELOG_DEBUG (
"Freeing Media SubItem List of %s : %p (%u)\n", ptr->pcAVMediaItemName, apstBrowser, ptr->ui32AVMediaNumberOfItems);
540 free ((
void*)ptr->pstAVMediaSubItems);
541 ptr->pstAVMediaSubItems = NULL;
542 ptr->ui32AVMediaNumberOfItems = 0;
545 ui32ArrayIdx[++ui8LoopIdx] = 0;
553 BTRCORELOG_DEBUG (
"Freeing Media Item %p:%s [ID: %llu]\n", ptr, ptr->pcAVMediaItemName, ptr->ui32AVMediaItemId);
559 mediaStatus.eAVMediaState = eBTRCoreAVMediaElementRemoved;
560 mediaElement->ui32AVMediaElementId = ptr->ui32BTMediaItemId;
562 if (apstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate) {
563 if (apstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate(&mediaStatus, apcBtDevAddr, apstlhBTRCoreAVM->pcBMediaStatusUserData) != enBTRCoreSuccess) {
564 BTRCORELOG_ERROR (
"fpcBBTRCoreAVMediaStatusUpdate - Failure !!!\n");
570 if (ptr->bIsMediaItemPlayable) {
571 (ptr->ui32AVMediaItemId & BTR_MEDIA_PLAYLIST_ID)? apstlhBTRCoreAVM->ui32AVMediaPlayListItemCount-- : apstlhBTRCoreAVM->ui32AVMediaBrowserItemCount--;
574 if (ptr == *apstMedItem) {
575 btrCore_AVMedia_DeallocateBrowserMemory (apstlhBTRCoreAVM, &ptr);
580 apstBrowser = apstBrowser->pvAVMediaParentItem;
582 ui32ArrayIdx[--ui8LoopIdx]++;
590 btrCore_AVMedia_FindMediaItem (
592 tBTRCoreAVMediaElementId aui32AVMediaItemId,
595 unsigned int ui32ArrayIdx[10] = {0};
596 unsigned int ui8LoopIdx = 0;
598 if (!apstBrowser || !apstMedItem) {
599 BTRCORELOG_ERROR (
"Invalid Args!\n");
605 while (apstBrowser) {
607 if (apstBrowser->ui32AVMediaNumberOfItems) {
609 if (!apstBrowser->bIsMediaItemPlayable && apstBrowser->pstAVMediaSubItems) {
610 if (0 < apstBrowser->ui32AVMediaNumberOfItems - ui32ArrayIdx[ui8LoopIdx]) {
611 if (apstBrowser->pstAVMediaSubItems[apstBrowser->ui32AVMediaNumberOfItems -ui32ArrayIdx[ui8LoopIdx] -1]) {
612 apstBrowser = apstBrowser->pstAVMediaSubItems[apstBrowser->ui32AVMediaNumberOfItems -ui32ArrayIdx[ui8LoopIdx] -1];
613 ui32ArrayIdx[++ui8LoopIdx] = 0;
620 if (apstBrowser->ui32AVMediaItemId == aui32AVMediaItemId) {
621 *apstMedItem = apstBrowser;
622 BTRCORELOG_INFO (
"Media Item Found : %s [%llu] - %d\n", apstBrowser->pcAVMediaItemName, apstBrowser->ui32AVMediaItemId, apstBrowser->bIsMediaItemPlayable);
625 if (ui8LoopIdx && !(*apstMedItem)) {
626 ui32ArrayIdx[--ui8LoopIdx]++;
627 apstBrowser = apstBrowser->pvAVMediaParentItem;
639 btrCore_AVMedia_SwitchToMediaBrowserItem (
647 if (!apstlhBTRCoreAVM || !(dest=apstAVMediaItem)) {
648 BTRCORELOG_ERROR (
"Invalid Args!\n");
652 if ((curr = apstlhBTRCoreAVM->pstAVMediaBrowser)) {
654 char mediaItemPath[15][BTRCORE_MAX_STR_LEN];
655 tBTRCoreAVMediaElementId comnItemId = 0;
660 memset (mediaItemPath, 0, 15 * BTRCORE_MAX_STR_LEN);
665 if (comnItemId != curr->ui32AVMediaItemId) {
667 while (curr->pvAVMediaParentItem) {
668 curr = curr->pvAVMediaParentItem;
670 if (comnItemId != dest->ui32AVMediaItemId || curr->ui32AVMediaItemId != comnItemId) {
671 strncpy (mediaItemPath[countIdx++], curr->pcAVMediaItemPath, BTRCORE_MAX_STR_LEN -1);
673 if (curr->ui32AVMediaItemId == comnItemId) {
682 if (comnItemId != dest->ui32AVMediaItemId) {
684 while (dest->pvAVMediaParentItem) {
685 dest = dest->pvAVMediaParentItem;
687 if (comnItemId != dest->ui32AVMediaItemId) {
688 strncpy (mediaItemPath[countIdx++], dest->pcAVMediaItemPath, BTRCORE_MAX_STR_LEN -1);
697 while (++arrayIdx < commnIdx || (arrayIdx = --countIdx) >= commnIdx) {
699 BTRCORELOG_ERROR (
"Failed to Change Media Folder Path %s !\n", mediaItemPath[arrayIdx]);
707 BTRCORELOG_ERROR (
"Media Browser Error - Browser root is NULL!\n");
714 static eBTRCoreAVMElementType
715 btrCore_AVMedia_MapFolderTypeToElementType (
716 enBTMediaFolderType aeMediaFolderType
718 eBTRCoreAVMElementType leAVMElementType;
720 switch (aeMediaFolderType) {
721 case enBTMediaFldTypAlbum:
722 leAVMElementType = eBTRCoreAVMETypeAlbum;
724 case enBTMediaFldTypArtist:
725 leAVMElementType = eBTRCoreAVMETypeArtist;
727 case enBTMediaFldTypGenre:
728 leAVMElementType = eBTRCoreAVMETypeGenre;
730 case enBTMediaFldTypCompilation:
731 leAVMElementType = eBTRCoreAVMETypeCompilation;
733 case enBTMediaFldTypPlayList:
734 leAVMElementType = eBTRCoreAVMETypePlayList;
736 case enBTMediaFldTypTrackList:
737 leAVMElementType = eBTRCoreAVMETypeTrackList;
739 case enBTMediaFldTypTrack:
740 leAVMElementType = eBTRCoreAVMETypeTrack;
743 leAVMElementType = eBTRCoreAVMETypeTrackList;
746 return leAVMElementType;
752 btrCore_AVMedia_PlaybackPositionPolling (
760 unsigned char isPlaying = 0;
761 unsigned int mediaPosition = 0;
766 BTRCORELOG_ERROR (
"Exiting.. enBTRCoreInvalidArg!!!\n");
770 BTRCORELOG_INFO (
"Started AVMedia Position Polling thread successfully...\n");
775 if (!pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate || !pstlhBTRCoreAVM->pvThreadData) {
776 BTRCORELOG_ERROR(
"Exiting.. Invalid stBTRCoreAVMediaHdl Data!!! | fpcBBTRCoreAVMediaStatusUpdate : %p | pvThreadData : %p\n"
777 , pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate, pstlhBTRCoreAVM->pvThreadData);
783 if (!pstAVMediaStUserData->apvAVMUserData || !pstAVMediaStUserData->apcAVMDevAddress) {
784 BTRCORELOG_ERROR(
"Exiting.. Invalid stBTRCoreAVMediaStatusUserData Data!!! | apvAVMUserData : %p | apcAVMDevAddress : %s\n"
785 , pstAVMediaStUserData->apvAVMUserData, pstAVMediaStUserData->apcAVMDevAddress);
789 lpstAVMediaPlayer = &pstlhBTRCoreAVM->pstAVMediaPlayer;
798 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
799 lpstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaPlaybackEnded;
802 if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaTrkStPlaying) {
804 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStPlaying;
806 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaTrkStForwardSeek) {
808 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStPlaying;
810 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaTrkStReverseSeek) {
812 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStPlaying;
814 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaTrkStPaused) {
815 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStPaused;
816 if(pstlhBTRCoreAVM->eAVMediaStPrev != eBTRCoreAVMediaTrkStPaused) {
820 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaTrkStStopped) {
821 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStStopped;
823 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaPlaybackEnded) {
824 mediaStatus.eAVMediaState = eBTRCoreAVMediaPlaybackEnded;
825 BTRCORELOG_WARN (
"Audio StreamIn Status : PlaybackEnded !!!\n");
829 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaPlaybackError) {
830 mediaStatus.eAVMediaState = eBTRCoreAVMediaPlaybackError;
831 BTRCORELOG_ERROR (
"[%s] Audio StreamIn Status : Error !!!\n", pstlhBTRCoreAVM->pcAVMediaPlayerPath);
833 else if (lpstAVMediaPlayer->eAVMediaStatusUpdate != eBTRCoreAVMediaTrkStStarted) {
834 mediaStatus.eAVMediaState = eBTRCoreAVMediaPlaybackError;
835 BTRCORELOG_ERROR (
"[%s] Unknown Audio StreamIn Status : %d !!!\n", pstlhBTRCoreAVM->pcAVMediaPlayerPath, lpstAVMediaPlayer->eAVMediaStatusUpdate);
841 if (mediaStatus.eAVMediaState != eBTRCoreAVMediaPlaybackEnded && mediaStatus.eAVMediaState != eBTRCoreAVMediaPlaybackError) {
843 lpstAVMediaPlayer->m_mediaPlayerPosition = mediaPosition;
846 BTRCORELOG_ERROR (
"Failed to get MediaPlayer Position Property !!!\n");
849 if (pstlhBTRCoreAVM->eAVMTState == enAVMTransportStConnected) {
850 if (lpstAVMediaPlayer->m_mediaTrackChanged) {
851 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStStarted;
852 lpstAVMediaPlayer->m_mediaTrackChanged = 0;
855 if(((pstlhBTRCoreAVM->eAVMediaStPrev == eBTRCoreAVMediaTrkStPlaying) || (pstlhBTRCoreAVM->eAVMediaStPrev == eBTRCoreAVMediaTrkPosition) )&&
856 (mediaStatus.eAVMediaState == eBTRCoreAVMediaTrkStPlaying)) {
857 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkPosition;
862 if (lpstAVMediaPlayer->eAVMediaStatusUpdate == eBTRCoreAVMediaTrkStPlaying) {
863 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStPaused;
872 mediaStatus.m_mediaPositionInfo.ui32Position = lpstAVMediaPlayer->m_mediaPlayerPosition;
873 mediaStatus.m_mediaPositionInfo.ui32Duration = lpstAVMediaPlayer->m_mediaTrackInfo.ui32Duration;
877 pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate(&mediaStatus,
878 pstAVMediaStUserData->apcAVMDevAddress,
879 pstlhBTRCoreAVM->pcBMediaStatusUserData);
882 if (pstlhBTRCoreAVM->eAVMTState != enAVMTransportStConnected) {
890 pstlhBTRCoreAVM->eAVMediaStPrev = mediaStatus.eAVMediaState;
892 if (eBTRCoreAVMediaTrkStStarted == mediaStatus.eAVMediaState || eBTRCoreAVMediaTrkStPlaying == mediaStatus.eAVMediaState || eBTRCoreAVMediaTrkPosition == mediaStatus.eAVMediaState ) {
902 BTRCORELOG_INFO (
"Exiting MediaPosition Polling Thread...\n");
913 tBTRCoreAVMediaHdl* phBTRCoreAVM,
915 const char* apBtAdapter
918 int lBtAVMediaDelayReport = 1;
919 int lBtAVMediaASinkRegRet = -1;
920 int lBtAVMediaASrcRegRet = -1;
921 int lBtAVMediaNegotiateRet = -1;
922 int lBtAVMediaTransportPRet = -1;
923 int lBTAVMediaPlayerPRet = -1;
924 int lBTAVMediaStatusRet = -1;
925 int lBTAVMediaBrowserRet = -1;
926 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
928 if (!phBTRCoreAVM || !apBtConn || !apBtAdapter) {
929 return enBTRCoreInvalidArg;
934 if (!pstlhBTRCoreAVM)
935 return enBTRCoreInitFailure;
939 pstlhBTRCoreAVM->pstBTMediaConfigOut = malloc(MAX(MAX(
sizeof(a2dp_aac_t),
sizeof(a2dp_mpeg_t)),
sizeof(a2dp_sbc_t)));
940 pstlhBTRCoreAVM->pstBTMediaConfigIn = malloc(MAX(MAX(
sizeof(a2dp_aac_t),
sizeof(a2dp_mpeg_t)),
sizeof(a2dp_sbc_t)));
942 if (!pstlhBTRCoreAVM->pstBTMediaConfigOut || !pstlhBTRCoreAVM->pstBTMediaConfigIn) {
944 if (pstlhBTRCoreAVM->pstBTMediaConfigIn)
945 free(pstlhBTRCoreAVM->pstBTMediaConfigIn);
947 if (pstlhBTRCoreAVM->pstBTMediaConfigOut)
948 free(pstlhBTRCoreAVM->pstBTMediaConfigOut);
950 free(pstlhBTRCoreAVM);
951 pstlhBTRCoreAVM = NULL;
952 return enBTRCoreInitFailure;
955 pstlhBTRCoreAVM->btIfceHdl = apBtConn;
956 pstlhBTRCoreAVM->iBTMediaDefSampFreqPref = BTR_SBC_SAMPLING_FREQ_48000;
957 pstlhBTRCoreAVM->eAVMediaTypeOut = eBTRCoreAVMTypeUnknown;
958 pstlhBTRCoreAVM->eAVMediaTypeIn = eBTRCoreAVMTypeUnknown;
959 pstlhBTRCoreAVM->pcAVMediaTransportPathOut = NULL;
960 pstlhBTRCoreAVM->pcAVMediaTransportPathIn = NULL;
961 pstlhBTRCoreAVM->pcAVMediaPlayerPath = NULL;
962 pstlhBTRCoreAVM->pcAVMediaControlPath = NULL;
963 pstlhBTRCoreAVM->pvThreadData = NULL;
964 pstlhBTRCoreAVM->pcBMediaStatusUserData = NULL;
965 pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate = NULL;
966 pstlhBTRCoreAVM->eAVMTState = enAVMTransportStDisconnected;
967 pstlhBTRCoreAVM->eAVMediaStPrev = eBTRCoreAVMediaStUnknown;
970 a2dp_sbc_t lstBtA2dpSbcCaps;
971 lstBtA2dpSbcCaps.channel_mode = BTR_SBC_CHANNEL_MODE_MONO | BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL |
972 BTR_SBC_CHANNEL_MODE_STEREO | BTR_SBC_CHANNEL_MODE_JOINT_STEREO;
974 lstBtA2dpSbcCaps.frequency = BTR_SBC_SAMPLING_FREQ_16000 | BTR_SBC_SAMPLING_FREQ_32000 |
975 BTR_SBC_SAMPLING_FREQ_44100 | BTR_SBC_SAMPLING_FREQ_48000;
978 lstBtA2dpSbcCaps.frequency = BTR_SBC_SAMPLING_FREQ_16000 | BTR_SBC_SAMPLING_FREQ_32000 |
979 BTR_SBC_SAMPLING_FREQ_48000;
981 lstBtA2dpSbcCaps.allocation_method = BTR_SBC_ALLOCATION_SNR | BTR_SBC_ALLOCATION_LOUDNESS;
982 lstBtA2dpSbcCaps.subbands = BTR_SBC_SUBBANDS_4 | BTR_SBC_SUBBANDS_8;
983 lstBtA2dpSbcCaps.block_length = BTR_SBC_BLOCK_LENGTH_4 | BTR_SBC_BLOCK_LENGTH_8 |
984 BTR_SBC_BLOCK_LENGTH_12 | BTR_SBC_BLOCK_LENGTH_16;
985 lstBtA2dpSbcCaps.min_bitpool = MIN_BITPOOL;
986 lstBtA2dpSbcCaps.max_bitpool = MAX_BITPOOL;
989 memcpy(pstlhBTRCoreAVM->pstBTMediaConfigOut, &lstBtA2dpSbcCaps,
sizeof(a2dp_sbc_t));
995 (
void*)&lstBtA2dpSbcCaps,
996 sizeof(lstBtA2dpSbcCaps),
997 lBtAVMediaDelayReport);
1000 lstBtA2dpSbcCaps.frequency |= BTR_SBC_SAMPLING_FREQ_44100;
1003 memcpy(pstlhBTRCoreAVM->pstBTMediaConfigIn, &lstBtA2dpSbcCaps,
sizeof(a2dp_sbc_t));
1009 (
void*)&lstBtA2dpSbcCaps,
1010 sizeof(lstBtA2dpSbcCaps),
1011 lBtAVMediaDelayReport);
1013 #if defined(AAC_SUPPORTED)
1014 a2dp_aac_t lstBtA2dpAacCaps;
1015 lstBtA2dpAacCaps.object_type = BTR_AAC_OT_MPEG2_AAC_LC | BTR_AAC_OT_MPEG4_AAC_LC |
1016 BTR_AAC_OT_MPEG4_AAC_LTP | BTR_AAC_OT_MPEG4_AAC_SCA;
1017 lstBtA2dpAacCaps.channels = BTR_AAC_CHANNELS_1 | BTR_AAC_CHANNELS_2;
1018 lstBtA2dpAacCaps.rfa = 0x3;
1019 lstBtA2dpAacCaps.vbr = 1;
1021 BTR_AAC_SET_FREQ (lstBtA2dpAacCaps,(BTR_AAC_SAMPLING_FREQ_8000 | BTR_AAC_SAMPLING_FREQ_11025 | BTR_AAC_SAMPLING_FREQ_12000 |
1022 BTR_AAC_SAMPLING_FREQ_16000 | BTR_AAC_SAMPLING_FREQ_22050 | BTR_AAC_SAMPLING_FREQ_24000 |
1023 BTR_AAC_SAMPLING_FREQ_32000 | BTR_AAC_SAMPLING_FREQ_44100 | BTR_AAC_SAMPLING_FREQ_48000 |
1024 BTR_AAC_SAMPLING_FREQ_64000 | BTR_AAC_SAMPLING_FREQ_88200 | BTR_AAC_SAMPLING_FREQ_96000));
1026 BTR_AAC_SET_BITRATE (lstBtA2dpAacCaps,(BTR_MPEG_BIT_RATE_VBR | BTR_MPEG_BIT_RATE_320000 | BTR_MPEG_BIT_RATE_256000 |
1027 BTR_MPEG_BIT_RATE_224000 | BTR_MPEG_BIT_RATE_192000 | BTR_MPEG_BIT_RATE_160000 |
1028 BTR_MPEG_BIT_RATE_128000 | BTR_MPEG_BIT_RATE_112000 | BTR_MPEG_BIT_RATE_96000 |
1029 BTR_MPEG_BIT_RATE_80000 | BTR_MPEG_BIT_RATE_64000 | BTR_MPEG_BIT_RATE_56000 |
1030 BTR_MPEG_BIT_RATE_48000 | BTR_MPEG_BIT_RATE_40000 | BTR_MPEG_BIT_RATE_32000));
1038 (
void*)&lstBtA2dpAacCaps,
1039 sizeof(lstBtA2dpAacCaps),
1040 lBtAVMediaDelayReport);
1048 (
void*)&lstBtA2dpAacCaps,
1049 sizeof(lstBtA2dpAacCaps),
1050 lBtAVMediaDelayReport);
1053 if (!lBtAVMediaASinkRegRet && !lBtAVMediaASrcRegRet)
1054 lBtAVMediaNegotiateRet = BtrCore_BTRegisterNegotiateMediaCb(apBtConn,
1056 &btrCore_AVMedia_NegotiateMediaCb,
1059 if (!lBtAVMediaASinkRegRet && !lBtAVMediaASrcRegRet && !lBtAVMediaNegotiateRet)
1060 lBtAVMediaTransportPRet = BtrCore_BTRegisterTransportPathMediaCb(apBtConn,
1062 &btrCore_AVMedia_TransportPathCb,
1065 if (!lBtAVMediaASinkRegRet && !lBtAVMediaASrcRegRet && !lBtAVMediaNegotiateRet && !lBtAVMediaTransportPRet)
1066 lBTAVMediaPlayerPRet = BtrCore_BTRegisterMediaPlayerPathCb(apBtConn,
1068 &btrCore_AVMedia_MediaPlayerPathCb,
1071 if (!lBtAVMediaASinkRegRet && !lBtAVMediaASrcRegRet && !lBtAVMediaNegotiateRet && !lBtAVMediaTransportPRet && !lBTAVMediaPlayerPRet)
1072 lBTAVMediaStatusRet = BtrCore_BTRegisterMediaStatusUpdateCb(apBtConn,
1073 &btrCore_AVMedia_MediaStatusUpdateCb,
1076 if (!lBtAVMediaASinkRegRet && !lBtAVMediaASrcRegRet && !lBtAVMediaNegotiateRet && !lBtAVMediaTransportPRet && !lBTAVMediaPlayerPRet && !lBTAVMediaStatusRet)
1077 lBTAVMediaBrowserRet = BtrCore_BTRegisterMediaBrowserUpdateCb(apBtConn,
1078 &btrCore_AVMedia_MediaBrowserUpdateCb,
1081 if (!lBtAVMediaASinkRegRet && !lBtAVMediaASrcRegRet && !lBtAVMediaNegotiateRet && !lBtAVMediaTransportPRet &&
1082 !lBTAVMediaPlayerPRet && !lBTAVMediaStatusRet && !lBTAVMediaBrowserRet)
1083 lenBTRCoreRet = enBTRCoreSuccess;
1085 if (lenBTRCoreRet != enBTRCoreSuccess) {
1086 free(pstlhBTRCoreAVM);
1087 pstlhBTRCoreAVM = NULL;
1090 *phBTRCoreAVM = (tBTRCoreAVMediaHdl)pstlhBTRCoreAVM;
1092 return lenBTRCoreRet;
1098 tBTRCoreAVMediaHdl hBTRCoreAVM,
1100 const char* apBtAdapter
1103 int lBtAVMediaASinkUnRegRet = -1;
1104 int lBtAVMediaASrcUnRegRet = -1;
1105 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
1107 if (!hBTRCoreAVM || !apBtConn || !apBtAdapter) {
1108 return enBTRCoreInvalidArg;
1113 if (pstlhBTRCoreAVM->btIfceHdl != apBtConn) {
1114 BTRCORELOG_WARN (
"Incorrect Argument - btIfceHdl : Continue\n");
1118 #if defined(AAC_SUPPORTED)
1142 if (pstlhBTRCoreAVM->pstBTMediaConfigIn) {
1143 free(pstlhBTRCoreAVM->pstBTMediaConfigIn);
1144 pstlhBTRCoreAVM->pstBTMediaConfigIn = NULL;
1147 if (pstlhBTRCoreAVM->pstBTMediaConfigOut) {
1148 free(pstlhBTRCoreAVM->pstBTMediaConfigOut);
1149 pstlhBTRCoreAVM->pstBTMediaConfigOut = NULL;
1152 if (pstlhBTRCoreAVM->pcAVMediaTransportPathOut) {
1153 free(pstlhBTRCoreAVM->pcAVMediaTransportPathOut);
1154 pstlhBTRCoreAVM->pcAVMediaTransportPathOut = NULL;
1157 if (pstlhBTRCoreAVM->pcAVMediaControlPath) {
1158 free(pstlhBTRCoreAVM->pcAVMediaControlPath);
1159 pstlhBTRCoreAVM->pcAVMediaControlPath = NULL;
1162 if (pstlhBTRCoreAVM->pcAVMediaTransportPathIn) {
1163 free(pstlhBTRCoreAVM->pcAVMediaTransportPathIn);
1164 pstlhBTRCoreAVM->pcAVMediaTransportPathIn = NULL;
1167 if (pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
1168 free(pstlhBTRCoreAVM->pcAVMediaPlayerPath);
1169 pstlhBTRCoreAVM->pcAVMediaPlayerPath = NULL;
1172 if (pstlhBTRCoreAVM->pstAVMediaBrowser) {
1173 const char* apcBtDevAddr = NULL;
1174 while (pstlhBTRCoreAVM->pstAVMediaBrowser->pvAVMediaParentItem) {
1175 pstlhBTRCoreAVM->pstAVMediaBrowser = pstlhBTRCoreAVM->pstAVMediaBrowser->pvAVMediaParentItem;
1177 if (!btrCore_AVMedia_DeallocateUnhandledBrowserMemory (pstlhBTRCoreAVM, apcBtDevAddr, &pstlhBTRCoreAVM->pstAVMediaBrowser)) {
1178 BTRCORELOG_ERROR (
"Media Browser Error - Deallocate Unhandled Browser Memory Failed!\n");
1180 pstlhBTRCoreAVM->pstAVMediaBrowser = NULL;
1183 if (pstlhBTRCoreAVM->pstAVMediaPlayList) {
1184 const char* apcBtDevAddr = NULL;
1185 if (!btrCore_AVMedia_DeallocateUnhandledBrowserMemory (pstlhBTRCoreAVM, apcBtDevAddr, &pstlhBTRCoreAVM->pstAVMediaPlayList)) {
1186 BTRCORELOG_ERROR (
"Media Browser Error - Deallocate Unhandled Browser Memory Failed!\n");
1188 pstlhBTRCoreAVM->pstAVMediaPlayList = NULL;
1191 pstlhBTRCoreAVM->ui8AVMediaTransportVolume = 0;
1192 pstlhBTRCoreAVM->bAVMediaTrVolAvrcp = FALSE;
1193 pstlhBTRCoreAVM->btIfceHdl = NULL;
1194 pstlhBTRCoreAVM->pvThreadData = NULL;
1195 pstlhBTRCoreAVM->pcBMediaStatusUserData = NULL;
1196 pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate = NULL;
1197 pstlhBTRCoreAVM->eAVMTState = enAVMTransportStDisconnected;
1199 if (!lBtAVMediaASrcUnRegRet && !lBtAVMediaASinkUnRegRet)
1200 lenBTRCoreRet = enBTRCoreSuccess;
1204 (void) pstlhBTRCoreAVM;
1209 return lenBTRCoreRet;
1215 tBTRCoreAVMediaHdl hBTRCoreAVM,
1216 const char* apBtDevAddr,
1220 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
1221 void* lpstBTMediaConfig = NULL;
1223 if (!hBTRCoreAVM || !apBtDevAddr || !apstBtrCoreAVMediaInfo) {
1224 return enBTRCoreInvalidArg;
1230 if (apstBtrCoreAVMediaInfo->eBtrCoreAVMFlow == eBTRCoreAVMediaFlowOut) {
1232 unsigned int ui32sleepIdx = 20;
1236 }
while ((!pstlhBTRCoreAVM->pcAVMediaTransportPathOut) && (--ui32sleepIdx));
1238 lpstBTMediaConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
1239 apstBtrCoreAVMediaInfo->eBtrCoreAVMType = pstlhBTRCoreAVM->eAVMediaTypeOut;
1241 else if (apstBtrCoreAVMediaInfo->eBtrCoreAVMFlow == eBTRCoreAVMediaFlowIn) {
1243 unsigned int ui32sleepIdx = 20;
1247 }
while ((!pstlhBTRCoreAVM->pcAVMediaTransportPathIn) && (--ui32sleepIdx));
1249 lpstBTMediaConfig = pstlhBTRCoreAVM->pstBTMediaConfigIn;
1250 apstBtrCoreAVMediaInfo->eBtrCoreAVMType = pstlhBTRCoreAVM->eAVMediaTypeIn;
1254 lpstBTMediaConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
1255 apstBtrCoreAVMediaInfo->eBtrCoreAVMType = pstlhBTRCoreAVM->eAVMediaTypeOut;
1259 if (!apstBtrCoreAVMediaInfo->pstBtrCoreAVMCodecInfo || !lpstBTMediaConfig) {
1260 return enBTRCoreFailure;
1264 if (apstBtrCoreAVMediaInfo->eBtrCoreAVMType == eBTRCoreAVMTypePCM) {
1266 else if (apstBtrCoreAVMediaInfo->eBtrCoreAVMType == eBTRCoreAVMTypeSBC) {
1267 a2dp_sbc_t* lpstBTMediaSbcConfig = (a2dp_sbc_t*)lpstBTMediaConfig;
1270 if (lpstBTMediaSbcConfig->frequency == BTR_SBC_SAMPLING_FREQ_16000) {
1271 pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq = 16000;
1273 else if (lpstBTMediaSbcConfig->frequency == BTR_SBC_SAMPLING_FREQ_32000) {
1274 pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq = 32000;
1276 else if (lpstBTMediaSbcConfig->frequency == BTR_SBC_SAMPLING_FREQ_44100) {
1277 pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq = 44100;
1279 else if (lpstBTMediaSbcConfig->frequency == BTR_SBC_SAMPLING_FREQ_48000) {
1280 pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq = 48000;
1283 pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq = 0;
1286 if (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_MONO) {
1287 pstBtrCoreAVMediaSbcInfo->eAVMAChan = eBTRCoreAVMAChanMono;
1288 pstBtrCoreAVMediaSbcInfo->ui32AVMAChan = 1;
1290 else if (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL) {
1291 pstBtrCoreAVMediaSbcInfo->eAVMAChan = eBTRCoreAVMAChanDualChannel;
1292 pstBtrCoreAVMediaSbcInfo->ui32AVMAChan = 2;
1294 else if (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_STEREO) {
1295 pstBtrCoreAVMediaSbcInfo->eAVMAChan = eBTRCoreAVMAChanStereo;
1296 pstBtrCoreAVMediaSbcInfo->ui32AVMAChan = 2;
1298 else if (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_JOINT_STEREO) {
1299 pstBtrCoreAVMediaSbcInfo->eAVMAChan = eBTRCoreAVMAChanJointStereo;
1300 pstBtrCoreAVMediaSbcInfo->ui32AVMAChan = 2;
1303 pstBtrCoreAVMediaSbcInfo->eAVMAChan = eBTRCoreAVMAChanUnknown;
1306 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcAllocMethod = lpstBTMediaSbcConfig->allocation_method;
1308 if (lpstBTMediaSbcConfig->subbands == BTR_SBC_SUBBANDS_4) {
1309 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands = 4;
1311 else if (lpstBTMediaSbcConfig->subbands == BTR_SBC_SUBBANDS_8) {
1312 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands = 8;
1315 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands = 0;
1318 if (lpstBTMediaSbcConfig->block_length == BTR_SBC_BLOCK_LENGTH_4) {
1319 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength = 4;
1321 else if (lpstBTMediaSbcConfig->block_length == BTR_SBC_BLOCK_LENGTH_8) {
1322 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength = 8;
1324 else if (lpstBTMediaSbcConfig->block_length == BTR_SBC_BLOCK_LENGTH_12) {
1325 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength = 12;
1327 else if (lpstBTMediaSbcConfig->block_length == BTR_SBC_BLOCK_LENGTH_16) {
1328 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength = 16;
1331 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength = 0;
1334 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMinBitpool = lpstBTMediaSbcConfig->min_bitpool;
1335 pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMaxBitpool = lpstBTMediaSbcConfig->max_bitpool;
1337 if ((lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_MONO) ||
1338 (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL)) {
1339 pstBtrCoreAVMediaSbcInfo->ui16AVMSbcFrameLen = 4 + ((4 * pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands * pstBtrCoreAVMediaSbcInfo->ui32AVMAChan) / 8) +
1340 ((pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength * pstBtrCoreAVMediaSbcInfo->ui32AVMAChan * pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMaxBitpool) / 8);
1342 else if (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_STEREO) {
1343 pstBtrCoreAVMediaSbcInfo->ui16AVMSbcFrameLen = 4 + (4 * pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands * pstBtrCoreAVMediaSbcInfo->ui32AVMAChan) / 8 +
1344 (pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength * pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMaxBitpool) / 8;
1346 else if (lpstBTMediaSbcConfig->channel_mode == BTR_SBC_CHANNEL_MODE_JOINT_STEREO) {
1347 pstBtrCoreAVMediaSbcInfo->ui16AVMSbcFrameLen = 4 + ((4 * pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands * pstBtrCoreAVMediaSbcInfo->ui32AVMAChan) / 8) +
1348 (pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands + (pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength * pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMaxBitpool)) / 8;
1351 pstBtrCoreAVMediaSbcInfo->ui16AVMSbcFrameLen = 0;
1354 if ((pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength != 0) && (pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands != 0))
1355 pstBtrCoreAVMediaSbcInfo->ui16AVMSbcBitrate = ((8.0 * pstBtrCoreAVMediaSbcInfo->ui16AVMSbcFrameLen * (float)pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq/1000) / pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands) / pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength;
1357 pstBtrCoreAVMediaSbcInfo->ui16AVMSbcBitrate = 0;
1359 BTRCORELOG_TRACE (
"ui32AVMSFreq = %d\n", pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq);
1360 BTRCORELOG_TRACE (
"ui32AVMAChan = %d\n", pstBtrCoreAVMediaSbcInfo->ui32AVMAChan);
1361 BTRCORELOG_TRACE (
"ui8AVMSbcAllocMethod = %d\n", pstBtrCoreAVMediaSbcInfo->ui8AVMSbcAllocMethod);
1362 BTRCORELOG_TRACE (
"ui8AVMSbcSubbands = %d\n", pstBtrCoreAVMediaSbcInfo->ui8AVMSbcSubbands);
1363 BTRCORELOG_TRACE (
"ui8AVMSbcBlockLength = %d\n", pstBtrCoreAVMediaSbcInfo->ui8AVMSbcBlockLength);
1364 BTRCORELOG_TRACE (
"ui8AVMSbcMinBitpool = %d\n", pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMinBitpool);
1365 BTRCORELOG_TRACE (
"ui8AVMSbcMaxBitpool = %d\n", pstBtrCoreAVMediaSbcInfo->ui8AVMSbcMaxBitpool);
1366 BTRCORELOG_TRACE (
"ui16AVMSbcFrameLen = %d\n", pstBtrCoreAVMediaSbcInfo->ui16AVMSbcFrameLen);
1367 BTRCORELOG_DEBUG (
"ui16AVMSbcBitrate = %d\n", pstBtrCoreAVMediaSbcInfo->ui16AVMSbcBitrate);
1369 if (pstBtrCoreAVMediaSbcInfo->ui32AVMSFreq && pstBtrCoreAVMediaSbcInfo->ui16AVMSbcBitrate)
1370 lenBTRCoreRet = enBTRCoreSuccess;
1373 else if (apstBtrCoreAVMediaInfo->eBtrCoreAVMType == eBTRCoreAVMTypeMPEG) {
1375 else if (apstBtrCoreAVMediaInfo->eBtrCoreAVMType == eBTRCoreAVMTypeAAC) {
1376 #if defined(AAC_SUPPORTED)
1377 unsigned short ui16AacFreq = 0;
1378 unsigned short ui16AacBitrate= 0;
1379 a2dp_aac_t* lpstBTMediaAacConfig = (a2dp_aac_t*)lpstBTMediaConfig;
1382 ui16AacFreq = BTR_AAC_GET_FREQ(*lpstBTMediaAacConfig);
1383 if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_8000) {
1384 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 8000;
1386 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_11025) {
1387 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 11025;
1389 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_12000) {
1390 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 12000;
1392 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_16000) {
1393 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 16000;
1395 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_22050) {
1396 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 22050;
1398 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_24000) {
1399 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 24000;
1401 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_32000) {
1402 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 32000;
1404 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_44100) {
1405 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 44100;
1407 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_48000) {
1408 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 48000;
1410 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_64000) {
1411 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 64000;
1413 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_88200) {
1414 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 88200;
1416 else if (ui16AacFreq & BTR_AAC_SAMPLING_FREQ_96000) {
1417 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 96000;
1420 pstBtrCoreAVMediaAacInfo->ui32AVMSFreq = 0;
1423 ui16AacBitrate = BTR_AAC_GET_BITRATE(*lpstBTMediaAacConfig);
1424 if (ui16AacBitrate & BTR_MPEG_BIT_RATE_VBR) {
1425 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 1;
1427 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_320000) {
1428 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 320;
1430 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_256000) {
1431 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 256;
1433 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_224000) {
1434 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 224;
1436 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_192000) {
1437 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 192;
1439 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_160000) {
1440 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 160;
1442 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_128000) {
1443 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 128;
1445 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_112000) {
1446 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 112;
1448 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_96000) {
1449 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 96;
1451 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_80000) {
1452 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 80;
1454 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_64000) {
1455 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 64;
1457 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_56000) {
1458 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 56;
1460 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_48000) {
1461 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 48;
1463 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_40000) {
1464 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 40;
1466 else if (ui16AacBitrate & BTR_MPEG_BIT_RATE_32000) {
1467 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 32;
1470 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = 0;
1474 if (lpstBTMediaAacConfig->vbr) {
1475 pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate = lpstBTMediaAacConfig->vbr;
1478 pstBtrCoreAVMediaAacInfo->ui8AVMMpegRfa = lpstBTMediaAacConfig->rfa;
1480 if (lpstBTMediaAacConfig->channels & BTR_AAC_CHANNELS_1) {
1481 pstBtrCoreAVMediaAacInfo->eAVMAChan = eBTRCoreAVMAChanMono;
1482 pstBtrCoreAVMediaAacInfo->ui32AVMAChan = 1;
1484 else if (lpstBTMediaAacConfig->channels & BTR_AAC_CHANNELS_2) {
1485 pstBtrCoreAVMediaAacInfo->eAVMAChan = eBTRCoreAVMAChanStereo;
1486 pstBtrCoreAVMediaAacInfo->ui32AVMAChan = 2;
1489 pstBtrCoreAVMediaAacInfo->eAVMAChan = eBTRCoreAVMAChanUnknown;
1490 pstBtrCoreAVMediaAacInfo->ui32AVMAChan = 0;
1493 if (lpstBTMediaAacConfig->object_type == BTR_AAC_OT_MPEG2_AAC_LC) {
1494 pstBtrCoreAVMediaAacInfo->ui8AVMMpegVersion = 2;
1495 pstBtrCoreAVMediaAacInfo->ui8AVMMpegType = 4;
1497 else if (lpstBTMediaAacConfig->object_type == BTR_AAC_OT_MPEG4_AAC_LC) {
1498 pstBtrCoreAVMediaAacInfo->ui8AVMMpegVersion = 4;
1499 pstBtrCoreAVMediaAacInfo->ui8AVMMpegType = 4;
1501 else if (lpstBTMediaAacConfig->object_type == BTR_AAC_OT_MPEG4_AAC_LTP) {
1502 pstBtrCoreAVMediaAacInfo->ui8AVMMpegVersion = 4;
1503 pstBtrCoreAVMediaAacInfo->ui8AVMMpegType = 4;
1505 else if (lpstBTMediaAacConfig->object_type == BTR_AAC_OT_MPEG4_AAC_SCA) {
1506 pstBtrCoreAVMediaAacInfo->ui8AVMMpegVersion = 4;
1507 pstBtrCoreAVMediaAacInfo->ui8AVMMpegType = 4;
1510 pstBtrCoreAVMediaAacInfo->ui8AVMMpegVersion = 0;
1511 pstBtrCoreAVMediaAacInfo->ui8AVMMpegType = 0;
1515 BTRCORELOG_TRACE (
"eAVMAChan = %d\n", pstBtrCoreAVMediaAacInfo->eAVMAChan);
1516 BTRCORELOG_TRACE (
"ui32AVMAChan = %d\n", pstBtrCoreAVMediaAacInfo->ui32AVMAChan);
1517 BTRCORELOG_DEBUG (
"ui32AVMSFreq = %d\n", pstBtrCoreAVMediaAacInfo->ui32AVMSFreq);
1518 BTRCORELOG_TRACE (
"ui8AVMMpegVersion = %d\n", pstBtrCoreAVMediaAacInfo->ui8AVMMpegVersion);
1519 BTRCORELOG_TRACE (
"ui8AVMMpegLayer = %d\n", pstBtrCoreAVMediaAacInfo->ui8AVMMpegLayer);
1520 BTRCORELOG_TRACE (
"ui8AVMMpegType = %d\n", pstBtrCoreAVMediaAacInfo->ui8AVMMpegType);
1521 BTRCORELOG_TRACE (
"ui8AVMMpegMpf = %d\n", pstBtrCoreAVMediaAacInfo->ui8AVMMpegMpf);
1522 BTRCORELOG_TRACE (
"ui8AVMMpegRfa = %d\n", pstBtrCoreAVMediaAacInfo->ui8AVMMpegRfa);
1523 BTRCORELOG_TRACE (
"ui16AVMMpegFrameLen = %d\n", pstBtrCoreAVMediaAacInfo->ui16AVMMpegFrameLen);
1524 BTRCORELOG_DEBUG (
"ui16AVMMpegBitrate = %d\n", pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate);
1526 if (pstBtrCoreAVMediaAacInfo->ui32AVMSFreq && pstBtrCoreAVMediaAacInfo->ui16AVMMpegBitrate)
1527 lenBTRCoreRet = enBTRCoreSuccess;
1533 return lenBTRCoreRet;
1539 tBTRCoreAVMediaHdl hBTRCoreAVM,
1540 const char* apBtDevAddr,
1543 int* apDataWriteMTU,
1544 unsigned int* apui32Delay
1547 char* lpcAVMediaTransportPath = NULL;
1548 int lBtAVMediaRet = -1;
1549 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
1551 unsigned int ui32Delay = 0xFFFFu;
1552 unsigned short ui16Vol = 0xFFFFu;
1554 if (!hBTRCoreAVM || !apBtDevAddr || !apui32Delay) {
1555 return enBTRCoreInvalidArg;
1561 if (pstlhBTRCoreAVM->pcAVMediaTransportPathOut && strstr(pstlhBTRCoreAVM->pcAVMediaTransportPathOut, apBtDevAddr)) {
1562 lpcAVMediaTransportPath = pstlhBTRCoreAVM->pcAVMediaTransportPathOut;
1564 else if (pstlhBTRCoreAVM->pcAVMediaTransportPathIn && strstr(pstlhBTRCoreAVM->pcAVMediaTransportPathIn, apBtDevAddr)) {
1565 lpcAVMediaTransportPath = pstlhBTRCoreAVM->pcAVMediaTransportPathIn;
1569 if (lpcAVMediaTransportPath == NULL) {
1570 return enBTRCoreFailure;
1573 if (!(lBtAVMediaRet =
BtrCore_BTAcquireDevDataPath(pstlhBTRCoreAVM->btIfceHdl, lpcAVMediaTransportPath, apDataPath, apDataReadMTU, apDataWriteMTU)))
1574 lenBTRCoreRet = enBTRCoreSuccess;
1576 lunBtOpMedTProp.enBtMediaTransportProp = enBTMedTPropDelay;
1577 if ((lBtAVMediaRet =
BtrCore_BTGetProp(pstlhBTRCoreAVM->btIfceHdl, lpcAVMediaTransportPath, enBTMediaTransport, lunBtOpMedTProp, &ui32Delay)))
1578 lenBTRCoreRet = enBTRCoreFailure;
1580 lunBtOpMedTProp.enBtMediaTransportProp = enBTMedTPropVol;
1581 if ((lBtAVMediaRet =
BtrCore_BTGetProp(pstlhBTRCoreAVM->btIfceHdl, lpcAVMediaTransportPath, enBTMediaTransport, lunBtOpMedTProp, &ui16Vol)))
1582 lenBTRCoreRet = enBTRCoreFailure;
1584 *apui32Delay = ui32Delay;
1585 BTRCORELOG_INFO (
"BTRCore_AVMedia_AcquireDataPath: Delay value = %d Volume = %d\n", ui32Delay, ui16Vol);
1587 return lenBTRCoreRet;
1593 tBTRCoreAVMediaHdl hBTRCoreAVM,
1594 const char* apBtDevAddr
1597 char* lpcAVMediaTransportPath = NULL;
1598 int lBtAVMediaRet = -1;
1599 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
1601 if (!hBTRCoreAVM || !apBtDevAddr) {
1602 return enBTRCoreInvalidArg;
1608 if (pstlhBTRCoreAVM->pcAVMediaTransportPathOut && strstr(pstlhBTRCoreAVM->pcAVMediaTransportPathOut, apBtDevAddr)) {
1609 lpcAVMediaTransportPath = pstlhBTRCoreAVM->pcAVMediaTransportPathOut;
1611 else if (pstlhBTRCoreAVM->pcAVMediaTransportPathIn && strstr(pstlhBTRCoreAVM->pcAVMediaTransportPathIn, apBtDevAddr)) {
1612 lpcAVMediaTransportPath = pstlhBTRCoreAVM->pcAVMediaTransportPathIn;
1616 if (lpcAVMediaTransportPath == NULL) {
1617 return enBTRCoreFailure;
1622 lenBTRCoreRet = enBTRCoreSuccess;
1624 return lenBTRCoreRet;
1630 tBTRCoreAVMediaHdl hBTRCoreAVM,
1631 const char* apBtDevAddr,
1632 enBTRCoreAVMediaCtrl aenBTRCoreAVMediaCtrl,
1633 eBTRCoreAVMediaFlow aenBTRCoreAVMediaFlow,
1637 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1640 unsigned short lui16TranspVol = 0xFFFFu;
1644 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
1645 return enBTRCoreInvalidArg;
1650 if ((aenBTRCoreAVMediaFlow == eBTRCoreAVMediaFlowIn) &&
1651 (!pstlhBTRCoreAVM->pcAVMediaPlayerPath)) {
1655 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
1656 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
1657 return enBTRCoreFailure;
1661 switch (aenBTRCoreAVMediaCtrl) {
1662 case enBTRCoreAVMediaCtrlPlay:
1663 aenBTMediaControl = enBTMediaCtrlPlay;
1665 case enBTRCoreAVMediaCtrlPause:
1666 aenBTMediaControl = enBTMediaCtrlPause;
1668 case enBTRCoreAVMediaCtrlStop:
1669 aenBTMediaControl = enBTMediaCtrlStop;
1671 case enBTRCoreAVMediaCtrlNext:
1672 aenBTMediaControl = enBTMediaCtrlNext;
1674 case enBTRCoreAVMediaCtrlPrevious:
1675 aenBTMediaControl = enBTMediaCtrlPrevious;
1677 case enBTRCoreAVMediaCtrlFastForward:
1678 aenBTMediaControl = enBTMediaCtrlFastForward;
1680 case enBTRCoreAVMediaCtrlRewind:
1681 aenBTMediaControl = enBTMediaCtrlRewind;
1683 case enBTRCoreAVMediaCtrlVolumeUp:
1684 aenBTMediaControl = enBTMediaCtrlVolumeUp;
1685 if (apstBTRCoreAVMediaCtrlData != NULL) {
1686 lui16TranspVol = (apstBTRCoreAVMediaCtrlData->m_mediaAbsTransportVolume < 255) ? (apstBTRCoreAVMediaCtrlData->m_mediaAbsTransportVolume / 2) : 127;
1689 lui16TranspVol = (pstlhBTRCoreAVM->ui8AVMediaTransportVolume < 240) ? ((pstlhBTRCoreAVM->ui8AVMediaTransportVolume + 10) / 2) : 127;
1692 case enBTRCoreAVMediaCtrlVolumeDown:
1693 aenBTMediaControl = enBTMediaCtrlVolumeDown;
1694 if (apstBTRCoreAVMediaCtrlData != NULL) {
1695 lui16TranspVol = (apstBTRCoreAVMediaCtrlData->m_mediaAbsTransportVolume < 255) ? (apstBTRCoreAVMediaCtrlData->m_mediaAbsTransportVolume / 2) : 127;
1698 lui16TranspVol = (pstlhBTRCoreAVM->ui8AVMediaTransportVolume > 15) ? ((pstlhBTRCoreAVM->ui8AVMediaTransportVolume - 10) / 2) : 0;
1701 case enBTRcoreAVMediaCtrlEqlzrOff:
1702 aenBTMediaControl = enBTMediaCtrlEqlzrOff;
1704 case enBTRcoreAVMediaCtrlEqlzrOn:
1705 aenBTMediaControl = enBTMediaCtrlEqlzrOn;
1707 case enBTRCoreAVMediaCtrlShflOff:
1708 aenBTMediaControl = enBTMediaCtrlShflOff;
1710 case enBTRCoreAVMediaCtrlShflAllTracks:
1711 aenBTMediaControl = enBTMediaCtrlShflAllTracks;
1713 case enBTRCoreAVMediaCtrlShflGroup:
1714 aenBTMediaControl = enBTMediaCtrlShflGroup;
1716 case enBTRCoreAVMediaCtrlRptOff:
1717 aenBTMediaControl = enBTMediaCtrlRptOff;
1719 case enBTRCoreAVMediaCtrlRptSingleTrack:
1720 aenBTMediaControl = enBTMediaCtrlRptSingleTrack;
1722 case enBTRCoreAVMediaCtrlRptAllTracks:
1723 aenBTMediaControl = enBTMediaCtrlRptAllTracks;
1725 case enBTRCoreAVMediaCtrlRptGroup:
1726 aenBTMediaControl = enBTMediaCtrlRptGroup;
1729 aenBTMediaControl = enBTMediaCtrlUnknown;
1732 if (aenBTMediaControl == enBTMediaCtrlUnknown) {
1733 BTRCORELOG_ERROR (
"Unknown Media Control option!\n");
1734 lenBTRCoreRet = enBTRCoreFailure;
1736 else if (aenBTRCoreAVMediaFlow == eBTRCoreAVMediaFlowIn) {
1738 BTRCORELOG_ERROR (
"Failed to set the Media control eBTRCoreAVMediaFlowIn!");
1739 lenBTRCoreRet = enBTRCoreFailure;
1742 else if (aenBTRCoreAVMediaFlow == eBTRCoreAVMediaFlowOut) {
1743 if (((pstlhBTRCoreAVM->bAVMediaTrVolAvrcp ==
TRUE) || (pstlhBTRCoreAVM->bAVMediaPlayerConnected ==
TRUE)) && (pstlhBTRCoreAVM->pcAVMediaTransportPathOut != NULL)) {
1744 lunBtOpMedTProp.enBtMediaTransportProp = enBTMedTPropVol;
1745 if (!
BtrCore_BTSetProp(pstlhBTRCoreAVM->btIfceHdl, pstlhBTRCoreAVM->pcAVMediaTransportPathOut, enBTMediaTransport, lunBtOpMedTProp, &lui16TranspVol)) {
1746 pstlhBTRCoreAVM->ui8AVMediaTransportVolume = (lui16TranspVol == 127) ? 255 : lui16TranspVol * 2;
1749 lenBTRCoreRet = enBTRCoreFailure;
1753 BTRCORELOG_ERROR (
"Failed to set the Media control eBTRCoreAVMediaFlowOut!\n");
1754 lenBTRCoreRet = enBTRCoreFailure;
1758 return lenBTRCoreRet;
1764 tBTRCoreAVMediaHdl hBTRCoreAVM,
1765 const char* apBtDevAddr,
1769 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1771 if (!hBTRCoreAVM || !apBtDevAddr || !apstBTAVMediaTrackInfo) {
1772 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
1773 return enBTRCoreInvalidArg;
1778 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
1782 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
1783 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
1784 return enBTRCoreFailure;
1789 BTRCORELOG_WARN (
"Failed to get Track information!!! from Bluez !");
1790 lenBTRCoreRet = enBTRCoreFailure;
1793 return lenBTRCoreRet;
1798 tBTRCoreAVMediaHdl hBTRCoreAVM,
1799 const char* apBtDevAddr,
1800 tBTRCoreAVMediaElementId aBtrAVMediaItemId,
1804 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1806 if (!hBTRCoreAVM || !apBtDevAddr || !apstBTAVMediaTrackInfo) {
1807 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
1808 return enBTRCoreInvalidArg;
1813 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
1817 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
1818 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
1819 return enBTRCoreFailure;
1823 if (aBtrAVMediaItemId && (pstlhBTRCoreAVM->SelectedaBtrAVMediaItemId == aBtrAVMediaItemId)) {
1824 if (apstBTAVMediaTrackInfo) {
1827 BTRCORELOG_DEBUG (
" Get track success");
1828 return lenBTRCoreRet;
1835 BTRCORELOG_WARN (
"Failed to get Track information!!! from Bluez !");
1836 lenBTRCoreRet = enBTRCoreFailure;
1839 return lenBTRCoreRet;
1847 tBTRCoreAVMediaHdl hBTRCoreAVM,
1848 const char* apBtDevAddr,
1852 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1854 if (!hBTRCoreAVM || !apBtDevAddr || !apstBTAVMediaPositionInfo) {
1855 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
1856 return enBTRCoreInvalidArg;
1861 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
1865 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
1866 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
1867 return enBTRCoreFailure;
1872 unsigned int mediaPosition = 0;
1873 enBTRCoreRet positionRet, trackRet;
1880 if (positionRet || trackRet) {
1881 BTRCORELOG_ERROR (
"Failed to get media info!!!");
1882 lenBTRCoreRet = enBTRCoreFailure;
1885 apstBTAVMediaPositionInfo->ui32Duration = mediaTrackInfo.ui32Duration;
1886 apstBTAVMediaPositionInfo->ui32Position = mediaPosition;
1889 return lenBTRCoreRet;
1896 tBTRCoreAVMediaHdl hBTRCoreAVM,
1897 const char* apBtDevAddr,
1898 const char* mediaPropertyKey,
1899 void* mediaPropertyValue
1902 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1904 if (!hBTRCoreAVM || !apBtDevAddr) {
1905 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
1906 return enBTRCoreInvalidArg;
1911 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
1915 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
1916 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
1917 return enBTRCoreFailure;
1922 BTRCORELOG_ERROR (
"Failed to get Media Property : %s!!!",mediaPropertyKey);
1923 lenBTRCoreRet = enBTRCoreFailure;
1926 return lenBTRCoreRet;
1932 tBTRCoreAVMediaHdl hBTRCoreAVM,
1933 const char* apBtDevAddr,
1934 tBTRCoreAVMediaElementId aBtrAVMediaElementId,
1935 eBTRCoreAVMElementType aeBtrAVMElementType
1937 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1940 const char* lpBtMediaFolderPath = NULL;
1942 if (!hBTRCoreAVM || !apBtDevAddr) {
1943 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
1944 return enBTRCoreInvalidArg;
1949 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
1953 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
1954 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
1955 return enBTRCoreFailure;
1959 if (!pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaPlayerBrowsable) {
1960 BTRCORELOG_ERROR (
"Connected Media is not Browsable!\n");
1961 return enBTRCoreFailure;
1966 if (!(aBtrAVMediaElementId & BTR_MEDIA_PLAYLIST_ID)) {
1968 if ((ptr = pstlhBTRCoreAVM->pstAVMediaBrowser)) {
1970 if (ptr->ui32AVMediaItemId == aBtrAVMediaElementId) {
1971 lpBtMediaFolderPath = ptr->pcAVMediaItemPath;
1974 if (!lpBtMediaFolderPath && ptr->pvAVMediaParentItem) {
1975 if (((
stBTRCoreAVMediaItem*)(ptr->pvAVMediaParentItem))->ui32AVMediaItemId == aBtrAVMediaElementId) {
1976 lpBtMediaFolderPath = (
char*)((
stBTRCoreAVMediaItem*)(ptr->pvAVMediaParentItem))->pcAVMediaItemPath;
1977 ptr = ptr->pvAVMediaParentItem;
1981 if (!lpBtMediaFolderPath) {
1982 if (ptr->ui32AVMediaNumberOfItems && ptr->pstAVMediaSubItems) {
1983 unsigned int ui32LoopIdx = 0;
1985 while (ui32LoopIdx < ptr->ui32AVMediaNumberOfItems) {
1986 if (ptr->pstAVMediaSubItems[ui32LoopIdx]->ui32AVMediaItemId == aBtrAVMediaElementId) {
1987 lpBtMediaFolderPath = ptr->pstAVMediaSubItems[ui32LoopIdx]->pcAVMediaItemPath;
1995 if (!lpBtMediaFolderPath) {
1996 while (ptr->pvAVMediaParentItem) {
1997 ptr = ptr->pvAVMediaParentItem;
2000 if (!btrCore_AVMedia_FindMediaItem (ptr, aBtrAVMediaElementId, &ptr)) {
2003 lpBtMediaFolderPath = ptr->pcAVMediaItemPath;
2004 if (btrCore_AVMedia_SwitchToMediaBrowserItem (pstlhBTRCoreAVM, ptr)) {
2005 BTRCORELOG_ERROR (
"Switching to MediaBrowserItem(%llu) Failed!\n", ptr->ui32AVMediaItemId);
2006 lenBTRCoreRet = enBTRCoreFailure;
2010 BTRCORELOG_ERROR (
"Media Item(%llu) Not Found!\n", aBtrAVMediaElementId);
2011 lenBTRCoreRet = enBTRCoreFailure;
2015 BTRCORELOG_ERROR (
"Failed to Find Media Item(%llu) !\n", aBtrAVMediaElementId);
2016 lenBTRCoreRet = enBTRCoreFailure;
2021 BTRCORELOG_ERROR (
"Media Browser Error - No parent Filesystem !\n");
2022 lenBTRCoreRet = enBTRCoreFailure;
2026 if (pstlhBTRCoreAVM->pstAVMediaPlayList) {
2027 lpBtMediaFolderPath = pstlhBTRCoreAVM->pstAVMediaPlayList->pcAVMediaItemPath;
2030 BTRCORELOG_ERROR (
"PlayList not found for Item : %llu !\n", aBtrAVMediaElementId);
2031 lenBTRCoreRet = enBTRCoreFailure;
2036 if (!lpBtMediaFolderPath) {
2037 BTRCORELOG_ERROR (
"Media Browser Error - cannot find item : %llu\n", aBtrAVMediaElementId);
2038 lenBTRCoreRet = enBTRCoreFailure;
2041 if (lenBTRCoreRet == enBTRCoreSuccess &&
2043 BTRCORELOG_ERROR (
"Failed to change Browser Location to %s(%llu) !\n", lpBtMediaFolderPath, aBtrAVMediaElementId);
2044 lenBTRCoreRet = enBTRCoreFailure;
2047 return lenBTRCoreRet;
2053 tBTRCoreAVMediaHdl hBTRCoreAVM,
2054 const char* apBtDevAddr,
2055 unsigned short aui16StartIdx,
2056 unsigned short aui16EndIdx
2058 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
2060 unsigned int ui32NumberOfItems = 0;
2062 if (!hBTRCoreAVM || !apBtDevAddr) {
2063 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2064 return enBTRCoreInvalidArg;
2069 if (!pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
2073 if (!lpcAVMediaPlayerPath || !(pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(lpcAVMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1))) {
2074 BTRCORELOG_ERROR (
"Failed to get Media Player Object!!!");
2075 return enBTRCoreFailure;
2079 if (!pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaPlayerBrowsable) {
2080 BTRCORELOG_ERROR (
"Connected Media is not Browsable!\n");
2081 return enBTRCoreFailure;
2086 BTRCORELOG_DEBUG (
"Number Of Items : %u\n", ui32NumberOfItems);
2087 if (ui32NumberOfItems && aui16EndIdx > ui32NumberOfItems) {
2088 aui16EndIdx = ui32NumberOfItems;
2092 BTRCORELOG_WARN (
"Couldn't get No. Of Items in current Browser location!\n");
2096 if (aui16StartIdx <= aui16EndIdx) {
2097 BTRCORELOG_DEBUG (
"Querying to list browser items from %u to %u\n", aui16StartIdx, aui16EndIdx);
2100 BTRCORELOG_ERROR (
"Failed to List Browser Items!\n");
2101 lenBTRCoreRet = enBTRCoreFailure;
2105 BTRCORELOG_ERROR (
"List indices not in Range!\n");
2106 lenBTRCoreRet = enBTRCoreFailure;
2110 int ui32sleepIdx = 10;
2112 while (ui32sleepIdx-- && pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaBrowserItem->ui32AVMediaNumberOfItems < aui16EndIdx) {
2117 return lenBTRCoreRet;
2122 tBTRCoreAVMediaHdl hBTRCoreAVM,
2123 const char* apBtDevAddr,
2124 tBTRCoreAVMediaElementId aBtrAVMediaElementId,
2125 unsigned short aui16StartIdx,
2126 unsigned short aui16EndIdx,
2127 eBTRCoreAVMElementType aeBtrAVMElementType,
2132 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
2134 if (!hBTRCoreAVM || !apBtDevAddr || !aAVMediaElementInfoList ||
2135 aui16EndIdx < aui16StartIdx) {
2136 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2137 return enBTRCoreInvalidArg;
2140 if (aui16EndIdx - aui16StartIdx > BTR_AV_MEDIA_ELEMENT_MAX -1) {
2141 aui16EndIdx = aui16StartIdx + BTR_AV_MEDIA_ELEMENT_MAX -1;
2146 if (!(lpstBtAVMediaItem = lpstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaBrowserItem)) {
2147 BTRCORELOG_ERROR (
"Media Browser Error - browsing handle is NULL!\n");
2148 return lenBTRCoreRet;
2151 if (lpstBtAVMediaItem->ui32AVMediaItemId != aBtrAVMediaElementId) {
2153 BTRCORELOG_WARN (
"Media Browser Error - Media ElementID(%llu) didn't match!\n", aBtrAVMediaElementId);
2156 while (ptr->pvAVMediaParentItem) {
2157 ptr = ptr->pvAVMediaParentItem;
2160 if (btrCore_AVMedia_FindMediaItem (ptr, aBtrAVMediaElementId, &lpstBtAVMediaItem)) {
2161 BTRCORELOG_ERROR (
"Failed to Find MediaTrack by Id(%llu) !\n", aBtrAVMediaElementId);
2166 if (!lpstBtAVMediaItem) {
2167 return lenBTRCoreRet;
2170 if (lpstBtAVMediaItem->bIsMediaItemPlayable) {
2171 BTRCORELOG_ERROR (
"Media Browser Error - Its a Playable Item!\n");
2172 return lenBTRCoreRet;
2175 if (lpstBtAVMediaItem->pstAVMediaSubItems) {
2176 unsigned short m_numOfElements = 0;
2180 while (aui16StartIdx <= aui16EndIdx && aui16StartIdx < lpstBtAVMediaItem->ui32AVMediaNumberOfItems && lpstBtAVMediaItem->pstAVMediaSubItems[aui16StartIdx]) {
2182 if ((aeBtrAVMElementType == eBTRCoreAVMETypeUnknown) || (aeBtrAVMElementType == lpstBtAVMediaItem->pstAVMediaSubItems[aui16StartIdx]->eMediaItemType)) {
2183 if (aeBtrAVMElementType == eBTRCoreAVMETypeUnknown) {
2184 aAVMediaElementInfoList->m_mediaElementInfo[m_numOfElements].eAVMElementType = eBTRCoreAVMETypeTrackList;
2187 aAVMediaElementInfoList->m_mediaElementInfo[m_numOfElements].eAVMElementType = lpstBtAVMediaItem->eMediaItemType;
2190 aAVMediaElementInfoList->m_mediaElementInfo[m_numOfElements].ui32AVMediaElementId = lpstBtAVMediaItem->pstAVMediaSubItems[aui16StartIdx]->ui32AVMediaItemId;
2191 aAVMediaElementInfoList->m_mediaElementInfo[m_numOfElements].bIsPlayable = lpstBtAVMediaItem->pstAVMediaSubItems[aui16StartIdx]->bIsMediaItemPlayable;
2192 strncpy(aAVMediaElementInfoList->m_mediaElementInfo[m_numOfElements].m_mediaElementName, lpstBtAVMediaItem->pstAVMediaSubItems[aui16StartIdx]->pcAVMediaItemName, BTRCORE_MAX_STR_LEN -1);
2193 memcpy (&aAVMediaElementInfoList->m_mediaElementInfo[m_numOfElements++].m_mediaTrackInfo, &lpstBtAVMediaItem->pstAVMediaSubItems[aui16StartIdx++]->mediaTrackInfo,
sizeof(
stBTRCoreAVMediaTrackInfo));
2199 aAVMediaElementInfoList->m_numOfElements = m_numOfElements;
2200 lenBTRCoreRet = enBTRCoreSuccess;
2201 BTRCORELOG_INFO (
"Number of MediaItems retrived : %d\n", aAVMediaElementInfoList->m_numOfElements);
2204 BTRCORELOG_ERROR (
"Media Browser Error - NumOfItems : %d | SubItems : %p\n", lpstBtAVMediaItem->ui32AVMediaNumberOfItems, lpstBtAVMediaItem->pstAVMediaSubItems);
2207 return lenBTRCoreRet;
2213 tBTRCoreAVMediaHdl hBTRCoreAVM,
2214 const char* apBtDevAddr,
2215 tBTRCoreAVMediaElementId aBtrAVMediaItemId
2220 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
2222 if (!hBTRCoreAVM || !apBtDevAddr) {
2223 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2224 return enBTRCoreInvalidArg;
2230 if (!(ptrBsr = (aBtrAVMediaItemId & BTR_MEDIA_PLAYLIST_ID)? pstlhBTRCoreAVM->pstAVMediaPlayList : pstlhBTRCoreAVM->pstAVMediaBrowser)) {
2231 BTRCORELOG_ERROR (
"Media Browser doesn't exist!\n");
2232 return lenBTRCoreRet;
2235 if (btrCore_AVMedia_FindMediaItem (ptrBsr, aBtrAVMediaItemId, &ptrTrack)) {
2236 BTRCORELOG_ERROR (
"Failed to Search MediaTrack by Id(%llu) !\n", aBtrAVMediaItemId);
2237 return lenBTRCoreRet;
2241 if (ptrTrack->bIsMediaItemPlayable) {
2242 if (ptrTrack->pcAVMediaItemPath[0]) {
2244 BTRCORELOG_ERROR (
"Failed to Play Media Track Item(%llu) %s !\n", aBtrAVMediaItemId, ptrTrack->pcAVMediaItemPath);
2247 lenBTRCoreRet = enBTRCoreSuccess;
2251 BTRCORELOG_ERROR (
"Media Item Path is not present!\n");
2255 BTRCORELOG_ERROR (
"Media Item %llu is not Playable!\n", aBtrAVMediaItemId);
2259 BTRCORELOG_ERROR (
"Media Track Item(%llu) not found!\n", aBtrAVMediaItemId);
2262 return lenBTRCoreRet;
2268 tBTRCoreAVMediaHdl hBTRCoreAVM,
2269 const char* apBtDevAddr,
2270 tBTRCoreAVMediaElementId aBtrAVMediaItemId
2276 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
2278 if (!hBTRCoreAVM || !apBtDevAddr) {
2279 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2280 return enBTRCoreInvalidArg;
2283 BTRCORELOG_DEBUG (
" SetTrack Entered \n");
2286 if (!(ptrBsr = (aBtrAVMediaItemId & BTR_MEDIA_PLAYLIST_ID)? pstlhBTRCoreAVM->pstAVMediaPlayList : pstlhBTRCoreAVM->pstAVMediaBrowser)) {
2287 BTRCORELOG_ERROR (
"Media Browser doesn't exist!\n");
2288 return lenBTRCoreRet;
2291 if (btrCore_AVMedia_FindMediaItem (ptrBsr, aBtrAVMediaItemId, &ptrTrack)) {
2292 BTRCORELOG_ERROR (
"Failed to Search MediaTrack by Id(%llu) !\n", aBtrAVMediaItemId);
2293 return lenBTRCoreRet;
2298 if (ptrTrack->bIsMediaItemPlayable) {
2299 if (ptrTrack->pcAVMediaItemPath[0]) {
2303 BTRCORELOG_ERROR (
"Failed to get media info!!!");
2304 lenBTRCoreRet = enBTRCoreFailure;
2306 pstlhBTRCoreAVM->SelectedaBtrAVMediaItemId = aBtrAVMediaItemId;
2309 BTRCORELOG_DEBUG (
" Get track info success ");
2310 lenBTRCoreRet = enBTRCoreSuccess;
2314 BTRCORELOG_ERROR (
"Media Item Path is not present!\n");
2318 BTRCORELOG_ERROR (
"Media Item %llu is not Playable!\n", aBtrAVMediaItemId);
2322 BTRCORELOG_ERROR (
"Media Track Item(%llu) not found!\n", aBtrAVMediaItemId);
2325 return lenBTRCoreRet;
2331 tBTRCoreAVMediaHdl hBTRCoreAVM,
2332 const char* apBtDevAddr,
2333 tBTRCoreAVMediaElementId aBtrAVMediaItemId,
2339 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
2341 if (!hBTRCoreAVM || !apBtDevAddr) {
2342 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2343 return enBTRCoreInvalidArg;
2349 if (aBtrAVMediaItemId & BTR_MEDIA_PLAYLIST_ID) {
2350 lpstBtAVMBrowser = lpstlhBTRCoreAVM->pstAVMediaPlayList;
2353 lpstBtAVMBrowser = lpstlhBTRCoreAVM->pstAVMediaBrowser;
2354 while (lpstBtAVMBrowser->pvAVMediaParentItem) {
2355 lpstBtAVMBrowser = lpstBtAVMBrowser->pvAVMediaParentItem;
2359 if (!lpstBtAVMBrowser) {
2360 BTRCORELOG_ERROR (
"Media Browser doesn't exist!\n");
2361 return lenBTRCoreRet;
2364 if (btrCore_AVMedia_FindMediaItem (lpstBtAVMBrowser, aBtrAVMediaItemId, &lpstBtAVMItem)) {
2365 BTRCORELOG_ERROR (
"Failed to Search MediaTrack by Id(%llu) !\n", aBtrAVMediaItemId);
2366 return lenBTRCoreRet;
2369 if (lpstBtAVMItem) {
2370 if ((*isPlayable = lpstBtAVMItem->bIsMediaItemPlayable)) {
2371 BTRCORELOG_DEBUG (
"Its a playable Media Item\n");
2374 BTRCORELOG_DEBUG (
"Its a non-playable Media Item\n");
2376 lenBTRCoreRet = enBTRCoreSuccess;
2379 BTRCORELOG_ERROR (
"Media Item(%llu) not found!\n", aBtrAVMediaItemId);
2383 return lenBTRCoreRet;
2389 tBTRCoreAVMediaHdl hBTRCoreAVM,
2390 fPtr_BTRCore_AVMediaStatusUpdateCb afpcBBTRCoreAVMediaStatusUpdate,
2391 void* apvBMediaStatusUserData
2395 if (!hBTRCoreAVM || !afpcBBTRCoreAVMediaStatusUpdate) {
2396 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2397 return enBTRCoreInvalidArg;
2402 pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate = afpcBBTRCoreAVMediaStatusUpdate;
2403 pstlhBTRCoreAVM->pcBMediaStatusUserData = apvBMediaStatusUserData;
2405 return enBTRCoreSuccess;
2411 btrCore_AVMedia_NegotiateMediaCb (
2412 void* apBtMediaCapsInput,
2413 void** appBtMediaCapsOutput,
2420 if (!apBtMediaCapsInput) {
2421 BTRCORELOG_ERROR (
"Invalid input MT Media Capabilities\n");
2428 if (aenBTMediaType == enBTMediaTypeSBC) {
2429 a2dp_sbc_t* apBtMediaSBCCaps = (a2dp_sbc_t*)apBtMediaCapsInput;
2430 a2dp_sbc_t lstBTMediaSbcConfig;
2432 memset(&lstBTMediaSbcConfig, 0,
sizeof(a2dp_sbc_t));
2435 lstBTMediaSbcConfig.frequency = pstlhBTRCoreAVM->iBTMediaDefSampFreqPref;
2437 if (apBtMediaSBCCaps->frequency & BTR_SBC_SAMPLING_FREQ_48000) {
2438 lstBTMediaSbcConfig.frequency = BTR_SBC_SAMPLING_FREQ_48000;
2440 else if (apBtMediaSBCCaps->frequency & BTR_SBC_SAMPLING_FREQ_44100) {
2441 lstBTMediaSbcConfig.frequency = BTR_SBC_SAMPLING_FREQ_44100;
2443 else if (apBtMediaSBCCaps->frequency & BTR_SBC_SAMPLING_FREQ_32000) {
2444 lstBTMediaSbcConfig.frequency = BTR_SBC_SAMPLING_FREQ_32000;
2446 else if (apBtMediaSBCCaps->frequency & BTR_SBC_SAMPLING_FREQ_16000) {
2447 lstBTMediaSbcConfig.frequency = BTR_SBC_SAMPLING_FREQ_16000;
2450 BTRCORELOG_ERROR (
"No supported frequency\n");
2455 if (apBtMediaSBCCaps->channel_mode & BTR_SBC_CHANNEL_MODE_JOINT_STEREO) {
2456 lstBTMediaSbcConfig.channel_mode = BTR_SBC_CHANNEL_MODE_JOINT_STEREO;
2458 else if (apBtMediaSBCCaps->channel_mode & BTR_SBC_CHANNEL_MODE_STEREO) {
2459 lstBTMediaSbcConfig.channel_mode = BTR_SBC_CHANNEL_MODE_STEREO;
2461 else if (apBtMediaSBCCaps->channel_mode & BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL) {
2462 lstBTMediaSbcConfig.channel_mode = BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL;
2464 else if (apBtMediaSBCCaps->channel_mode & BTR_SBC_CHANNEL_MODE_MONO) {
2465 lstBTMediaSbcConfig.channel_mode = BTR_SBC_CHANNEL_MODE_MONO;
2468 BTRCORELOG_ERROR (
"No supported channel modes\n");
2472 if (apBtMediaSBCCaps->block_length & BTR_SBC_BLOCK_LENGTH_16) {
2473 lstBTMediaSbcConfig.block_length = BTR_SBC_BLOCK_LENGTH_16;
2475 else if (apBtMediaSBCCaps->block_length & BTR_SBC_BLOCK_LENGTH_12) {
2476 lstBTMediaSbcConfig.block_length = BTR_SBC_BLOCK_LENGTH_12;
2478 else if (apBtMediaSBCCaps->block_length & BTR_SBC_BLOCK_LENGTH_8) {
2479 lstBTMediaSbcConfig.block_length = BTR_SBC_BLOCK_LENGTH_8;
2481 else if (apBtMediaSBCCaps->block_length & BTR_SBC_BLOCK_LENGTH_4) {
2482 lstBTMediaSbcConfig.block_length = BTR_SBC_BLOCK_LENGTH_4;
2485 BTRCORELOG_ERROR (
"No supported block lengths\n");
2489 if (apBtMediaSBCCaps->subbands & BTR_SBC_SUBBANDS_8) {
2490 lstBTMediaSbcConfig.subbands = BTR_SBC_SUBBANDS_8;
2492 else if (apBtMediaSBCCaps->subbands & BTR_SBC_SUBBANDS_4) {
2493 lstBTMediaSbcConfig.subbands = BTR_SBC_SUBBANDS_4;
2496 BTRCORELOG_ERROR (
"No supported subbands\n");
2500 if (apBtMediaSBCCaps->allocation_method & BTR_SBC_ALLOCATION_LOUDNESS) {
2501 lstBTMediaSbcConfig.allocation_method = BTR_SBC_ALLOCATION_LOUDNESS;
2503 else if (apBtMediaSBCCaps->allocation_method & BTR_SBC_ALLOCATION_SNR) {
2504 lstBTMediaSbcConfig.allocation_method = BTR_SBC_ALLOCATION_SNR;
2507 lstBTMediaSbcConfig.min_bitpool = (uint8_t) MAX(MIN_BITPOOL, apBtMediaSBCCaps->min_bitpool);
2508 lstBTMediaSbcConfig.max_bitpool = (uint8_t) MIN(btrCore_AVMedia_GetA2DPDefaultBitpool(lstBTMediaSbcConfig.frequency,
2509 lstBTMediaSbcConfig.channel_mode),
2510 apBtMediaSBCCaps->max_bitpool);
2512 BTRCORELOG_TRACE(
"Negotiated Configuration\n");
2513 BTRCORELOG_INFO (
"channel_mode = %d\n", lstBTMediaSbcConfig.channel_mode);
2514 BTRCORELOG_INFO (
"frequency = %d\n", lstBTMediaSbcConfig.frequency);
2515 BTRCORELOG_INFO (
"allocation_method = %d\n", lstBTMediaSbcConfig.allocation_method);
2516 BTRCORELOG_INFO (
"subbands = %d\n", lstBTMediaSbcConfig.subbands);
2517 BTRCORELOG_INFO (
"block_length = %d\n", lstBTMediaSbcConfig.block_length);
2518 BTRCORELOG_INFO (
"min_bitpool = %d\n", lstBTMediaSbcConfig.min_bitpool);
2519 BTRCORELOG_INFO (
"max_bitpool = %d\n", lstBTMediaSbcConfig.max_bitpool);
2521 if (pstlhBTRCoreAVM) {
2522 a2dp_sbc_t* lpstBTAVMMediaSbcConfigOut = (a2dp_sbc_t*)pstlhBTRCoreAVM->pstBTMediaConfigOut;
2523 a2dp_sbc_t* lpstBTAVMMediaSbcConfigIn = (a2dp_sbc_t*)pstlhBTRCoreAVM->pstBTMediaConfigIn;
2525 if (lpstBTAVMMediaSbcConfigOut &&
2526 (aenBTDeviceType == enBTDevAudioSink) &&
2527 (pstlhBTRCoreAVM->eAVMediaTypeOut != eBTRCoreAVMTypeSBC)) {
2528 pstlhBTRCoreAVM->eAVMediaTypeOut = eBTRCoreAVMTypeSBC;
2529 lpstBTAVMMediaSbcConfigOut->channel_mode = lstBTMediaSbcConfig.channel_mode;
2530 lpstBTAVMMediaSbcConfigOut->frequency = lstBTMediaSbcConfig.frequency;
2531 lpstBTAVMMediaSbcConfigOut->allocation_method = lstBTMediaSbcConfig.allocation_method;
2532 lpstBTAVMMediaSbcConfigOut->subbands = lstBTMediaSbcConfig.subbands;
2533 lpstBTAVMMediaSbcConfigOut->block_length = lstBTMediaSbcConfig.block_length;
2534 lpstBTAVMMediaSbcConfigOut->min_bitpool = lstBTMediaSbcConfig.min_bitpool;
2535 lpstBTAVMMediaSbcConfigOut->max_bitpool = lstBTMediaSbcConfig.max_bitpool;
2537 *appBtMediaCapsOutput = (
void*)lpstBTAVMMediaSbcConfigOut;
2540 if (lpstBTAVMMediaSbcConfigIn &&
2541 (aenBTDeviceType == enBTDevAudioSource) &&
2542 (pstlhBTRCoreAVM->eAVMediaTypeIn != eBTRCoreAVMTypeSBC)) {
2543 pstlhBTRCoreAVM->eAVMediaTypeIn = eBTRCoreAVMTypeSBC;
2544 lpstBTAVMMediaSbcConfigIn->channel_mode = lstBTMediaSbcConfig.channel_mode;
2545 lpstBTAVMMediaSbcConfigIn->frequency = lstBTMediaSbcConfig.frequency;
2546 lpstBTAVMMediaSbcConfigIn->allocation_method = lstBTMediaSbcConfig.allocation_method;
2547 lpstBTAVMMediaSbcConfigIn->subbands = lstBTMediaSbcConfig.subbands;
2548 lpstBTAVMMediaSbcConfigIn->block_length = lstBTMediaSbcConfig.block_length;
2549 lpstBTAVMMediaSbcConfigIn->min_bitpool = lstBTMediaSbcConfig.min_bitpool;
2550 lpstBTAVMMediaSbcConfigIn->max_bitpool = lstBTMediaSbcConfig.max_bitpool;
2552 *appBtMediaCapsOutput = (
void*)lpstBTAVMMediaSbcConfigIn;
2556 else if (aenBTMediaType == enBTMediaTypePCM) {
2559 else if (aenBTMediaType == enBTMediaTypeAAC) {
2560 #if defined(AAC_SUPPORTED)
2561 a2dp_aac_t* apBtMediaAACCaps = (a2dp_aac_t*)apBtMediaCapsInput;
2562 a2dp_aac_t lstBTMediaAacConfig;
2563 unsigned short ui16AacInFreq = 0;
2564 unsigned short ui16AacOutFreq = 0;
2565 unsigned short ui16AacInBitrate= 0;
2566 unsigned short ui16AacOutBitrate= 0;
2568 memset(&lstBTMediaAacConfig, 0,
sizeof(a2dp_aac_t));
2570 ui16AacInFreq = BTR_AAC_GET_FREQ(*apBtMediaAACCaps);
2571 if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_8000) {
2572 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_8000;
2574 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_11025) {
2575 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_11025;
2577 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_12000) {
2578 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_12000;
2580 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_16000) {
2581 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_16000;
2583 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_22050) {
2584 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_22050;
2586 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_24000) {
2587 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_24000;
2589 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_32000) {
2590 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_32000;
2592 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_44100) {
2593 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_44100;
2595 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_48000) {
2596 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_48000;
2598 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_64000) {
2599 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_64000;
2601 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_88200) {
2602 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_88200;
2604 else if (ui16AacInFreq & BTR_AAC_SAMPLING_FREQ_96000) {
2605 ui16AacOutFreq = BTR_AAC_SAMPLING_FREQ_96000;
2608 BTRCORELOG_ERROR (
"No supported frequency\n");
2612 BTR_AAC_SET_FREQ(lstBTMediaAacConfig, ui16AacOutFreq);
2614 ui16AacInBitrate = BTR_AAC_GET_BITRATE(*apBtMediaAACCaps);
2615 if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_VBR) {
2616 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_VBR;
2618 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_320000) {
2619 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_320000;
2621 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_256000) {
2622 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_256000;
2624 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_224000) {
2625 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_224000;
2627 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_192000) {
2628 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_192000;
2630 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_160000) {
2631 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_160000;
2633 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_128000) {
2634 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_128000;
2636 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_112000) {
2637 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_112000;
2639 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_96000) {
2640 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_96000;
2642 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_80000) {
2643 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_80000;
2645 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_64000) {
2646 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_64000;
2648 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_56000) {
2649 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_56000;
2651 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_48000) {
2652 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_48000;
2654 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_40000) {
2655 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_40000;
2657 else if (ui16AacInBitrate & BTR_MPEG_BIT_RATE_32000) {
2658 ui16AacOutBitrate = BTR_MPEG_BIT_RATE_32000;
2661 BTRCORELOG_ERROR (
"No supported bitrate\n");
2665 BTR_AAC_SET_BITRATE(lstBTMediaAacConfig, ui16AacOutBitrate);
2668 if (apBtMediaAACCaps->object_type & BTR_AAC_OT_MPEG2_AAC_LC) {
2669 lstBTMediaAacConfig.object_type = BTR_AAC_OT_MPEG2_AAC_LC;
2671 else if (apBtMediaAACCaps->object_type & BTR_AAC_OT_MPEG4_AAC_LC) {
2672 lstBTMediaAacConfig.object_type = BTR_AAC_OT_MPEG4_AAC_LC;
2674 else if (apBtMediaAACCaps->object_type & BTR_AAC_OT_MPEG4_AAC_LTP) {
2675 lstBTMediaAacConfig.object_type = BTR_AAC_OT_MPEG4_AAC_LTP;
2677 else if (apBtMediaAACCaps->object_type & BTR_AAC_OT_MPEG4_AAC_SCA) {
2678 lstBTMediaAacConfig.object_type = BTR_AAC_OT_MPEG4_AAC_SCA;
2681 BTRCORELOG_ERROR (
"No supported aac object type\n");
2686 if (apBtMediaAACCaps->channels & BTR_AAC_CHANNELS_1) {
2687 lstBTMediaAacConfig.channels = BTR_AAC_CHANNELS_1;
2689 else if (apBtMediaAACCaps->channels & BTR_AAC_CHANNELS_2) {
2690 lstBTMediaAacConfig.channels = BTR_AAC_CHANNELS_2;
2693 BTRCORELOG_ERROR (
"No supported aac channel\n");
2697 lstBTMediaAacConfig.vbr = apBtMediaAACCaps->vbr;
2698 lstBTMediaAacConfig.rfa = apBtMediaAACCaps->rfa;
2701 BTRCORELOG_TRACE(
"Negotiated Configuration\n");
2702 BTRCORELOG_INFO (
"object_type = %d\n", lstBTMediaAacConfig.object_type);
2703 BTRCORELOG_INFO (
"frequency1 = %d\n", lstBTMediaAacConfig.frequency1);
2704 BTRCORELOG_INFO (
"rfa = %d\n", lstBTMediaAacConfig.rfa);
2705 BTRCORELOG_INFO (
"channels = %d\n", lstBTMediaAacConfig.channels);
2706 BTRCORELOG_INFO (
"frequency2 = %d\n", lstBTMediaAacConfig.frequency2);
2707 BTRCORELOG_INFO (
"bitrate1 = %d\n", lstBTMediaAacConfig.bitrate1);
2708 BTRCORELOG_INFO (
"vbr = %d\n", lstBTMediaAacConfig.vbr);
2709 BTRCORELOG_INFO (
"bitrate2 = %d\n", lstBTMediaAacConfig.bitrate2);
2710 BTRCORELOG_INFO (
"bitrate3 = %d\n", lstBTMediaAacConfig.bitrate3);
2712 if (pstlhBTRCoreAVM) {
2713 a2dp_aac_t* lpstBTAVMMediaAacConfigOut = (a2dp_aac_t*)pstlhBTRCoreAVM->pstBTMediaConfigOut;
2714 a2dp_aac_t* lpstBTAVMMediaAacConfigIn = (a2dp_aac_t*)pstlhBTRCoreAVM->pstBTMediaConfigIn;
2716 if (lpstBTAVMMediaAacConfigOut &&
2717 (aenBTDeviceType == enBTDevAudioSink) &&
2718 (pstlhBTRCoreAVM->eAVMediaTypeOut != eBTRCoreAVMTypeAAC)) {
2719 pstlhBTRCoreAVM->eAVMediaTypeOut = eBTRCoreAVMTypeAAC;
2720 lpstBTAVMMediaAacConfigOut->object_type = lstBTMediaAacConfig.object_type;
2721 lpstBTAVMMediaAacConfigOut->frequency1 = lstBTMediaAacConfig.frequency1;
2722 lpstBTAVMMediaAacConfigOut->rfa = lstBTMediaAacConfig.rfa;
2723 lpstBTAVMMediaAacConfigOut->channels = lstBTMediaAacConfig.channels;
2724 lpstBTAVMMediaAacConfigOut->frequency2 = lstBTMediaAacConfig.frequency2;
2725 lpstBTAVMMediaAacConfigOut->bitrate1 = lstBTMediaAacConfig.bitrate1;
2726 lpstBTAVMMediaAacConfigOut->vbr = lstBTMediaAacConfig.vbr;
2727 lpstBTAVMMediaAacConfigOut->bitrate2 = lstBTMediaAacConfig.bitrate2;
2728 lpstBTAVMMediaAacConfigOut->bitrate3 = lstBTMediaAacConfig.bitrate3;
2730 *appBtMediaCapsOutput = (
void*)lpstBTAVMMediaAacConfigOut;
2733 if (lpstBTAVMMediaAacConfigIn &&
2734 (aenBTDeviceType == enBTDevAudioSource) &&
2735 (pstlhBTRCoreAVM->eAVMediaTypeIn != eBTRCoreAVMTypeAAC)) {
2736 pstlhBTRCoreAVM->eAVMediaTypeIn = eBTRCoreAVMTypeAAC;
2737 lpstBTAVMMediaAacConfigIn->object_type = lstBTMediaAacConfig.object_type;
2738 lpstBTAVMMediaAacConfigIn->frequency1 = lstBTMediaAacConfig.frequency1;
2739 lpstBTAVMMediaAacConfigIn->rfa = lstBTMediaAacConfig.rfa;
2740 lpstBTAVMMediaAacConfigIn->channels = lstBTMediaAacConfig.channels;
2741 lpstBTAVMMediaAacConfigIn->frequency2 = lstBTMediaAacConfig.frequency2;
2742 lpstBTAVMMediaAacConfigIn->bitrate1 = lstBTMediaAacConfig.bitrate1;
2743 lpstBTAVMMediaAacConfigIn->vbr = lstBTMediaAacConfig.vbr;
2744 lpstBTAVMMediaAacConfigIn->bitrate2 = lstBTMediaAacConfig.bitrate2;
2745 lpstBTAVMMediaAacConfigIn->bitrate3 = lstBTMediaAacConfig.bitrate3;
2747 *appBtMediaCapsOutput = (
void*)lpstBTAVMMediaAacConfigIn;
2752 else if (aenBTMediaType == enBTMediaTypeMP3) {
2756 return *appBtMediaCapsOutput ? 0 : -1;
2761 btrCore_AVMedia_TransportPathCb (
2762 const char* apBtMediaTransportPath,
2763 const char* apBtMediaUuid,
2764 void* apBtMediaCaps,
2772 if (!apBtMediaTransportPath) {
2773 BTRCORELOG_ERROR (
"Invalid transport path\n");
2779 if (apBtMediaCaps && apBtMediaUuid) {
2780 if (aenBTMediaType == enBTMediaTypeSBC) {
2781 a2dp_sbc_t* apBtMediaSBCCaps = NULL;
2782 a2dp_sbc_t lstBTMediaSbcConfig;
2784 apBtMediaSBCCaps = (a2dp_sbc_t*)apBtMediaCaps;
2786 lstBTMediaSbcConfig.channel_mode = apBtMediaSBCCaps->channel_mode;
2787 lstBTMediaSbcConfig.frequency = apBtMediaSBCCaps->frequency;
2788 lstBTMediaSbcConfig.allocation_method = apBtMediaSBCCaps->allocation_method;
2789 lstBTMediaSbcConfig.subbands = apBtMediaSBCCaps->subbands;
2790 lstBTMediaSbcConfig.block_length = apBtMediaSBCCaps->block_length;
2792 if (apBtMediaSBCCaps->min_bitpool == MIN_BITPOOL)
2793 lstBTMediaSbcConfig.min_bitpool = (uint8_t) MAX(MIN_BITPOOL, apBtMediaSBCCaps->min_bitpool);
2795 lstBTMediaSbcConfig.min_bitpool = apBtMediaSBCCaps->min_bitpool;
2797 if (apBtMediaSBCCaps->max_bitpool == MAX_BITPOOL)
2798 lstBTMediaSbcConfig.max_bitpool = (uint8_t) MIN(btrCore_AVMedia_GetA2DPDefaultBitpool(lstBTMediaSbcConfig.frequency,
2799 lstBTMediaSbcConfig.channel_mode),
2800 apBtMediaSBCCaps->max_bitpool);
2802 lstBTMediaSbcConfig.max_bitpool = apBtMediaSBCCaps->max_bitpool;
2804 BTRCORELOG_TRACE(
"Set Configuration\n");
2805 BTRCORELOG_INFO (
"channel_mode = %d\n", lstBTMediaSbcConfig.channel_mode);
2806 BTRCORELOG_INFO (
"frequency = %d\n", lstBTMediaSbcConfig.frequency);
2807 BTRCORELOG_INFO (
"allocation_method = %d\n", lstBTMediaSbcConfig.allocation_method);
2808 BTRCORELOG_INFO (
"subbands = %d\n", lstBTMediaSbcConfig.subbands);
2809 BTRCORELOG_INFO (
"block_length = %d\n", lstBTMediaSbcConfig.block_length);
2810 BTRCORELOG_INFO (
"min_bitpool = %d\n", lstBTMediaSbcConfig.min_bitpool);
2811 BTRCORELOG_INFO (
"max_bitpool = %d\n", lstBTMediaSbcConfig.max_bitpool);
2823 if (pstlhBTRCoreAVM) {
2824 a2dp_sbc_t* lpstBTAVMMediaSbcConfig = NULL;
2827 lpstBTAVMMediaSbcConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
2828 pstlhBTRCoreAVM->eAVMediaTypeOut = eBTRCoreAVMTypeSBC;
2830 BTRCORELOG_INFO (
"max_bitpool Incoming = %d Stored/Calculated = %d\n", lstBTMediaSbcConfig.max_bitpool, lpstBTAVMMediaSbcConfig->max_bitpool);
2831 if (lstBTMediaSbcConfig.frequency == BTR_SBC_SAMPLING_FREQ_44100) {
2833 lpstBTAVMMediaSbcConfig->frequency = BTR_SBC_SAMPLING_FREQ_48000;
2836 lpstBTAVMMediaSbcConfig->frequency = lstBTMediaSbcConfig.frequency;
2839 if (apBtMediaSBCCaps->max_bitpool == MAX_BITPOOL) {
2840 lpstBTAVMMediaSbcConfig->max_bitpool = (uint8_t) MIN(btrCore_AVMedia_GetA2DPDefaultBitpool(lpstBTAVMMediaSbcConfig->frequency,
2841 lstBTMediaSbcConfig.channel_mode),
2842 apBtMediaSBCCaps->max_bitpool);
2844 else if (lstBTMediaSbcConfig.max_bitpool < lpstBTAVMMediaSbcConfig->max_bitpool) {
2845 lpstBTAVMMediaSbcConfig->max_bitpool = lstBTMediaSbcConfig.max_bitpool;
2849 lpstBTAVMMediaSbcConfig = pstlhBTRCoreAVM->pstBTMediaConfigIn;
2850 pstlhBTRCoreAVM->eAVMediaTypeIn = eBTRCoreAVMTypeSBC;
2851 lpstBTAVMMediaSbcConfig->frequency = lstBTMediaSbcConfig.frequency;
2852 lpstBTAVMMediaSbcConfig->max_bitpool= lstBTMediaSbcConfig.max_bitpool;
2855 lpstBTAVMMediaSbcConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
2856 pstlhBTRCoreAVM->eAVMediaTypeOut = eBTRCoreAVMTypeSBC;
2857 if (lstBTMediaSbcConfig.frequency == BTR_SBC_SAMPLING_FREQ_44100) {
2859 lpstBTAVMMediaSbcConfig->frequency = BTR_SBC_SAMPLING_FREQ_48000;
2862 lpstBTAVMMediaSbcConfig->frequency = lstBTMediaSbcConfig.frequency;
2865 if (apBtMediaSBCCaps->max_bitpool == MAX_BITPOOL) {
2866 lpstBTAVMMediaSbcConfig->max_bitpool = (uint8_t) MIN(btrCore_AVMedia_GetA2DPDefaultBitpool(lpstBTAVMMediaSbcConfig->frequency,
2867 lstBTMediaSbcConfig.channel_mode),
2868 apBtMediaSBCCaps->max_bitpool);
2870 else if (lstBTMediaSbcConfig.max_bitpool < lpstBTAVMMediaSbcConfig->max_bitpool) {
2871 lpstBTAVMMediaSbcConfig->max_bitpool = lstBTMediaSbcConfig.max_bitpool;
2875 if (lpstBTAVMMediaSbcConfig) {
2876 lpstBTAVMMediaSbcConfig->channel_mode = lstBTMediaSbcConfig.channel_mode;
2877 lpstBTAVMMediaSbcConfig->allocation_method = lstBTMediaSbcConfig.allocation_method;
2878 lpstBTAVMMediaSbcConfig->subbands = lstBTMediaSbcConfig.subbands;
2879 lpstBTAVMMediaSbcConfig->block_length = lstBTMediaSbcConfig.block_length;
2880 lpstBTAVMMediaSbcConfig->min_bitpool = lstBTMediaSbcConfig.min_bitpool;
2885 else if (aenBTMediaType == enBTMediaTypePCM) {
2888 else if (aenBTMediaType == enBTMediaTypeAAC) {
2889 #if defined(AAC_SUPPORTED)
2890 a2dp_aac_t* apBtMediaAACCaps = NULL;
2891 a2dp_aac_t lstBTMediaAacConfig;
2893 apBtMediaAACCaps = (a2dp_aac_t*)apBtMediaCaps;
2895 lstBTMediaAacConfig.object_type = apBtMediaAACCaps->object_type;
2896 lstBTMediaAacConfig.frequency1 = apBtMediaAACCaps->frequency1;
2897 lstBTMediaAacConfig.rfa = apBtMediaAACCaps->rfa;
2898 lstBTMediaAacConfig.channels = apBtMediaAACCaps->channels;
2899 lstBTMediaAacConfig.frequency2 = apBtMediaAACCaps->frequency2;
2900 lstBTMediaAacConfig.bitrate1 = apBtMediaAACCaps->bitrate1;
2901 lstBTMediaAacConfig.vbr = apBtMediaAACCaps->vbr;
2902 lstBTMediaAacConfig.bitrate2 = apBtMediaAACCaps->bitrate2;
2903 lstBTMediaAacConfig.bitrate3 = apBtMediaAACCaps->bitrate3;
2905 BTRCORELOG_TRACE(
"Set Configuration\n");
2906 BTRCORELOG_INFO (
"object_type = %d\n", lstBTMediaAacConfig.object_type);
2907 BTRCORELOG_INFO (
"frequency1 = %d\n", lstBTMediaAacConfig.frequency1);
2908 BTRCORELOG_INFO (
"rfa = %d\n", lstBTMediaAacConfig.rfa);
2909 BTRCORELOG_INFO (
"channels = %d\n", lstBTMediaAacConfig.channels);
2910 BTRCORELOG_INFO (
"frequency2 = %d\n", lstBTMediaAacConfig.frequency2);
2911 BTRCORELOG_INFO (
"bitrate1 = %d\n", lstBTMediaAacConfig.bitrate1);
2912 BTRCORELOG_INFO (
"vbr = %d\n", lstBTMediaAacConfig.vbr);
2913 BTRCORELOG_INFO (
"bitrate2 = %d\n", lstBTMediaAacConfig.bitrate2);
2914 BTRCORELOG_INFO (
"bitrate3 = %d\n", lstBTMediaAacConfig.bitrate3);
2919 if (pstlhBTRCoreAVM) {
2920 a2dp_aac_t* lpstBTAVMMediaAacConfig = NULL;
2923 lpstBTAVMMediaAacConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
2924 pstlhBTRCoreAVM->eAVMediaTypeOut= eBTRCoreAVMTypeAAC;
2927 lpstBTAVMMediaAacConfig = pstlhBTRCoreAVM->pstBTMediaConfigIn;
2928 pstlhBTRCoreAVM->eAVMediaTypeIn = eBTRCoreAVMTypeAAC;
2931 lpstBTAVMMediaAacConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
2932 pstlhBTRCoreAVM->eAVMediaTypeOut= eBTRCoreAVMTypeAAC;
2935 if (lpstBTAVMMediaAacConfig) {
2936 lpstBTAVMMediaAacConfig->object_type = lstBTMediaAacConfig.object_type;
2937 lpstBTAVMMediaAacConfig->frequency1 = lstBTMediaAacConfig.frequency1;
2938 lpstBTAVMMediaAacConfig->rfa = lstBTMediaAacConfig.rfa;
2939 lpstBTAVMMediaAacConfig->channels = lstBTMediaAacConfig.channels;
2940 lpstBTAVMMediaAacConfig->frequency2 = lstBTMediaAacConfig.frequency2;
2941 lpstBTAVMMediaAacConfig->bitrate1 = lstBTMediaAacConfig.bitrate1;
2942 lpstBTAVMMediaAacConfig->vbr = lstBTMediaAacConfig.vbr;
2943 lpstBTAVMMediaAacConfig->bitrate2 = lstBTMediaAacConfig.bitrate2;
2944 lpstBTAVMMediaAacConfig->bitrate3 = lstBTMediaAacConfig.bitrate3;
2950 else if (aenBTMediaType == enBTMediaTypeMP3) {
2955 a2dp_sbc_t lstBtA2dpSbcCaps;
2956 lstBtA2dpSbcCaps.channel_mode = BTR_SBC_CHANNEL_MODE_MONO | BTR_SBC_CHANNEL_MODE_DUAL_CHANNEL |
2957 BTR_SBC_CHANNEL_MODE_STEREO | BTR_SBC_CHANNEL_MODE_JOINT_STEREO;
2958 lstBtA2dpSbcCaps.frequency = BTR_SBC_SAMPLING_FREQ_16000 | BTR_SBC_SAMPLING_FREQ_32000 |
2959 BTR_SBC_SAMPLING_FREQ_44100 | BTR_SBC_SAMPLING_FREQ_48000;
2960 lstBtA2dpSbcCaps.allocation_method = BTR_SBC_ALLOCATION_SNR | BTR_SBC_ALLOCATION_LOUDNESS;
2961 lstBtA2dpSbcCaps.subbands = BTR_SBC_SUBBANDS_4 | BTR_SBC_SUBBANDS_8;
2962 lstBtA2dpSbcCaps.block_length = BTR_SBC_BLOCK_LENGTH_4 | BTR_SBC_BLOCK_LENGTH_8 |
2963 BTR_SBC_BLOCK_LENGTH_12 | BTR_SBC_BLOCK_LENGTH_16;
2964 lstBtA2dpSbcCaps.min_bitpool = MIN_BITPOOL;
2965 lstBtA2dpSbcCaps.max_bitpool = MAX_BITPOOL;
2967 if (pstlhBTRCoreAVM) {
2968 void* lpstBTAVMMediaConfig = NULL;
2970 if (pstlhBTRCoreAVM->pcAVMediaTransportPathOut) {
2971 if(!strncmp(pstlhBTRCoreAVM->pcAVMediaTransportPathOut, apBtMediaTransportPath, strlen(pstlhBTRCoreAVM->pcAVMediaTransportPathOut))) {
2972 BTRCORELOG_INFO (
"Freeing %p:%s\n", pstlhBTRCoreAVM->pcAVMediaTransportPathOut, pstlhBTRCoreAVM->pcAVMediaTransportPathOut);
2974 free(pstlhBTRCoreAVM->pcAVMediaTransportPathOut);
2975 pstlhBTRCoreAVM->pcAVMediaTransportPathOut = NULL;
2976 pstlhBTRCoreAVM->eAVMediaTypeOut = eBTRCoreAVMTypeUnknown;
2978 lpstBTAVMMediaConfig = pstlhBTRCoreAVM->pstBTMediaConfigOut;
2981 if (lpstBTAVMMediaConfig) {
2982 BTRCORELOG_TRACE(
"Retain Media Configuration\n");
2989 if (pstlhBTRCoreAVM->pcAVMediaTransportPathIn) {
2990 if(!strncmp(pstlhBTRCoreAVM->pcAVMediaTransportPathIn, apBtMediaTransportPath, strlen(pstlhBTRCoreAVM->pcAVMediaTransportPathIn))) {
2991 BTRCORELOG_INFO (
"Freeing %p:%s\n", pstlhBTRCoreAVM->pcAVMediaTransportPathIn, pstlhBTRCoreAVM->pcAVMediaTransportPathIn);
2993 free(pstlhBTRCoreAVM->pcAVMediaTransportPathIn);
2994 pstlhBTRCoreAVM->pcAVMediaTransportPathIn = NULL;
2995 pstlhBTRCoreAVM->eAVMediaTypeIn = eBTRCoreAVMTypeUnknown;
2997 lpstBTAVMMediaConfig = pstlhBTRCoreAVM->pstBTMediaConfigIn;
3000 if (lpstBTAVMMediaConfig) {
3001 BTRCORELOG_TRACE(
"Reset Media Configuration\n");
3002 memcpy(lpstBTAVMMediaConfig, &lstBtA2dpSbcCaps,
sizeof(a2dp_sbc_t));
3011 if (pstlhBTRCoreAVM) {
3013 if (pstlhBTRCoreAVM->pcAVMediaTransportPathOut) {
3014 if(!strncmp(pstlhBTRCoreAVM->pcAVMediaTransportPathOut, apBtMediaTransportPath, strlen(pstlhBTRCoreAVM->pcAVMediaTransportPathOut))) {
3015 BTRCORELOG_ERROR (
"Freeing %p:%s - Unexpected\n", pstlhBTRCoreAVM->pcAVMediaTransportPathOut, pstlhBTRCoreAVM->pcAVMediaTransportPathOut);
3019 free(pstlhBTRCoreAVM->pcAVMediaTransportPathOut);
3020 pstlhBTRCoreAVM->pcAVMediaTransportPathOut = NULL;
3023 pstlhBTRCoreAVM->pcAVMediaTransportPathOut = strndup(apBtMediaTransportPath, BTRCORE_MAX_STR_LEN - 1);
3027 if (pstlhBTRCoreAVM->pcAVMediaTransportPathIn) {
3028 if(!strncmp(pstlhBTRCoreAVM->pcAVMediaTransportPathIn, apBtMediaTransportPath, strlen(pstlhBTRCoreAVM->pcAVMediaTransportPathIn))) {
3029 BTRCORELOG_ERROR (
"Freeing %p:%s - Unexpected\n", pstlhBTRCoreAVM->pcAVMediaTransportPathIn, pstlhBTRCoreAVM->pcAVMediaTransportPathIn);
3033 free(pstlhBTRCoreAVM->pcAVMediaTransportPathIn);
3034 pstlhBTRCoreAVM->pcAVMediaTransportPathIn = NULL;
3037 pstlhBTRCoreAVM->pcAVMediaTransportPathIn = strndup(apBtMediaTransportPath, BTRCORE_MAX_STR_LEN - 1);
3048 btrCore_AVMedia_MediaPlayerPathCb (
3049 const char* apcBTMediaPlayerPath,
3055 if (!apcBTMediaPlayerPath) {
3056 BTRCORELOG_ERROR (
"Invalid media path\n");
3062 if (pstlhBTRCoreAVM) {
3063 if (pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
3064 char* ptr = pstlhBTRCoreAVM->pcAVMediaPlayerPath;
3066 if (!strncmp(pstlhBTRCoreAVM->pcAVMediaPlayerPath, apcBTMediaPlayerPath,
3067 (strlen(pstlhBTRCoreAVM->pcAVMediaPlayerPath) > strlen(apcBTMediaPlayerPath)) ? strlen(pstlhBTRCoreAVM->pcAVMediaPlayerPath) : strlen(apcBTMediaPlayerPath))) {
3068 BTRCORELOG_INFO (
"Freeing %p:%s\n", pstlhBTRCoreAVM->pcAVMediaPlayerPath, pstlhBTRCoreAVM->pcAVMediaPlayerPath);
3070 pstlhBTRCoreAVM->pcAVMediaPlayerPath = NULL;
3074 BTRCORELOG_INFO (
"Switching Media Player from %s to %s\n", pstlhBTRCoreAVM->pcAVMediaPlayerPath, apcBTMediaPlayerPath);
3075 pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(apcBTMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1);
3078 memset (&pstlhBTRCoreAVM->pstAVMediaPlayer, 0,
sizeof(pstlhBTRCoreAVM->pstAVMediaPlayer));
3079 strncpy (pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaPlayerName,
"UnknownPlayer", BTRCORE_MAX_STR_LEN -1);
3083 BTRCORELOG_INFO (
"Storing Media Player : %s\n", apcBTMediaPlayerPath);
3084 pstlhBTRCoreAVM->pcAVMediaPlayerPath = strndup(apcBTMediaPlayerPath, BTRCORE_MAX_STR_LEN - 1);
3096 btrCore_AVMedia_MediaStatusUpdateCb (
3099 const char* apcBtDevAddr,
3107 if (!apcBtDevAddr || !apstBtMediaStUpdate || !apUserData) {
3108 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg!!!\n");
3111 BTRCORELOG_DEBUG (
"AV Media Status Cb\n");
3116 switch (apstBtMediaStUpdate->aenBtOpIfceType) {
3117 case enBTMediaTransport:
3119 switch (apstBtMediaStUpdate->aunBtOpIfceProp.enBtMediaTransportProp) {
3120 case enBTMedTPropState:
3122 switch (apstBtMediaStUpdate->m_mediaTransportState) {
3123 case enBTMedTransportStIdle:
3124 pstlhBTRCoreAVM->eAVMTState = enAVMTransportStDisconnected;
3126 case enBTMedTransportStPending:
3127 pstlhBTRCoreAVM->eAVMTState = enAVMTransportStToBeConnected;
3129 case enBTMedTransportStActive:
3130 pstlhBTRCoreAVM->eAVMTState = enAVMTransportStConnected;
3135 BTRCORELOG_DEBUG (
"AV Media Transport State : %d\n", pstlhBTRCoreAVM->eAVMTState);
3138 case enBTMedTPropVol:
3139 mediaStatus.eAVMediaState = eBTRCoreAVMediaPlyrVolume;
3140 mediaStatus.bIsAVMediaCtrlAvail = pstlhBTRCoreAVM->bAVMediaPlayerConnected;
3141 mediaStatus.m_mediaPlayerTransportVolume = apstBtMediaStUpdate->m_mediaTransportVolume;
3142 pstlhBTRCoreAVM->ui8AVMediaTransportVolume = apstBtMediaStUpdate->m_mediaTransportVolume;
3143 pstlhBTRCoreAVM->bAVMediaTrVolAvrcp =
TRUE;
3144 BTRCORELOG_DEBUG (
"AV Media Transport Volume : %d%%\n", pstlhBTRCoreAVM->ui8AVMediaTransportVolume);
3152 case enBTMediaControl:
3154 switch (apstBtMediaStUpdate->aunBtOpIfceProp.enBtMediaControlProp) {
3155 case enBTMedControlPropConnected:
3156 if (enBTDevAudioSource == aeBtDeviceType) {
3157 if (apstBtMediaStUpdate->m_mediaPlayerConnected) {
3162 if (!(pstlhBTRCoreAVM->bAVMediaPlayerConnected || pstlhBTRCoreAVM->pMediaPollingThread)) {
3166 strncpy (pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaPlayerName,
"UnknownPlayer", BTRCORE_MAX_STR_LEN -1);
3168 pstAVMediaStUserData->apvAVMUserData = pstlhBTRCoreAVM->btIfceHdl;
3169 pstAVMediaStUserData->apcAVMDevAddress = strndup(apcBtDevAddr, BTRCORE_MAX_STR_LEN - 1);
3171 pstlhBTRCoreAVM->pvThreadData = (
void*)pstAVMediaStUserData;
3173 pstlhBTRCoreAVM->pMediaPollingThread = g_thread_new (
"btrCore_AVMedia_PlaybackPositionPolling", btrCore_AVMedia_PlaybackPositionPolling, (
void*)(pstlhBTRCoreAVM));
3175 if (!pstlhBTRCoreAVM->pMediaPollingThread) {
3176 BTRCORELOG_ERROR (
"Failed to thread create btrCore_AVMedia_PlaybackPositionPolling");
3181 BTRCORELOG_WARN (
"btrCore_AVMedia_PlaybackPositionPolling thread is running already!!!");
3185 if (pstlhBTRCoreAVM->pstAVMediaBrowser || pstlhBTRCoreAVM->pstAVMediaPlayList ||
3186 pstlhBTRCoreAVM->ui32AVMediaBrowserItemCount || pstlhBTRCoreAVM->ui32AVMediaPlayListItemCount) {
3187 BTRCORELOG_WARN (
"Media Browser Error - ####### Possibility Of Memory Leak #####\n");
3188 BTRCORELOG_WARN (
"Media Browser Error - MediaBrowser : %p(%u) | MediaPlayList : %p(%u)\n"
3189 , pstlhBTRCoreAVM->pstAVMediaBrowser
3190 , pstlhBTRCoreAVM->ui32AVMediaBrowserItemCount
3191 , pstlhBTRCoreAVM->pstAVMediaPlayList
3192 , pstlhBTRCoreAVM->ui32AVMediaPlayListItemCount);
3194 if (pstlhBTRCoreAVM->pstAVMediaBrowser) {
3195 while (pstlhBTRCoreAVM->pstAVMediaBrowser->pvAVMediaParentItem) {
3196 pstlhBTRCoreAVM->pstAVMediaBrowser = pstlhBTRCoreAVM->pstAVMediaBrowser->pvAVMediaParentItem;
3198 if (!btrCore_AVMedia_DeallocateUnhandledBrowserMemory (pstlhBTRCoreAVM, apcBtDevAddr, &pstlhBTRCoreAVM->pstAVMediaBrowser)) {
3199 BTRCORELOG_ERROR (
"Media Browser Error - Deallocate Unhandled Browser Memory Failed!\n");
3201 pstlhBTRCoreAVM->pstAVMediaBrowser = NULL;
3204 if (pstlhBTRCoreAVM->pstAVMediaPlayList) {
3205 if (!btrCore_AVMedia_DeallocateUnhandledBrowserMemory (pstlhBTRCoreAVM, apcBtDevAddr, &pstlhBTRCoreAVM->pstAVMediaPlayList)) {
3206 BTRCORELOG_ERROR (
"Media Browser Error - Deallocate Unhandled Browser Memory Failed!\n");
3208 pstlhBTRCoreAVM->pstAVMediaPlayList = NULL;
3211 pstlhBTRCoreAVM->ui32AVMediaBrowserItemCount = 0;
3212 pstlhBTRCoreAVM->ui32AVMediaPlayListItemCount = 0;
3215 if (pstlhBTRCoreAVM->bAVMediaPlayerConnected && pstlhBTRCoreAVM->pMediaPollingThread) {
3217 pstlhBTRCoreAVM->pstAVMediaPlayer.eAVMediaStatusUpdate = eBTRCoreAVMediaPlaybackEnded;
3218 g_thread_join (pstlhBTRCoreAVM->pMediaPollingThread);
3220 if (pstlhBTRCoreAVM->pvThreadData) {
3224 free (pstlhBTRCoreAVM->pvThreadData);
3225 pstlhBTRCoreAVM->pvThreadData = NULL;
3227 pstlhBTRCoreAVM->pMediaPollingThread = NULL;
3228 pstlhBTRCoreAVM->eAVMTState = enAVMTransportStDisconnected;
3230 BTRCORELOG_INFO (
"Successfully Exited Media Position Polling Thread\n");
3233 if (pstlhBTRCoreAVM->pcAVMediaPlayerPath) {
3234 BTRCORELOG_INFO (
"Freeing %p:%s\n", pstlhBTRCoreAVM->pcAVMediaPlayerPath, pstlhBTRCoreAVM->pcAVMediaPlayerPath);
3235 free (pstlhBTRCoreAVM->pcAVMediaPlayerPath);
3236 pstlhBTRCoreAVM->pcAVMediaPlayerPath = NULL;
3240 BTRCORELOG_ERROR (
"pstlhBTRCoreAVM->pMediaPollingThread doesn't exists!!!");
3244 pstlhBTRCoreAVM->bAVMediaPlayerConnected = apstBtMediaStUpdate->m_mediaPlayerConnected;
3247 pstlhBTRCoreAVM->bAVMediaPlayerConnected = apstBtMediaStUpdate->m_mediaPlayerConnected;
3248 pstlhBTRCoreAVM->pcAVMediaControlPath = strndup(apcBtDevAddr, BTRCORE_MAX_STR_LEN - 1);
3249 BTRCORELOG_DEBUG (
"Device Type : %d Control Path : %s\n", aeBtDeviceType, pstlhBTRCoreAVM->pcAVMediaControlPath);
3252 BTRCORELOG_DEBUG (
"AV Media Player Connected : %s - %d\n", apcBtDevAddr, apstBtMediaStUpdate->m_mediaPlayerConnected);
3255 case enBTMedControlPropPath:
3256 BTRCORELOG_DEBUG (
"AV Media Player connected Path : %s\n", apstBtMediaStUpdate->m_mediaPlayerPath);
3263 case enBTMediaPlayer:
3267 switch (apstBtMediaStUpdate->aunBtOpIfceProp.enBtMediaPlayerProp) {
3268 case enBTMedPlayerPropName:
3269 mediaStatus.eAVMediaState = eBTRCoreAVMediaPlyrName;
3270 strncpy(lstAVMediaPlayer->m_mediaPlayerName, apstBtMediaStUpdate->m_mediaPlayerName, BTRCORE_MAX_STR_LEN - 1);
3271 strncpy(mediaStatus.m_mediaPlayerName, lstAVMediaPlayer->m_mediaPlayerName, BTRCORE_MAX_STR_LEN - 1);
3272 BTRCORELOG_DEBUG (
"AV Media Player Name : %s\n", lstAVMediaPlayer->m_mediaPlayerName);
3276 case enBTMedPlayerPropType:
3277 switch (apstBtMediaStUpdate->enMediaPlayerType) {
3278 case enBTMedPlayerTypAudio:
3279 lstAVMediaPlayer->eAVMediaPlayerType = eBTRCoreAVMPTypAudio;
3281 case enBTMedPlayerTypVideo:
3282 lstAVMediaPlayer->eAVMediaPlayerType = eBTRCoreAVMPTypVideo;
3284 case enBTMedPlayerTypAudioBroadcasting:
3285 lstAVMediaPlayer->eAVMediaPlayerType = eBTRCoreAVMPTypAudioBroadcasting;
3287 case enBTMedPlayerTypVideoBroadcasting:
3288 lstAVMediaPlayer->eAVMediaPlayerType = eBTRCoreAVMPTypVideoBroadcasting;
3291 lstAVMediaPlayer->eAVMediaPlayerType = eBTRCoreAVMPTypUnknown;
3293 BTRCORELOG_DEBUG (
"AV Media Player Type : %d\n", lstAVMediaPlayer->eAVMediaPlayerType);
3296 case enBTMedPlayerPropSubtype:
3297 switch (apstBtMediaStUpdate->enMediaPlayerSubtype) {
3298 case enBTMedPlayerSbTypAudioBook:
3299 lstAVMediaPlayer->eAVMediaPlayerSubtype = eBTRCoreAVMPSbTypAudioBook;
3301 case enBTMedPlayerSbTypPodcast:
3302 lstAVMediaPlayer->eAVMediaPlayerSubtype = eBTRCoreAVMPSbTypPodcast;
3305 lstAVMediaPlayer->eAVMediaPlayerSubtype = eBTRCoreAVMPSbTypUnknown;
3307 BTRCORELOG_DEBUG (
"AV Media Player Subtype : %d\n", lstAVMediaPlayer->eAVMediaPlayerSubtype);
3310 case enBTMedPlayerPropTrack:
3311 mediaStatus.eAVMediaState = eBTRCoreAVMediaTrkStChanged;
3312 lstAVMediaPlayer->m_mediaTrackChanged = 1;
3325 if (apstBtMediaStUpdate->m_mediaTrackInfo.pcTitle[0]) {
3329 if (!apstBtMediaStUpdate->m_mediaTrackInfo.pcAlbum[0] && !apstBtMediaStUpdate->m_mediaTrackInfo.pcArtist[0] &&
3330 !apstBtMediaStUpdate->m_mediaTrackInfo.pcGenre[0] && !apstBtMediaStUpdate->m_mediaTrackInfo.ui32Duration) {
3331 strncpy (apstBtMediaStUpdate->m_mediaTrackInfo.pcTitle,
3332 strncpy (apstBtMediaStUpdate->m_mediaTrackInfo.pcArtist,
3333 strncpy (apstBtMediaStUpdate->m_mediaTrackInfo.pcAlbum,
3334 strncpy (apstBtMediaStUpdate->m_mediaTrackInfo.pcGenre,
"Unknown", BTRCORE_MAX_STR_LEN -1),
3335 BTRCORE_MAX_STR_LEN -1),
3336 BTRCORE_MAX_STR_LEN -1),
3337 BTRCORE_MAX_STR_LEN -1);
3340 if (apstBtMediaStUpdate->m_mediaTrackInfo.ui32Duration) {
3341 lstAVMediaPlayer->m_mediaTrackInfo.ui32Duration = apstBtMediaStUpdate->m_mediaTrackInfo.ui32Duration;
3343 if (apstBtMediaStUpdate->m_mediaTrackInfo.pcArtist[0]) {
3344 strncpy (lstAVMediaPlayer->m_mediaTrackInfo.pcArtist, apstBtMediaStUpdate->m_mediaTrackInfo.pcArtist, BTRCORE_MAX_STR_LEN - 1);
3346 if (apstBtMediaStUpdate->m_mediaTrackInfo.pcAlbum[0]) {
3347 strncpy (lstAVMediaPlayer->m_mediaTrackInfo.pcAlbum, apstBtMediaStUpdate->m_mediaTrackInfo.pcAlbum, BTRCORE_MAX_STR_LEN - 1);
3349 if (apstBtMediaStUpdate->m_mediaTrackInfo.pcGenre[0]) {
3350 strncpy (lstAVMediaPlayer->m_mediaTrackInfo.pcGenre, apstBtMediaStUpdate->m_mediaTrackInfo.pcGenre, BTRCORE_MAX_STR_LEN - 1);
3355 BTRCORELOG_DEBUG (
"AV Media Player Track Updated : %s", mediaStatus.m_mediaTrackInfo.pcTitle);
3359 case enBTMedPlayerPropEqualizer:
3360 switch (apstBtMediaStUpdate->enMediaPlayerEqualizer) {
3361 case enBTMedPlayerEqualizerOff:
3362 lstAVMediaPlayer->eAVMediaPlayerEqualizer = eBTRCoreAVMediaPlyrEqlzrStOff;
3364 case enBTMedPlayerEqualizerOn:
3365 lstAVMediaPlayer->eAVMediaPlayerEqualizer = eBTRCoreAVMediaPlyrEqlzrStOn;
3368 lstAVMediaPlayer->eAVMediaPlayerEqualizer = enBTRCoreAVMediaCtrlUnknown;
3370 mediaStatus.eAVMediaState = lstAVMediaPlayer->eAVMediaPlayerEqualizer;
3371 BTRCORELOG_DEBUG (
"AV Media Player Equalizer : %d\n", lstAVMediaPlayer->eAVMediaPlayerEqualizer);
3375 case enBTMedPlayerPropShuffle:
3376 switch (apstBtMediaStUpdate->enMediaPlayerShuffle) {
3377 case enBTMedPlayerShuffleOff:
3378 lstAVMediaPlayer->eAVMediaPlayerShuffle = eBTRCoreAVMediaPlyrShflStOff;
3380 case enBTMedPlayerShuffleAllTracks:
3381 lstAVMediaPlayer->eAVMediaPlayerShuffle = eBTRCoreAVMediaPlyrShflStAllTracks;
3383 case enBTMedPlayerShuffleGroup:
3384 lstAVMediaPlayer->eAVMediaPlayerShuffle = eBTRCoreAVMediaPlyrShflStGroup;
3387 lstAVMediaPlayer->eAVMediaPlayerShuffle = eBTRCoreAVMediaStUnknown;
3389 mediaStatus.eAVMediaState = lstAVMediaPlayer->eAVMediaPlayerShuffle;
3390 BTRCORELOG_DEBUG (
"AV Media Player Shuffle : %d\n", lstAVMediaPlayer->eAVMediaPlayerShuffle);
3394 case enBTMedPlayerPropRepeat:
3395 switch (apstBtMediaStUpdate->enMediaPlayerRepeat) {
3396 case enBTMedPlayerRpOff:
3397 lstAVMediaPlayer->eAVMediaPlayerRepeat = eBTRCoreAVMediaPlyrRptStOff;
3399 case enBTMedPlayerRpSingleTrack:
3400 lstAVMediaPlayer->eAVMediaPlayerRepeat = eBTRCoreAVMediaPlyrRptStSingleTrack;
3402 case enBTMedPlayerRpAllTracks:
3403 lstAVMediaPlayer->eAVMediaPlayerRepeat = eBTRCoreAVMediaPlyrRptStAllTracks;
3405 case enBTMedPlayerRpGroup:
3406 lstAVMediaPlayer->eAVMediaPlayerRepeat = eBTRCoreAVMediaPlyrRptStGroup;
3409 lstAVMediaPlayer->eAVMediaPlayerRepeat = eBTRCoreAVMediaStUnknown;
3411 mediaStatus.eAVMediaState = lstAVMediaPlayer->eAVMediaPlayerRepeat;
3412 BTRCORELOG_DEBUG (
"AV Media Player Repeat : %d\n", lstAVMediaPlayer->eAVMediaPlayerRepeat);
3416 case enBTMedPlayerPropScan:
3417 switch (apstBtMediaStUpdate->enMediaPlayerScan) {
3418 case enBTMedPlayerScanOff:
3419 lstAVMediaPlayer->eAVMediaPlayerScan = eBTRCoreAVMediaPlyrScanStOff;
3421 case enBTMedPlayerScanAllTracks:
3422 lstAVMediaPlayer->eAVMediaPlayerScan = eBTRCoreAVMediaPlyrScanStAllTracks;
3424 case enBTMedPlayerScanGroup:
3425 lstAVMediaPlayer->eAVMediaPlayerScan = eBTRCoreAVMediaPlyrScanStGroup;
3428 lstAVMediaPlayer->eAVMediaPlayerScan = eBTRCoreAVMediaStUnknown;
3430 BTRCORELOG_DEBUG (
"AV Media Player Scan : %d\n", lstAVMediaPlayer->eAVMediaPlayerScan);
3433 case enBTMedPlayerPropPosition:
3434 lstAVMediaPlayer->m_mediaPlayerPosition = apstBtMediaStUpdate->m_mediaPlayerPosition;
3435 BTRCORELOG_DEBUG (
"AV Media Player Position : %d\n", lstAVMediaPlayer->m_mediaPlayerPosition);
3438 case enBTMedPlayerPropStatus:
3439 switch (apstBtMediaStUpdate->enMediaPlayerStatus) {
3440 case enBTMedPlayerStPlaying:
3441 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaTrkStPlaying;
3443 case enBTMedPlayerStStopped:
3444 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaTrkStStopped;
3446 case enBTMedPlayerStPaused:
3447 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaTrkStPaused;
3449 case enBTMedPlayerStForwardSeek:
3450 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaTrkStForwardSeek;
3452 case enBTMedPlayerStReverseSeek:
3453 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaTrkStReverseSeek;
3455 case enBTMedPlayerStError:
3456 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaPlaybackError;
3459 lstAVMediaPlayer->eAVMediaStatusUpdate = eBTRCoreAVMediaPlaybackError;
3461 BTRCORELOG_DEBUG (
"AV Media Player Status : %d\n", lstAVMediaPlayer->eAVMediaStatusUpdate);
3464 case enBTMedPlayerPropBrowsable:
3465 lstAVMediaPlayer->m_mediaPlayerBrowsable = apstBtMediaStUpdate->m_mediaPlayerBrowsable;
3466 BTRCORELOG_DEBUG (
"AV Media Player Browsable : %d\n", lstAVMediaPlayer->m_mediaPlayerBrowsable);
3470 case enBTMedPlayerPropSearchable:
3471 lstAVMediaPlayer->m_mediaPlayerSearchable = apstBtMediaStUpdate->m_mediaPlayerSearchable;
3472 BTRCORELOG_DEBUG (
"AV Media Player Searchable : %d\n", lstAVMediaPlayer->m_mediaPlayerSearchable);
3476 case enBTMedPlayerPropPlaylist:
3477 mediaStatus.eAVMediaState = eBTRCoreAVMediaElementAdded;
3479 if (pstlhBTRCoreAVM->pstAVMediaPlayList) {
3480 strncpy (mediaStatus.m_mediaElementInfo.m_mediaElementName, pstlhBTRCoreAVM->pstAVMediaPlayList->pcAVMediaItemName, BTRCORE_MAX_STR_LEN -1);
3481 mediaStatus.m_mediaElementInfo.ui32AVMediaElementId = pstlhBTRCoreAVM->pstAVMediaPlayList->ui32AVMediaItemId;
3482 mediaStatus.m_mediaElementInfo.bIsPlayable = 0;
3483 BTRCORELOG_DEBUG (
"AV Media Player PlayList %p:%s [ID: %llu]\n", pstlhBTRCoreAVM->pstAVMediaPlayList
3484 , pstlhBTRCoreAVM->pstAVMediaPlayList->pcAVMediaItemName
3485 , pstlhBTRCoreAVM->pstAVMediaPlayList->ui32AVMediaItemId);
3490 BTRCORELOG_WARN (
"AV Media Player PlayList %p Exist\n", pstlhBTRCoreAVM->pstAVMediaPlayList);
3507 case enBTMediaFolder:
3508 switch(apstBtMediaStUpdate->aunBtOpIfceProp.enBtMediaFolderProp) {
3509 case enBTMedFolderPropName:
3511 unsigned char bChanged = 0;
3514 BTRCORELOG_DEBUG (
"AV Media Folder Name : %s\n", apstBtMediaStUpdate->m_mediaFolderName);
3516 if (strcmp(apstBtMediaStUpdate->m_mediaFolderName,
"NowPlaying") && (ptr = pstlhBTRCoreAVM->pstAVMediaBrowser)) {
3517 unsigned int ui32Index = 0;
3518 char* staStr = apstBtMediaStUpdate->m_mediaFolderName;
3520 if (ptr->pvAVMediaParentItem) {
3523 if (!strncmp(staStr, bsrStr, (strlen(staStr) > strlen(bsrStr))? strlen(staStr) : strlen(bsrStr))) {
3524 ptrPlayer->m_mediaBrowserItem = pstlhBTRCoreAVM->pstAVMediaBrowser = ptr->pvAVMediaParentItem;
3529 ptr = pstlhBTRCoreAVM->pstAVMediaBrowser;
3531 while (!bChanged && ui32Index < ptr->ui32AVMediaNumberOfItems) {
3532 char* bsrStr = ptr->pstAVMediaSubItems[ui32Index]->pcAVMediaItemName;
3534 if (!strncmp(staStr, bsrStr, (strlen(staStr) > strlen(bsrStr))? strlen(staStr) : strlen(bsrStr))) {
3535 ptrPlayer->m_mediaBrowserItem = pstlhBTRCoreAVM->pstAVMediaBrowser = ptr->pstAVMediaSubItems[ui32Index];
3541 else if (!strcmp(apstBtMediaStUpdate->m_mediaFolderName,
"NowPlaying") && pstlhBTRCoreAVM->pstAVMediaPlayList) {
3542 ptrPlayer->m_mediaBrowserItem = pstlhBTRCoreAVM->pstAVMediaPlayList;
3546 BTRCORELOG_ERROR (
"No Filesystem is present for %s !\n", apstBtMediaStUpdate->m_mediaFolderName);
3550 BTRCORELOG_DEBUG (
"Browsing Location %p:%s [ID: %llu]\n", ptrPlayer->m_mediaBrowserItem
3551 , ptrPlayer->m_mediaBrowserItem->pcAVMediaItemName
3552 , ptrPlayer->m_mediaBrowserItem->ui32AVMediaItemId);
3556 case enBTMedFolderPropNumberOfItems:
3557 BTRCORELOG_DEBUG (
"AV Media Folder NumberOfItems : %u\n", apstBtMediaStUpdate->m_mediaFolderNumberOfItems);
3567 if (!pstlhBTRCoreAVM->pcBMediaStatusUserData) {
3568 BTRCORELOG_ERROR (
"pstlhBTRCoreAVM->pcBMediaStatusUserData is NULL!!!\n");
3574 if (postEvent && pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate) {
3576 if (aeBtDeviceType == enBTDevAudioSink) {
3577 mediaStatus.eAVMediaDataFlow = eBTRCoreAVMediaFlowOut;
3579 else if (aeBtDeviceType == enBTDevAudioSource) {
3580 mediaStatus.eAVMediaDataFlow = eBTRCoreAVMediaFlowIn;
3582 else if ((aeBtDeviceType == enBTDevHFPHeadset) || (aeBtDeviceType == enBTDevHFPAudioGateway)) {
3583 mediaStatus.eAVMediaDataFlow = eBTRCoreAVMediaFlowInOut;
3586 mediaStatus.eAVMediaDataFlow = eBTRCoreAVMediaFlowUnknown;
3589 if (pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate(&mediaStatus, apcBtDevAddr, pstlhBTRCoreAVM->pcBMediaStatusUserData) != enBTRCoreSuccess) {
3590 BTRCORELOG_ERROR (
"fpcBBTRCoreAVMediaStatusUpdate - Failure !!!\n");
3599 btrCore_AVMedia_MediaBrowserUpdateCb (
3601 unsigned char ucItemScope,
3602 const char* apcBtDevAddr,
3614 if (!apstBtMediaBsrUpdate || !apUserData) {
3615 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg!!!\n");
3618 BTRCORELOG_DEBUG (
"AV Media Browser Cb\n");
3622 if (!pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaPlayerBrowsable &&
3623 apstBtMediaBsrUpdate->ui32BTMediaItemId != BTR_MEDIA_PLAYLIST_ID &&
3624 apstBtMediaBsrUpdate->ui32BTMediaItemId) {
3628 mediaElement = &mediaStatus.m_mediaElementInfo;
3629 ptr = *(ptrRoot = (apstBtMediaBsrUpdate->ui32BTMediaItemId & BTR_MEDIA_PLAYLIST_ID)? &pstlhBTRCoreAVM->pstAVMediaPlayList : &pstlhBTRCoreAVM->pstAVMediaBrowser);
3635 if (apstBtMediaBsrUpdate->eMediaItemType == enBTMediaItemTypFolder ||
3636 apstBtMediaBsrUpdate->eMediaItemType == enBTMediaItemTypAudio) {
3638 if (!(i32BtRet = btrCore_AVMedia_AllocateBrowserMemory (pstlhBTRCoreAVM, ptr, &lpstBroswer))) {
3640 lpstBroswer->pvAVMediaParentItem = ptr;
3641 lpstBroswer->ui32AVMediaNumberOfItems = 0;
3642 lpstBroswer->eMediaItemType = btrCore_AVMedia_MapFolderTypeToElementType (apstBtMediaBsrUpdate->eMediaFolderType);
3643 lpstBroswer->ui32AVMediaItemId = apstBtMediaBsrUpdate->ui32BTMediaItemId;
3644 strncpy(lpstBroswer->pcAVMediaItemPath, apstBtMediaBsrUpdate->pcMediaItemPath, BTRCORE_MAX_STR_LEN -1);
3645 strncpy(lpstBroswer->pcAVMediaItemName, apstBtMediaBsrUpdate->pcMediaItemName, BTRCORE_MAX_STR_LEN -1);
3647 if ((lpstBroswer->bIsMediaItemPlayable = (apstBtMediaBsrUpdate->eMediaItemType == enBTMediaItemTypAudio))) {
3649 (lpstBroswer->ui32AVMediaItemId & BTR_MEDIA_PLAYLIST_ID)? pstlhBTRCoreAVM->ui32AVMediaPlayListItemCount++ : pstlhBTRCoreAVM->ui32AVMediaBrowserItemCount++;
3653 if (!(*ptrRoot = lpstBroswer)->ui32AVMediaItemId) {
3654 pstlhBTRCoreAVM->pstAVMediaPlayer.m_mediaBrowserItem = lpstBroswer;
3660 mediaStatus.eAVMediaState = eBTRCoreAVMediaElementAdded;
3661 mediaElement->eAVMElementType = btrCore_AVMedia_MapFolderTypeToElementType (apstBtMediaBsrUpdate->eMediaFolderType);
3662 mediaElement->ui32AVMediaElementId = lpstBroswer->ui32AVMediaItemId = apstBtMediaBsrUpdate->ui32BTMediaItemId;
3663 if ((mediaElement->bIsPlayable = lpstBroswer->bIsMediaItemPlayable)) {
3666 strncpy(mediaElement->m_mediaElementName, lpstBroswer->pcAVMediaItemName, BTRCORE_MAX_STR_LEN -1);
3668 BTRCORELOG_DEBUG (
"Storing Media Item %p:%s [ID: %llu]\n", lpstBroswer, lpstBroswer->pcAVMediaItemName, lpstBroswer->ui32AVMediaItemId);
3671 BTRCORELOG_ERROR (
"Media Browser Error - Allocate Browser Memory Failed!\n");
3674 else if (apstBtMediaBsrUpdate->eMediaItemType == enBTMediaItemTypVideo) {
3675 BTRCORELOG_DEBUG (
"enBTMediaItemTypVideo received\n");
3679 BTRCORELOG_ERROR (
"Unknown MediaItem type received : %d !\n", apstBtMediaBsrUpdate->eMediaItemType);
3685 if (!(pstMediaItemRoot = ptr)) {
3686 BTRCORELOG_ERROR (
"Media Browser Error - No parent Filesystem !\n");
3690 while (pstMediaItemRoot->pvAVMediaParentItem) {
3691 pstMediaItemRoot = pstMediaItemRoot->pvAVMediaParentItem;
3694 if (btrCore_AVMedia_FindMediaItem (pstMediaItemRoot, apstBtMediaBsrUpdate->ui32BTMediaItemId, &ptr)) {
3695 BTRCORELOG_ERROR (
"Media Browser Error - Couldn't Find MediaItem %llu\n", apstBtMediaBsrUpdate->ui32BTMediaItemId);
3700 if (ptr->ui32AVMediaNumberOfItems || (ptr->pstAVMediaSubItems && !ptr->bIsMediaItemPlayable)) {
3701 BTRCORELOG_WARN (
"!!!Media Browser Error - contains MediaSubItems\n");
3702 BTRCORELOG_WARN (
"!!!No.OfItems : %u | SubItems : %p\n", ptr->ui32AVMediaNumberOfItems, ptr->pstAVMediaSubItems);
3703 mediaElement->ui32AVMediaElementId = (*ptrRoot)->ui32AVMediaItemId;
3705 if (!(i32BtRet = btrCore_AVMedia_DeallocateUnhandledBrowserMemory (pstlhBTRCoreAVM, apcBtDevAddr, &ptr))) {
3706 if (mediaElement->ui32AVMediaElementId == apstBtMediaBsrUpdate->ui32BTMediaItemId) {
3711 BTRCORELOG_ERROR (
"Media Browser Error - Deallocate Unhandled Browser Memory Failed!\n");
3716 BTRCORELOG_DEBUG (
"Freeing Media Item %p:%s [ID: %llu]\n", ptr, ptr->pcAVMediaItemName, ptr->ui32AVMediaItemId);
3717 mediaElement->ui32AVMediaElementId = (*ptrRoot)->ui32AVMediaItemId;
3719 if (ptr->bIsMediaItemPlayable) {
3720 (apstBtMediaBsrUpdate->ui32BTMediaItemId & BTR_MEDIA_PLAYLIST_ID)? pstlhBTRCoreAVM->ui32AVMediaPlayListItemCount-- : pstlhBTRCoreAVM->ui32AVMediaBrowserItemCount--;
3723 if (!(i32BtRet = btrCore_AVMedia_DeallocateBrowserMemory(pstlhBTRCoreAVM, &ptr))) {
3724 if (mediaElement->ui32AVMediaElementId == apstBtMediaBsrUpdate->ui32BTMediaItemId) {
3728 mediaStatus.eAVMediaState = eBTRCoreAVMediaElementRemoved;
3729 mediaElement->ui32AVMediaElementId = apstBtMediaBsrUpdate->ui32BTMediaItemId;
3732 BTRCORELOG_ERROR (
"Media Browser Error - Deallocate Browser Memory Failed!\n");
3739 if (postEvent && !i32BtRet && pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate) {
3740 if (pstlhBTRCoreAVM->fpcBBTRCoreAVMediaStatusUpdate(&mediaStatus, apcBtDevAddr, pstlhBTRCoreAVM->pcBMediaStatusUserData) != enBTRCoreSuccess) {
3741 BTRCORELOG_ERROR (
"fpcBBTRCoreAVMediaStatusUpdate - Failure !!!\n");