• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 AUDIOENCODER_H
17 #define AUDIOENCODER_H
18 
19 #include "multimedia/player_framework/native_avcodec_audiocodec.h"
20 #include "multimedia/player_framework/native_avbuffer_info.h"
21 #include "multimedia/native_audio_channel_layout.h"
22 #include "sample_info.h"
23 #include "sample_callback.h"
24 #include "dfx/error/av_codec_sample_error.h"
25 #include "dfx/log/av_codec_sample_log.h"
26 
27 class AudioEncoder {
28 public:
29     AudioEncoder() = default;
30     ~AudioEncoder();
31 
32     int32_t Create(const std::string &codecMime);
33     int32_t Config(const SampleInfo &sampleInfo, CodecUserData *codecUserData);
34     int32_t Start();
35     int32_t PushInputData(CodecBufferInfo &info);
36     int32_t FreeOutputData(uint32_t bufferIndex);
37     int32_t Stop();
38     int32_t Release();
39 
40 private:
41     int32_t SetCallback(CodecUserData *codecUserData);
42     int32_t Configure(const SampleInfo &sampleInfo);
43 
44     bool isAVBufferMode_ = false;
45     OH_AVCodec *encoder_;
46 };
47 
48 #endif // AUDIOENCODER_H