• 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 BASE_VIDEO_POST_PROCESSOR_H
17 #define BASE_VIDEO_POST_PROCESSOR_H
18 
19 #include "surface.h"
20 #include "sync_fence.h"
21 #include "buffer/avbuffer.h"
22 #include "meta/format.h"
23 #include "filter/filter.h"
24 #include "common/log.h"
25 #include "common/media_core.h"
26 
27 namespace OHOS {
28 namespace Media {
29 
30 class PostProcessorCallback {
31 public:
32     virtual ~PostProcessorCallback() = default;
33     virtual void OnError(int32_t errorCode) = 0;
34     virtual void OnOutputFormatChanged(const Format &format) = 0;
35     virtual void OnInputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) = 0;
36     virtual void OnOutputBufferAvailable(uint32_t index, std::shared_ptr<AVBuffer> buffer) = 0;
37 };
38 
39 enum VideoPostProcessorType {
40     NONE,
41     SUPER_RESOLUTION,
42     CAMERA_INSERT_FRAME,
43     CAMERA_MP_PWP,
44 };
45 
46 class BaseVideoPostProcessor {
47 public:
48     BaseVideoPostProcessor() = default;
49     virtual ~BaseVideoPostProcessor() = default;
50 
51     virtual Status Init() = 0;
52     virtual Status Flush() = 0;
53     virtual Status Stop() = 0;
54     virtual Status Start() = 0;
55     virtual Status Release() = 0;
Pause()56     virtual Status Pause()
57     {
58         return Status::OK;
59     }
60     virtual Status NotifyEos(int64_t eosPts = 0)
61     {
62         return Status::OK;
63     }
64 
65     virtual sptr<Surface> GetInputSurface() = 0;
66     virtual Status SetOutputSurface(sptr<Surface> surface) = 0;
67 
68     virtual Status ReleaseOutputBuffer(uint32_t index, bool render) = 0;
69     virtual Status RenderOutputBufferAtTime(uint32_t index, int64_t renderTimestampNs) = 0;
70 
71     virtual Status SetCallback(const std::shared_ptr<PostProcessorCallback> callback) = 0;
72     virtual Status SetEventReceiver(const std::shared_ptr<Pipeline::EventReceiver> &receiver) = 0;
73 
74     virtual Status SetParameter(const Format &format) = 0;
75     virtual Status SetPostProcessorOn(bool isPostProcessorOn) = 0;
76     virtual Status SetVideoWindowSize(int32_t width, int32_t height) = 0;
77 
StartSeekContinous()78     virtual Status StartSeekContinous()
79     {
80         return Status::OK;
81     }
StopSeekContinous()82     virtual Status StopSeekContinous()
83     {
84         return Status::OK;
85     }
SetFd(int32_t fd)86     virtual Status SetFd(int32_t fd)
87     {
88         (void)fd;
89         return Status::OK;
90     }
SetCameraPostProcessing(bool isOpen)91     virtual Status SetCameraPostProcessing(bool isOpen)
92     {
93         (void)isOpen;
94         return Status::OK;
95     }
SetSeekTime(int64_t seekTimeUs,PlayerSeekMode mode)96     virtual void SetSeekTime(int64_t seekTimeUs, PlayerSeekMode mode)
97     {
98         (void)seekTimeUs;
99         (void)mode;
100     }
ResetSeekInfo()101     virtual void ResetSeekInfo()
102     {}
SetSpeed(float speed)103     virtual Status SetSpeed(float speed)
104     {
105         (void)speed;
106         return Status::OK;
107     }
108 };
109 
110 } // namespace Media
111 } // namespace OHOS
112 #endif // BASE_VIDEO_POST_PROCESSOR_H
113