• 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 };
43 
44 class BaseVideoPostProcessor {
45 public:
46     BaseVideoPostProcessor() = default;
47     virtual ~BaseVideoPostProcessor() = default;
48 
49     virtual Status Init() = 0;
50     virtual Status Flush() = 0;
51     virtual Status Stop() = 0;
52     virtual Status Start() = 0;
53     virtual Status Release() = 0;
NotifyEos()54     virtual Status NotifyEos()
55     {
56         return Status::OK;
57     }
58 
59     virtual sptr<Surface> GetInputSurface() = 0;
60     virtual Status SetOutputSurface(sptr<Surface> surface) = 0;
61 
62     virtual Status ReleaseOutputBuffer(uint32_t index, bool render) = 0;
63     virtual Status RenderOutputBufferAtTime(uint32_t index, int64_t renderTimestampNs) = 0;
64 
65     virtual Status SetCallback(const std::shared_ptr<PostProcessorCallback> callback) = 0;
66     virtual Status SetEventReceiver(const std::shared_ptr<Pipeline::EventReceiver> &receiver) = 0;
67 
68     virtual Status SetParameter(const Format &format) = 0;
69     virtual Status SetPostProcessorOn(bool isPostProcessorOn) = 0;
70     virtual Status SetVideoWindowSize(int32_t width, int32_t height) = 0;
71 };
72 
73 } // namespace Media
74 } // namespace OHOS
75 #endif // BASE_VIDEO_POST_PROCESSOR_H
76