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 * Conversion parameters: 26 * inFile = gstreamer-GstUtils.html 27 * outPack = gstreamer 28 * outFile = Utils 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = Utils 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_util_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gobject.ObjectG 48 * - gobject.Value 49 * structWrap: 50 * - GObject* -> ObjectG 51 * - GValue* -> Value 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gstreamer.Utils; 58 59 public import gstreamerc.gstreamertypes; 60 61 private import gstreamerc.gstreamer; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 66 private import glib.Str; 67 private import gobject.ObjectG; 68 private import gobject.Value; 69 70 71 72 73 /** 74 */ 75 public class Utils 76 { 77 78 /** 79 */ 80 81 /** 82 * Read a 32 bit float value in little endian format from the memory buffer. 83 * Params: 84 * data = memory location 85 * Returns: The floating point value read from data 86 */ 87 public static float GST_READ_FLOAT_LE(ubyte* data) 88 { 89 // gfloat GST_READ_FLOAT_LE (const guint8 *data); 90 return GST_READ_FLOAT_LE(data); 91 } 92 93 /** 94 * Read a 32 bit float value in big endian format from the memory buffer. 95 * Params: 96 * data = memory location 97 * Returns: The floating point value read from data 98 */ 99 public static float GST_READ_FLOAT_BE(ubyte* data) 100 { 101 // gfloat GST_READ_FLOAT_BE (const guint8 *data); 102 return GST_READ_FLOAT_BE(data); 103 } 104 105 /** 106 * Read a 64 bit double value in little endian format from the memory buffer. 107 * Params: 108 * data = memory location 109 * Returns: The double-precision floating point value read from data 110 */ 111 public static double GST_READ_DOUBLE_LE(ubyte* data) 112 { 113 // gdouble GST_READ_DOUBLE_LE (const guint8 *data); 114 return GST_READ_DOUBLE_LE(data); 115 } 116 117 /** 118 * Read a 64 bit double value in big endian format from the memory buffer. 119 * Params: 120 * data = memory location 121 * Returns: The double-precision floating point value read from data 122 */ 123 public static double GST_READ_DOUBLE_BE(ubyte* data) 124 { 125 // gdouble GST_READ_DOUBLE_BE (const guint8 *data); 126 return GST_READ_DOUBLE_BE(data); 127 } 128 129 /** 130 * Store a 32 bit float value in little endian format into the memory buffer. 131 * Params: 132 * data = memory location 133 * num = value to store 134 */ 135 public static void GST_WRITE_FLOAT_LE(ubyte* data, float num) 136 { 137 // void GST_WRITE_FLOAT_LE (guint8 *data, gfloat num); 138 GST_WRITE_FLOAT_LE(data, num); 139 } 140 141 /** 142 * Store a 32 bit float value in big endian format into the memory buffer. 143 * Params: 144 * data = memory location 145 * num = value to store 146 */ 147 public static void GST_WRITE_FLOAT_BE(ubyte* data, float num) 148 { 149 // void GST_WRITE_FLOAT_BE (guint8 *data, gfloat num); 150 GST_WRITE_FLOAT_BE(data, num); 151 } 152 153 /** 154 * Store a 64 bit double value in little endian format into the memory buffer. 155 * Params: 156 * data = memory location 157 * num = value to store 158 */ 159 public static void GST_WRITE_DOUBLE_LE(ubyte* data, double num) 160 { 161 // void GST_WRITE_DOUBLE_LE (guint8 *data, gdouble num); 162 GST_WRITE_DOUBLE_LE(data, num); 163 } 164 165 /** 166 * Store a 64 bit double value in big endian format into the memory buffer. 167 * Params: 168 * data = memory location 169 * num = value to store 170 */ 171 public static void GST_WRITE_DOUBLE_BE(ubyte* data, double num) 172 { 173 // void GST_WRITE_DOUBLE_BE (guint8 *data, gdouble num); 174 GST_WRITE_DOUBLE_BE(data, num); 175 } 176 177 /** 178 * Swap byte order of a 64-bit floating point value (double). 179 * Params: 180 * in = input value 181 * Returns: in byte-swapped. 182 */ 183 public static double GDOUBLE_SWAP_LE_BE(double inn) 184 { 185 // gdouble GDOUBLE_SWAP_LE_BE (gdouble in); 186 return GDOUBLE_SWAP_LE_BE(inn); 187 } 188 189 /** 190 * Swap byte order of a 32-bit floating point value (float). 191 * Params: 192 * in = input value 193 * Returns: in byte-swapped. 194 */ 195 public static float GFLOAT_SWAP_LE_BE(float inn) 196 { 197 // gfloat GFLOAT_SWAP_LE_BE (gfloat in); 198 return GFLOAT_SWAP_LE_BE(inn); 199 } 200 201 /** 202 * Dumps the memory block into a hex representation. Useful for debugging. 203 * Params: 204 * mem = a pointer to the memory to dump 205 * size = the size of the memory block to dump 206 */ 207 public static void dumpMem(char* mem, uint size) 208 { 209 // void gst_util_dump_mem (const guchar *mem, guint size); 210 gst_util_dump_mem(mem, size); 211 } 212 213 /** 214 * Scale val by the rational number num / denom, avoiding overflows and 215 * underflows and without loss of precision. 216 * This function can potentially be very slow if val and num are both 217 * greater than G_MAXUINT32. 218 * Params: 219 * val = the number to scale 220 * num = the numerator of the scale ratio 221 * denom = the denominator of the scale ratio 222 * Returns: val * num / denom. In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer it is truncated. See also gst_util_uint64_scale_round(), gst_util_uint64_scale_ceil(), gst_util_uint64_scale_int(), gst_util_uint64_scale_int_round(), gst_util_uint64_scale_int_ceil(). 223 */ 224 public static ulong uint64_Scale(ulong val, ulong num, ulong denom) 225 { 226 // guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom); 227 return gst_util_uint64_scale(val, num, denom); 228 } 229 230 /** 231 * Scale val by the rational number num / denom, avoiding overflows and 232 * underflows and without loss of precision. 233 * This function can potentially be very slow if val and num are both 234 * greater than G_MAXUINT32. 235 * Params: 236 * val = the number to scale 237 * num = the numerator of the scale ratio 238 * denom = the denominator of the scale ratio 239 * Returns: val * num / denom. In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded to the nearest integer (half-way cases are rounded up). See also gst_util_uint64_scale(), gst_util_uint64_scale_ceil(), gst_util_uint64_scale_int(), gst_util_uint64_scale_int_round(), gst_util_uint64_scale_int_ceil(). 240 */ 241 public static ulong uint64_ScaleRound(ulong val, ulong num, ulong denom) 242 { 243 // guint64 gst_util_uint64_scale_round (guint64 val, guint64 num, guint64 denom); 244 return gst_util_uint64_scale_round(val, num, denom); 245 } 246 247 /** 248 * Scale val by the rational number num / denom, avoiding overflows and 249 * underflows and without loss of precision. 250 * This function can potentially be very slow if val and num are both 251 * greater than G_MAXUINT32. 252 * Params: 253 * val = the number to scale 254 * num = the numerator of the scale ratio 255 * denom = the denominator of the scale ratio 256 * Returns: val * num / denom. In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded up. See also gst_util_uint64_scale(), gst_util_uint64_scale_round(), gst_util_uint64_scale_int(), gst_util_uint64_scale_int_round(), gst_util_uint64_scale_int_ceil(). 257 */ 258 public static ulong uint64_ScaleCeil(ulong val, ulong num, ulong denom) 259 { 260 // guint64 gst_util_uint64_scale_ceil (guint64 val, guint64 num, guint64 denom); 261 return gst_util_uint64_scale_ceil(val, num, denom); 262 } 263 264 /** 265 * Scale val by the rational number num / denom, avoiding overflows and 266 * underflows and without loss of precision. num must be non-negative and 267 * denom must be positive. 268 * Params: 269 * val = guint64 (such as a GstClockTime) to scale. 270 * num = numerator of the scale factor. 271 * denom = denominator of the scale factor. 272 * Returns: val * num / denom. In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is truncated. See also gst_util_uint64_scale_int_round(), gst_util_uint64_scale_int_ceil(), gst_util_uint64_scale(), gst_util_uint64_scale_round(), gst_util_uint64_scale_ceil(). 273 */ 274 public static ulong uint64_ScaleInt(ulong val, int num, int denom) 275 { 276 // guint64 gst_util_uint64_scale_int (guint64 val, gint num, gint denom); 277 return gst_util_uint64_scale_int(val, num, denom); 278 } 279 280 /** 281 * Scale val by the rational number num / denom, avoiding overflows and 282 * underflows and without loss of precision. num must be non-negative and 283 * denom must be positive. 284 * Params: 285 * val = guint64 (such as a GstClockTime) to scale. 286 * num = numerator of the scale factor. 287 * denom = denominator of the scale factor. 288 * Returns: val * num / denom. In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded to the nearest integer (half-way cases are rounded up). See also gst_util_uint64_scale_int(), gst_util_uint64_scale_int_ceil(), gst_util_uint64_scale(), gst_util_uint64_scale_round(), gst_util_uint64_scale_ceil(). 289 */ 290 public static ulong uint64_ScaleIntRound(ulong val, int num, int denom) 291 { 292 // guint64 gst_util_uint64_scale_int_round (guint64 val, gint num, gint denom); 293 return gst_util_uint64_scale_int_round(val, num, denom); 294 } 295 296 /** 297 * Scale val by the rational number num / denom, avoiding overflows and 298 * underflows and without loss of precision. num must be non-negative and 299 * denom must be positive. 300 * Params: 301 * val = guint64 (such as a GstClockTime) to scale. 302 * num = numerator of the scale factor. 303 * denom = denominator of the scale factor. 304 * Returns: val * num / denom. In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded up. See also gst_util_uint64_scale_int(), gst_util_uint64_scale_int_round(), gst_util_uint64_scale(), gst_util_uint64_scale_round(), gst_util_uint64_scale_ceil(). 305 */ 306 public static ulong uint64_ScaleIntCeil(ulong val, int num, int denom) 307 { 308 // guint64 gst_util_uint64_scale_int_ceil (guint64 val, gint num, gint denom); 309 return gst_util_uint64_scale_int_ceil(val, num, denom); 310 } 311 312 /** 313 * Calculates the greatest common divisor of a 314 * and b. 315 * Params: 316 * a = First value as gint 317 * b = Second value as gint 318 * Returns: Greatest common divisor of a and b 319 */ 320 public static int greatestCommonDivisor(int a, int b) 321 { 322 // gint gst_util_greatest_common_divisor (gint a, gint b); 323 return gst_util_greatest_common_divisor(a, b); 324 } 325 326 /** 327 * Calculates the greatest common divisor of a 328 * and b. 329 * Params: 330 * a = First value as gint64 331 * b = Second value as gint64 332 * Returns: Greatest common divisor of a and b 333 */ 334 public static long greatestCommonDivisorInt64(long a, long b) 335 { 336 // gint64 gst_util_greatest_common_divisor_int64 (gint64 a, gint64 b); 337 return gst_util_greatest_common_divisor_int64(a, b); 338 } 339 340 /** 341 * Transforms a fraction to a gdouble. 342 * Params: 343 * srcN = Fraction numerator as gint 344 * srcD = Fraction denominator gint 345 * dest = pointer to a gdouble for the result. [out] 346 */ 347 public static void fractionToDouble(int srcN, int srcD, out double dest) 348 { 349 // void gst_util_fraction_to_double (gint src_n, gint src_d, gdouble *dest); 350 gst_util_fraction_to_double(srcN, srcD, &dest); 351 } 352 353 /** 354 * Transforms a gdouble to a fraction and simplifies 355 * the result. 356 * Params: 357 * src = gdouble to transform 358 * destN = pointer to a gint to hold the result numerator. [out] 359 * destD = pointer to a gint to hold the result denominator. [out] 360 */ 361 public static void doubleToFraction(double src, out int destN, out int destD) 362 { 363 // void gst_util_double_to_fraction (gdouble src, gint *dest_n, gint *dest_d); 364 gst_util_double_to_fraction(src, &destN, &destD); 365 } 366 367 /** 368 * Multiplies the fractions a_n/a_d and b_n/b_d and stores 369 * the result in res_n and res_d. 370 * Params: 371 * aN = Numerator of first value 372 * aD = Denominator of first value 373 * bN = Numerator of second value 374 * bD = Denominator of second value 375 * resN = Pointer to gint to hold the result numerator. [out] 376 * resD = Pointer to gint to hold the result denominator. [out] 377 * Returns: FALSE on overflow, TRUE otherwise. 378 */ 379 public static int fractionMultiply(int aN, int aD, int bN, int bD, out int resN, out int resD) 380 { 381 // gboolean gst_util_fraction_multiply (gint a_n, gint a_d, gint b_n, gint b_d, gint *res_n, gint *res_d); 382 return gst_util_fraction_multiply(aN, aD, bN, bD, &resN, &resD); 383 } 384 385 /** 386 * Adds the fractions a_n/a_d and b_n/b_d and stores 387 * the result in res_n and res_d. 388 * Params: 389 * aN = Numerator of first value 390 * aD = Denominator of first value 391 * bN = Numerator of second value 392 * bD = Denominator of second value 393 * resN = Pointer to gint to hold the result numerator. [out] 394 * resD = Pointer to gint to hold the result denominator. [out] 395 * Returns: FALSE on overflow, TRUE otherwise. 396 */ 397 public static int fractionAdd(int aN, int aD, int bN, int bD, out int resN, out int resD) 398 { 399 // gboolean gst_util_fraction_add (gint a_n, gint a_d, gint b_n, gint b_d, gint *res_n, gint *res_d); 400 return gst_util_fraction_add(aN, aD, bN, bD, &resN, &resD); 401 } 402 403 /** 404 * Compares the fractions a_n/a_d and b_n/b_d and returns 405 * -1 if a < b, 0 if a = b and 1 if a > b. 406 * Params: 407 * aN = Numerator of first value 408 * aD = Denominator of first value 409 * bN = Numerator of second value 410 * bD = Denominator of second value 411 * Returns: -1 if a < b; 0 if a = b; 1 if a > b. 412 */ 413 public static int fractionCompare(int aN, int aD, int bN, int bD) 414 { 415 // gint gst_util_fraction_compare (gint a_n, gint a_d, gint b_n, gint b_d); 416 return gst_util_fraction_compare(aN, aD, bN, bD); 417 } 418 419 /** 420 * Return a constantly incrementing sequence number. 421 * This function is used internally to GStreamer to be able to determine which 422 * events and messages are "the same". For example, elements may set the seqnum 423 * on a segment-done message to be the same as that of the last seek event, to 424 * indicate that event and the message correspond to the same segment. 425 * Returns: A constantly incrementing 32-bit unsigned integer, which might overflow back to 0 at some point. Use gst_util_seqnum_compare() to make sure you handle wraparound correctly. 426 */ 427 public static uint seqnumNext() 428 { 429 // guint32 gst_util_seqnum_next (void); 430 return gst_util_seqnum_next(); 431 } 432 433 /** 434 * Compare two sequence numbers, handling wraparound. 435 * The current implementation just returns (gint32)(s1 - s2). 436 * Params: 437 * s1 = A sequence number. 438 * s2 = Another sequence number. 439 * Returns: A negative number if s1 is before s2, 0 if they are equal, or a positive number if s1 is after s2. 440 */ 441 public static int seqnumCompare(uint s1, uint s2) 442 { 443 // gint32 gst_util_seqnum_compare (guint32 s1, guint32 s2); 444 return gst_util_seqnum_compare(s1, s2); 445 } 446 447 /** 448 * Return a constantly incrementing group id. 449 * This function is used to generate a new group-id for the 450 * stream-start event. 451 * Returns: A constantly incrementing unsigned integer, which might overflow back to 0 at some point. 452 */ 453 public static uint groupIdNext() 454 { 455 // guint gst_util_group_id_next (void); 456 return gst_util_group_id_next(); 457 } 458 459 /** 460 * Convertes the string value to the type of the objects argument and 461 * sets the argument with it. 462 * Note that this function silently returns if object has no property named 463 * name or when value cannot be converted to the type of the property. 464 * Params: 465 * object = the object to set the argument of 466 * name = the name of the argument to set 467 * value = the string value to set 468 */ 469 public static void setObjectArg(ObjectG object, string name, string value) 470 { 471 // void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value); 472 gst_util_set_object_arg((object is null) ? null : object.getObjectGStruct(), Str.toStringz(name), Str.toStringz(value)); 473 } 474 475 /** 476 * Converts the string to the type of the value and 477 * sets the value with it. 478 * Note that this function is dangerous as it does not return any indication 479 * if the conversion worked or not. 480 * Params: 481 * value = the value to set. [out caller-allocates] 482 * valueStr = the string to get the value from 483 */ 484 public static void setValueFromString(Value value, string valueStr) 485 { 486 // void gst_util_set_value_from_string (GValue *value, const gchar *value_str); 487 gst_util_set_value_from_string((value is null) ? null : value.getValueStruct(), Str.toStringz(valueStr)); 488 } 489 490 /** 491 * Get a timestamp as GstClockTime to be used for interval measurements. 492 * The timestamp should not be interpreted in any other way. 493 * Returns: the timestamp 494 */ 495 public static GstClockTime getTimestamp() 496 { 497 // GstClockTime gst_util_get_timestamp (void); 498 return gst_util_get_timestamp(); 499 } 500 501 /** 502 * Searches inside array for search_data by using the comparison function 503 * search_func. array must be sorted ascending. 504 * As search_data is always passed as second argument to search_func it's 505 * not required that search_data has the same type as the array elements. 506 * The complexity of this search function is O(log (num_elements)). 507 * Params: 508 * array = the sorted input array 509 * numElements = number of elements in the array 510 * elementSize = size of every element in bytes 511 * searchFunc = function to compare two elements, search_data will always be passed as second argument. [scope call] 512 * mode = search mode that should be used 513 * searchData = element that should be found 514 * userData = data to pass to search_func. [closure] 515 * Returns: The address of the found element or NULL if nothing was found. [transfer none] 516 */ 517 public static void* arrayBinarySearch(void* array, uint numElements, gsize elementSize, GCompareDataFunc searchFunc, GstSearchMode mode, void* searchData, void* userData) 518 { 519 // gpointer gst_util_array_binary_search (gpointer array, guint num_elements, gsize element_size, GCompareDataFunc search_func, GstSearchMode mode, gconstpointer search_data, gpointer user_data); 520 return gst_util_array_binary_search(array, numElements, elementSize, searchFunc, mode, searchData, userData); 521 } 522 }