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 AIHDR_ENHANCER_VIDEO_H 17 #define AIHDR_ENHANCER_VIDEO_H 18 19 #include <string> 20 #include <stdio.h> 21 22 #include "external_window.h" 23 24 #include "aihdr_enhancer_video_common.h" 25 26 namespace OHOS { 27 namespace Media { 28 namespace VideoProcessingEngine { 29 // typedef struct Surface Surface; 30 31 class __attribute__((visibility("default"))) AihdrEnhancerVideo { 32 public: 33 static std::shared_ptr<AihdrEnhancerVideo> Create(); 34 virtual ~AihdrEnhancerVideo() = default; 35 /* * 36 * @brief Registers a AihdrEnhancerVideo callback. 37 * 38 * This function must be called before {@link Prepare} 39 * 40 * @param callback Indicates the callback to register. For details, see {@link AihdrEnhancerVideoCallback}. 41 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 42 * @since 5.0 43 */ 44 virtual int32_t SetCallback(const std::shared_ptr<AihdrEnhancerVideoCallback> &callback) = 0; 45 46 /* * 47 * @brief Sets the window on which to render the output of this AihdrEnhancerVideo. 48 * 49 * This function must be called before {@link Prepare} 50 * 51 * @param window The output window. 52 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 53 * @since 5.0 54 */ 55 virtual int32_t SetSurface(const OHNativeWindow* window) = 0; 56 57 /* * 58 * @brief Obtains the surface from AihdrEnhancerVideo. 59 * 60 * This function can only be called before {@link Prepare} 61 * 62 * @return Returns the pointer to the surface. 63 * @since 5.0 64 */ 65 virtual int32_t GetSurface(OHNativeWindow** window) = 0; 66 67 /* * 68 * @brief Configure the AihdrEnhancerVideo. 69 * 70 * @param window The input window. 71 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 72 * @since 5.0 73 */ 74 virtual int32_t Configure() = 0; 75 76 /* * 77 * @brief Prepare for AihdrEnhancerVideo. 78 * 79 * This function must be called before {@link Start} 80 * 81 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 82 * @since 5.0 83 */ 84 virtual int32_t Prepare() = 0; 85 86 /* * 87 * @brief Start AihdrEnhancerVideo. 88 * 89 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 90 * @since 5.0 91 */ 92 virtual int32_t Start() = 0; 93 94 /* * 95 * @brief Stop AihdrEnhancerVideo. 96 * 97 * This function must be called during running 98 * 99 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 100 * @since 5.0 101 */ 102 virtual int32_t Stop() = 0; 103 104 /* * 105 * @brief Restores the AihdrEnhancerVideo to the initial state. 106 * 107 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 108 * @since 5.0 109 */ 110 virtual int32_t Reset() = 0; 111 112 /* * 113 * @brief Releases AihdrEnhancerVideo resources. All methods are unavailable after calling this. 114 * 115 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 116 * @since 5.0 117 */ 118 virtual int32_t Release() = 0; 119 120 /* * 121 * @brief Notify eos of the AihdrEnhancerVideo. 122 * 123 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 124 * @since 5.0 125 */ 126 virtual int32_t NotifyEos() = 0; 127 128 /* * 129 * @brief Returns the output buffer to the AihdrEnhancerVideo. 130 * 131 * This function must be called during running 132 * 133 * @param index The index of the output buffer. 134 * @param render Whether to render the buffer. 135 * @return Returns {@link VPE_ALGO_ERR_OK} if success; returns an error code otherwise. 136 * @since 5.0 137 */ 138 virtual int32_t ReleaseOutputBuffer(uint32_t index, bool render) = 0; 139 140 virtual int32_t Flush() = 0; 141 }; 142 using ArgumentType = void; 143 } // namespace VideoProcessingEngine 144 } // namespace Media 145 } // namespace OHOS 146 #endif // AIHDR_ENHANCER_VIDEO_H