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 #ifndef MMC_CODEC_SERVER_HFP_LC3_MMC_DECODER_H_ 18 #define MMC_CODEC_SERVER_HFP_LC3_MMC_DECODER_H_ 19 20 #include <lc3.h> 21 22 #include "mmc/mmc_interface/mmc_interface.h" 23 #include "mmc/proto/mmc_config.pb.h" 24 25 namespace mmc { 26 27 // Implementation of MmcInterface. 28 // HfpLc3Decoder wraps lc3 decode libraries. 29 class HfpLc3Decoder : public MmcInterface { 30 public: 31 explicit HfpLc3Decoder(); 32 ~HfpLc3Decoder(); 33 34 // HfpLc3Decoder is neither copyable nor movable. 35 HfpLc3Decoder(const HfpLc3Decoder&) = delete; 36 HfpLc3Decoder& operator=(const HfpLc3Decoder&) = delete; 37 38 // Inits decoder instance. 39 // 40 // Returns: 41 // Input packet size accepted by the decoder, if init succeeded. 42 // Negative errno on error, otherwise. 43 int init(ConfigParam config) override; 44 45 // Releases decoder instance. 46 void cleanup() override; 47 48 // Decodes data from |i_buf| and stores the result in |o_buf|. 49 // 50 // Returns: 51 // Decoded data length, if decode succeeded. 52 // Negative errno on error, otherwise. 53 int transcode(uint8_t* i_buf, int i_len, uint8_t* o_buf, int o_len) override; 54 55 private: 56 void* hfp_lc3_decoder_mem_; 57 lc3_decoder_t hfp_lc3_decoder_; 58 Lc3Param param_; 59 }; 60 61 } // namespace mmc 62 63 #endif // MMC_CODEC_SERVER_HFP_LC3_MMC_DECODER_H_ 64