• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 POST_PROCESSING_CONTROLLER_H
17 #define POST_PROCESSING_CONTROLLER_H
18 
19 #include <type_traits>
20 #include "surface.h"
21 #include "avcodec_errors.h"
22 #include "meta/format.h"
23 #include "post_processing_utils.h"
24 
25 namespace OHOS {
26 namespace MediaAVCodec {
27 namespace PostProcessing {
28 
29 template<typename T>
30 class Controller {
31 public:
32     virtual ~Controller() = default;
33 
LoadInterfaces()34     bool LoadInterfaces()
35     {
36         return This()->LoadInterfacesImpl();
37     }
38 
UnloadInterfaces()39     void UnloadInterfaces()
40     {
41         return This()->UnloadInterfacesImpl();
42     }
43 
IsColorSpaceConversionSupported(const CapabilityInfo & input,const CapabilityInfo & output)44     bool IsColorSpaceConversionSupported(const CapabilityInfo& input, const CapabilityInfo& output)
45     {
46         return This()->IsColorSpaceConversionSupportedImpl(input, output);
47     }
48 
Create()49     int32_t Create()
50     {
51         return This()->CreateImpl();
52     }
53 
Destroy()54     void Destroy()
55     {
56         return This()->DestroyImpl();
57     }
58 
SetCallback(void * callback,void * userData)59     int32_t SetCallback(void* callback, void* userData)
60     {
61         return This()->SetCallbackImpl(callback, userData);
62     }
63 
SetOutputSurface(sptr<Surface> surface)64     int32_t SetOutputSurface(sptr<Surface> surface)
65     {
66         return This()->SetOutputSurfaceImpl(surface);
67     }
68 
CreateInputSurface(sptr<Surface> & surface)69     int32_t CreateInputSurface(sptr<Surface>& surface)
70     {
71         return This()->CreateInputSurfaceImpl(surface);
72     }
73 
Configure(Media::Format & config)74     int32_t Configure(Media::Format& config)
75     {
76         return This()->ConfigureImpl(config);
77     }
78 
Prepare()79     int32_t Prepare()
80     {
81         return This()->PrepareImpl();
82     }
83 
Start()84     int32_t Start()
85     {
86         return This()->StartImpl();
87     }
88 
Stop()89     int32_t Stop()
90     {
91         return This()->StopImpl();
92     }
93 
Flush()94     int32_t Flush()
95     {
96         return This()->FlushImpl();
97     }
98 
GetOutputFormat(Media::Format & format)99     int32_t GetOutputFormat(Media::Format& format)
100     {
101         return This()->GetOutputFormatImpl(format);
102     }
103 
Reset()104     int32_t Reset()
105     {
106         return This()->ResetImpl();
107     }
108 
Release()109     int32_t Release()
110     {
111         return This()->ReleaseImpl();
112     }
113 
ReleaseOutputBuffer(uint32_t index,bool render)114     int32_t ReleaseOutputBuffer(uint32_t index, bool render)
115     {
116         return This()->ReleaseOutputBufferImpl(index, render);
117     }
118 
NotifyEos()119     int32_t NotifyEos()
120     {
121         return This()->NotifyEosImpl();
122     }
123 private:
This()124     T* This()
125     {
126         return static_cast<T*>(this);
127     }
128 
129     static constexpr HiviewDFX::HiLogLabel LABEL{LogLabel("Controller")};
130 };
131 
132 template<typename T>
133 using IsDerivedController = std::enable_if_t<
134     std::conjunction_v<
135         std::is_base_of<Controller<T>, T>,
136         std::is_convertible<const volatile T*, const volatile Controller<T>*>
137     >
138 >;
139 
140 } // namespace OHOS
141 } // namespace MediaAVCodec
142 } // namespace PostProcessing
143 
144 #endif // POST_PROCESSING_CONTROLLER_H