1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD 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 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gst.base.Aggregator; 26 27 private import glib.MemorySlice; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gst.base.AggregatorPad; 31 private import gst.base.c.functions; 32 public import gst.base.c.types; 33 private import gstreamer.AllocationParams; 34 private import gstreamer.Allocator; 35 private import gstreamer.Buffer; 36 private import gstreamer.BufferList; 37 private import gstreamer.BufferPool; 38 private import gstreamer.Caps; 39 private import gstreamer.Element; 40 private import gstreamer.Sample; 41 private import gstreamer.Segment; 42 private import gstreamer.Structure; 43 private import std.algorithm; 44 45 46 /** 47 * Manages a set of pads with the purpose of aggregating their buffers. 48 * Control is given to the subclass when all pads have data. 49 * 50 * * Base class for mixers and muxers. Subclasses should at least implement 51 * the #GstAggregatorClass.aggregate() virtual method. 52 * 53 * * Installs a #GstPadChainFunction, a #GstPadEventFullFunction and a 54 * #GstPadQueryFunction to queue all serialized data packets per sink pad. 55 * Subclasses should not overwrite those, but instead implement 56 * #GstAggregatorClass.sink_event() and #GstAggregatorClass.sink_query() as 57 * needed. 58 * 59 * * When data is queued on all pads, the aggregate vmethod is called. 60 * 61 * * One can peek at the data on any given GstAggregatorPad with the 62 * gst_aggregator_pad_peek_buffer() method, and remove it from the pad 63 * with the gst_aggregator_pad_pop_buffer () method. When a buffer 64 * has been taken with pop_buffer (), a new buffer can be queued 65 * on that pad. 66 * 67 * * When gst_aggregator_pad_peek_buffer() or gst_aggregator_pad_has_buffer() 68 * are called, a reference is taken to the returned buffer, which stays 69 * valid until either: 70 * 71 * - gst_aggregator_pad_pop_buffer() is called, in which case the caller 72 * is guaranteed that the buffer they receive is the same as the peeked 73 * buffer. 74 * - gst_aggregator_pad_drop_buffer() is called, in which case the caller 75 * is guaranteed that the dropped buffer is the one that was peeked. 76 * - the subclass implementation of #GstAggregatorClass.aggregate returns. 77 * 78 * Subsequent calls to gst_aggregator_pad_peek_buffer() or 79 * gst_aggregator_pad_has_buffer() return / check the same buffer that was 80 * returned / checked, until one of the conditions listed above is met. 81 * 82 * Subclasses are only allowed to call these methods from the aggregate 83 * thread. 84 * 85 * * If the subclass wishes to push a buffer downstream in its aggregate 86 * implementation, it should do so through the 87 * gst_aggregator_finish_buffer() method. This method will take care 88 * of sending and ordering mandatory events such as stream start, caps 89 * and segment. Buffer lists can also be pushed out with 90 * gst_aggregator_finish_buffer_list(). 91 * 92 * * Same goes for EOS events, which should not be pushed directly by the 93 * subclass, it should instead return GST_FLOW_EOS in its aggregate 94 * implementation. 95 * 96 * * Note that the aggregator logic regarding gap event handling is to turn 97 * these into gap buffers with matching PTS and duration. It will also 98 * flag these buffers with GST_BUFFER_FLAG_GAP and GST_BUFFER_FLAG_DROPPABLE 99 * to ease their identification and subsequent processing. 100 * 101 * * Subclasses must use (a subclass of) #GstAggregatorPad for both their 102 * sink and source pads. 103 * See gst_element_class_add_static_pad_template_with_gtype(). 104 * 105 * This class used to live in gst-plugins-bad and was moved to core. 106 * 107 * Since: 1.14 108 */ 109 public class Aggregator : Element 110 { 111 /** the main Gtk struct */ 112 protected GstAggregator* gstAggregator; 113 114 /** Get the main Gtk struct */ 115 public GstAggregator* getAggregatorStruct(bool transferOwnership = false) 116 { 117 if (transferOwnership) 118 ownedRef = false; 119 return gstAggregator; 120 } 121 122 /** the main Gtk struct as a void* */ 123 protected override void* getStruct() 124 { 125 return cast(void*)gstAggregator; 126 } 127 128 /** 129 * Sets our main struct and passes it to the parent class. 130 */ 131 public this (GstAggregator* gstAggregator, bool ownedRef = false) 132 { 133 this.gstAggregator = gstAggregator; 134 super(cast(GstElement*)gstAggregator, ownedRef); 135 } 136 137 138 /** */ 139 public static GType getType() 140 { 141 return gst_aggregator_get_type(); 142 } 143 144 /** 145 * This method will push the provided output buffer downstream. If needed, 146 * mandatory events such as stream-start, caps, and segment events will be 147 * sent before pushing the buffer. 148 * 149 * Params: 150 * buffer = the #GstBuffer to push. 151 */ 152 public GstFlowReturn finishBuffer(Buffer buffer) 153 { 154 return gst_aggregator_finish_buffer(gstAggregator, (buffer is null) ? null : buffer.getBufferStruct()); 155 } 156 157 /** 158 * This method will push the provided output buffer list downstream. If needed, 159 * mandatory events such as stream-start, caps, and segment events will be 160 * sent before pushing the buffer. 161 * 162 * Params: 163 * bufferlist = the #GstBufferList to push. 164 * 165 * Since: 1.18 166 */ 167 public GstFlowReturn finishBufferList(BufferList bufferlist) 168 { 169 return gst_aggregator_finish_buffer_list(gstAggregator, (bufferlist is null) ? null : bufferlist.getBufferListStruct()); 170 } 171 172 /** 173 * Lets #GstAggregator sub-classes get the memory @allocator 174 * acquired by the base class and its @params. 175 * 176 * Unref the @allocator after use it. 177 * 178 * Params: 179 * allocator = the #GstAllocator 180 * used 181 * params = the 182 * #GstAllocationParams of @allocator 183 */ 184 public void getAllocator(out Allocator allocator, out AllocationParams params) 185 { 186 GstAllocator* outallocator = null; 187 GstAllocationParams* outparams = sliceNew!GstAllocationParams(); 188 189 gst_aggregator_get_allocator(gstAggregator, &outallocator, outparams); 190 191 allocator = ObjectG.getDObject!(Allocator)(outallocator); 192 params = ObjectG.getDObject!(AllocationParams)(outparams, true); 193 } 194 195 /** 196 * Returns: the instance of the #GstBufferPool used 197 * by @trans; free it after use it 198 */ 199 public BufferPool getBufferPool() 200 { 201 auto __p = gst_aggregator_get_buffer_pool(gstAggregator); 202 203 if(__p is null) 204 { 205 return null; 206 } 207 208 return ObjectG.getDObject!(BufferPool)(cast(GstBufferPool*) __p, true); 209 } 210 211 /** 212 * Retrieves the latency values reported by @self in response to the latency 213 * query, or %GST_CLOCK_TIME_NONE if there is not live source connected and the element 214 * will not wait for the clock. 215 * 216 * Typically only called by subclasses. 217 * 218 * Returns: The latency or %GST_CLOCK_TIME_NONE if the element does not sync 219 */ 220 public GstClockTime getLatency() 221 { 222 return gst_aggregator_get_latency(gstAggregator); 223 } 224 225 /** 226 * Negotiates src pad caps with downstream elements. 227 * Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again 228 * if #GstAggregatorClass.negotiate() fails. 229 * 230 * Returns: %TRUE if the negotiation succeeded, else %FALSE. 231 * 232 * Since: 1.18 233 */ 234 public bool negotiate() 235 { 236 return gst_aggregator_negotiate(gstAggregator) != 0; 237 } 238 239 /** 240 * Use this function to determine what input buffers will be aggregated 241 * to produce the next output buffer. This should only be called from 242 * a #GstAggregator::samples-selected handler, and can be used to precisely 243 * control aggregating parameters for a given set of input samples. 244 * 245 * Returns: The sample that is about to be aggregated. It may hold a #GstBuffer 246 * or a #GstBufferList. The contents of its info structure is subclass-dependent, 247 * and documented on a subclass basis. The buffers held by the sample are 248 * not writable. 249 * 250 * Since: 1.18 251 */ 252 public Sample peekNextSample(AggregatorPad pad) 253 { 254 auto __p = gst_aggregator_peek_next_sample(gstAggregator, (pad is null) ? null : pad.getAggregatorPadStruct()); 255 256 if(__p is null) 257 { 258 return null; 259 } 260 261 return ObjectG.getDObject!(Sample)(cast(GstSample*) __p, true); 262 } 263 264 /** 265 * Subclasses should call this when they have prepared the 266 * buffers they will aggregate for each of their sink pads, but 267 * before using any of the properties of the pads that govern 268 * *how* aggregation should be performed, for example z-index 269 * for video aggregators. 270 * 271 * If gst_aggregator_update_segment() is used by the subclass, 272 * it MUST be called before gst_aggregator_selected_samples(). 273 * 274 * This function MUST only be called from the #GstAggregatorClass::aggregate() 275 * function. 276 * 277 * Params: 278 * pts = The presentation timestamp of the next output buffer 279 * dts = The decoding timestamp of the next output buffer 280 * duration = The duration of the next output buffer 281 * info = a #GstStructure containing additional information 282 * 283 * Since: 1.18 284 */ 285 public void selectedSamples(GstClockTime pts, GstClockTime dts, GstClockTime duration, Structure info) 286 { 287 gst_aggregator_selected_samples(gstAggregator, pts, dts, duration, (info is null) ? null : info.getStructureStruct()); 288 } 289 290 /** 291 * Lets #GstAggregator sub-classes tell the baseclass what their internal 292 * latency is. Will also post a LATENCY message on the bus so the pipeline 293 * can reconfigure its global latency. 294 * 295 * Params: 296 * minLatency = minimum latency 297 * maxLatency = maximum latency 298 */ 299 public void setLatency(GstClockTime minLatency, GstClockTime maxLatency) 300 { 301 gst_aggregator_set_latency(gstAggregator, minLatency, maxLatency); 302 } 303 304 /** 305 * Sets the caps to be used on the src pad. 306 * 307 * Params: 308 * caps = The #GstCaps to set on the src pad. 309 */ 310 public void setSrcCaps(Caps caps) 311 { 312 gst_aggregator_set_src_caps(gstAggregator, (caps is null) ? null : caps.getCapsStruct()); 313 } 314 315 /** 316 * This is a simple #GstAggregatorClass.get_next_time() implementation that 317 * just looks at the #GstSegment on the srcpad of the aggregator and bases 318 * the next time on the running time there. 319 * 320 * This is the desired behaviour in most cases where you have a live source 321 * and you have a dead line based aggregator subclass. 322 * 323 * Returns: The running time based on the position 324 * 325 * Since: 1.16 326 */ 327 public GstClockTime simpleGetNextTime() 328 { 329 return gst_aggregator_simple_get_next_time(gstAggregator); 330 } 331 332 /** 333 * Subclasses should use this to update the segment on their 334 * source pad, instead of directly pushing new segment events 335 * downstream. 336 * 337 * Subclasses MUST call this before gst_aggregator_selected_samples(), 338 * if it is used at all. 339 * 340 * Since: 1.18 341 */ 342 public void updateSegment(Segment segment) 343 { 344 gst_aggregator_update_segment(gstAggregator, (segment is null) ? null : segment.getSegmentStruct()); 345 } 346 347 /** 348 * Signals that the #GstAggregator subclass has selected the next set 349 * of input samples it will aggregate. Handlers may call 350 * gst_aggregator_peek_next_sample() at that point. 351 * 352 * Params: 353 * segment = The #GstSegment the next output buffer is part of 354 * pts = The presentation timestamp of the next output buffer 355 * dts = The decoding timestamp of the next output buffer 356 * duration = The duration of the next output buffer 357 * info = a #GstStructure containing additional information 358 * 359 * Since: 1.18 360 */ 361 gulong addOnSamplesSelected(void delegate(Segment, ulong, ulong, ulong, Structure, Aggregator) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 362 { 363 return Signals.connect(this, "samples-selected", dlg, connectFlags ^ ConnectFlags.SWAPPED); 364 } 365 }