1 /* Generic video aggregator plugin 2 * Copyright (C) 2008 Wim Taymans <wim@fluendo.com> 3 * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_VIDEO_AGGREGATOR_H__ 22 #define __GST_VIDEO_AGGREGATOR_H__ 23 24 #include <gst/video/video.h> 25 #include <gst/base/gstaggregator.h> 26 27 G_BEGIN_DECLS 28 29 typedef struct _GstVideoAggregator GstVideoAggregator; 30 typedef struct _GstVideoAggregatorClass GstVideoAggregatorClass; 31 typedef struct _GstVideoAggregatorPrivate GstVideoAggregatorPrivate; 32 33 /************************* 34 * GstVideoAggregatorPad * 35 *************************/ 36 37 #define GST_TYPE_VIDEO_AGGREGATOR_PAD (gst_video_aggregator_pad_get_type()) 38 #define GST_VIDEO_AGGREGATOR_PAD(obj) \ 39 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR_PAD, GstVideoAggregatorPad)) 40 #define GST_VIDEO_AGGREGATOR_PAD_CAST(obj) ((GstVideoAggregatorPad *)(obj)) 41 #define GST_VIDEO_AGGREGATOR_PAD_CLASS(klass) \ 42 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR_PAD, GstVideoAggregatorPadClass)) 43 #define GST_IS_VIDEO_AGGREGATOR_PAD(obj) \ 44 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR_PAD)) 45 #define GST_IS_VIDEO_AGGREGATOR_PAD_CLASS(klass) \ 46 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR_PAD)) 47 #define GST_VIDEO_AGGREGATOR_PAD_GET_CLASS(obj) \ 48 (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_AGGREGATOR_PAD,GstVideoAggregatorPadClass)) 49 50 typedef struct _GstVideoAggregatorPad GstVideoAggregatorPad; 51 typedef struct _GstVideoAggregatorPadClass GstVideoAggregatorPadClass; 52 typedef struct _GstVideoAggregatorPadPrivate GstVideoAggregatorPadPrivate; 53 54 /** 55 * GstVideoAggregatorPad: 56 * @info: The #GstVideoInfo currently set on the pad 57 * 58 * Since: 1.16 59 */ 60 struct _GstVideoAggregatorPad 61 { 62 GstAggregatorPad parent; 63 64 /*< public >*/ 65 /* read-only, with OBJECT_LOCK */ 66 GstVideoInfo info; 67 68 /* < private > */ 69 GstVideoAggregatorPadPrivate *priv; 70 71 gpointer _gst_reserved[GST_PADDING]; 72 }; 73 74 /** 75 * GstVideoAggregatorPadClass: 76 * @update_conversion_info: Called when either the input or output formats 77 * have changed. 78 * @prepare_frame: Prepare the frame from the pad buffer and sets it to prepared_frame 79 * @clean_frame: clean the frame previously prepared in prepare_frame 80 * 81 * Since: 1.16 82 */ 83 struct _GstVideoAggregatorPadClass 84 { 85 GstAggregatorPadClass parent_class; 86 void (*update_conversion_info) (GstVideoAggregatorPad * pad); 87 88 gboolean (*prepare_frame) (GstVideoAggregatorPad * pad, 89 GstVideoAggregator * videoaggregator, 90 GstBuffer * buffer, 91 GstVideoFrame * prepared_frame); 92 93 void (*clean_frame) (GstVideoAggregatorPad * pad, 94 GstVideoAggregator * videoaggregator, 95 GstVideoFrame * prepared_frame); 96 97 gpointer _gst_reserved[GST_PADDING_LARGE]; 98 }; 99 100 GST_VIDEO_API 101 GType gst_video_aggregator_pad_get_type (void); 102 103 GST_VIDEO_API 104 gboolean gst_video_aggregator_pad_has_current_buffer (GstVideoAggregatorPad *pad); 105 106 GST_VIDEO_API 107 GstBuffer * gst_video_aggregator_pad_get_current_buffer (GstVideoAggregatorPad *pad); 108 109 GST_VIDEO_API 110 GstVideoFrame * gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad *pad); 111 112 GST_VIDEO_API 113 void gst_video_aggregator_pad_set_needs_alpha (GstVideoAggregatorPad *pad, gboolean needs_alpha); 114 115 /******************************** 116 * GstVideoAggregatorConvertPad * 117 *******************************/ 118 119 #define GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD (gst_video_aggregator_convert_pad_get_type()) 120 #define GST_VIDEO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD, GstVideoAggregatorConvertPad)) 121 #define GST_VIDEO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD, GstVideoAggregatorConvertPadClass)) 122 #define GST_VIDEO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD, GstVideoAggregatorConvertPadClass)) 123 #define GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD)) 124 #define GST_IS_VIDEO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR_CONVERT_PAD)) 125 126 typedef struct _GstVideoAggregatorConvertPad GstVideoAggregatorConvertPad; 127 typedef struct _GstVideoAggregatorConvertPadClass GstVideoAggregatorConvertPadClass; 128 typedef struct _GstVideoAggregatorConvertPadPrivate GstVideoAggregatorConvertPadPrivate; 129 130 /** 131 * GstVideoAggregatorConvertPad: 132 * 133 * An implementation of GstPad that can be used with #GstVideoAggregator. 134 * 135 * See #GstVideoAggregator for more details. 136 * 137 * Since: 1.16 138 */ 139 struct _GstVideoAggregatorConvertPad 140 { 141 /*< private >*/ 142 GstVideoAggregatorPad parent; 143 144 GstVideoAggregatorConvertPadPrivate *priv; 145 146 gpointer _gst_reserved[GST_PADDING]; 147 }; 148 149 /** 150 * GstVideoAggregatorConvertPadClass: 151 * 152 * Since: 1.16 153 */ 154 struct _GstVideoAggregatorConvertPadClass 155 { 156 GstVideoAggregatorPadClass parent_class; 157 158 void (*create_conversion_info) (GstVideoAggregatorConvertPad *pad, GstVideoAggregator *agg, GstVideoInfo *conversion_info); 159 160 /*< private >*/ 161 gpointer _gst_reserved[GST_PADDING]; 162 }; 163 164 GST_VIDEO_API 165 GType gst_video_aggregator_convert_pad_get_type (void); 166 167 GST_VIDEO_API 168 void gst_video_aggregator_convert_pad_update_conversion_info (GstVideoAggregatorConvertPad * pad); 169 170 /********************** 171 * GstVideoAggregator * 172 *********************/ 173 174 #define GST_TYPE_VIDEO_AGGREGATOR (gst_video_aggregator_get_type()) 175 #define GST_VIDEO_AGGREGATOR(obj) \ 176 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregator)) 177 #define GST_VIDEO_AGGREGATOR_CAST(obj) ((GstVideoAggregator *)(obj)) 178 #define GST_VIDEO_AGGREGATOR_CLASS(klass) \ 179 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregatorClass)) 180 #define GST_IS_VIDEO_AGGREGATOR(obj) \ 181 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_AGGREGATOR)) 182 #define GST_IS_VIDEO_AGGREGATOR_CLASS(klass) \ 183 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_AGGREGATOR)) 184 #define GST_VIDEO_AGGREGATOR_GET_CLASS(obj) \ 185 (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_AGGREGATOR,GstVideoAggregatorClass)) 186 187 /** 188 * GstVideoAggregator: 189 * @info: The #GstVideoInfo representing the currently set 190 * srcpad caps. 191 * 192 * Since: 1.16 193 */ 194 struct _GstVideoAggregator 195 { 196 GstAggregator aggregator; 197 198 /*< public >*/ 199 /* Output caps */ 200 GstVideoInfo info; 201 202 /* < private > */ 203 GstVideoAggregatorPrivate *priv; 204 gpointer _gst_reserved[GST_PADDING_LARGE]; 205 }; 206 207 /** 208 * GstVideoAggregatorClass: 209 * @update_caps: Optional. 210 * Lets subclasses update the #GstCaps representing 211 * the src pad caps before usage. Return %NULL to indicate failure. 212 * @aggregate_frames: Lets subclasses aggregate frames that are ready. Subclasses 213 * should iterate the GstElement.sinkpads and use the already 214 * mapped #GstVideoFrame from gst_video_aggregator_pad_get_prepared_frame() 215 * or directly use the #GstBuffer from gst_video_aggregator_pad_get_current_buffer() 216 * if it needs to map the buffer in a special way. The result of the 217 * aggregation should land in @outbuffer. 218 * @create_output_buffer: Optional. 219 * Lets subclasses provide a #GstBuffer to be used as @outbuffer of 220 * the #aggregate_frames vmethod. 221 * @find_best_format: Optional. 222 * Lets subclasses decide of the best common format to use. 223 * 224 * Since: 1.16 225 **/ 226 struct _GstVideoAggregatorClass 227 { 228 /*< private >*/ 229 GstAggregatorClass parent_class; 230 231 /*< public >*/ 232 GstCaps * (*update_caps) (GstVideoAggregator * videoaggregator, 233 GstCaps * caps); 234 GstFlowReturn (*aggregate_frames) (GstVideoAggregator * videoaggregator, 235 GstBuffer * outbuffer); 236 GstFlowReturn (*create_output_buffer) (GstVideoAggregator * videoaggregator, 237 GstBuffer ** outbuffer); 238 void (*find_best_format) (GstVideoAggregator * vagg, 239 GstCaps * downstream_caps, 240 GstVideoInfo * best_info, 241 gboolean * at_least_one_alpha); 242 243 /* < private > */ 244 gpointer _gst_reserved[GST_PADDING_LARGE]; 245 }; 246 247 GST_VIDEO_API 248 GType gst_video_aggregator_get_type (void); 249 250 G_END_DECLS 251 #endif /* __GST_VIDEO_AGGREGATOR_H__ */ 252