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 * Since: 1.14 82 */ 83 public class Aggregator : Element 84 { 85 /** the main Gtk struct */ 86 protected GstAggregator* gstAggregator; 87 88 /** Get the main Gtk struct */ 89 public GstAggregator* getAggregatorStruct(bool transferOwnership = false) 90 { 91 if (transferOwnership) 92 ownedRef = false; 93 return gstAggregator; 94 } 95 96 /** the main Gtk struct as a void* */ 97 protected override void* getStruct() 98 { 99 return cast(void*)gstAggregator; 100 } 101 102 /** 103 * Sets our main struct and passes it to the parent class. 104 */ 105 public this (GstAggregator* gstAggregator, bool ownedRef = false) 106 { 107 this.gstAggregator = gstAggregator; 108 super(cast(GstElement*)gstAggregator, ownedRef); 109 } 110 111 112 /** */ 113 public static GType getType() 114 { 115 return gst_aggregator_get_type(); 116 } 117 118 /** 119 * This method will push the provided output buffer downstream. If needed, 120 * mandatory events such as stream-start, caps, and segment events will be 121 * sent before pushing the buffer. 122 * 123 * Params: 124 * buffer = the #GstBuffer to push. 125 */ 126 public GstFlowReturn finishBuffer(Buffer buffer) 127 { 128 return gst_aggregator_finish_buffer(gstAggregator, (buffer is null) ? null : buffer.getBufferStruct()); 129 } 130 131 /** 132 * Lets #GstAggregator sub-classes get the memory @allocator 133 * acquired by the base class and its @params. 134 * 135 * Unref the @allocator after use it. 136 * 137 * Params: 138 * allocator = the #GstAllocator 139 * used 140 * params = the 141 * #GstAllocationParams of @allocator 142 */ 143 public void getAllocator(out Allocator allocator, out AllocationParams params) 144 { 145 GstAllocator* outallocator = null; 146 GstAllocationParams* outparams = sliceNew!GstAllocationParams(); 147 148 gst_aggregator_get_allocator(gstAggregator, &outallocator, outparams); 149 150 allocator = ObjectG.getDObject!(Allocator)(outallocator); 151 params = ObjectG.getDObject!(AllocationParams)(outparams, true); 152 } 153 154 /** 155 * Returns: the instance of the #GstBufferPool used 156 * by @trans; free it after use it 157 */ 158 public BufferPool getBufferPool() 159 { 160 auto p = gst_aggregator_get_buffer_pool(gstAggregator); 161 162 if(p is null) 163 { 164 return null; 165 } 166 167 return ObjectG.getDObject!(BufferPool)(cast(GstBufferPool*) p, true); 168 } 169 170 /** 171 * Retrieves the latency values reported by @self in response to the latency 172 * query, or %GST_CLOCK_TIME_NONE if there is not live source connected and the element 173 * will not wait for the clock. 174 * 175 * Typically only called by subclasses. 176 * 177 * Returns: The latency or %GST_CLOCK_TIME_NONE if the element does not sync 178 */ 179 public GstClockTime getLatency() 180 { 181 return gst_aggregator_get_latency(gstAggregator); 182 } 183 184 /** 185 * Lets #GstAggregator sub-classes tell the baseclass what their internal 186 * latency is. Will also post a LATENCY message on the bus so the pipeline 187 * can reconfigure its global latency. 188 * 189 * Params: 190 * minLatency = minimum latency 191 * maxLatency = maximum latency 192 */ 193 public void setLatency(GstClockTime minLatency, GstClockTime maxLatency) 194 { 195 gst_aggregator_set_latency(gstAggregator, minLatency, maxLatency); 196 } 197 198 /** 199 * Sets the caps to be used on the src pad. 200 * 201 * Params: 202 * caps = The #GstCaps to set on the src pad. 203 */ 204 public void setSrcCaps(Caps caps) 205 { 206 gst_aggregator_set_src_caps(gstAggregator, (caps is null) ? null : caps.getCapsStruct()); 207 } 208 209 /** 210 * This is a simple #GstAggregator::get_next_time implementation that 211 * just looks at the #GstSegment on the srcpad of the aggregator and bases 212 * the next time on the running time there. 213 * 214 * This is the desired behaviour in most cases where you have a live source 215 * and you have a dead line based aggregator subclass. 216 * 217 * Returns: The running time based on the position 218 * 219 * Since: 1.16 220 */ 221 public GstClockTime simpleGetNextTime() 222 { 223 return gst_aggregator_simple_get_next_time(gstAggregator); 224 } 225 }