From d4d34c14573585f16fd301c086568cfb979c6a10 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Fri, 4 Nov 2016 18:33:57 +0800 Subject: [PATCH] component/bt: move bta_av_co.c out to example directory --- components/bt/bluedroid/bta/av/bta_av_aact.c | 6 +- components/bt/bluedroid/bta/av/bta_av_api.c | 3 +- components/bt/bluedroid/bta/av/bta_av_int.h | 6 +- components/bt/bluedroid/bta/av/bta_av_main.c | 6 +- .../bt/bluedroid/bta/include/bta_av_api.h | 40 ++++- .../components/bluedroid_demos/btif/btif_av.c | 4 +- .../bluedroid_demos/btif/co}/bta_av_co.c | 148 ++---------------- .../components/bluedroid_demos/component.mk | 1 + 8 files changed, 71 insertions(+), 143 deletions(-) rename {components/bt/bluedroid/btif => examples/09_a2dp/components/bluedroid_demos/btif/co}/bta_av_co.c (94%) diff --git a/components/bt/bluedroid/bta/av/bta_av_aact.c b/components/bt/bluedroid/bta/av/bta_av_aact.c index 4177104ec..d3f813aeb 100755 --- a/components/bt/bluedroid/bta/av/bta_av_aact.c +++ b/components/bt/bluedroid/bta/av/bta_av_aact.c @@ -76,7 +76,7 @@ enum /* the call out functions for audio stream */ -const tBTA_AV_CO_FUNCTS bta_av_a2d_cos = +/* const tBTA_AV_CO_FUNCTS bta_av_a2d_cos = { bta_av_co_audio_init, bta_av_co_audio_disc_res, @@ -89,6 +89,10 @@ const tBTA_AV_CO_FUNCTS bta_av_a2d_cos = bta_av_co_audio_src_data_path, bta_av_co_audio_delay }; +*/ +tBTA_AV_CO_FUNCTS *p_bta_av_a2d_cos = NULL; + + /* ssm action functions for audio stream */ const tBTA_AV_SACT bta_av_a2d_action[] = diff --git a/components/bt/bluedroid/bta/av/bta_av_api.c b/components/bt/bluedroid/bta/av/bta_av_api.c index ecc05e1bc..5a5c9e38f 100755 --- a/components/bt/bluedroid/bta/av/bta_av_api.c +++ b/components/bt/bluedroid/bta/av/bta_av_api.c @@ -108,7 +108,7 @@ void BTA_AvDisable(void) ** Returns void ** *******************************************************************************/ -void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback) +void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos) { tBTA_AV_API_REG *p_buf; @@ -128,6 +128,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, } p_buf->app_id = app_id; p_buf->p_app_data_cback = p_data_cback; + p_buf->bta_av_cos = bta_av_cos; bta_sys_sendmsg(p_buf); } } diff --git a/components/bt/bluedroid/bta/av/bta_av_int.h b/components/bt/bluedroid/bta/av/bta_av_int.h index 6764e941d..15f13afca 100755 --- a/components/bt/bluedroid/bta/av/bta_av_int.h +++ b/components/bt/bluedroid/bta/av/bta_av_int.h @@ -156,7 +156,7 @@ enum /***************************************************************************** ** Data types *****************************************************************************/ - +#if 0 /* function types for call-out functions */ typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index); @@ -193,6 +193,7 @@ typedef struct tBTA_AV_CO_DATAPATH data; tBTA_AV_CO_DELAY delay; } tBTA_AV_CO_FUNCTS; +#endif /* data type for BTA_AV_API_ENABLE_EVT */ typedef struct @@ -210,6 +211,7 @@ typedef struct char p_service_name[BTA_SERVICE_NAME_LEN+1]; UINT8 app_id; tBTA_AV_DATA_CBACK *p_app_data_cback; + tBTA_AV_CO_FUNCTS *bta_av_cos; } tBTA_AV_API_REG; @@ -611,7 +613,7 @@ extern UINT16 *p_bta_av_rc_id; extern UINT16 *p_bta_av_rc_id_ac; extern const tBTA_AV_SACT bta_av_a2d_action[]; -extern const tBTA_AV_CO_FUNCTS bta_av_a2d_cos; +// extern const tBTA_AV_CO_FUNCTS bta_av_a2d_cos; extern const tBTA_AV_SACT bta_av_vdp_action[]; extern tAVDT_CTRL_CBACK * const bta_av_dt_cback[]; extern void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt); diff --git a/components/bt/bluedroid/bta/av/bta_av_main.c b/components/bt/bluedroid/bta/av/bta_av_main.c index 8c9998629..a598b46ac 100755 --- a/components/bt/bluedroid/bta/av/bta_av_main.c +++ b/components/bt/bluedroid/bta/av/bta_av_main.c @@ -562,6 +562,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) registr.status = BTA_AV_FAIL_RESOURCES; registr.app_id = p_data->api_reg.app_id; registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific; + registr.p_bta_av_cos = p_data->api_reg.bta_av_cos; do { p_scb = bta_av_alloc_scb(registr.chnl); @@ -649,7 +650,8 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) { /* set up the audio stream control block */ p_scb->p_act_tbl = (const tBTA_AV_ACT *)bta_av_a2d_action; - p_scb->p_cos = &bta_av_a2d_cos; + // p_scb->p_cos = &bta_av_a2d_cos; + p_scb->p_cos = registr.p_bta_av_cos; p_scb->media_type= AVDT_MEDIA_AUDIO; cs.cfg.psc_mask = AVDT_PSC_TRANS; cs.media_type = AVDT_MEDIA_AUDIO; @@ -671,7 +673,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) /* keep the configuration in the stream control block */ memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG)); while(index < BTA_AV_MAX_SEPS && - (*bta_av_a2d_cos.init)(&codec_type, cs.cfg.codec_info, + (p_scb->p_cos->init)(&codec_type, cs.cfg.codec_info, &cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE) { diff --git a/components/bt/bluedroid/bta/include/bta_av_api.h b/components/bt/bluedroid/bta/include/bta_av_api.h index e0e356f75..90ca461e0 100755 --- a/components/bt/bluedroid/bta/include/bta_av_api.h +++ b/components/bt/bluedroid/bta/include/bta_av_api.h @@ -255,6 +255,43 @@ typedef UINT8 tBTA_AV_ERR; #define BTA_AV_MAX_EVT 22 +/* function types for call-out functions */ +typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, + UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index); +typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps, + UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local); +typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, + UINT8 *p_num_protect, UINT8 *p_protect_info); +typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, + UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, + UINT8 num_protect, UINT8 *p_protect_info, + UINT8 t_local_sep, UINT8 avdt_handle); +typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl, + tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, + UINT16 mtu); +typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu); +typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr); +typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); +typedef void * (*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type, + UINT32 *p_len, UINT32 *p_timestamp); +typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay); + +/* the call-out functions for one stream */ +typedef struct +{ + tBTA_AV_CO_INIT init; + tBTA_AV_CO_DISC_RES disc_res; + tBTA_AV_CO_GETCFG getcfg; + tBTA_AV_CO_SETCFG setcfg; + tBTA_AV_CO_OPEN open; + tBTA_AV_CO_CLOSE close; + tBTA_AV_CO_START start; + tBTA_AV_CO_STOP stop; + tBTA_AV_CO_DATAPATH data; + tBTA_AV_CO_DELAY delay; +} tBTA_AV_CO_FUNCTS; + typedef UINT8 tBTA_AV_EVT; /* Event associated with BTA_AV_ENABLE_EVT */ @@ -270,6 +307,7 @@ typedef struct tBTA_AV_HNDL hndl; /* Handle associated with the stream. */ UINT8 app_id; /* ID associated with call to BTA_AvRegister() */ tBTA_AV_STATUS status; + tBTA_AV_CO_FUNCTS *p_bta_av_cos; } tBTA_AV_REGISTER; /* data associated with BTA_AV_OPEN_EVT */ @@ -560,7 +598,7 @@ void BTA_AvDisable(void); ** *******************************************************************************/ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, - UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback); + UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS * bta_av_cos); /******************************************************************************* ** diff --git a/examples/09_a2dp/components/bluedroid_demos/btif/btif_av.c b/examples/09_a2dp/components/bluedroid_demos/btif/btif_av.c index 78e87c731..dd9575a73 100755 --- a/examples/09_a2dp/components/bluedroid_demos/btif/btif_av.c +++ b/examples/09_a2dp/components/bluedroid_demos/btif/btif_av.c @@ -155,6 +155,8 @@ extern void btif_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data); extern BOOLEAN btif_rc_get_connected_peer(BD_ADDR peer_addr); extern void btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp); + +extern tBTA_AV_CO_FUNCTS bta_av_a2d_cos; /***************************************************************************** ** Local helper functions ******************************************************************************/ @@ -1327,7 +1329,7 @@ bt_status_t btif_av_execute_service(BOOLEAN b_enable) BTA_AvEnable(BTA_SEC_AUTHENTICATE, (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_NO_SCO_SSPD), bte_av_callback); #endif - BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTIF_AV_SERVICE_NAME, 0, bte_av_media_callback); + BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTIF_AV_SERVICE_NAME, 0, bte_av_media_callback, &bta_av_a2d_cos); } else { BTA_AvDeregister(btif_av_cb.bta_handle); diff --git a/components/bt/bluedroid/btif/bta_av_co.c b/examples/09_a2dp/components/bluedroid_demos/btif/co/bta_av_co.c similarity index 94% rename from components/bt/bluedroid/btif/bta_av_co.c rename to examples/09_a2dp/components/bluedroid_demos/btif/co/bta_av_co.c index d35bb64b3..63c476b7f 100755 --- a/components/bt/bluedroid/btif/bta_av_co.c +++ b/examples/09_a2dp/components/bluedroid_demos/btif/co/bta_av_co.c @@ -31,7 +31,6 @@ #include "bta_av_co.h" #include "bta_av_ci.h" #include "bta_av_sbc.h" -#if 0 // todo : port the call out functions #include "btif_media.h" #include "sbc_encoder.h" #include "btif_av_co.h" @@ -1840,138 +1839,17 @@ BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max) return TRUE; } - -#else /* #if 0 */ - -extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, - UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index) +/* the call out functions for audio stream */ +tBTA_AV_CO_FUNCTS bta_av_a2d_cos = { - return FALSE; -} - -extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, - UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local) -{ - return; -} - -extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, - UINT8 num_snk, BD_ADDR addr) -{ - return; -} - -extern UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, - UINT8 *p_num_protect, UINT8 *p_protect_info) -{ - return 0; -} - -extern UINT8 bta_av_co_video_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid, - UINT8 *p_num_protect, UINT8 *p_protect_info) -{ - return 0; -} - -extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, - UINT8 num_protect, UINT8 *p_protect_info,UINT8 t_local_sep, UINT8 avdt_handle) -{ - return; -} - -extern void bta_av_co_video_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr, - UINT8 num_protect, UINT8 *p_protect_info) -{ - return; -} - -extern void bta_av_co_audio_open(tBTA_AV_HNDL hndl, - tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, - UINT16 mtu) -{ - return; -} - -extern void bta_av_co_video_open(tBTA_AV_HNDL hndl, - tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, - UINT16 mtu) -{ - return; -} - -extern void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT16 mtu) -{ - return; -} - -extern void bta_av_co_video_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT16 mtu) -{ - return; -} - -extern void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr) -{ - return; -} - -extern void bta_av_co_video_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, - UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr) -{ - return; -} - -extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type) -{ - return; -} - -extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type) -{ - return; -} - -extern void * bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, - UINT32 *p_len, UINT32 *p_timestamp) -{ - return NULL; -} - -extern void * bta_av_co_video_src_data_path(tBTA_AV_CODEC codec_type, - UINT32 *p_len, UINT32 *p_timestamp) -{ - return NULL; -} - -extern void bta_av_co_audio_drop(tBTA_AV_HNDL hndl) -{ - return; -} - -extern void bta_av_co_video_report_conn (BOOLEAN open, UINT8 avdt_handle) -{ - return; -} - -extern void bta_av_co_video_report_rr (UINT32 packet_lost) -{ - return; -} - -extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay) -{ - return; -} - -extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay) -{ - return; -} - -#endif + bta_av_co_audio_init, + bta_av_co_audio_disc_res, + bta_av_co_audio_getconfig, + bta_av_co_audio_setconfig, + bta_av_co_audio_open, + bta_av_co_audio_close, + bta_av_co_audio_start, + bta_av_co_audio_stop, + bta_av_co_audio_src_data_path, + bta_av_co_audio_delay +}; diff --git a/examples/09_a2dp/components/bluedroid_demos/component.mk b/examples/09_a2dp/components/bluedroid_demos/component.mk index 6e20af736..9b0268fe6 100755 --- a/examples/09_a2dp/components/bluedroid_demos/component.mk +++ b/examples/09_a2dp/components/bluedroid_demos/component.mk @@ -21,6 +21,7 @@ COMPONENT_SRCDIRS := \ udrv/ulinux \ embdrv/sbc/encoder \ embdrv/sbc/decoder \ + btif/co \ btif CFLAGS += -Wno-error=unused-label -Wno-error=return-type -Wno-error=missing-braces -Wno-error=pointer-sign -Wno-error=parentheses -I./include