comparison src/ui/mfw/mfw_BtipsA2dp.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /* =========================================================
2 * Texas Instruments OMAP(TM) Platform Software
3 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
4 *
5 * Use of this software is controlled by the terms and conditions found
6 * in the license agreement under which this software has been supplied.
7 * ========================================================== */
8 /*
9 $Project name: Basic Bluetooth MMI
10 $Project code:
11 $Module: Bluetooth BMG APPlication
12 $File: mfw_BtipsA2dp.c
13 $Revision: 1.0
14 $Author: Texas Instruments
15 $Date: 26/06/07
16
17 ********************************************************************************
18
19 Description:
20
21 This module provides the BTIPS BMG APPlication functionality.
22
23 ********************************************************************************
24 $History: mfw_BtipsA2dp.c
25
26 26/06/07 Sasken original version
27
28 $End
29
30 *******************************************************************************/
31
32
33
34
35 /*******************************************************************************
36
37 Include files
38
39 *******************************************************************************/
40
41 #define ENTITY_MFW
42
43 #if BT_STACK == XA_ENABLED
44 #include <me.h>
45 #include <bttypes.h>
46 #include <sec.h>
47 #endif
48
49 #include "btl_common.h"
50 #include "debug.h"
51 #include "vsi.h"
52 #include "overide.h"
53
54 /* BTL includes */
55 #include "btl_a2dp.h"
56 #include "btl_config.h"
57 #include "bthal_mm.h"
58
59
60 #if defined (NEW_FRAME)
61
62 #include "typedefs.h"
63 #include "vsi.h"
64 #include "pei.h"
65 #include "custom.h"
66 #include "gsm.h"
67 #include "prim.h"
68
69 #else
70
71 #include "STDDEFS.H"
72 #include "custom.h"
73 #include "gsm.h"
74 #include "vsi.h"
75
76 #endif
77 #include "mfw_BtipsA2dp.h"
78 #include "mfw_mfw.h"
79 #include "mfw_win.h"
80 #include "mfw_icn.h" /* included for mfw_mnu.h */
81 #include "mfw_mnu.h"
82 #include "mfw_tim.h"
83 #include "mfw_kbd.h"
84 #include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */
85 #include "mfw_btips.h"
86 #include "mfw_ffs.h"
87
88 extern char szSelectedFileName[256];
89 extern char* szSelectedFileExt;
90 extern int a2dp_files_count;
91 //Array to load fileNames in content directory
92 extern char* a2dp_file_names[A2DP_MAX_FILES];
93
94
95 /*-------------------------------------------------------------------------------
96 * MAX_SUPPORTED_BITPOOL type
97 *
98 * Represents the maximum supported bitpool
99 */
100 #define MAX_SUPPORTED_BITPOOL (53)
101
102 /*-------------------------------------------------------------------------------
103 * MIN_SUPPORTED_BITPOOL type
104 *
105 * Represents the minimum supported bitpool
106 */
107 #define MIN_SUPPORTED_BITPOOL (2)
108
109 #define A2DP_MAX_NUM_STREAMS (BTL_CONFIG_A2DP_MAX_NUM_SBC_STREAMS_PER_CONTEXT + \
110 BTL_CONFIG_A2DP_MAX_NUM_MPEG1_2_AUDIO_STREAMS_PER_CONTEXT)
111 static BOOL isStreamClosed[A2DP_MAX_NUM_STREAMS];
112 static BOOL playingNow = FALSE;
113 static BOOL streamingNow = FALSE;
114 static BtSecurityLevel securityLevel = BSL_NO_SECURITY;
115 static BtlA2dpContext *btlA2dpContext = 0;
116 static BtlA2dpCodec codec;
117 BtlA2dpStreamId streamId = -1;
118 static BthalMmSbcInfo sbcLocalCap;
119 static BthalMmMpeg1_2_audioInfo mp3LocalCap;
120 static BOOL streamSbcFile = FALSE;
121 extern T_MFW_HND hA2dpDeviceWnd;
122 BOOL bPlayMp3File = FALSE;
123 BOOL bPlaySbcFile = FALSE;
124
125 void APP_A2DP_StartPcmStream(BTHAL_U32 streamId);
126
127 static void mfw_btips_a2dpEventCallBack(const BtlA2dpEvent *event);
128 static char * pCodecType(AvdtpCodecType CType);
129 static char * pAvError(AvdtpError Error);
130 static void mfw_btips_a2dpSetDefaultSbcLocalCap(void);
131 static void mfw_btips_a2dpSetDefaultMp3LocalCap(void);
132
133 #ifdef FF_MMI_BTIPS_APP
134
135 /*Function Definitions*/
136 void APP_A2DP_StartPcmStream(BTHAL_U32 streamId)
137 {
138 BtStatus status;
139 status = BTL_A2DP_StartStream(btlA2dpContext, streamId);
140 TRACE_FUNCTION_P1("BTL_A2DP_StartStream() returned %s.",
141 pBT_Status(status));
142 }
143
144 /*******************************************************************************
145
146 $Function: mfw_btips_a2dpInit
147
148 $Description: Function to initialise the a2dp file list.
149
150 $Returns: None
151
152 $Arguments: None
153
154 *******************************************************************************/
155 void mfw_btips_a2dpInit(void)
156 {
157 BtStatus status;
158 TRACE_FUNCTION("mfw_btips_a2dpInit");
159
160 status = BTL_A2DP_Create(0, mfw_btips_a2dpEventCallBack, &securityLevel, &btlA2dpContext);
161 mfw_btips_a2dpSetDefaultSbcLocalCap();
162 mfw_btips_a2dpSetDefaultMp3LocalCap();
163 bthalMmSetExternalSbcEncoder(streamSbcFile);
164 bthalMmSetPcmPlatformSupportedCapabilities(&sbcLocalCap);
165 TRACE_FUNCTION("SBC Local capabilities has been set");
166
167 bthalMmSetMp3PlatformSupportedCapabilities(&mp3LocalCap);
168 TRACE_FUNCTION("MP3 Local capabilities has been set");
169
170 status = BTL_A2DP_Enable(btlA2dpContext, 0, (BTL_A2DP_SUPPORTED_FEATURES_PLAYER | BTL_A2DP_SUPPORTED_FEATURES_MIXER));
171
172 TRACE_FUNCTION_P1("BTL_A2DP_Enable() returned %s.", pBT_Status(status));
173 if (status == BT_STATUS_SUCCESS)
174 {
175 OS_MemSet(isStreamClosed, TRUE, A2DP_MAX_NUM_STREAMS);
176
177 }
178 else
179 {
180 TRACE_FUNCTION("A2DP Enable Failed!");
181 }
182 }
183 /*******************************************************************************
184
185 $Function: mfw_btips_a2dpPopulateFiles
186
187 $Description:Populates the MIDI file names into the array
188
189 $Returns: The count of the files in the directory
190
191 $Arguments: file_names:Pointer to the arrayto store file names
192 max_files_count:Max file counts to be stored in array
193 *******************************************************************************/
194
195 int mfw_btips_a2dpPopulateFiles(char **file_names, int max_files_count,char* dir_name_p)
196 {
197
198 T_FFS_DIR dir = {0};
199 char dest_name_p[100] = "";
200 int i, files_count = 0;
201 char *fileExt;
202
203 TRACE_FUNCTION("mfw_btips_a2dpPopulateFiles");
204
205 TRACE_FUNCTION_P1("a2dp_files_count - %s", dir_name_p);
206 if (ffs_opendir (dir_name_p, &dir) <= 0)
207 {
208 TRACE_FUNCTION("Cld not open Dir");
209
210 files_count = 0;
211 }
212 //Release previous allocated memory before allocating again
213 mfw_btips_a2dpUnpopulateFiles(file_names);
214 //read the file names
215 //file_count will be used to populate the array index
216 for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++)
217 {
218
219 TRACE_FUNCTION_P1("Reading Dir - %s",dest_name_p);
220 (file_names[files_count]) = (char*)mfwAlloc(strlen(dest_name_p) + 1);
221 if(file_names[files_count] != NULL)
222 {
223 //Retrieve file extension.Store only the supported file formats in array
224 fileExt =mfw_btips_a2dpGetExtension(dest_name_p);
225 //List the MP3 files also.Mp3 files hsould not be listed or ULC
226 if ( (strcmp(fileExt, "mp3") == 0))
227 {
228
229 strcpy (file_names[files_count], dest_name_p);
230 TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]);
231 files_count++;
232 }
233 else if ( (strcmp(fileExt, "wav")== 0))
234 {
235
236 strcpy (file_names[files_count], dest_name_p);
237 TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]);
238 files_count++;
239 }
240 else if ( (strcmp(fileExt, "pcm")== 0))
241 {
242 strcpy (file_names[files_count], dest_name_p);
243 TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]);
244 files_count++;
245 }
246 else if(files_count >= max_files_count)
247 break;
248 }
249 else
250 {
251 //files_count = 0;
252 }
253
254 }
255 //Closing the directory aa per the new FFS logic
256 ffs_closedir(dir);
257
258 TRACE_EVENT_P1("read files_count is %d",files_count);
259 return files_count;
260 }
261 /*******************************************************************************
262
263 $Function: mfw_btips_a2dpUnpopulateFiles
264
265 $Description:Frees the memory allocated for the array
266 $Returns: None
267
268 $Arguments: file_names:Pointer to the arrayto store file names
269
270 *******************************************************************************/
271 void mfw_btips_a2dpUnpopulateFiles(char **file_names)
272 {
273 int i;
274 TRACE_FUNCTION("mfw_btips_a2dpUnpopulateFiles");
275
276 //Free the allocated memory for file names
277 for (i = 0; i<A2DP_MAX_FILES; i++)
278 {
279 if(file_names[i])
280 {
281 mfwFree((U8 *)file_names[i],(U16)strlen(file_names[i]) + 1);
282 }
283 file_names[i]=NULL;
284 }
285
286 }
287 /*******************************************************************************
288
289 $Function: mfw_btips_a2dpGetExtension
290
291 $Description: public function to retrieve the extension of a file
292
293 $Returns:Extention of the filename
294
295 $Arguments: scr- Filename
296
297 *******************************************************************************/
298 char *mfw_btips_a2dpGetExtension(char *src)
299 {
300 int i,len;
301
302 TRACE_FUNCTION("mfw_btips_a2dpGetExtension");
303 len = strlen(src);
304 for(i = 0; i < len; i++){
305 if(src[i] == '.'){
306 return (src+i+1);
307 }
308 }
309 return (src+i);
310 }
311 /*******************************************************************************
312
313 $Function: sounds_midi_return_file_number
314
315 $Description: returns the file count
316
317 $Returns: Count of the Midi files
318
319 $Arguments: None
320
321 *******************************************************************************/
322 int mfw_btips_a2dpGetNumFiles(void)
323 {
324 TRACE_FUNCTION("sounds_midi_return_file_number");
325 TRACE_FUNCTION_P1("mfw_btips_a2dpGetNumFiles -a2dp_files_count - %d", a2dp_files_count);
326 if(a2dp_files_count<=0)
327 return 0;
328 else
329 return a2dp_files_count;
330
331 }
332 /*******************************************************************************
333
334 $Function: mfw_btips_a2dpGetFileName
335
336 $Description: Returns the file name
337
338 $Returns: Name of the file
339
340 $Arguments: index:The index of the file, whose name has to be retrieved
341
342 *******************************************************************************/
343
344 char* mfw_btips_a2dpGetFileName(UBYTE index)
345 {
346
347 TRACE_FUNCTION("mfw_btips_a2dpGetFileName");
348 TRACE_EVENT_P2("A2dp_file_names[%d] is %s",index,(char *)a2dp_file_names[index]);
349 return (char *) a2dp_file_names[index];
350
351 }
352
353 /*******************************************************************************
354
355 $Function: mfw_btips_a2dpEventCallBack
356
357 $Description: Returns the file name
358
359 $Returns: Name of the file
360
361 $Arguments: index:The index of the file, whose name has to be retrieved
362
363 *******************************************************************************/
364
365 static void mfw_btips_a2dpEventCallBack(const BtlA2dpEvent *event)
366 {
367
368 A2dpError error = A2DP_ERR_NO_ERROR;
369 A2dpCallbackParms *Parms;
370 BOOL streamStopped = FALSE;
371 BtStatus status;
372 // char szSelectedFilePath[256]
373
374 Parms = event->callbackParms;
375
376 TRACE_FUNCTION_P1("mfw_btips_a2dpEventCallBack %d",Parms->event);
377
378 switch (Parms->event) {
379 case A2DP_EVENT_STREAM_OPEN_IND:
380 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_OPEN_IND streamId %d.", event->streamId);
381 TRACE_FUNCTION_P2(" Codec: %s, Length: %d",
382 pCodecType(Parms->p.configReq->codec.codecType),
383 Parms->p.configReq->codec.elemLen);
384
385 /*if (promptUserOnIncomingConAndStart)
386 {
387 AppReport("Please Accept or Reject open stream request");
388 }
389 else
390 */
391 {
392 /* Auto-accept connection */
393 status = BTL_A2DP_OpenStreamResponse(btlA2dpContext, event->streamId, A2DP_ERR_NO_ERROR);
394 TRACE_FUNCTION_P1("BTL_A2DP_OpenStreamResponse() returned %s.",
395 pBT_Status(status));
396 }
397
398 break;
399
400 case A2DP_EVENT_GET_CONFIG_IND:
401 TRACE_FUNCTION_P1("A2DP_EVENT_GET_CONFIG_IND streamId %d.", event->streamId);
402 TRACE_FUNCTION("To configure and open strean press 'Open Stream' button ");
403 /*if(streamId > 0)
404 {
405 mfw_btips_a2dpCloseStream();
406 }*/
407
408 status = BTL_A2DP_OpenStream(btlA2dpContext, streamId);
409 isStreamClosed[event->streamId] = FALSE;
410 bthalMmStreamStateIsConnected(event->streamId, TRUE);
411 TRACE_FUNCTION_P1("BTL_A2DP_OpenStream() returned %s.",
412 pBT_Status(status));
413 break;
414
415 case A2DP_EVENT_STREAM_OPEN:
416 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_OPEN streamId %d.", event->streamId);
417 isStreamClosed[event->streamId] = FALSE;
418 bthalMmStreamStateIsConnected(event->streamId, TRUE);
419 if(bPlaySbcFile)
420 {
421 TRACE_FUNCTION("Opening PCM File ");
422 if(AppPcmSimOpenFile(szSelectedFileName))
423 {
424 TRACE_FUNCTION("PCM File Open Success!!");
425 }
426 else
427 {
428 TRACE_FUNCTION("PCM File Open Failed!!");
429 }
430 }
431
432 if(bPlayMp3File)
433 {
434 TRACE_FUNCTION("Opening Mp3 File ");
435 if(AppMp3OpenFile(szSelectedFileName))
436 {
437 TRACE_FUNCTION("Mp3 File Open Success!!");
438 }
439 else
440 {
441 TRACE_FUNCTION("Mp3 File Open Failed!!");
442 }
443 status = BTL_A2DP_StartStream(btlA2dpContext, streamId);
444 TRACE_FUNCTION_P1("BTL_A2DP_StartStream() returned %s.",
445 pBT_Status(status));
446
447 }
448
449
450 break;
451
452 case A2DP_EVENT_STREAM_IDLE:
453 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_IDLE streamId %d.", event->streamId);
454 isStreamClosed[event->streamId] = FALSE;
455 streamStopped = TRUE;
456
457 break;
458
459 case A2DP_EVENT_STREAM_CLOSED:
460 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_CLOSED streamId %d.", event->streamId);
461 isStreamClosed[event->streamId] = TRUE;
462 streamStopped = TRUE;
463 bthalMmStreamStateIsConnected(event->streamId, FALSE);
464 break;
465
466 case A2DP_EVENT_STREAM_START_IND:
467 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_START_IND streamId %d.", event->streamId);
468
469 /*if (promptUserOnIncomingConAndStart)
470 {
471 AppReport("Please Accept or Reject start stream request");
472 }
473 else
474 */
475 {
476 /* Auto-accept stream start */
477 status = BTL_A2DP_StartStreamResponse(btlA2dpContext, event->streamId, A2DP_ERR_NO_ERROR);
478 TRACE_FUNCTION_P1("BTL_A2DP_StartStreamResponse() returned %s.",
479 pBT_Status(status));
480 }
481
482 break;
483
484 case A2DP_EVENT_STREAM_STARTED:
485 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_STARTED streamId %d.", event->streamId);
486
487 isStreamClosed[event->streamId] = FALSE;
488 streamingNow = TRUE;
489 if(bPlaySbcFile)
490 {
491 TRACE_FUNCTION("Playing PCM File ");
492 AppPcmSimPlayFile();
493 }
494 else if(bPlayMp3File)
495 {
496 TRACE_FUNCTION("Playing Mp3 File ");
497 AppMp3PlayFile();
498
499 }
500 TRACE_FUNCTION_P1("Playing File %s : ", szSelectedFileName);
501 break;
502
503 case A2DP_EVENT_STREAM_SUSPENDED:
504 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_SUSPENDED streamId %d.", event->streamId);
505
506 isStreamClosed[event->streamId] = FALSE;
507
508 if (Parms->error != AVDTP_ERR_NO_ERROR)
509 {
510 TRACE_FUNCTION_P2("Stream Suspend Failed, reason: %s, status: %s",
511 pAvError(Parms->error),
512 pBT_Status(Parms->status));
513 }
514 /*switch (event->streamId)
515 {
516 case (0):
517 SendDlgItemMessage(AppWnd, IDC_STREAM0_OPEND, BM_SETCHECK, BST_CHECKED, 0L);
518 SendDlgItemMessage(AppWnd, IDC_STREAM0_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
519 break;
520
521 case (1):
522 SendDlgItemMessage(AppWnd, IDC_STREAM1_OPEND, BM_SETCHECK, BST_CHECKED, 0L);
523 SendDlgItemMessage(AppWnd, IDC_STREAM1_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
524 break;
525
526 case (2):
527 SendDlgItemMessage(AppWnd, IDC_STREAM2_OPEND, BM_SETCHECK, BST_CHECKED, 0L);
528 SendDlgItemMessage(AppWnd, IDC_STREAM2_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
529 break;
530
531 case (3):
532 SendDlgItemMessage(AppWnd, IDC_STREAM3_OPEND, BM_SETCHECK, BST_CHECKED, 0L);
533 SendDlgItemMessage(AppWnd, IDC_STREAM3_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
534 break;
535 }
536 */
537 break;
538
539 case A2DP_EVENT_STREAM_ABORTED:
540 TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_ABORTED streamId %d.", event->streamId);
541 if (Parms->error != AVDTP_ERR_NO_ERROR) {
542 TRACE_FUNCTION_P2("Stream Abort Failed, reason: %s, status: %s",
543 pAvError(Parms->error),
544 pBT_Status(Parms->status));
545 }
546 /*switch (event->streamId)
547 {
548 case (0):
549 if(isStreamClosed[0] == FALSE)
550 {
551
552 SendDlgItemMessage(AppWnd, IDC_STREAM0_IDLE, BM_SETCHECK, BST_CHECKED, 0L);
553 }
554 SendDlgItemMessage(AppWnd, IDC_STREAM0_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
555 SendDlgItemMessage(AppWnd, IDC_STREAM0_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
556 break;
557
558 case (1):
559 if(isStreamClosed[1] == FALSE)
560 {
561
562 SendDlgItemMessage(AppWnd, IDC_STREAM1_IDLE, BM_SETCHECK, BST_CHECKED, 0L);
563 }
564 SendDlgItemMessage(AppWnd, IDC_STREAM1_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
565 SendDlgItemMessage(AppWnd, IDC_STREAM1_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
566 break;
567
568 case (2):
569 if(isStreamClosed[2] == FALSE)
570 {
571
572 SendDlgItemMessage(AppWnd, IDC_STREAM2_IDLE, BM_SETCHECK, BST_CHECKED, 0L);
573 }
574 SendDlgItemMessage(AppWnd, IDC_STREAM2_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
575 SendDlgItemMessage(AppWnd, IDC_STREAM2_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
576 break;
577
578 case (3):
579 if(isStreamClosed[3] == FALSE)
580 {
581
582 SendDlgItemMessage(AppWnd, IDC_STREAM3_IDLE, BM_SETCHECK, BST_CHECKED, 0L);
583 }
584 SendDlgItemMessage(AppWnd, IDC_STREAM3_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
585 SendDlgItemMessage(AppWnd, IDC_STREAM3_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
586 break;
587 }
588 */
589 isStreamClosed[event->streamId] = FALSE;
590 streamStopped = TRUE;
591 bPlaySbcFile = FALSE;
592 bPlayMp3File = FALSE;
593 break;
594
595 case A2DP_EVENT_DISABLED:
596 TRACE_FUNCTION("A2DP_EVENT_DISABLED");
597 /*SendDlgItemMessage(AppWnd, IDC_STREAM0_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L);
598 SendDlgItemMessage(AppWnd, IDC_STREAM0_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
599 SendDlgItemMessage(AppWnd, IDC_STREAM0_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
600 SendDlgItemMessage(AppWnd, IDC_STREAM0_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L);
601 SendDlgItemMessage(AppWnd, IDC_STREAM1_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L);
602 SendDlgItemMessage(AppWnd, IDC_STREAM1_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
603 SendDlgItemMessage(AppWnd, IDC_STREAM1_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
604 SendDlgItemMessage(AppWnd, IDC_STREAM1_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L);
605 SendDlgItemMessage(AppWnd, IDC_STREAM2_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L);
606 SendDlgItemMessage(AppWnd, IDC_STREAM2_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
607 SendDlgItemMessage(AppWnd, IDC_STREAM2_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
608 SendDlgItemMessage(AppWnd, IDC_STREAM2_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L);
609 SendDlgItemMessage(AppWnd, IDC_STREAM3_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L);
610 SendDlgItemMessage(AppWnd, IDC_STREAM3_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L);
611 SendDlgItemMessage(AppWnd, IDC_STREAM3_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L);
612 SendDlgItemMessage(AppWnd, IDC_STREAM3_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L);
613 */
614 streamStopped = TRUE;
615
616 break;
617
618 default:
619 TRACE_FUNCTION_P1("MFW A2DP Unexpected event %d!", Parms->event);
620 break;
621 }
622
623 if ( streamStopped )
624 {
625 streamingNow = FALSE;
626 }
627 }
628 /*---------------------------------------------------------------------------
629 * pCodecType()
630 *---------------------------------------------------------------------------
631 *
632 * Synopsis: Prints codec type message
633 *
634 */
635 static char * pCodecType(AvdtpCodecType CType)
636 {
637 switch (CType) {
638 case AVDTP_CODEC_TYPE_SBC:
639 return "SBC";
640 case AVDTP_CODEC_TYPE_MPEG1_2_AUDIO:
641 return "MPEG1_2_AUDIO";
642 case AVDTP_CODEC_TYPE_MPEG2_4_AAC:
643 return "MPEG2_4_AAC";
644 case AVDTP_CODEC_TYPE_ATRAC:
645 return "ATRAC";
646 case AVDTP_CODEC_TYPE_NON_A2DP:
647 return "Non-A2DP";
648 default:
649 return "UNKNOWN";
650 }
651 }
652 /*---------------------------------------------------------------------------
653 * pAvError()
654 *---------------------------------------------------------------------------
655 *
656 * Synopsis: Prints AV error message
657 *
658 */
659 static char * pAvError(AvdtpError Error)
660 {
661 switch (Error) {
662 case AVDTP_ERR_NO_ERROR:
663 return "AVDTP_ERR_NO_ERROR";
664 case AVDTP_ERR_BAD_HEADER_FORMAT:
665 return "AVDTP_ERR_BAD_HEADER_FORMAT";
666 case AVDTP_ERR_BAD_LENGTH:
667 return "AVDTP_ERR_BAD_LENGTH";
668 case AVDTP_ERR_BAD_ACP_SEID:
669 return "AVDTP_ERR_BAD_ACP_SEID";
670 case AVDTP_ERR_IN_USE:
671 return "AVDTP_ERR_IN_USE";
672 case AVDTP_ERR_NOT_IN_USE:
673 return "AVDTP_ERR_NOT_IN_USE";
674 case AVDTP_ERR_BAD_SERV_CATEGORY:
675 return "AVDTP_ERR_BAD_SERV_CATEGORY";
676 case AVDTP_ERR_BAD_PAYLOAD_FORMAT:
677 return "AVDTP_ERR_BAD_PAYLOAD_FORMAT";
678 case AVDTP_ERR_NOT_SUPPORTED_COMMAND:
679 return "AVDTP_ERR_NOT_SUPPORTED_COMMAND";
680 case AVDTP_ERR_INVALID_CAPABILITIES:
681 return "AVDTP_ERR_INVALID_CAPABILITIES";
682 case AVDTP_ERR_BAD_RECOVERY_TYPE:
683 return "AVDTP_ERR_BAD_RECOVERY_TYPE";
684 case AVDTP_ERR_BAD_MEDIA_TRANSPORT_FORMAT:
685 return "AVDTP_ERR_BAD_MEDIA_TRANSPORT_FORMAT";
686 case AVDTP_ERR_BAD_RECOVERY_FORMAT:
687 return "AVDTP_ERR_BAD_RECOVERY_FORMAT";
688 case AVDTP_ERR_BAD_ROHC_FORMAT:
689 return "AVDTP_ERR_BAD_ROHC_FORMAT";
690 case AVDTP_ERR_BAD_CP_FORMAT:
691 return "AVDTP_ERR_BAD_CP_FORMAT";
692 case AVDTP_ERR_BAD_MULTIPLEXING_FORMAT:
693 return "AVDTP_ERR_BAD_MULTIPLEXING_FORMAT";
694 case AVDTP_ERR_UNSUPPORTED_CONFIGURATION:
695 return "AVDTP_ERR_UNSUPPORTED_CONFIGURATION";
696 case AVDTP_ERR_BAD_STATE:
697 return "AVDTP_ERR_BAD_STATE";
698 case A2DP_ERR_BAD_SERVICE:
699 return" A2DP_ERR_BAD_SERVICE";
700 case A2DP_ERR_INSUFFICIENT_RESOURCE:
701 return" A2DP_ERR_INSUFFICENT_RESOURCE";
702 case A2DP_ERR_INVALID_CODEC_TYPE:
703 return" A2DP_ERR_INVALID_CODEC_TYPE";
704 case A2DP_ERR_NOT_SUPPORTED_CODEC_TYPE:
705 return" A2DP_ERR_NOT_SUPPORTED_CODEC_TYPE";
706 case A2DP_ERR_INVALID_SAMPLING_FREQUENCY:
707 return" A2DP_ERR_INVALID_SAMPLING_FREQUENCY";
708 case A2DP_ERR_NOT_SUPPORTED_SAMP_FREQ:
709 return" A2DP_ERR_NOT_SUPPORTED_SAMP_FREQ";
710 case A2DP_ERR_INVALID_CHANNEL_MODE:
711 return" A2DP_ERR_INVALID_CHANNEL_MODE";
712 case A2DP_ERR_NOT_SUPPORTED_CHANNEL_MODE:
713 return" A2DP_ERR_NOT_SUPPORTED_CHANNEL_MODE";
714 case A2DP_ERR_INVALID_SUBBANDS:
715 return" A2DP_ERR_INVALID_SUBBANDS";
716 case A2DP_ERR_NOT_SUPPORTED_SUBBANDS:
717 return" A2DP_ERR_NOT_SUPPORTED_SUBBANDS";
718 case A2DP_ERR_INVALID_ALLOCATION_METHOD:
719 return" A2DP_ERR_INVALID_ALLOCATION_METHOD";
720 case A2DP_ERR_NOT_SUPPORTED_ALLOC_METHOD:
721 return" A2DP_ERR_NOT_SUPPORTED_ALLOC_METHOD";
722 case A2DP_ERR_INVALID_MIN_BITPOOL_VALUE:
723 return" A2DP_ERR_INVALID_MIN_BITPOOL_VALUE";
724 case A2DP_ERR_NOT_SUPPORTED_MIN_BITPOOL_VALUE:
725 return" A2DP_ERR_NOT_SUPPORTED_MIN_BITPOOL_VALUE";
726 case A2DP_ERR_INVALID_MAX_BITPOOL_VALUE:
727 return" A2DP_ERR_INVALID_MAX_BITPOOL_VALUE";
728 case A2DP_ERR_NOT_SUPPORTED_MAX_BITPOOL_VALUE:
729 return" A2DP_ERR_NOT_SUPPORTED_MAX_BITPOOL_VALUE";
730 case A2DP_ERR_INVALID_LAYER:
731 return" A2DP_ERR_INVALID_LAYER";
732 case A2DP_ERR_NOT_SUPPORTED_LAYER:
733 return" A2DP_ERR_NOT_SUPPORTED_LAYER";
734 case A2DP_ERR_NOT_SUPPORTED_CRC:
735 return" A2DP_ERR_NOT_SUPPORTED_CRC";
736 case A2DP_ERR_NOT_SUPPORTED_MPF:
737 return" A2DP_ERR_NOT_SUPPORTED_MPF";
738 case A2DP_ERR_NOT_SUPPORTED_VBR:
739 return" A2DP_ERR_NOT_SUPPORTED_VBR";
740 case A2DP_ERR_INVALID_BIT_RATE:
741 return" A2DP_ERR_INVALID_BIT_RATE";
742 case A2DP_ERR_NOT_SUPPORTED_BIT_RATE:
743 return" A2DP_ERR_NOT_SUPPORTED_BIT_RATE";
744 case A2DP_ERR_INVALID_OBJECT_TYPE:
745 return" A2DP_ERR_INVALID_OBJECT_TYPE";
746 case A2DP_ERR_NOT_SUPPORTED_OBJECT_TYPE:
747 return" A2DP_ERR_NOT_SUPPORTED_OBJECT_TYPE";
748 case A2DP_ERR_INVALID_CHANNELS:
749 return" A2DP_ERR_INVALID_CHANNELS";
750 case A2DP_ERR_NOT_SUPPORTED_CHANNELS:
751 return" A2DP_ERR_NOT_SUPPORTED_CHANNELS";
752 case A2DP_ERR_INVALID_VERSION:
753 return" A2DP_ERR_INVALID_VERSION";
754 case A2DP_ERR_NOT_SUPPORTED_VERSION:
755 return" A2DP_ERR_NOT_SUPPORTED_VERSION";
756 case A2DP_ERR_NOT_SUPPORTED_MAXIMUM_SUL:
757 return" A2DP_ERR_NOT_SUPPORTED_MAXIMUM_SUL";
758 case A2DP_ERR_INVALID_BLOCK_LENGTH:
759 return" A2DP_ERR_INVALID_BLOCK_LENGTH";
760 case A2DP_ERR_INVALID_CP_TYPE:
761 return" A2DP_ERR_INVALID_CP_TYPE";
762 case A2DP_ERR_INVALID_CP_FORMAT:
763 return" A2DP_ERR_INVALID_CP_FORMAT";
764 default:
765 return "UNKNOWN";
766 }
767 }
768
769
770 /*---------------------------------------------------------------------------
771 * mfw_btips_a2dpSetDefaultSbcLocalCap()
772 *---------------------------------------------------------------------------
773 *
774 * Synopsis: Save local SBC capabilities
775 *
776 */
777 static void mfw_btips_a2dpSetDefaultSbcLocalCap(void)
778 {
779 sbcLocalCap.samplingFreq = ( BTHAL_MM_SBC_SAMPLING_FREQ_16000 | BTHAL_MM_SBC_SAMPLING_FREQ_32000|BTHAL_MM_SBC_SAMPLING_FREQ_44100 |BTHAL_MM_SBC_SAMPLING_FREQ_48000);
780 sbcLocalCap.channelMode = BTHAL_MM_SBC_CHANNEL_MODE_MONO | BTHAL_MM_SBC_CHANNEL_MODE_DUAL_CHANNEL | BTHAL_MM_SBC_CHANNEL_MODE_STEREO | BTHAL_MM_SBC_CHANNEL_MODE_JOINT_STEREO;
781 sbcLocalCap.blockLength = (BTHAL_MM_SBC_BLOCK_LENGTH_4 | BTHAL_MM_SBC_BLOCK_LENGTH_8 | BTHAL_MM_SBC_BLOCK_LENGTH_12 | BTHAL_MM_SBC_BLOCK_LENGTH_16);
782 sbcLocalCap.subbands = BTHAL_MM_SBC_SUBBANDS_8 | BTHAL_MM_SBC_SUBBANDS_4;
783 sbcLocalCap.allocationMethod = BTHAL_MM_SBC_ALLOCATION_METHOD_LOUDNESS | BTHAL_MM_SBC_ALLOCATION_METHOD_SNR;
784 sbcLocalCap.maxBitpoolValue = MAX_SUPPORTED_BITPOOL;
785 sbcLocalCap.minBitpoolValue = MIN_SUPPORTED_BITPOOL;
786 }
787
788 /*---------------------------------------------------------------------------
789 * mfw_btips_a2dpSetDefaultMp3LocalCap()
790 *---------------------------------------------------------------------------
791 *
792 * Synopsis: Save local PM3 capabilities
793 *
794 */
795 static void mfw_btips_a2dpSetDefaultMp3LocalCap(void)
796 {
797 mp3LocalCap.bitRate = 0xFFFF;
798 mp3LocalCap.channelMode = (BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_MONO | BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_DUAL_CHANNEL | BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_STEREO | BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_JOINT_STEREO);
799 mp3LocalCap.crcProtection = BTHAL_MM_MPEG1_2_AUDIO_CRC_PROTECTION_SUPPORTED;
800 mp3LocalCap.layer = (BTHAL_MM_MPEG1_2_AUDIO_LAYER_1 | BTHAL_MM_MPEG1_2_AUDIO_LAYER_2 | BTHAL_MM_MPEG1_2_AUDIO_LAYER_3);
801 mp3LocalCap.mpf2 = BTHAL_MM_MPEG1_2_AUDIO_MPF2_SUPPORTED;
802 mp3LocalCap.samplingFreq = (BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_48000 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_44100 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_32000 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_24000 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_22050 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_16000);
803 mp3LocalCap.vbr = BTHAL_MM_MPEG1_2_AUDIO_VBR_SUPPORTED;
804
805 }
806 BtStatus mfw_btips_a2dpConnectStream(BD_ADDR bdAddr)
807 {
808 BtStatus status;
809
810 TRACE_FUNCTION("mfw_btips_a2dpConnectStream");
811
812 if ( (strcmp(szSelectedFileExt, "mp3") == 0))
813 {
814 bPlayMp3File = TRUE;
815 bPlaySbcFile = FALSE;
816 codec = BTL_A2DP_CODEC_MPEG1_2_AUDIO;
817 status = BTL_A2DP_ConnectStream(btlA2dpContext,&bdAddr, codec, &streamId);
818 if (status == BT_STATUS_PENDING)
819 {
820 TRACE_FUNCTION("Connecting Mp3 stream (opening signaling channel in process)...");
821 }
822 else
823 {
824 TRACE_FUNCTION_P1("connecting Mp3 stream failed, status: %s", pBT_Status(status));
825 }
826 }
827 else if ( (strcmp(szSelectedFileExt, "pcm") == 0))
828 {
829 bPlaySbcFile = TRUE;
830 bPlayMp3File = FALSE;
831 codec = BTL_A2DP_CODEC_SBC;
832 status = BTL_A2DP_ConnectStream(btlA2dpContext,&bdAddr, codec, &streamId);
833 if (status == BT_STATUS_PENDING)
834 {
835 TRACE_FUNCTION("Connecting SBC stream (opening signaling channel in process)...");
836 }
837 else
838 {
839 TRACE_FUNCTION_P1("connecting SBC stream failed, status: %s", pBT_Status(status));
840 }
841
842 }
843 else if ( (strcmp(szSelectedFileExt, "wav") == 0))
844 {
845 bPlaySbcFile = TRUE;
846 bPlayMp3File = FALSE;
847 codec = BTL_A2DP_CODEC_SBC;
848 status = BTL_A2DP_ConnectStream(btlA2dpContext,&bdAddr, codec, &streamId);
849 if (status == BT_STATUS_PENDING)
850 {
851 TRACE_FUNCTION("Connecting SBC stream (opening signaling channel in process)...");
852 }
853 else
854 {
855 TRACE_FUNCTION_P1("connecting SBC stream failed, status: %s", pBT_Status(status));
856 }
857
858 }
859 return status;
860 }
861 BtStatus mfw_btips_a2dpCloseStream()
862 {
863 BtStatus status;
864
865 TRACE_FUNCTION("mfw_btips_a2dpCloseStream");
866
867 if ( (strcmp(szSelectedFileExt, "mp3") == 0))
868 {
869 //AppMp3StopFile();
870 AppStopAudioFile();
871 AppMp3CloseFile();
872 }
873 else if ( (strcmp(szSelectedFileExt, "pcm") == 0))
874 {
875
876 AppPcmSimStopFile();
877 AppPcmSimCloseFile();
878 }
879 else if ( (strcmp(szSelectedFileExt, "wav") == 0))
880 {
881
882 AppPcmSimStopFile();
883 AppPcmSimCloseFile();
884 }
885 status = BTL_A2DP_CloseStream(btlA2dpContext, streamId);
886 TRACE_FUNCTION_P1("BTL_A2DP_CloseStream returned %s", pBT_Status(status));
887 return status;
888 }
889
890 BOOL mfw_btips_a2dpGetConnectedDevice (BD_ADDR *bdAddr, U8 *name)
891 {
892 BtStatus status;
893
894 status = BTL_A2DP_GetConnectedDevice (btlA2dpContext, streamId, bdAddr);
895
896 if (status == BT_STATUS_SUCCESS)
897 {
898 mfw_btips_bmgGetDeviceName (bdAddr, name);
899 return TRUE;
900 }
901 return FALSE;
902 }
903
904 BOOL mfw_btips_a2dpDisconnect (BD_ADDR bdAddr)
905 {
906 BtStatus btStatus;
907
908 btStatus = BTL_A2DP_CloseStream (btlA2dpContext, streamId);
909
910 return TRUE;
911 }
912
913 #endif