• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 OHOS_AUDIO_ENCODER_CALLBACK_H
17 #define OHOS_AUDIO_ENCODER_CALLBACK_H
18 
19 #include <memory>
20 
21 #include "avcodec_common.h"
22 #include "media_errors.h"
23 #include "format.h"
24 
25 #include "audio_encoder.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class AudioEncoder;
30 class AudioEncoderCallback : public Media::AVCodecCallback {
31 public:
AudioEncoderCallback(const std::weak_ptr<AudioEncoder> & encoder)32     explicit AudioEncoderCallback(const std::weak_ptr<AudioEncoder> &encoder)
33         : audioEncoder_(encoder) {};
34     ~AudioEncoderCallback() override = default;
35 
36     void OnError(Media::AVCodecErrorType errorType, int32_t errorCode) override;
37     void OnOutputBufferAvailable(uint32_t index, Media::AVCodecBufferInfo info, Media::AVCodecBufferFlag flag) override;
38     void OnInputBufferAvailable(uint32_t index) override;
39     void OnOutputFormatChanged(const Media::Format &format) override;
40 
41 private:
42     std::weak_ptr<AudioEncoder> audioEncoder_;
43 };
44 } // namespace DistributedHardware
45 } // namespace OHOS
46 #endif // OHOS_AUDIO_ENCODER_CALLBACK_H
47