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 "decode_data_process.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 class DecodeDataProcess;
28 
29 class DecodeVideoCallback : public MediaAVCodec::AVCodecCallback {
30 public:
DecodeVideoCallback(const std::weak_ptr<DecodeDataProcess> & decodeVideoNode)31     explicit DecodeVideoCallback(const std::weak_ptr<DecodeDataProcess>& decodeVideoNode)
32         : decodeVideoNode_(decodeVideoNode) {}
33     ~DecodeVideoCallback() 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<DecodeDataProcess> decodeVideoNode_;
42 };
43 } // namespace DistributedHardware
44 } // namespace OHOS
45 #endif // OHOS_DECODE_VIDEO_CALLBACK_H
46