1 /******************************************************************************
2  *
3  *  Copyright (C) 2005-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the implementation file for advanced audio/video call-in
22  *  functions.
23  *
24  ******************************************************************************/
25 
26 #include "common/bt_target.h"
27 #include "bta/bta_api.h"
28 #include "bta/bta_sys.h"
29 #include "bta_av_int.h"
30 #include "bta/bta_av_ci.h"
31 #include "osi/allocator.h"
32 
33 #include <string.h>
34 
35 #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
36 /*******************************************************************************
37 **
38 ** Function         bta_av_ci_src_data_ready
39 **
40 ** Description      This function sends an event to the AV indicating that
41 **                  the phone has audio stream data ready to send and AV
42 **                  should call bta_av_co_audio_src_data_path() or
43 **                  bta_av_co_video_src_data_path().
44 **
45 ** Returns          void
46 **
47 *******************************************************************************/
bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)48 void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
49 {
50     BT_HDR  *p_buf;
51 
52     if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
53         p_buf->layer_specific   = chnl;
54         p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
55         bta_sys_sendmsg(p_buf);
56     }
57 }
58 
59 /*******************************************************************************
60 **
61 ** Function         bta_av_ci_setconfig
62 **
63 ** Description      This function must be called in response to function
64 **                  bta_av_co_audio_setconfig() or bta_av_co_video_setconfig.
65 **                  Parameter err_code is set to an AVDTP status value;
66 **                  AVDT_SUCCESS if the codec configuration is ok,
67 **                  otherwise error.
68 **
69 ** Returns          void
70 **
71 *******************************************************************************/
bta_av_ci_setconfig(tBTA_AV_HNDL hndl,UINT8 err_code,UINT8 category,UINT8 num_seid,UINT8 * p_seid,BOOLEAN recfg_needed,UINT8 avdt_handle)72 void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
73                          UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed, UINT8 avdt_handle)
74 {
75     tBTA_AV_CI_SETCONFIG  *p_buf;
76 
77     if ((p_buf = (tBTA_AV_CI_SETCONFIG *) osi_malloc(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL) {
78         p_buf->hdr.layer_specific   = hndl;
79         p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
80                            BTA_AV_CI_SETCONFIG_OK_EVT : BTA_AV_CI_SETCONFIG_FAIL_EVT;
81         p_buf->err_code = err_code;
82         p_buf->category = category;
83         p_buf->recfg_needed = recfg_needed;
84         p_buf->num_seid = num_seid;
85         p_buf->avdt_handle = avdt_handle;
86         if (p_seid && num_seid) {
87             p_buf->p_seid   = (UINT8 *)(p_buf + 1);
88             memcpy(p_buf->p_seid, p_seid, num_seid);
89         } else {
90             p_buf->p_seid   = NULL;
91             p_buf->num_seid = 0;
92         }
93 
94         bta_sys_sendmsg(p_buf);
95     }
96 }
97 
98 #endif /* #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
99