1 /** 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <vector> 20 21 #include "a2dp_codec_api.h" 22 #include "audio_hal_interface/a2dp_encoding.h" 23 24 /// Codec configuration for codecs that are supported by a2dp hardware offload 25 /// codec extensibility. The codec index may be a standard codec, in which case 26 /// this class is preferred over the dedicated class, or an unknown codec in 27 /// the reserved ranges for codec extensibility. 28 /// The codec priority is always the lowest, so that software codecs 29 /// can be picked over offloaded codecs. 30 class A2dpCodecConfigExt : public A2dpCodecConfig { 31 public: 32 A2dpCodecConfigExt(btav_a2dp_codec_index_t codec_index, bool is_source); 33 init()34 bool init() override { return false; } useRtpHeaderMarkerBit()35 bool useRtpHeaderMarkerBit() const override { return false; } 36 bool setCodecConfig(const uint8_t* p_peer_codec_info, bool is_capability, 37 uint8_t* p_result_codec_config) override; 38 bool setPeerCodecCapabilities( 39 const uint8_t* p_peer_codec_capabilities) override; 40 getVendorCodecParameters()41 const std::vector<uint8_t>& getVendorCodecParameters() const { 42 return vendor_specific_parameters_; 43 } 44 setVendorSpecificParameters(std::vector<uint8_t> const & parameters)45 void setVendorSpecificParameters(std::vector<uint8_t> const& parameters) {} 46 setCodecConfig(btav_a2dp_codec_config_t codec_parameters,uint8_t const codec_config[AVDT_CODEC_SIZE],std::vector<uint8_t> const & vendor_specific_parameters)47 void setCodecConfig(btav_a2dp_codec_config_t codec_parameters, 48 uint8_t const codec_config[AVDT_CODEC_SIZE], 49 std::vector<uint8_t> const& vendor_specific_parameters) { 50 codec_config_ = codec_parameters; 51 codec_capability_ = codec_parameters; 52 memcpy(ota_codec_config_, codec_config, sizeof(ota_codec_config_)); 53 vendor_specific_parameters_ = vendor_specific_parameters; 54 } 55 56 private: 57 [[maybe_unused]] bool is_source_; // True if local is Source 58 std::vector<uint8_t> vendor_specific_parameters_; 59 }; 60 61 // Gets a mock A2DP encoder interface. 62 // The A2DP source path always sets up the encoder interface, 63 // whether the codec encoding is offloaded or not. 64 // |p_codec_info| contains the codec information. 65 const tA2DP_ENCODER_INTERFACE* A2DP_GetEncoderInterfaceExt( 66 const uint8_t* p_codec_info); 67