component/bt: move bta_av_co.c out to example directory

This commit is contained in:
wangmengyang 2016-11-04 18:33:57 +08:00
parent ecafe5306f
commit d4d34c1457
8 changed files with 71 additions and 143 deletions

View file

@ -76,7 +76,7 @@ enum
/* the call out functions for audio stream */ /* 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_init,
bta_av_co_audio_disc_res, 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_src_data_path,
bta_av_co_audio_delay bta_av_co_audio_delay
}; };
*/
tBTA_AV_CO_FUNCTS *p_bta_av_a2d_cos = NULL;
/* ssm action functions for audio stream */ /* ssm action functions for audio stream */
const tBTA_AV_SACT bta_av_a2d_action[] = const tBTA_AV_SACT bta_av_a2d_action[] =

View file

@ -108,7 +108,7 @@ void BTA_AvDisable(void)
** Returns 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; 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->app_id = app_id;
p_buf->p_app_data_cback = p_data_cback; p_buf->p_app_data_cback = p_data_cback;
p_buf->bta_av_cos = bta_av_cos;
bta_sys_sendmsg(p_buf); bta_sys_sendmsg(p_buf);
} }
} }

View file

@ -156,7 +156,7 @@ enum
/***************************************************************************** /*****************************************************************************
** Data types ** Data types
*****************************************************************************/ *****************************************************************************/
#if 0
/* function types for call-out functions */ /* function types for call-out functions */
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info, typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index); UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
@ -193,6 +193,7 @@ typedef struct
tBTA_AV_CO_DATAPATH data; tBTA_AV_CO_DATAPATH data;
tBTA_AV_CO_DELAY delay; tBTA_AV_CO_DELAY delay;
} tBTA_AV_CO_FUNCTS; } tBTA_AV_CO_FUNCTS;
#endif
/* data type for BTA_AV_API_ENABLE_EVT */ /* data type for BTA_AV_API_ENABLE_EVT */
typedef struct typedef struct
@ -210,6 +211,7 @@ typedef struct
char p_service_name[BTA_SERVICE_NAME_LEN+1]; char p_service_name[BTA_SERVICE_NAME_LEN+1];
UINT8 app_id; UINT8 app_id;
tBTA_AV_DATA_CBACK *p_app_data_cback; tBTA_AV_DATA_CBACK *p_app_data_cback;
tBTA_AV_CO_FUNCTS *bta_av_cos;
} tBTA_AV_API_REG; } tBTA_AV_API_REG;
@ -611,7 +613,7 @@ extern UINT16 *p_bta_av_rc_id;
extern UINT16 *p_bta_av_rc_id_ac; extern UINT16 *p_bta_av_rc_id_ac;
extern const tBTA_AV_SACT bta_av_a2d_action[]; 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 const tBTA_AV_SACT bta_av_vdp_action[];
extern tAVDT_CTRL_CBACK * const bta_av_dt_cback[]; 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); extern void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt);

View file

@ -562,6 +562,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
registr.status = BTA_AV_FAIL_RESOURCES; registr.status = BTA_AV_FAIL_RESOURCES;
registr.app_id = p_data->api_reg.app_id; registr.app_id = p_data->api_reg.app_id;
registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific; registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific;
registr.p_bta_av_cos = p_data->api_reg.bta_av_cos;
do do
{ {
p_scb = bta_av_alloc_scb(registr.chnl); 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 */ /* set up the audio stream control block */
p_scb->p_act_tbl = (const tBTA_AV_ACT *)bta_av_a2d_action; 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; p_scb->media_type= AVDT_MEDIA_AUDIO;
cs.cfg.psc_mask = AVDT_PSC_TRANS; cs.cfg.psc_mask = AVDT_PSC_TRANS;
cs.media_type = AVDT_MEDIA_AUDIO; 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 */ /* keep the configuration in the stream control block */
memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG)); memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG));
while(index < BTA_AV_MAX_SEPS && 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) &cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE)
{ {

View file

@ -255,6 +255,43 @@ typedef UINT8 tBTA_AV_ERR;
#define BTA_AV_MAX_EVT 22 #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; typedef UINT8 tBTA_AV_EVT;
/* Event associated with BTA_AV_ENABLE_EVT */ /* Event associated with BTA_AV_ENABLE_EVT */
@ -270,6 +307,7 @@ typedef struct
tBTA_AV_HNDL hndl; /* Handle associated with the stream. */ tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
UINT8 app_id; /* ID associated with call to BTA_AvRegister() */ UINT8 app_id; /* ID associated with call to BTA_AvRegister() */
tBTA_AV_STATUS status; tBTA_AV_STATUS status;
tBTA_AV_CO_FUNCTS *p_bta_av_cos;
} tBTA_AV_REGISTER; } tBTA_AV_REGISTER;
/* data associated with BTA_AV_OPEN_EVT */ /* 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, 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);
/******************************************************************************* /*******************************************************************************
** **

View file

@ -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 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 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 ** 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), BTA_AvEnable(BTA_SEC_AUTHENTICATE, (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_NO_SCO_SSPD),
bte_av_callback); bte_av_callback);
#endif #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 { else {
BTA_AvDeregister(btif_av_cb.bta_handle); BTA_AvDeregister(btif_av_cb.bta_handle);

View file

@ -31,7 +31,6 @@
#include "bta_av_co.h" #include "bta_av_co.h"
#include "bta_av_ci.h" #include "bta_av_ci.h"
#include "bta_av_sbc.h" #include "bta_av_sbc.h"
#if 0 // todo : port the call out functions
#include "btif_media.h" #include "btif_media.h"
#include "sbc_encoder.h" #include "sbc_encoder.h"
#include "btif_av_co.h" #include "btif_av_co.h"
@ -1840,138 +1839,17 @@ BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max)
return TRUE; return TRUE;
} }
/* the call out functions for audio stream */
#else /* #if 0 */ tBTA_AV_CO_FUNCTS bta_av_a2d_cos =
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)
{ {
return FALSE; bta_av_co_audio_init,
} bta_av_co_audio_disc_res,
bta_av_co_audio_getconfig,
extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, bta_av_co_audio_setconfig,
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local) bta_av_co_audio_open,
{ bta_av_co_audio_close,
return; bta_av_co_audio_start,
} bta_av_co_audio_stop,
bta_av_co_audio_src_data_path,
extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps, bta_av_co_audio_delay
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

View file

@ -21,6 +21,7 @@ COMPONENT_SRCDIRS := \
udrv/ulinux \ udrv/ulinux \
embdrv/sbc/encoder \ embdrv/sbc/encoder \
embdrv/sbc/decoder \ embdrv/sbc/decoder \
btif/co \
btif btif
CFLAGS += -Wno-error=unused-label -Wno-error=return-type -Wno-error=missing-braces -Wno-error=pointer-sign -Wno-error=parentheses -I./include CFLAGS += -Wno-error=unused-label -Wno-error=return-type -Wno-error=missing-braces -Wno-error=pointer-sign -Wno-error=parentheses -I./include