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