]> granicus.if.org Git - esp-idf/commitdiff
component/bt: move bta_av_co.c out to example directory
authorwangmengyang <wangmengyang@espressif.com>
Fri, 4 Nov 2016 10:33:57 +0000 (18:33 +0800)
committerwangmengyang <wangmengyang@espressif.com>
Fri, 4 Nov 2016 10:33:57 +0000 (18:33 +0800)
components/bt/bluedroid/bta/av/bta_av_aact.c
components/bt/bluedroid/bta/av/bta_av_api.c
components/bt/bluedroid/bta/av/bta_av_int.h
components/bt/bluedroid/bta/av/bta_av_main.c
components/bt/bluedroid/bta/include/bta_av_api.h
examples/09_a2dp/components/bluedroid_demos/btif/btif_av.c
examples/09_a2dp/components/bluedroid_demos/btif/co/bta_av_co.c [moved from components/bt/bluedroid/btif/bta_av_co.c with 94% similarity]
examples/09_a2dp/components/bluedroid_demos/component.mk

index 4177104ec32e31d2edc7f56177153e2a9dcbe95d..d3f813aebecab22e4870d7c6e826b7fe3c85bdd8 100755 (executable)
@@ -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[] =
index ecc05e1bc5dd7cd83bfc36790a4b7bff6f6290e1..5a5c9e38f3dd3cf91be9ae5b8d44104227ab478f 100755 (executable)
@@ -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);
     }
 }
index 6764e941dd109047410393a7f12947093e9fa069..15f13afca68ea65fc472846b822e1ab436b99207 100755 (executable)
@@ -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);
index 8c99986299c442c69f7304f9b6c10a4627442238..a598b46ac91c8303732807784432906c5b586466 100755 (executable)
@@ -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)
             {
 
index e0e356f75b2cf83892fe740c4f16202e191a1542..90ca461e07df855ccd8745e292d19d41242fce95 100755 (executable)
@@ -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);
 
 /*******************************************************************************
 **
index 78e87c731fbb8e1617169be7b451d892be065ff9..dd9575a73c3472f9d2777a566d3d185edaee8dfb 100755 (executable)
@@ -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);
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 d35bb64b3956fafe1f39d9fc788dfe9d46c5d64f..63c476b7fa72d9b010744ac36272b1438b1209d6 100755 (executable)
@@ -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)
-{
-    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
+/* the call out functions for audio stream */
+tBTA_AV_CO_FUNCTS bta_av_a2d_cos =
+{
+    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
+};
index 6e20af73622f923b2abb5c686a54be8776e3af29..9b0268fe6383f3b06584745de412c0e1fe97fe69 100755 (executable)
@@ -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