1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
221
222
223
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
258
259
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
336
337
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
373
374
380
381
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
488
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
527
528
531
532
538
539
540
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
573
576
579
580
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
627
628
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
674
675
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
712
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
746
747
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
779
780
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
814
815
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
848
849
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
986
987
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1018
1019
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1229
1230
1231
1232
1233
1234
1235
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1302
1303
/* ... */
/* ... */
#include <string.h>
#include "stack/bt_types.h"
#include "common/bt_target.h"
#include "stack/avdt_api.h"
#include "stack/avdtc_api.h"
#include "avdt_int.h"
#include "stack/l2c_api.h"
#include "stack/btm_api.h"
#include "stack/btu.h"
#include "osi/allocator.h"10 includes
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
#if AVDT_DYNAMIC_MEMORY == FALSE
tAVDT_CB avdt_cb;
#else
tAVDT_CB *avdt_cb_ptr;
#endif
/* ... */
void avdt_process_timeout(TIMER_LIST_ENT *p_tle)
{
UINT8 event = 0;
UINT8 err_code = AVDT_ERR_TIMEOUT;
switch (p_tle->event) {
case BTU_TTYPE_AVDT_SCB_DELAY_RPT:
event = AVDT_SCB_DELAY_RPT_RSP_TOUT_EVT;
break;...
case BTU_TTYPE_AVDT_CCB_RET:
event = AVDT_CCB_RET_TOUT_EVT + AVDT_CCB_MKR;
break;
...
case BTU_TTYPE_AVDT_CCB_RSP:
event = AVDT_CCB_RSP_TOUT_EVT + AVDT_CCB_MKR;
break;
...
case BTU_TTYPE_AVDT_CCB_IDLE:
event = AVDT_CCB_IDLE_TOUT_EVT + AVDT_CCB_MKR;
break;
...
case BTU_TTYPE_AVDT_SCB_TC:
event = AVDT_SCB_TC_TOUT_EVT;
break;
...
default:
break;...
}{...}
if (event & AVDT_CCB_MKR) {
avdt_ccb_event((tAVDT_CCB *) p_tle->param, (UINT8) (event & ~AVDT_CCB_MKR),
(tAVDT_CCB_EVT *) &err_code);
}{...} else {
avdt_scb_event((tAVDT_SCB *) p_tle->param, event, NULL);
}{...}
}{...}
/* ... */
void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback)
{
L2CA_Register(AVDT_PSM, (tL2CAP_APPL_INFO *) &avdt_l2c_appl);
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVDTP, p_reg->sec_mask,
AVDT_PSM, BTM_SEC_PROTO_AVDT, AVDT_CHAN_SIG);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVDTP, p_reg->sec_mask,
AVDT_PSM, BTM_SEC_PROTO_AVDT, AVDT_CHAN_SIG);
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVDTP_NOSEC, BTM_SEC_NONE,
AVDT_PSM, BTM_SEC_PROTO_AVDT, AVDT_CHAN_MEDIA);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVDTP_NOSEC, BTM_SEC_NONE,
AVDT_PSM, BTM_SEC_PROTO_AVDT, AVDT_CHAN_MEDIA);
#if AVDT_REPORTING == TRUE
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVDTP_NOSEC, BTM_SEC_NONE,
AVDT_PSM, BTM_SEC_PROTO_AVDT, AVDT_CHAN_REPORT);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVDTP_NOSEC, BTM_SEC_NONE,
AVDT_PSM, BTM_SEC_PROTO_AVDT, AVDT_CHAN_REPORT);/* ... */
#endif
avdt_scb_init();
avdt_ccb_init();
avdt_ad_init();
memcpy(&avdt_cb.rcb, p_reg, sizeof(tAVDT_REG));
avdt_cb.p_conn_cback = p_cback;
}{...}
/* ... */
void AVDT_Deregister(void)
{
L2CA_Deregister(AVDT_PSM);
}{...}
/* ... */
void AVDT_SINK_Activate(void)
{
tAVDT_SCB *p_scb = &avdt_cb.scb[0];
int i;
AVDT_TRACE_DEBUG("AVDT_SINK_Activate");
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) {
AVDT_TRACE_DEBUG("AVDT_SINK_Activate found scb");
p_scb->sink_activated = TRUE;
p_scb->in_use = FALSE;
break;
}{...}
}{...}
}{...}
/* ... */
void AVDT_SINK_Deactivate(void)
{
tAVDT_SCB *p_scb = &avdt_cb.scb[0];
int i;
AVDT_TRACE_DEBUG("AVDT_SINK_Deactivate");
for (i = 0; i < AVDT_NUM_SEPS; i++, p_scb++) {
if ((p_scb->allocated) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) {
AVDT_TRACE_DEBUG("AVDT_SINK_Deactivate, found scb");
p_scb->sink_activated = FALSE;
p_scb->in_use = TRUE;
break;
}{...}
}{...}
}{...}
void AVDT_AbortReq(UINT8 handle)
{
AVDT_TRACE_ERROR("%s\n", __func__);
tAVDT_SCB *p_scb = avdt_scb_by_hdl(handle);
if (p_scb != NULL) {
avdt_scb_event(p_scb, AVDT_SCB_API_ABORT_REQ_EVT, NULL);
}{...} else {
AVDT_TRACE_ERROR("%s Improper SCB, can not abort the stream\n", __func__);
}{...}
}{...}
/* ... */
UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs)
{
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB *p_scb;
if (((p_cs->cfg.psc_mask & (~AVDT_PSC)) != 0) || (p_cs->p_ctrl_cback == NULL)) {
result = AVDT_BAD_PARAMS;
}{...}
else if ((p_scb = avdt_scb_alloc(p_cs)) == NULL) {
result = AVDT_NO_RESOURCES;
}{...} else {
*p_handle = avdt_scb_to_hdl(p_scb);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_RemoveStream(UINT8 handle)
{
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB *p_scb;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else {
avdt_scb_event(p_scb, AVDT_SCB_API_REMOVE_EVT, NULL);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info,
UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback)
{
tAVDT_CCB *p_ccb;
UINT16 result = AVDT_SUCCESS;
tAVDT_CCB_EVT evt;
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
result = AVDT_NO_RESOURCES;
}{...}
}{...}
if (result == AVDT_SUCCESS) {
if (p_ccb->proc_busy) {
result = AVDT_BUSY;
}{...}
else {
evt.discover.p_sep_info = p_sep_info;
evt.discover.num_seps = max_seps;
evt.discover.p_cback = p_cback;
avdt_ccb_event(p_ccb, AVDT_CCB_API_DISCOVER_REQ_EVT, &evt);
}{...}
}{...}
return result;
}{...}
/* ... */
static UINT16 avdt_get_cap_req(BD_ADDR bd_addr, tAVDT_CCB_API_GETCAP *p_evt)
{
tAVDT_CCB *p_ccb = NULL;
UINT16 result = AVDT_SUCCESS;
if ((p_evt->single.seid < AVDT_SEID_MIN) || (p_evt->single.seid > AVDT_SEID_MAX)) {
AVDT_TRACE_ERROR("seid: %d\n", p_evt->single.seid);
result = AVDT_BAD_PARAMS;
}{...}
else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
result = AVDT_NO_RESOURCES;
}{...}
}{...}
if (result == AVDT_SUCCESS) {
if (p_ccb->proc_busy) {
result = AVDT_BUSY;
}{...}
else {
avdt_ccb_event(p_ccb, AVDT_CCB_API_GETCAP_REQ_EVT, (tAVDT_CCB_EVT *)p_evt);
}{...}
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback)
{
tAVDT_CCB_API_GETCAP getcap;
getcap.single.seid = seid;
getcap.single.sig_id = AVDT_SIG_GETCAP;
getcap.p_cfg = p_cfg;
getcap.p_cback = p_cback;
return avdt_get_cap_req (bd_addr, &getcap);
}{...}
/* ... */
UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback)
{
tAVDT_CCB_API_GETCAP getcap;
getcap.single.seid = seid;
getcap.single.sig_id = AVDT_SIG_GET_ALLCAP;
getcap.p_cfg = p_cfg;
getcap.p_cback = p_cback;
return avdt_get_cap_req (bd_addr, &getcap);
}{...}
/* ... */
UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB_EVT evt;
UNUSED(seid);
AVDT_TRACE_DEBUG("%s: delay value: 0x%04x\n", __func__, delay);
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else
{
if ((p_scb->cs.tsep == AVDT_TSEP_SNK) && (p_scb->curr_cfg.psc_mask & AVDT_PSC_DELAY_RPT)) {
evt.apidelay.hdr.seid = p_scb->peer_seid;
evt.apidelay.delay = delay;
avdt_scb_event(p_scb, AVDT_SCB_API_DELAY_RPT_REQ_EVT, &evt);
}{...} else {
AVDT_TRACE_WARNING("%s: peer device does not supported\n", __func__);
result = AVDT_BAD_PARAMS;
}{...}
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg)
{
tAVDT_CCB *p_ccb = NULL;
tAVDT_SCB *p_scb = NULL;
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB_EVT evt;
if ((seid < AVDT_SEID_MIN) || (seid > AVDT_SEID_MAX)) {
result = AVDT_BAD_PARAMS;
}{...}
else if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...}
else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
result = AVDT_NO_RESOURCES;
}{...}
}{...}
if (result == AVDT_SUCCESS) {
evt.msg.config_cmd.hdr.seid = seid;
evt.msg.config_cmd.hdr.ccb_idx = avdt_ccb_to_idx(p_ccb);
evt.msg.config_cmd.int_seid = handle;
evt.msg.config_cmd.p_cfg = p_cfg;
avdt_scb_event(p_scb, AVDT_SCB_API_SETCONFIG_REQ_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT8 category)
{
tAVDT_SCB *p_scb;
tAVDT_SCB_EVT evt;
UINT16 result = AVDT_SUCCESS;
UINT8 event_code;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...}
/* ... */
else if (!p_scb->in_use) {
result = AVDT_BAD_HANDLE;
}{...}
else {
evt.msg.hdr.err_code = error_code;
evt.msg.hdr.err_param = category;
evt.msg.hdr.label = label;
if (error_code == 0) {
event_code = AVDT_SCB_API_SETCONFIG_RSP_EVT;
}{...} else {
event_code = AVDT_SCB_API_SETCONFIG_REJ_EVT;
}{...}
avdt_scb_event(p_scb, event_code, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles)
{
tAVDT_SCB *p_scb = NULL;
tAVDT_CCB_EVT evt;
UINT16 result = AVDT_SUCCESS;
int i;
if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) {
result = AVDT_BAD_PARAMS;
}{...} else {
for (i = 0; i < num_handles; i++) {
if ((p_scb = avdt_scb_by_hdl(p_handles[i])) == NULL) {
result = AVDT_BAD_HANDLE;
break;
}{...}
}{...}
}{...}
if (result == AVDT_SUCCESS) {
if (p_scb->p_ccb == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else {
memcpy(evt.msg.multi.seid_list, p_handles, num_handles);
evt.msg.multi.num_seps = num_handles;
avdt_ccb_event(p_scb->p_ccb, AVDT_CCB_API_START_REQ_EVT, &evt);
}{...}
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles)
{
tAVDT_SCB *p_scb = NULL;
tAVDT_CCB_EVT evt;
UINT16 result = AVDT_SUCCESS;
int i;
if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) {
result = AVDT_BAD_PARAMS;
}{...} else {
for (i = 0; i < num_handles; i++) {
if ((p_scb = avdt_scb_by_hdl(p_handles[i])) == NULL) {
result = AVDT_BAD_HANDLE;
break;
}{...}
}{...}
}{...}
if (result == AVDT_SUCCESS) {
if (p_scb->p_ccb == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else {
memcpy(evt.msg.multi.seid_list, p_handles, num_handles);
evt.msg.multi.num_seps = num_handles;
avdt_ccb_event(p_scb->p_ccb, AVDT_CCB_API_SUSPEND_REQ_EVT, &evt);
}{...}
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_CloseReq(UINT8 handle)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_SUCCESS;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else
{
avdt_scb_event(p_scb, AVDT_SCB_API_CLOSE_REQ_EVT, NULL);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB_EVT evt;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...}
else {
p_cfg->psc_mask = 0;
evt.msg.reconfig_cmd.p_cfg = p_cfg;
avdt_scb_event(p_scb, AVDT_SCB_API_RECONFIG_REQ_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT8 category)
{
tAVDT_SCB *p_scb;
tAVDT_SCB_EVT evt;
UINT16 result = AVDT_SUCCESS;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...}
else {
evt.msg.hdr.err_code = error_code;
evt.msg.hdr.err_param = category;
evt.msg.hdr.label = label;
avdt_scb_event(p_scb, AVDT_SCB_API_RECONFIG_RSP_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB_EVT evt;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...}
else {
evt.msg.security_rsp.p_data = p_data;
evt.msg.security_rsp.len = len;
avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_REQ_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code,
UINT8 *p_data, UINT16 len)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_SUCCESS;
tAVDT_SCB_EVT evt;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...}
else {
evt.msg.security_rsp.hdr.err_code = error_code;
evt.msg.security_rsp.hdr.label = label;
evt.msg.security_rsp.p_data = p_data;
evt.msg.security_rsp.len = len;
avdt_scb_event(p_scb, AVDT_SCB_API_SECURITY_RSP_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt, tAVDT_DATA_OPT_MASK opt)
{
tAVDT_SCB *p_scb;
tAVDT_SCB_EVT evt;
UINT16 result = AVDT_SUCCESS;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else {
evt.apiwrite.p_buf = p_pkt;
evt.apiwrite.time_stamp = time_stamp;
evt.apiwrite.m_pt = m_pt;
evt.apiwrite.opt = opt;
avdt_scb_event(p_scb, AVDT_SCB_API_WRITE_REQ_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt)
{
return AVDT_WriteReqOpt(handle, p_pkt, time_stamp, m_pt, AVDT_DATA_OPT_NONE);
}{...}
/* ... */
UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, tAVDT_CTRL_CBACK *p_cback)
{
tAVDT_CCB *p_ccb = NULL;
UINT16 result = AVDT_SUCCESS;
tAVDT_CCB_EVT evt;
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
result = AVDT_NO_RESOURCES;
}{...}
}{...} else if (p_ccb->ll_opened == FALSE) {
AVDT_TRACE_WARNING("AVDT_ConnectReq: CCB LL is in the middle of opening");
result = AVDT_BUSY;
}{...}
if (result == AVDT_SUCCESS) {
evt.connect.p_cback = p_cback;
evt.connect.sec_mask = sec_mask;
avdt_ccb_event(p_ccb, AVDT_CCB_API_CONNECT_REQ_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback)
{
tAVDT_CCB *p_ccb = NULL;
UINT16 result = AVDT_SUCCESS;
tAVDT_CCB_EVT evt;
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
result = AVDT_BAD_PARAMS;
}{...}
if (result == AVDT_SUCCESS) {
evt.disconnect.p_cback = p_cback;
avdt_ccb_event(p_ccb, AVDT_CCB_API_DISCONNECT_REQ_EVT, &evt);
}{...}
return result;
}{...}
/* ... */
UINT16 AVDT_GetL2CapChannel(UINT8 handle)
{
tAVDT_SCB *p_scb;
tAVDT_CCB *p_ccb;
UINT8 tcid;
UINT16 lcid = 0;
if (((p_scb = avdt_scb_by_hdl(handle)) != NULL)
&& ((p_ccb = p_scb->p_ccb) != NULL)) {
tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
}{...}
return (lcid);
}{...}
/* ... */
UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr)
{
tAVDT_SCB *p_scb;
tAVDT_CCB *p_ccb;
UINT8 tcid = 0;
UINT16 lcid = 0;
if (((p_scb = avdt_scb_by_hdl(handle)) != NULL)
&& ((p_ccb = p_scb->p_ccb) != NULL)) {
lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
}{...} else if ((p_ccb = avdt_ccb_by_bd(bd_addr)) != NULL) {
lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
}{...}
return (lcid);
}{...}
#if AVDT_MULTIPLEXING == TRUE
/* ... */
extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_SUCCESS;
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
}{...} else {
if (p_buf && p_scb->cs.p_media_cback == NULL) {
result = AVDT_NO_RESOURCES;
}{...} else {
p_scb->p_media_buf = p_buf;
p_scb->media_buf_len = buf_len;
}{...}
}{...}
return result;
}{...}
/* ... */#endif
#if AVDT_REPORTING == TRUE
/* ... */
UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
tAVDT_REPORT_DATA *p_data)
{
tAVDT_SCB *p_scb;
UINT16 result = AVDT_BAD_PARAMS;
BT_HDR *p_pkt;
tAVDT_TC_TBL *p_tbl;
UINT8 *p, *plen, *pm1, *p_end;
#if AVDT_MULTIPLEXING == TRUE
UINT8 *p_al = NULL, u;
#endif
UINT32 ssrc;
UINT16 len;
if (((p_scb = avdt_scb_by_hdl(handle)) != NULL)
&& (p_scb->p_ccb != NULL)
&& (((type == AVDT_RTCP_PT_SR) && (p_scb->cs.tsep == AVDT_TSEP_SRC)) ||
((type == AVDT_RTCP_PT_RR) && (p_scb->cs.tsep == AVDT_TSEP_SNK)) ||
(type == AVDT_RTCP_PT_SDES)) ) {
result = AVDT_NO_RESOURCES;
p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb);
if ((p_tbl->state == AVDT_AD_ST_OPEN) &&
(p_pkt = (BT_HDR *)osi_malloc(p_tbl->peer_mtu)) != NULL) {
p_pkt->offset = L2CAP_MIN_OFFSET;
p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
#if AVDT_MULTIPLEXING == TRUE
if (p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX) {
p_al = p;
p += 2;
}{...}
/* ... */#endif
pm1 = p;
*p++ = AVDT_MEDIA_OCTET1 | 1;
*p++ = type;
plen = p;
p += 2;
ssrc = avdt_scb_gen_ssrc(p_scb);
UINT32_TO_BE_STREAM(p, ssrc);
switch (type) {
case AVDT_RTCP_PT_SR:
*pm1 = AVDT_MEDIA_OCTET1;
UINT32_TO_BE_STREAM(p, p_data->sr.ntp_sec);
UINT32_TO_BE_STREAM(p, p_data->sr.ntp_frac);
UINT32_TO_BE_STREAM(p, p_data->sr.rtp_time);
UINT32_TO_BE_STREAM(p, p_data->sr.pkt_count);
UINT32_TO_BE_STREAM(p, p_data->sr.octet_count);
break;
...
case AVDT_RTCP_PT_RR:
*p++ = p_data->rr.frag_lost;
AVDT_TRACE_API("packet_lost: %d\n", p_data->rr.packet_lost);
p_data->rr.packet_lost &= 0xFFFFFF;
AVDT_TRACE_API("packet_lost: %d\n", p_data->rr.packet_lost);
UINT24_TO_BE_STREAM(p, p_data->rr.packet_lost);
UINT32_TO_BE_STREAM(p, p_data->rr.seq_num_rcvd);
UINT32_TO_BE_STREAM(p, p_data->rr.jitter);
UINT32_TO_BE_STREAM(p, p_data->rr.lsr);
UINT32_TO_BE_STREAM(p, p_data->rr.dlsr);
break;
...
case AVDT_RTCP_PT_SDES:
*p++ = AVDT_RTCP_SDES_CNAME;
len = strlen((char *)p_data->cname);
if (len > AVDT_MAX_CNAME_SIZE) {
len = AVDT_MAX_CNAME_SIZE;
}{...}
*p++ = (UINT8)len;
BCM_STRNCPY_S((char *)p, (char *)p_data->cname, AVDT_MAX_CNAME_SIZE + 1);
p += len;
break;...
}{...}
p_end = p;
len = p - pm1 - 1;
UINT16_TO_BE_STREAM(plen, len);
#if AVDT_MULTIPLEXING == TRUE
if (p_scb->curr_cfg.psc_mask & AVDT_PSC_MUX) {
p = p_al;
len++;
UINT16_TO_BE_STREAM(p_al, len );
u = *p;
*p = (p_scb->curr_cfg.mux_tsid_report << 3) | AVDT_ALH_LCODE_9BITM0;
if (u) {
*p |= AVDT_ALH_LCODE_9BITM1;
}{...}
}{...}
/* ... */#endif
p_pkt->len = p_end - p;
if (L2CAP_DW_FAILED != avdt_ad_write_req(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb, p_pkt)) {
result = AVDT_SUCCESS;
}{...}
}{...}
}{...}
return result;
}{...}
/* ... */#endif
/* ... */
UINT8 AVDT_SetTraceLevel (UINT8 new_level)
{
if (new_level != 0xFF) {
avdt_cb.trace_level = new_level;
}{...}
return (avdt_cb.trace_level);
}{...}
/* ... */
void AVDT_SetDelayValue(UINT16 delay_value)
{
avdt_cb.delay_value = delay_value;
}{...}
/* ... */
UINT16 AVDT_GetDelayValue(void)
{
return avdt_cb.delay_value;
}{...}
/* ... */
#endif