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