Home | History | Annotate | Download | only in av
      1 /******************************************************************************
      2  *
      3  *  Copyright 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 #define LOG_TAG "bt_bta_av"
     27 
     28 #include "osi/include/log.h"
     29 
     30 #include "bta_av_ci.h"
     31 #include "bta_api.h"
     32 #include "bta_av_int.h"
     33 #include "bta_sys.h"
     34 
     35 #include <string.h>
     36 
     37 /*******************************************************************************
     38  *
     39  * Function         bta_av_ci_src_data_ready
     40  *
     41  * Description      This function sends an event to the AV indicating that
     42  *                  the phone has audio stream data ready to send and AV
     43  *                  should call bta_av_co_audio_source_data_path().
     44  *
     45  * Returns          void
     46  *
     47  ******************************************************************************/
     48 void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl) {
     49   BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
     50 
     51   p_buf->layer_specific = chnl;
     52   p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
     53 
     54   bta_sys_sendmsg(p_buf);
     55 }
     56 
     57 /*******************************************************************************
     58  *
     59  * Function         bta_av_ci_setconfig
     60  *
     61  * Description      This function must be called in response to function
     62  *                  bta_av_co_audio_setconfig().
     63  *                  Parameter err_code is set to an AVDTP status value;
     64  *                  AVDT_SUCCESS if the codec configuration is ok,
     65  *                  otherwise error.
     66  *
     67  * Returns          void
     68  *
     69  ******************************************************************************/
     70 void bta_av_ci_setconfig(tBTA_AV_HNDL bta_av_handle, uint8_t err_code,
     71                          uint8_t category, uint8_t num_seid, uint8_t* p_seid,
     72                          bool recfg_needed, uint8_t avdt_handle) {
     73   LOG_DEBUG(LOG_TAG,
     74             "%s: bta_av_handle=%d err_code=%d category=%d "
     75             "num_seid=%d recfg_needed=%s avdt_handle=%d",
     76             __func__, bta_av_handle, err_code, category, num_seid,
     77             recfg_needed ? "true" : "false", avdt_handle);
     78 
     79   tBTA_AV_CI_SETCONFIG* p_buf =
     80       (tBTA_AV_CI_SETCONFIG*)osi_malloc(sizeof(tBTA_AV_CI_SETCONFIG));
     81 
     82   p_buf->hdr.layer_specific = bta_av_handle;
     83   p_buf->hdr.event = (err_code == A2DP_SUCCESS) ? BTA_AV_CI_SETCONFIG_OK_EVT
     84                                                 : BTA_AV_CI_SETCONFIG_FAIL_EVT;
     85   p_buf->err_code = err_code;
     86   p_buf->category = category;
     87   p_buf->recfg_needed = recfg_needed;
     88   p_buf->num_seid = num_seid;
     89   p_buf->avdt_handle = avdt_handle;
     90   if (p_seid && num_seid) {
     91     p_buf->p_seid = (uint8_t*)(p_buf + 1);
     92     memcpy(p_buf->p_seid, p_seid, num_seid);
     93   } else {
     94     p_buf->p_seid = NULL;
     95     p_buf->num_seid = 0;
     96   }
     97 
     98   bta_sys_sendmsg(p_buf);
     99 }
    100