1 /*
2  * Copyright (c) 2022-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 OHOS_DECODE_VIDEO_CALLBACK_H
17 #define OHOS_DECODE_VIDEO_CALLBACK_H
18 
19 #include "avcodec_errors.h"
20 #include "avcodec_common.h"
21 #include "meta/format.h"
22 
23 #include "encode_data_process.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 class EncodeDataProcess;
28 
29 class EncodeVideoCallback : public MediaAVCodec::AVCodecCallback {
30 public:
EncodeVideoCallback(const std::weak_ptr<EncodeDataProcess> & encodeVideoNode)31     explicit EncodeVideoCallback(const std::weak_ptr<EncodeDataProcess>& encodeVideoNode)
32         : encodeVideoNode_(encodeVideoNode) {}
33     ~EncodeVideoCallback() override = default;
34 
35     void OnError(MediaAVCodec::AVCodecErrorType errorType, int32_t errorCode) override;
36     void OnInputBufferAvailable(uint32_t index, std::shared_ptr<Media::AVSharedMemory> buffer) override;
37     void OnOutputFormatChanged(const Media::Format &format) override;
38     void OnOutputBufferAvailable(uint32_t index, MediaAVCodec::AVCodecBufferInfo info,
39         MediaAVCodec::AVCodecBufferFlag flag, std::shared_ptr<Media::AVSharedMemory> buffer) override;
40 private:
41     std::weak_ptr<EncodeDataProcess> encodeVideoNode_;
42 };
43 } // namespace DistributedHardware
44 } // namespace OHOS
45 #endif // OHOS_DECODE_VIDEO_CALLBACK_H
46