1 /* 2 * Copyright (c) 2022-2022 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 HISTREAMER_AUDIO_AAC_DECODER_PLUGIN_H 17 #define HISTREAMER_AUDIO_AAC_DECODER_PLUGIN_H 18 19 #include <functional> 20 #include <map> 21 #include "aac_wrapper.h" 22 #include "foundation/osal/thread/scoped_lock.h" 23 #include "plugin/common/plugin_types.h" 24 #include "plugin/interface/codec_plugin.h" 25 26 namespace OHOS { 27 namespace Media { 28 namespace Plugin { 29 namespace LiteAacPlugin { 30 class LiteAACDecoderPlugin : public CodecPlugin { 31 public: 32 explicit LiteAACDecoderPlugin(std::string name); 33 34 ~LiteAACDecoderPlugin() override; 35 36 Status Init() override; 37 38 Status Deinit() override; 39 40 Status Prepare() override; 41 42 Status Reset() override; 43 44 Status Start() override; 45 46 Status Stop() override; 47 48 Status GetParameter(Tag tag, ValueType& value) override; 49 50 Status SetParameter(Tag tag, const ValueType& value) override; 51 52 std::shared_ptr<Allocator> GetAllocator() override; 53 54 Status SetCallback(Callback* cb) override; 55 56 Status QueueInputBuffer(const std::shared_ptr<Buffer>& inputBuffer, int32_t timeoutMs) override; 57 58 Status QueueOutputBuffer(const std::shared_ptr<Buffer>& outputBuffers, int32_t timeoutMs) override; 59 60 Status Flush() override; 61 62 Status SetDataCallback(DataCallback* dataCallback) override; 63 64 Status SendOutputBuffer(); 65 66 private: 67 Status ReceiveBuffer(); 68 69 Status ReceiveBufferLocked(const std::shared_ptr<Buffer> &ioInfo); 70 71 Status AudioDecoderAACMp4Open(); 72 73 void AudioDecoderAACMp4Close(); 74 75 Status AudioDecoderAACMp4Process(std::shared_ptr<Buffer> inBuffer, std::shared_ptr<Buffer> outBuffer); 76 77 std::map<Tag, ValueType> audioParameter_ {}; 78 mutable OSAL::Mutex avMutex_ {}; 79 DataCallback* dataCb_ {}; 80 std::shared_ptr<Buffer> inBuffer_ {nullptr}; 81 std::shared_ptr<Buffer> outBuffer_ {nullptr}; 82 }; 83 } // LiteAacPlugin 84 } // namespace Plugin 85 } // namespace Media 86 } // namespace OHOS 87 88 #endif // HISTREAMER_MINIMP4_AAC_DECODER_PLUGIN_H 89 90