1 /* 2 * Copyright (c) 2021-2021 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 HISTREAMER_PLUGIN_INTF_VIDEO_SINK_PLUGIN_H 17 #define HISTREAMER_PLUGIN_INTF_VIDEO_SINK_PLUGIN_H 18 19 #include "plugin/common/plugin_buffer.h" 20 #include "plugin/common/plugin_caps.h" 21 #include "plugin/interface/plugin_base.h" 22 #include "plugin/interface/plugin_definition.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace Plugin { 27 /** 28 * @brief Video Sink Plugin. 29 * 30 * Component that receives media streams. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 struct VideoSinkPlugin : public PluginBase { 36 /// constructor VideoSinkPluginVideoSinkPlugin37 explicit VideoSinkPlugin(std::string name): PluginBase(std::move(name)) {} 38 /** 39 * @brief Pauses video rendering 40 * 41 * The function is valid only in the RUNNING state. If the pause is successful, 42 * the plugin enters the PAUSED state. 43 * 44 * @return Execution status return 45 * @retval OK: Plugin Pause succeeded. 46 */ 47 virtual Status Pause() = 0; 48 49 /** 50 * @brief Resumes video rendering 51 * 52 * The function is valid only in the PAUSED state. If the resume is successful, 53 * the plugin enters the RUNNING state. 54 * 55 * @return Execution status return 56 * @retval OK: Plugin Resume succeeded. 57 */ 58 virtual Status Resume() = 0; 59 60 /** 61 * @brief Writes a frame of output data into the video display device for rendering. 62 * 63 * The function is valid only in the RUNNING state. 64 * 65 * @param input Indicates the pointer to the frame to write. 66 * @return Execution status return 67 * @retval OK: Plugin Write succeeded. 68 */ 69 virtual Status Write(const std::shared_ptr<Buffer>& input) = 0; 70 71 /** 72 * @brief Flushes data in the video buffer. 73 * 74 * The function is valid only in after RUNNING state. 75 * 76 * @return Execution status return 77 * @retval OK: Plugin Flush succeeded. 78 */ 79 virtual Status Flush() = 0; 80 81 /** 82 * @brief Get the estimated latency of the video device driver. 83 * 84 * The function is valid only in the after PREPARED state. 85 * 86 * @param nanoSec Indicates the pointer to the latency (in nanoseconds) to be obtained. 87 * @return Execution status return 88 * @retval OK: Plugin GetLatency succeeded. 89 */ 90 virtual Status GetLatency(uint64_t& nanoSec) = 0; 91 }; 92 93 /// Video sink plugin api major number. 94 #define VIDEO_SINK_API_VERSION_MAJOR (1) 95 96 /// Video sink plugin api minor number 97 #define VIDEO_SINK_API_VERSION_MINOR (0) 98 99 /// Video sink plugin version 100 #define VIDEO_SINK_API_VERSION MAKE_VERSION(VIDEO_SINK_API_VERSION_MAJOR, VIDEO_SINK_API_VERSION_MINOR) 101 102 /** 103 * @brief Describes the video sink plugin information. 104 * 105 * @since 1.0 106 * @version 1.0 107 */ 108 struct VideoSinkPluginDef : public PluginDefBase { 109 CapabilitySet inCaps; ///< Plug-in input capability, For details, @see Capability. 110 PluginCreatorFunc<VideoSinkPlugin> creator; ///< Video sink plugin create function. VideoSinkPluginDefVideoSinkPluginDef111 VideoSinkPluginDef() 112 { 113 apiVersion = VIDEO_SINK_API_VERSION; ///< Video sink plugin version. 114 pluginType = PluginType::VIDEO_SINK; ///< Plugin type, MUST be VIDEO_SINK. 115 } 116 }; 117 } // namespace Plugin 118 } // namespace Media 119 } // namespace OHOS 120 #endif // HISTREAMER_PLUGIN_INTF_VIDEO_SINK_PLUGIN_H 121