pinebuds/services/bt_app/a2dp_codecs/scalable/a2dp_codec_scalable.cpp

97 lines
3 KiB
C++
Raw Normal View History

2022-08-15 04:20:27 -05:00
/***************************************************************************
*
* Copyright 2015-2019 BES.
* All rights reserved. All unpublished rights reserved.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of BES.
*
* Use of this work is governed by a license granted by BES.
* This work contains confidential and proprietary information of
* BES. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#include "a2dp_api.h"
2022-08-15 04:20:27 -05:00
#include "analog.h"
#include "app.h"
#include "app_audio.h"
#include "audioflinger.h"
2022-08-15 04:20:27 -05:00
#include "bluetooth.h"
#include "bt_drv.h"
#include "cmsis_os.h"
#include "hal_cmu.h"
#include "hal_location.h"
#include "hal_timer.h"
#include "hal_trace.h"
#include "hal_uart.h"
#include "lockcqueue.h"
2022-08-15 04:20:27 -05:00
#include "nvrecord.h"
#include "nvrecord_dev.h"
#include "nvrecord_env.h"
#include <stdio.h>
2022-08-15 04:20:27 -05:00
#if defined(NEW_NV_RECORD_ENABLED)
#include "nvrecord_bt.h"
#endif
#include "a2dp_api.h"
#include "avrcp_api.h"
#include "besbt.h"
#include "app_bt.h"
#include "app_bt_media_manager.h"
#include "apps.h"
2022-08-15 04:20:27 -05:00
#include "bt_drv_interface.h"
#include "btapp.h"
#include "cqueue.h"
2022-08-15 04:20:27 -05:00
#include "hci_api.h"
#include "resources.h"
#include "tgt_hardware.h"
2022-08-15 04:20:27 -05:00
#include "a2dp_codec_scalable.h"
#include "avdtp_api.h"
extern struct BT_DEVICE_T app_bt_device;
2022-08-15 04:20:27 -05:00
#if defined(A2DP_SCALABLE_ON)
btif_avdtp_codec_t a2dp_scalable_avdtpcodec;
// Vendor Specific value (8bit) : 0x78 (not support UHQ) 0xF8  (support UHQ)
2022-08-15 04:20:27 -05:00
// - bit 7 : 96kHz   sampling frequency supported
// - bit 6 : 32kHz   sampling frequency supported
// - bit 5 : 44.1kHz sampling frequency supported
// - bit 4 : 48kHz   sampling frequency supported
// - bit 3 : high quality supported 
// - bit 2 : additional information (current 0)
// - bit 1 : additional information (current 0)
// - bit 0 : additional information (current 0)
//<1byte Vendor Specific values for Scalable codec> 
const unsigned char a2dp_codec_scalable_elements[A2DP_SCALABLE_OCTET_NUMBER] = {
0x75, 0x0, 0x0, 0x0, // vendor id
0x03, 0x01, // vendor specific codec id
2022-08-15 04:20:27 -05:00
#if defined(A2DP_SCALABLE_UHQ_SUPPORT)
0xf8, // vendor specific value
2022-08-15 04:20:27 -05:00
#else
0x78, // vendor specific value
2022-08-15 04:20:27 -05:00
#endif
};
bt_status_t a2dp_codec_scalable_init(int index) {
bt_status_t st;
2022-08-15 04:20:27 -05:00
struct BT_DEVICE_T *bt_dev = &app_bt_device;
2022-08-15 04:20:27 -05:00
a2dp_scalable_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_NON_A2DP;
a2dp_scalable_avdtpcodec.discoverable = 1;
a2dp_scalable_avdtpcodec.elements = (U8 *)&a2dp_codec_scalable_elements;
a2dp_scalable_avdtpcodec.elemLen = sizeof(a2dp_codec_scalable_elements);
2022-08-15 04:20:27 -05:00
st = btif_a2dp_register(bt_dev->a2dp_scalable_stream[index]->a2dp_stream,
BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_scalable_avdtpcodec,
NULL, 4, index, a2dp_callback);
2022-08-15 04:20:27 -05:00
return st;
2022-08-15 04:20:27 -05:00
}
#endif /* A2DP_SCALABLE_ON */