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