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 gst.base.c.functions; 30 public import gst.base.c.types; 31 private import gstreamer.AllocationParams; 32 private import gstreamer.Allocator; 33 private import gstreamer.Buffer; 34 private import gstreamer.BufferPool; 35 private import gstreamer.Caps; 36 private import gstreamer.Element; 37 38 39 /** 40 * Manages a set of pads with the purpose of aggregating their buffers. 41 * Control is given to the subclass when all pads have data. 42 * 43 * * Base class for mixers and muxers. Subclasses should at least implement 44 * the #GstAggregatorClass.aggregate() virtual method. 45 * 46 * * Installs a #GstPadChainFunction, a #GstPadEventFullFunction and a 47 * #GstPadQueryFunction to queue all serialized data packets per sink pad. 48 * Subclasses should not overwrite those, but instead implement 49 * #GstAggregatorClass.sink_event() and #GstAggregatorClass.sink_query() as 50 * needed. 51 * 52 * * When data is queued on all pads, the aggregate vmethod is called. 53 * 54 * * One can peek at the data on any given GstAggregatorPad with the 55 * gst_aggregator_pad_peek_buffer () method, and remove it from the pad 56 * with the gst_aggregator_pad_pop_buffer () method. When a buffer 57 * has been taken with pop_buffer (), a new buffer can be queued 58 * on that pad. 59 * 60 * * If the subclass wishes to push a buffer downstream in its aggregate 61 * implementation, it should do so through the 62 * gst_aggregator_finish_buffer () method. This method will take care 63 * of sending and ordering mandatory events such as stream start, caps 64 * and segment. 65 * 66 * * Same goes for EOS events, which should not be pushed directly by the 67 * subclass, it should instead return GST_FLOW_EOS in its aggregate 68 * implementation. 69 * 70 * * Note that the aggregator logic regarding gap event handling is to turn 71 * these into gap buffers with matching PTS and duration. It will also 72 * flag these buffers with GST_BUFFER_FLAG_GAP and GST_BUFFER_FLAG_DROPPABLE 73 * to ease their identification and subsequent processing. 74 * 75 * * Subclasses must use (a subclass of) #GstAggregatorPad for both their 76 * sink and source pads. 77 * See gst_element_class_add_static_pad_template_with_gtype(). 78 * 79 * This class used to live in gst-plugins-bad and was moved to core. 80 */ 81 public class Aggregator : Element 82 { 83 /** the main Gtk struct */ 84 protected GstAggregator* gstAggregator; 85 86 /** Get the main Gtk struct */ 87 public GstAggregator* getAggregatorStruct(bool transferOwnership = false) 88 { 89 if (transferOwnership) 90 ownedRef = false; 91 return gstAggregator; 92 } 93 94 /** the main Gtk struct as a void* */ 95 protected override void* getStruct() 96 { 97 return cast(void*)gstAggregator; 98 } 99 100 /** 101 * Sets our main struct and passes it to the parent class. 102 */ 103 public this (GstAggregator* gstAggregator, bool ownedRef = false) 104 { 105 this.gstAggregator = gstAggregator; 106 super(cast(GstElement*)gstAggregator, ownedRef); 107 } 108 109 110 /** */ 111 public static GType getType() 112 { 113 return gst_aggregator_get_type(); 114 } 115 116 /** 117 * This method will push the provided output buffer downstream. If needed, 118 * mandatory events such as stream-start, caps, and segment events will be 119 * sent before pushing the buffer. 120 * 121 * Params: 122 * buffer = the #GstBuffer to push. 123 */ 124 public GstFlowReturn finishBuffer(Buffer buffer) 125 { 126 return gst_aggregator_finish_buffer(gstAggregator, (buffer is null) ? null : buffer.getBufferStruct()); 127 } 128 129 /** 130 * Lets #GstAggregator sub-classes get the memory @allocator 131 * acquired by the base class and its @params. 132 * 133 * Unref the @allocator after use it. 134 * 135 * Params: 136 * allocator = the #GstAllocator 137 * used 138 * params = the 139 * #GstAllocationParams of @allocator 140 */ 141 public void getAllocator(out Allocator allocator, out AllocationParams params) 142 { 143 GstAllocator* outallocator = null; 144 GstAllocationParams* outparams = sliceNew!GstAllocationParams(); 145 146 gst_aggregator_get_allocator(gstAggregator, &outallocator, outparams); 147 148 allocator = ObjectG.getDObject!(Allocator)(outallocator); 149 params = ObjectG.getDObject!(AllocationParams)(outparams, true); 150 } 151 152 /** 153 * Returns: the instance of the #GstBufferPool used 154 * by @trans; free it after use it 155 */ 156 public BufferPool getBufferPool() 157 { 158 auto p = gst_aggregator_get_buffer_pool(gstAggregator); 159 160 if(p is null) 161 { 162 return null; 163 } 164 165 return ObjectG.getDObject!(BufferPool)(cast(GstBufferPool*) p, true); 166 } 167 168 /** 169 * Retrieves the latency values reported by @self in response to the latency 170 * query, or %GST_CLOCK_TIME_NONE if there is not live source connected and the element 171 * will not wait for the clock. 172 * 173 * Typically only called by subclasses. 174 * 175 * Returns: The latency or %GST_CLOCK_TIME_NONE if the element does not sync 176 */ 177 public GstClockTime getLatency() 178 { 179 return gst_aggregator_get_latency(gstAggregator); 180 } 181 182 /** 183 * Lets #GstAggregator sub-classes tell the baseclass what their internal 184 * latency is. Will also post a LATENCY message on the bus so the pipeline 185 * can reconfigure its global latency. 186 * 187 * Params: 188 * minLatency = minimum latency 189 * maxLatency = maximum latency 190 */ 191 public void setLatency(GstClockTime minLatency, GstClockTime maxLatency) 192 { 193 gst_aggregator_set_latency(gstAggregator, minLatency, maxLatency); 194 } 195 196 /** 197 * Sets the caps to be used on the src pad. 198 * 199 * Params: 200 * caps = The #GstCaps to set on the src pad. 201 */ 202 public void setSrcCaps(Caps caps) 203 { 204 gst_aggregator_set_src_caps(gstAggregator, (caps is null) ? null : caps.getCapsStruct()); 205 } 206 }