• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 #include "mock_codec_interface.h"
18 
19 namespace bluetooth::le_audio {
20 
21 struct CodecInterface::Impl : public MockCodecInterface {
22  public:
Implbluetooth::le_audio::CodecInterface::Impl23   Impl(const types::LeAudioCodecId& codec_id) {
24     output_channel_data_.resize(1);
25   };
26   ~Impl() = default;
27 
GetDecodedSamplesbluetooth::le_audio::CodecInterface::Impl28   std::vector<int16_t>& GetDecodedSamples() { return output_channel_data_; }
29   std::vector<int16_t> output_channel_data_;
30 };
31 
CodecInterface(const types::LeAudioCodecId & codec_id)32 CodecInterface::CodecInterface(const types::LeAudioCodecId& codec_id) {
33   impl = new Impl(codec_id);
34 }
~CodecInterface()35 CodecInterface::~CodecInterface() { delete impl; }
IsReady()36 bool CodecInterface::IsReady() { return impl->IsReady(); };
InitEncoder(const LeAudioCodecConfiguration & pcm_config,const LeAudioCodecConfiguration & codec_config)37 CodecInterface::Status CodecInterface::InitEncoder(
38     const LeAudioCodecConfiguration& pcm_config,
39     const LeAudioCodecConfiguration& codec_config) {
40   return impl->InitEncoder(pcm_config, codec_config);
41 }
InitDecoder(const LeAudioCodecConfiguration & codec_config,const LeAudioCodecConfiguration & pcm_config)42 CodecInterface::Status CodecInterface::InitDecoder(
43     const LeAudioCodecConfiguration& codec_config,
44     const LeAudioCodecConfiguration& pcm_config) {
45   return impl->InitDecoder(codec_config, pcm_config);
46 }
GetDecodedSamples()47 std::vector<int16_t>& CodecInterface::GetDecodedSamples() {
48   return impl->GetDecodedSamples();
49 }
Decode(uint8_t * data,uint16_t size)50 CodecInterface::Status CodecInterface::Decode(uint8_t* data, uint16_t size) {
51   return impl->Decode(data, size);
52 }
Encode(const uint8_t * data,int stride,uint16_t out_size,std::vector<int16_t> * out_buffer,uint16_t out_offset)53 CodecInterface::Status CodecInterface::Encode(const uint8_t* data, int stride,
54                                               uint16_t out_size,
55                                               std::vector<int16_t>* out_buffer,
56                                               uint16_t out_offset) {
57   return impl->Encode(data, stride, out_size, out_buffer, out_offset);
58 }
Cleanup()59 void CodecInterface::Cleanup() { return impl->Cleanup(); }
60 
GetNumOfSamplesPerChannel()61 uint16_t CodecInterface::GetNumOfSamplesPerChannel() {
62   return impl->GetNumOfSamplesPerChannel();
63 };
GetNumOfBytesPerSample()64 uint8_t CodecInterface::GetNumOfBytesPerSample() {
65   return impl->GetNumOfBytesPerSample();
66 };
67 }  // namespace bluetooth::le_audio
68