• 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_DYNAMIC_INTERFACE_TYPES_H
17 #define POST_PROCESSING_DYNAMIC_INTERFACE_TYPES_H
18 
19 #include "post_processing_utils.h"
20 
21 namespace OHOS {
22 namespace MediaAVCodec {
23 namespace PostProcessing {
24 
25 // processing handler type
26 using DynamicColorSpaceConverterHandle = void;
27 
28 // function pointer types
29 using DynamicIsColorSpaceConversionSupportedFunc = int32_t(*)(const void*, const void*);
30 using DynamicCreateFunc = DynamicColorSpaceConverterHandle*(*)();
31 using DynamicDestroyFunc = void(*)(DynamicColorSpaceConverterHandle*);
32 using DynamicSetCallbackFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, void*, void*);
33 using DynamicSetOutputSurfaceFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, void*);
34 using DynamicCreateInputSurfaceFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, void*);
35 using DynamicConfigureFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, void*);
36 using DynamicPrepareFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
37 using DynamicStartFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
38 using DynamicStopFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
39 using DynamicFlushFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
40 using DynamicResetFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
41 using DynamicReleaseFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
42 using DynamicReleaseOutputBufferFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, uint32_t, bool);
43 using DynamicGetOutputFormatFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, void*);
44 using DynamicOnProducerBufferReleasedFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
45 using DynamicNotifyEos = int32_t(*)(DynamicColorSpaceConverterHandle*);
46 
47 // function pointer types array
48 using DynamicInterfaceFuncTypes = TypeArray<
49     DynamicIsColorSpaceConversionSupportedFunc,
50     DynamicCreateFunc,
51     DynamicDestroyFunc,
52     DynamicSetCallbackFunc,
53     DynamicSetOutputSurfaceFunc,
54     DynamicCreateInputSurfaceFunc,
55     DynamicConfigureFunc,
56     DynamicPrepareFunc,
57     DynamicStartFunc,
58     DynamicStopFunc,
59     DynamicFlushFunc,
60     DynamicResetFunc,
61     DynamicReleaseFunc,
62     DynamicReleaseOutputBufferFunc,
63     DynamicGetOutputFormatFunc,
64     DynamicOnProducerBufferReleasedFunc,
65     DynamicNotifyEos
66 >;
67 
68 // function symbols
69 constexpr const char* DYNAMIC_INTERFACE_SYMBOLS[]{
70     "ColorSpaceConvertVideoIsColorSpaceConversionSupported",
71     "ColorSpaceConvertVideoCreate",
72     "ColorSpaceConvertVideoDestroy",
73     "ColorSpaceConvertVideoSetCallback",
74     "ColorSpaceConvertVideoSetOutputSurface",
75     "ColorSpaceConvertVideoCreateInputSurface",
76     "ColorSpaceConvertVideoConfigure",
77     "ColorSpaceConvertVideoPrepare",
78     "ColorSpaceConvertVideoStart",
79     "ColorSpaceConvertVideoStop",
80     "ColorSpaceConvertVideoFlush",
81     "ColorSpaceConvertVideoReset",
82     "ColorSpaceConvertVideoRelease",
83     "ColorSpaceConvertVideoReleaseOutputBuffer",
84     "ColorSpaceConvertVideoGetOutputFormat",
85     "ColorSpaceConvertVideoOnProducerBufferReleased",
86     "ColorSpaceConvertVideoNotifyEos"
87 };
88 
89 // function name enumeration
90 enum class DynamicInterfaceName : size_t {
91     IS_COLORSPACE_CONVERSION_SUPPORTED,
92     CREATE,
93     DESTROY,
94     SET_CALLBACK,
95     SET_OUTPUT_SURFACE,
96     CREATE_INPUT_SURFACE,
97     CONFIGURE,
98     PREPARE,
99     START,
100     STOP,
101     FLUSH,
102     RESET,
103     RELEASE,
104     RELEASE_OUPUT_BUFFER,
105     GET_OUTPUT_FORMAT,
106     ON_PRODUCER_BUFFER_RELEASED,
107     NOTIFY_EOS,
108 };
109 
110 // dynamic interface helper types
111 template<DynamicInterfaceName E>
112 using DynamicInterfaceIndex = EnumerationValue<DynamicInterfaceName, E>;
113 
114 template<DynamicInterfaceName E>
115 using DynamicInterfaceIndexType = typename DynamicInterfaceIndex<E>::UnderlyingType;
116 
117 template<DynamicInterfaceName E>
118 constexpr DynamicInterfaceIndexType<E> DynamicInterfaceIndexValue = DynamicInterfaceIndex<E>::value;
119 
120 template<DynamicInterfaceName E, typename... Args>
121 using DynamicInterfaceReturnType =
122     std::invoke_result_t<DynamicInterfaceFuncTypes::Get<DynamicInterfaceIndexValue<E>>, Args...>;
123 
124 constexpr size_t DYNAMIC_INTERFACE_NUM{DynamicInterfaceFuncTypes::size};
125 
126 } // namespace PostProcessing
127 } // namespace MediaAVCodec
128 } // namespace OHOS
129 
130 #endif // POST_PROCESSING_DYNAMIC_INTERFACE_TYPES_H