1 /* 2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef CSADPA2DP 16 #define CSADPA2DP 17 /*chipsea_ohos proguard begin*/ 18 #include "cs_proguard.h" 19 /*chipsea_ohos proguard end*/ 20 #include "cs_adp_type.h" 21 22 23 24 #define A2DP_CSIE_SAMP_FREQ_MSK 0xF0 /* b7-b4 sampling frequency */ 25 #define A2DP_CSIE_SAMP_FREQ_16 0x80 /* b7:16 kHz */ 26 #define A2DP_CSIE_SAMP_FREQ_32 0x40 /* b6:32 kHz */ 27 #define A2DP_CSIE_SAMP_FREQ_44 0x20 /* b5:44.1kHz */ 28 #define A2DP_CSIE_SAMP_FREQ_48 0x10 /* b4:48 kHz */ 29 #define A2DP_CSIE_SAMP_FREQ_96 0xF0 30 31 #define A2DP_SBC_CHANNEL_MODE_MSK 0x0F 32 #define A2DP_SBC_BLOCK_LENGTH_MSK 0xF0 33 #define A2DP_SBC_SUBBANDS_MSK 0x0C 34 35 typedef U8 bt_a2dp_adp_state; 36 #define A2DP_ADP_STATE_IDLE 0 37 #define A2DP_ADP_STATE_CLOSE 1 38 #define A2DP_ADP_STATE_PENDING 2 39 #define A2DP_ADP_STATE_CONNECTED 3 40 #define A2DP_ADP_STATE_OPEN 4 41 #define A2DP_ADP_STATE_PLAY 5 42 #define A2DP_ADP_STATE_PAUSE 6 43 #define A2DP_ADP_STATE_STOP 7 44 45 typedef U8 CodecType; 46 47 #define AVDTP_CODEC_TYPE_SBC 0x00 48 #define AVDTP_CODEC_TYPE_MPEG_AUDIO 0x01 49 #define AVDTP_CODEC_TYPE_MPEG_AAC 0x02 50 #define AVDTP_CODEC_TYPE_ATRAC 0x04 51 #define AVDTP_CODEC_TYPE_NON_A2DP 0xFF 52 53 typedef struct _A2DP_AUDIO_CAP{ 54 CodecType codec_type; 55 U8 sample_rate_bit; 56 U8 sbc_frame_number; 57 U8 channel; 58 U8 numBlocks;//used for SBC (4, 8, 12, or 16) 59 U8 numSubBands;//used for SBC (4 or 8) 60 }A2DP_AUDIO_CAP; 61 62 typedef struct _A2DP_AUDIO_DATA{ 63 U8 *data; 64 U16 datalen; 65 U16 headerlen; 66 }A2DP_AUDIO_DATA; 67 68 typedef uint8_t AdpAvdtpCodecType; 69 70 typedef enum { 71 BT_A2DP_SOURCE = 0, 72 BT_A2DP_SINK 73 }BT_A2DP_ROLE; 74 75 typedef struct { 76 A2DP_AUDIO_CAP *audioCodecP; 77 }A2dp_Signaling_t; 78 79 typedef struct { 80 A2DP_AUDIO_CAP *audioCodecP; 81 A2DP_AUDIO_DATA *audioDataP; 82 }A2dp_Media_t; 83 84 typedef struct _CS_ADP_A2DP_EVENT_{ 85 BT_ADDR bdaddr; 86 BT_A2DP_ROLE role; 87 union { 88 A2dp_Signaling_t signalingP; 89 A2dp_Media_t mediaP; 90 bt_err_type disc_reason; 91 }p; 92 }CS_ADP_A2DP_EVENT; 93 94 void cs_adp_a2dp_source_start(void); 95 void cs_adp_a2dp_source_suspend(void); 96 Status_BTDef cs_adp_a2dp_send_sbc_data(BT_ADDR bdaddr,U8 * data,U16 dataLen,U16 frameSize); 97 98 void cs_adp_a2dp_support_cb(void);//contend protection 99 void cs_adp_a2dp_register_source(void); 100 void cs_adp_a2dp_register_sink_sbc(void); 101 void cs_adp_a2dp_register_sink_aac(void); 102 void cs_adp_a2dp_source_init(void); 103 void cs_adp_a2dp_init(void); 104 105 Status_BTDef cs_adp_a2dp_connect(BT_ADDR bdaddr); 106 Status_BTDef cs_adp_a2dp_disconnect(BT_ADDR bdaddr); 107 A2DP_AUDIO_CAP *cs_adp_a2dp_get_audio_cap_by_addr(BT_ADDR bdaddr); 108 Status_BTDef cs_adp_a2dp_source_connect(BT_ADDR bdaddr); 109 110 111 112 #endif 113