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.BaseTransform; 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.BufferPool; 34 private import gstreamer.Caps; 35 private import gstreamer.Element; 36 37 38 /** 39 * This base class is for filter elements that process data. Elements 40 * that are suitable for implementation using #GstBaseTransform are ones 41 * where the size and caps of the output is known entirely from the input 42 * caps and buffer sizes. These include elements that directly transform 43 * one buffer into another, modify the contents of a buffer in-place, as 44 * well as elements that collate multiple input buffers into one output buffer, 45 * or that expand one input buffer into multiple output buffers. See below 46 * for more concrete use cases. 47 * 48 * It provides for: 49 * 50 * * one sinkpad and one srcpad 51 * * Possible formats on sink and source pad implemented 52 * with custom transform_caps function. By default uses 53 * same format on sink and source. 54 * 55 * * Handles state changes 56 * * Does flushing 57 * * Push mode 58 * * Pull mode if the sub-class transform can operate on arbitrary data 59 * 60 * # Use Cases 61 * 62 * ## Passthrough mode 63 * 64 * * Element has no interest in modifying the buffer. It may want to inspect it, 65 * in which case the element should have a transform_ip function. If there 66 * is no transform_ip function in passthrough mode, the buffer is pushed 67 * intact. 68 * 69 * * The #GstBaseTransformClass.passthrough_on_same_caps variable 70 * will automatically set/unset passthrough based on whether the 71 * element negotiates the same caps on both pads. 72 * 73 * * #GstBaseTransformClass.passthrough_on_same_caps on an element that 74 * doesn't implement a transform_caps function is useful for elements that 75 * only inspect data (such as level) 76 * 77 * * Example elements 78 * 79 * * Level 80 * * Videoscale, audioconvert, videoconvert, audioresample in certain modes. 81 * 82 * ## Modifications in-place - input buffer and output buffer are the same thing. 83 * 84 * * The element must implement a transform_ip function. 85 * * Output buffer size must <= input buffer size 86 * * If the always_in_place flag is set, non-writable buffers will be copied 87 * and passed to the transform_ip function, otherwise a new buffer will be 88 * created and the transform function called. 89 * 90 * * Incoming writable buffers will be passed to the transform_ip function 91 * immediately. 92 * * only implementing transform_ip and not transform implies always_in_place = %TRUE 93 * 94 * * Example elements: 95 * * Volume 96 * * Audioconvert in certain modes (signed/unsigned conversion) 97 * * videoconvert in certain modes (endianness swapping) 98 * 99 * ## Modifications only to the caps/metadata of a buffer 100 * 101 * * The element does not require writable data, but non-writable buffers 102 * should be subbuffered so that the meta-information can be replaced. 103 * 104 * * Elements wishing to operate in this mode should replace the 105 * prepare_output_buffer method to create subbuffers of the input buffer 106 * and set always_in_place to %TRUE 107 * 108 * * Example elements 109 * * Capsfilter when setting caps on outgoing buffers that have 110 * none. 111 * * identity when it is going to re-timestamp buffers by 112 * datarate. 113 * 114 * ## Normal mode 115 * * always_in_place flag is not set, or there is no transform_ip function 116 * * Element will receive an input buffer and output buffer to operate on. 117 * * Output buffer is allocated by calling the prepare_output_buffer function. 118 * * Example elements: 119 * * Videoscale, videoconvert, audioconvert when doing 120 * scaling/conversions 121 * 122 * ## Special output buffer allocations 123 * * Elements which need to do special allocation of their output buffers 124 * beyond allocating output buffers via the negotiated allocator or 125 * buffer pool should implement the prepare_output_buffer method. 126 * 127 * * Example elements: 128 * * efence 129 * 130 * # Sub-class settable flags on GstBaseTransform 131 * 132 * * passthrough 133 * 134 * * Implies that in the current configuration, the sub-class is not interested in modifying the buffers. 135 * * Elements which are always in passthrough mode whenever the same caps has been negotiated on both pads can set the class variable passthrough_on_same_caps to have this behaviour automatically. 136 * 137 * * always_in_place 138 * * Determines whether a non-writable buffer will be copied before passing 139 * to the transform_ip function. 140 * 141 * * Implied %TRUE if no transform function is implemented. 142 * * Implied %FALSE if ONLY transform function is implemented. 143 */ 144 public class BaseTransform : Element 145 { 146 /** the main Gtk struct */ 147 protected GstBaseTransform* gstBaseTransform; 148 149 /** Get the main Gtk struct */ 150 public GstBaseTransform* getBaseTransformStruct(bool transferOwnership = false) 151 { 152 if (transferOwnership) 153 ownedRef = false; 154 return gstBaseTransform; 155 } 156 157 /** the main Gtk struct as a void* */ 158 protected override void* getStruct() 159 { 160 return cast(void*)gstBaseTransform; 161 } 162 163 protected override void setStruct(GObject* obj) 164 { 165 gstBaseTransform = cast(GstBaseTransform*)obj; 166 super.setStruct(obj); 167 } 168 169 /** 170 * Sets our main struct and passes it to the parent class. 171 */ 172 public this (GstBaseTransform* gstBaseTransform, bool ownedRef = false) 173 { 174 this.gstBaseTransform = gstBaseTransform; 175 super(cast(GstElement*)gstBaseTransform, ownedRef); 176 } 177 178 179 /** */ 180 public static GType getType() 181 { 182 return gst_base_transform_get_type(); 183 } 184 185 /** 186 * Lets #GstBaseTransform sub-classes to know the memory @allocator 187 * used by the base class and its @params. 188 * 189 * Unref the @allocator after use it. 190 * 191 * Params: 192 * allocator = the #GstAllocator 193 * used 194 * params = the 195 * #GstAllocationParams of @allocator 196 */ 197 public void getAllocator(out Allocator allocator, out AllocationParams params) 198 { 199 GstAllocator* outallocator = null; 200 GstAllocationParams* outparams = sliceNew!GstAllocationParams(); 201 202 gst_base_transform_get_allocator(gstBaseTransform, &outallocator, outparams); 203 204 allocator = ObjectG.getDObject!(Allocator)(outallocator); 205 params = ObjectG.getDObject!(AllocationParams)(outparams, true); 206 } 207 208 /** 209 * Returns: the instance of the #GstBufferPool used 210 * by @trans; free it after use it 211 */ 212 public BufferPool getBufferPool() 213 { 214 auto p = gst_base_transform_get_buffer_pool(gstBaseTransform); 215 216 if(p is null) 217 { 218 return null; 219 } 220 221 return ObjectG.getDObject!(BufferPool)(cast(GstBufferPool*) p, true); 222 } 223 224 /** 225 * See if @trans is configured as a in_place transform. 226 * 227 * Returns: %TRUE is the transform is configured in in_place mode. 228 * 229 * MT safe. 230 */ 231 public bool isInPlace() 232 { 233 return gst_base_transform_is_in_place(gstBaseTransform) != 0; 234 } 235 236 /** 237 * See if @trans is configured as a passthrough transform. 238 * 239 * Returns: %TRUE is the transform is configured in passthrough mode. 240 * 241 * MT safe. 242 */ 243 public bool isPassthrough() 244 { 245 return gst_base_transform_is_passthrough(gstBaseTransform) != 0; 246 } 247 248 /** 249 * Queries if the transform will handle QoS. 250 * 251 * Returns: %TRUE if QoS is enabled. 252 * 253 * MT safe. 254 */ 255 public bool isQosEnabled() 256 { 257 return gst_base_transform_is_qos_enabled(gstBaseTransform) != 0; 258 } 259 260 /** 261 * Instructs @trans to request renegotiation upstream. This function is 262 * typically called after properties on the transform were set that 263 * influence the input format. 264 */ 265 public void reconfigureSink() 266 { 267 gst_base_transform_reconfigure_sink(gstBaseTransform); 268 } 269 270 /** 271 * Instructs @trans to renegotiate a new downstream transform on the next 272 * buffer. This function is typically called after properties on the transform 273 * were set that influence the output format. 274 */ 275 public void reconfigureSrc() 276 { 277 gst_base_transform_reconfigure_src(gstBaseTransform); 278 } 279 280 /** 281 * If @gap_aware is %FALSE (the default), output buffers will have the 282 * %GST_BUFFER_FLAG_GAP flag unset. 283 * 284 * If set to %TRUE, the element must handle output buffers with this flag set 285 * correctly, i.e. it can assume that the buffer contains neutral data but must 286 * unset the flag if the output is no neutral data. 287 * 288 * MT safe. 289 * 290 * Params: 291 * gapAware = New state 292 */ 293 public void setGapAware(bool gapAware) 294 { 295 gst_base_transform_set_gap_aware(gstBaseTransform, gapAware); 296 } 297 298 /** 299 * Determines whether a non-writable buffer will be copied before passing 300 * to the transform_ip function. 301 * 302 * * Always %TRUE if no transform function is implemented. 303 * * Always %FALSE if ONLY transform function is implemented. 304 * 305 * MT safe. 306 * 307 * Params: 308 * inPlace = Boolean value indicating that we would like to operate 309 * on in_place buffers. 310 */ 311 public void setInPlace(bool inPlace) 312 { 313 gst_base_transform_set_in_place(gstBaseTransform, inPlace); 314 } 315 316 /** 317 * Set passthrough mode for this filter by default. This is mostly 318 * useful for filters that do not care about negotiation. 319 * 320 * Always %TRUE for filters which don't implement either a transform 321 * or transform_ip method. 322 * 323 * MT safe. 324 * 325 * Params: 326 * passthrough = boolean indicating passthrough mode. 327 */ 328 public void setPassthrough(bool passthrough) 329 { 330 gst_base_transform_set_passthrough(gstBaseTransform, passthrough); 331 } 332 333 /** 334 * If @prefer_passthrough is %TRUE (the default), @trans will check and 335 * prefer passthrough caps from the list of caps returned by the 336 * transform_caps vmethod. 337 * 338 * If set to %FALSE, the element must order the caps returned from the 339 * transform_caps function in such a way that the preferred format is 340 * first in the list. This can be interesting for transforms that can do 341 * passthrough transforms but prefer to do something else, like a 342 * capsfilter. 343 * 344 * MT safe. 345 * 346 * Params: 347 * preferPassthrough = New state 348 * 349 * Since: 1.0.1 350 */ 351 public void setPreferPassthrough(bool preferPassthrough) 352 { 353 gst_base_transform_set_prefer_passthrough(gstBaseTransform, preferPassthrough); 354 } 355 356 /** 357 * Enable or disable QoS handling in the transform. 358 * 359 * MT safe. 360 * 361 * Params: 362 * enabled = new state 363 */ 364 public void setQosEnabled(bool enabled) 365 { 366 gst_base_transform_set_qos_enabled(gstBaseTransform, enabled); 367 } 368 369 /** 370 * Set the QoS parameters in the transform. This function is called internally 371 * when a QOS event is received but subclasses can provide custom information 372 * when needed. 373 * 374 * MT safe. 375 * 376 * Params: 377 * proportion = the proportion 378 * diff = the diff against the clock 379 * timestamp = the timestamp of the buffer generating the QoS expressed in 380 * running_time. 381 */ 382 public void updateQos(double proportion, GstClockTimeDiff diff, GstClockTime timestamp) 383 { 384 gst_base_transform_update_qos(gstBaseTransform, proportion, diff, timestamp); 385 } 386 387 /** 388 * Updates the srcpad caps and send the caps downstream. This function 389 * can be used by subclasses when they have already negotiated their caps 390 * but found a change in them (or computed new informations). This way, 391 * they can notify downstream about that change without loosing any 392 * buffer. 393 * 394 * Params: 395 * updatedCaps = An updated version of the srcpad caps to be pushed 396 * downstream 397 * 398 * Returns: %TRUE if the caps could be send downstream %FALSE otherwise 399 * 400 * Since: 1.6 401 */ 402 public bool updateSrcCaps(Caps updatedCaps) 403 { 404 return gst_base_transform_update_src_caps(gstBaseTransform, (updatedCaps is null) ? null : updatedCaps.getCapsStruct()) != 0; 405 } 406 }