• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef AUDIO_FFMPEG_AMRNB_DECODER_PLUGIN_H
17 #define AUDIO_FFMPEG_AMRNB_DECODER_PLUGIN_H
18 
19 #include "audio_base_codec.h"
20 #include "audio_ffmpeg_decoder_plugin.h"
21 #include "avcodec_codec_name.h"
22 
23 namespace OHOS {
24 namespace MediaAVCodec {
25 class AudioFFMpegAmrnbDecoderPlugin : public AudioBaseCodec::CodecRegister<AudioFFMpegAmrnbDecoderPlugin> {
26 public:
27     AudioFFMpegAmrnbDecoderPlugin();
28     ~AudioFFMpegAmrnbDecoderPlugin() override;
29 
30     int32_t Init(const Format &format) override;
31     int32_t ProcessSendData(const std::shared_ptr<AudioBufferInfo> &inputBuffer) override;
32     int32_t ProcessRecieveData(std::shared_ptr<AudioBufferInfo> &outBuffer) override;
33     int32_t Reset() override;
34     int32_t Release() override;
35     int32_t Flush() override;
36     int32_t GetInputBufferSize() const override;
37     int32_t GetOutputBufferSize() const override;
38     Format GetFormat() const noexcept override;
39     std::string_view GetCodecType() const noexcept override;
40 
Identify()41     const static std::string Identify()
42     {
43         return std::string(AVCodecCodecName::AUDIO_DECODER_AMRNB_NAME);
44     }
45 
46 private:
47     int32_t Checkinit(const Format &format);
48     bool CheckSampleFormat(const Format &format);
49     int channels;
50     int sampleRate;
51     int64_t bitRate;
52     std::unique_ptr<AudioFfmpegDecoderPlugin> basePlugin;
53 };
54 } // namespace MediaAVCodec
55 } // namespace OHOS
56 #endif