~ubuntu-branches/ubuntu/precise/gst-plugins-base0.10/precise-updates

« back to all changes in this revision

Viewing changes to gst-libs/gst/audio/audio.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2011-12-12 12:40:13 UTC
  • mfrom: (36.1.15 experimental)
  • Revision ID: package-import@ubuntu.com-20111212124013-onyadfb150d8c5dk
Tags: 0.10.35.2-2
* debian/libgstreamer-plugins-base.install:
  + Add license translations file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include <gst/gststructure.h>
34
34
 
 
35
#include <string.h>
 
36
 
35
37
/**
36
38
 * gst_audio_frame_byte_size:
37
39
 * @pad: the #GstPad to get the caps from
268
270
}
269
271
#endif /* GST_REMOVE_DEPRECATED */
270
272
 
 
273
#define SINT (GST_AUDIO_FORMAT_FLAG_INTEGER | GST_AUDIO_FORMAT_FLAG_SIGNED)
 
274
#define UINT (GST_AUDIO_FORMAT_FLAG_INTEGER)
 
275
 
 
276
#define MAKE_FORMAT(str,flags,end,width,depth,silent) \
 
277
  { GST_AUDIO_FORMAT_ ##str, G_STRINGIFY(str), flags, end, width, depth, silent }
 
278
 
 
279
#define SILENT_0         { 0, 0, 0, 0, 0, 0, 0, 0 }
 
280
#define SILENT_U8        { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }
 
281
#define SILENT_U16LE     { 0x00, 0x80,  0x00, 0x80,  0x00, 0x80,  0x00, 0x80 }
 
282
#define SILENT_U16BE     { 0x80, 0x00,  0x80, 0x00,  0x80, 0x00,  0x80, 0x00 }
 
283
#define SILENT_U24_32LE  { 0x00, 0x00, 0x80, 0x00,  0x00, 0x00, 0x80, 0x00 }
 
284
#define SILENT_U24_32BE  { 0x00, 0x80, 0x00, 0x00,  0x00, 0x80, 0x00, 0x00 }
 
285
#define SILENT_U32LE     { 0x00, 0x00, 0x00, 0x80,  0x00, 0x00, 0x00, 0x80 }
 
286
#define SILENT_U32BE     { 0x80, 0x00, 0x00, 0x00,  0x80, 0x00, 0x00, 0x00 }
 
287
#define SILENT_U24LE     { 0x00, 0x00, 0x80,  0x00, 0x00, 0x80 }
 
288
#define SILENT_U24BE     { 0x80, 0x00, 0x00,  0x80, 0x00, 0x00 }
 
289
#define SILENT_U20LE     { 0x00, 0x00, 0x08,  0x00, 0x00, 0x08 }
 
290
#define SILENT_U20BE     { 0x08, 0x00, 0x00,  0x08, 0x00, 0x00 }
 
291
#define SILENT_U18LE     { 0x00, 0x00, 0x02,  0x00, 0x00, 0x02 }
 
292
#define SILENT_U18BE     { 0x02, 0x00, 0x00,  0x02, 0x00, 0x00 }
 
293
 
 
294
static GstAudioFormatInfo formats[] = {
 
295
  {GST_AUDIO_FORMAT_UNKNOWN, "UNKNOWN", 0, 0, 0, 0},
 
296
  /* 8 bit */
 
297
  MAKE_FORMAT (S8, SINT, 0, 8, 8, SILENT_0),
 
298
  MAKE_FORMAT (U8, UINT, 0, 8, 8, SILENT_U8),
 
299
  /* 16 bit */
 
300
  MAKE_FORMAT (S16LE, SINT, G_LITTLE_ENDIAN, 16, 16, SILENT_0),
 
301
  MAKE_FORMAT (S16BE, SINT, G_BIG_ENDIAN, 16, 16, SILENT_0),
 
302
  MAKE_FORMAT (U16LE, UINT, G_LITTLE_ENDIAN, 16, 16, SILENT_U16LE),
 
303
  MAKE_FORMAT (U16BE, UINT, G_BIG_ENDIAN, 16, 16, SILENT_U16BE),
 
304
  /* 24 bit in low 3 bytes of 32 bits */
 
305
  MAKE_FORMAT (S24_32LE, SINT, G_LITTLE_ENDIAN, 32, 24, SILENT_0),
 
306
  MAKE_FORMAT (S24_32BE, SINT, G_BIG_ENDIAN, 32, 24, SILENT_0),
 
307
  MAKE_FORMAT (U24_32LE, UINT, G_LITTLE_ENDIAN, 32, 24, SILENT_U24_32LE),
 
308
  MAKE_FORMAT (U24_32BE, UINT, G_BIG_ENDIAN, 32, 24, SILENT_U24_32BE),
 
309
  /* 32 bit */
 
310
  MAKE_FORMAT (S32LE, SINT, G_LITTLE_ENDIAN, 32, 32, SILENT_0),
 
311
  MAKE_FORMAT (S32BE, SINT, G_BIG_ENDIAN, 32, 32, SILENT_0),
 
312
  MAKE_FORMAT (U32LE, UINT, G_LITTLE_ENDIAN, 32, 32, SILENT_U32LE),
 
313
  MAKE_FORMAT (U32BE, UINT, G_BIG_ENDIAN, 32, 32, SILENT_U32BE),
 
314
  /* 24 bit in 3 bytes */
 
315
  MAKE_FORMAT (S24LE, SINT, G_LITTLE_ENDIAN, 24, 24, SILENT_0),
 
316
  MAKE_FORMAT (S24BE, SINT, G_BIG_ENDIAN, 24, 24, SILENT_0),
 
317
  MAKE_FORMAT (U24LE, UINT, G_LITTLE_ENDIAN, 24, 24, SILENT_U24LE),
 
318
  MAKE_FORMAT (U24BE, UINT, G_BIG_ENDIAN, 24, 24, SILENT_U24BE),
 
319
  /* 20 bit in 3 bytes */
 
320
  MAKE_FORMAT (S20LE, SINT, G_LITTLE_ENDIAN, 24, 20, SILENT_0),
 
321
  MAKE_FORMAT (S20BE, SINT, G_BIG_ENDIAN, 24, 20, SILENT_0),
 
322
  MAKE_FORMAT (U20LE, UINT, G_LITTLE_ENDIAN, 24, 20, SILENT_U20LE),
 
323
  MAKE_FORMAT (U20BE, UINT, G_BIG_ENDIAN, 24, 20, SILENT_U20BE),
 
324
  /* 18 bit in 3 bytes */
 
325
  MAKE_FORMAT (S18LE, SINT, G_LITTLE_ENDIAN, 24, 18, SILENT_0),
 
326
  MAKE_FORMAT (S18BE, SINT, G_BIG_ENDIAN, 24, 18, SILENT_0),
 
327
  MAKE_FORMAT (U18LE, UINT, G_LITTLE_ENDIAN, 24, 18, SILENT_U18LE),
 
328
  MAKE_FORMAT (U18BE, UINT, G_BIG_ENDIAN, 24, 18, SILENT_U18BE),
 
329
  /* float */
 
330
  MAKE_FORMAT (F32LE, GST_AUDIO_FORMAT_FLAG_FLOAT, G_LITTLE_ENDIAN, 32, 32,
 
331
      SILENT_0),
 
332
  MAKE_FORMAT (F32BE, GST_AUDIO_FORMAT_FLAG_FLOAT, G_BIG_ENDIAN, 32, 32,
 
333
      SILENT_0),
 
334
  MAKE_FORMAT (F64LE, GST_AUDIO_FORMAT_FLAG_FLOAT, G_LITTLE_ENDIAN, 64, 64,
 
335
      SILENT_0),
 
336
  MAKE_FORMAT (F64BE, GST_AUDIO_FORMAT_FLAG_FLOAT, G_BIG_ENDIAN, 64, 64,
 
337
      SILENT_0)
 
338
};
 
339
 
 
340
static GstAudioFormat
 
341
gst_audio_format_from_caps_structure (const GstStructure * s)
 
342
{
 
343
  gint endianness, width, depth;
 
344
  guint i;
 
345
 
 
346
  if (gst_structure_has_name (s, "audio/x-raw-int")) {
 
347
    gboolean sign;
 
348
 
 
349
    if (!gst_structure_get_boolean (s, "signed", &sign))
 
350
      goto missing_field_signed;
 
351
 
 
352
    if (!gst_structure_get_int (s, "endianness", &endianness))
 
353
      goto missing_field_endianness;
 
354
 
 
355
    if (!gst_structure_get_int (s, "width", &width))
 
356
      goto missing_field_width;
 
357
 
 
358
    if (!gst_structure_get_int (s, "depth", &depth))
 
359
      goto missing_field_depth;
 
360
 
 
361
    for (i = 0; i < G_N_ELEMENTS (formats); i++) {
 
362
      if (GST_AUDIO_FORMAT_INFO_IS_INTEGER (&formats[i]) &&
 
363
          sign == GST_AUDIO_FORMAT_INFO_IS_SIGNED (&formats[i]) &&
 
364
          GST_AUDIO_FORMAT_INFO_ENDIANNESS (&formats[i]) == endianness &&
 
365
          GST_AUDIO_FORMAT_INFO_WIDTH (&formats[i]) == width &&
 
366
          GST_AUDIO_FORMAT_INFO_DEPTH (&formats[i]) == depth) {
 
367
        return GST_AUDIO_FORMAT_INFO_FORMAT (&formats[i]);
 
368
      }
 
369
    }
 
370
  } else if (gst_structure_has_name (s, "audio/x-raw-float")) {
 
371
    /* fallbacks are for backwards compatibility (is this needed at all?) */
 
372
    if (!gst_structure_get_int (s, "endianness", &endianness)) {
 
373
      GST_WARNING ("float audio caps without endianness %" GST_PTR_FORMAT, s);
 
374
      endianness = G_BYTE_ORDER;
 
375
    }
 
376
 
 
377
    if (!gst_structure_get_int (s, "width", &width)) {
 
378
      GST_WARNING ("float audio caps without width %" GST_PTR_FORMAT, s);
 
379
      width = 32;
 
380
    }
 
381
 
 
382
    for (i = 0; i < G_N_ELEMENTS (formats); i++) {
 
383
      if (GST_AUDIO_FORMAT_INFO_IS_FLOAT (&formats[i]) &&
 
384
          GST_AUDIO_FORMAT_INFO_ENDIANNESS (&formats[i]) == endianness &&
 
385
          GST_AUDIO_FORMAT_INFO_WIDTH (&formats[i]) == width) {
 
386
        return GST_AUDIO_FORMAT_INFO_FORMAT (&formats[i]);
 
387
      }
 
388
    }
 
389
  }
 
390
 
 
391
  /* no match */
 
392
  return GST_AUDIO_FORMAT_UNKNOWN;
 
393
 
 
394
missing_field_signed:
 
395
  {
 
396
    GST_ERROR ("missing 'signed' field in audio caps %" GST_PTR_FORMAT, s);
 
397
    return GST_AUDIO_FORMAT_UNKNOWN;
 
398
  }
 
399
missing_field_endianness:
 
400
  {
 
401
    GST_ERROR ("missing 'endianness' field in audio caps %" GST_PTR_FORMAT, s);
 
402
    return GST_AUDIO_FORMAT_UNKNOWN;
 
403
  }
 
404
missing_field_depth:
 
405
  {
 
406
    GST_ERROR ("missing 'depth' field in audio caps %" GST_PTR_FORMAT, s);
 
407
    return GST_AUDIO_FORMAT_UNKNOWN;
 
408
  }
 
409
missing_field_width:
 
410
  {
 
411
    GST_ERROR ("missing 'width' field in audio caps %" GST_PTR_FORMAT, s);
 
412
    return GST_AUDIO_FORMAT_UNKNOWN;
 
413
  }
 
414
}
 
415
 
 
416
/* FIXME: remove these if we don't actually go for deep alloc positions */
 
417
void
 
418
gst_audio_info_init (GstAudioInfo * info)
 
419
{
 
420
  memset (info, 0, sizeof (GstAudioInfo));
 
421
}
 
422
 
 
423
void
 
424
gst_audio_info_clear (GstAudioInfo * info)
 
425
{
 
426
  memset (info, 0, sizeof (GstAudioInfo));
 
427
}
 
428
 
 
429
GstAudioInfo *
 
430
gst_audio_info_copy (GstAudioInfo * info)
 
431
{
 
432
  return (GstAudioInfo *) g_slice_copy (sizeof (GstAudioInfo), info);
 
433
}
 
434
 
 
435
void
 
436
gst_audio_info_free (GstAudioInfo * info)
 
437
{
 
438
  g_slice_free (GstAudioInfo, info);
 
439
}
 
440
 
 
441
static void
 
442
gst_audio_info_set_format (GstAudioInfo * info, GstAudioFormat format,
 
443
    gint rate, gint channels)
 
444
{
 
445
  const GstAudioFormatInfo *finfo;
 
446
 
 
447
  g_return_if_fail (info != NULL);
 
448
  g_return_if_fail (format != GST_AUDIO_FORMAT_UNKNOWN);
 
449
 
 
450
  finfo = &formats[format];
 
451
 
 
452
  info->flags = 0;
 
453
  info->finfo = finfo;
 
454
  info->rate = rate;
 
455
  info->channels = channels;
 
456
  info->bpf = (finfo->width * channels) / 8;
 
457
}
 
458
 
 
459
/* from multichannel.c */
 
460
void priv_gst_audio_info_fill_default_channel_positions (GstAudioInfo * info);
 
461
 
 
462
/**
 
463
 * gst_audio_info_from_caps:
 
464
 * @info: a #GstAudioInfo
 
465
 * @caps: a #GstCaps
 
466
 *
 
467
 * Parse @caps and update @info.
 
468
 *
 
469
 * Returns: TRUE if @caps could be parsed
 
470
 *
 
471
 * Since: 0.10.36
 
472
 */
 
473
gboolean
 
474
gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
 
475
{
 
476
  GstStructure *str;
 
477
  GstAudioFormat format;
 
478
  gint rate, channels;
 
479
  const GValue *pos_val_arr, *pos_val_entry;
 
480
  gint i;
 
481
 
 
482
  g_return_val_if_fail (info != NULL, FALSE);
 
483
  g_return_val_if_fail (caps != NULL, FALSE);
 
484
  g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
 
485
 
 
486
  GST_DEBUG ("parsing caps %" GST_PTR_FORMAT, caps);
 
487
 
 
488
  str = gst_caps_get_structure (caps, 0);
 
489
 
 
490
  format = gst_audio_format_from_caps_structure (str);
 
491
  if (format == GST_AUDIO_FORMAT_UNKNOWN)
 
492
    goto unknown_format;
 
493
 
 
494
  if (!gst_structure_get_int (str, "rate", &rate))
 
495
    goto no_rate;
 
496
  if (!gst_structure_get_int (str, "channels", &channels))
 
497
    goto no_channels;
 
498
 
 
499
  gst_audio_info_set_format (info, format, rate, channels);
 
500
 
 
501
  pos_val_arr = gst_structure_get_value (str, "channel-positions");
 
502
  if (pos_val_arr) {
 
503
    if (channels <= G_N_ELEMENTS (info->position)) {
 
504
      for (i = 0; i < channels; i++) {
 
505
        pos_val_entry = gst_value_array_get_value (pos_val_arr, i);
 
506
        info->position[i] = g_value_get_enum (pos_val_entry);
 
507
      }
 
508
    } else {
 
509
      /* for that many channels, the positions are always NONE */
 
510
      for (i = 0; i < G_N_ELEMENTS (info->position); i++)
 
511
        info->position[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
 
512
      info->flags |= GST_AUDIO_FLAG_DEFAULT_POSITIONS;
 
513
    }
 
514
  } else {
 
515
    info->flags |= GST_AUDIO_FLAG_DEFAULT_POSITIONS;
 
516
    priv_gst_audio_info_fill_default_channel_positions (info);
 
517
  }
 
518
 
 
519
  return TRUE;
 
520
 
 
521
  /* ERROR */
 
522
unknown_format:
 
523
  {
 
524
    GST_ERROR ("unknown format given");
 
525
    return FALSE;
 
526
  }
 
527
no_rate:
 
528
  {
 
529
    GST_ERROR ("no rate property given");
 
530
    return FALSE;
 
531
  }
 
532
no_channels:
 
533
  {
 
534
    GST_ERROR ("no channels property given");
 
535
    return FALSE;
 
536
  }
 
537
}
 
538
 
 
539
/**
 
540
 * gst_audio_info_to_caps:
 
541
 * @info: a #GstAudioInfo
 
542
 *
 
543
 * Convert the values of @info into a #GstCaps.
 
544
 *
 
545
 * Returns: (transfer full): the new #GstCaps containing the
 
546
 *          info of @info.
 
547
 *
 
548
 * Since: 0.10.36
 
549
 */
 
550
GstCaps *
 
551
gst_audio_info_to_caps (GstAudioInfo * info)
 
552
{
 
553
  GstCaps *caps;
 
554
 
 
555
  g_return_val_if_fail (info != NULL, NULL);
 
556
  g_return_val_if_fail (info->finfo != NULL, NULL);
 
557
  g_return_val_if_fail (info->finfo->format != GST_AUDIO_FORMAT_UNKNOWN, NULL);
 
558
 
 
559
  if (GST_AUDIO_FORMAT_INFO_IS_INTEGER (info->finfo)) {
 
560
    caps = gst_caps_new_simple ("audio/x-raw-int",
 
561
        "width", G_TYPE_INT, GST_AUDIO_INFO_WIDTH (info),
 
562
        "depth", G_TYPE_INT, GST_AUDIO_INFO_DEPTH (info),
 
563
        "endianness", G_TYPE_INT,
 
564
        GST_AUDIO_FORMAT_INFO_ENDIANNESS (info->finfo), "signed",
 
565
        G_TYPE_BOOLEAN, GST_AUDIO_FORMAT_INFO_IS_SIGNED (info->finfo), "rate",
 
566
        G_TYPE_INT, GST_AUDIO_INFO_RATE (info), "channels", G_TYPE_INT,
 
567
        GST_AUDIO_INFO_CHANNELS (info), NULL);
 
568
  } else if (GST_AUDIO_FORMAT_INFO_IS_FLOAT (info->finfo)) {
 
569
    caps = gst_caps_new_simple ("audio/x-raw-float",
 
570
        "width", G_TYPE_INT, GST_AUDIO_INFO_WIDTH (info),
 
571
        "endianness", G_TYPE_INT,
 
572
        GST_AUDIO_FORMAT_INFO_ENDIANNESS (info->finfo), "rate", G_TYPE_INT,
 
573
        GST_AUDIO_INFO_RATE (info), "channels", G_TYPE_INT,
 
574
        GST_AUDIO_INFO_CHANNELS (info), NULL);
 
575
  } else {
 
576
    GST_ERROR ("unknown audio format, neither integer nor float");
 
577
    return NULL;
 
578
  }
 
579
 
 
580
  if (info->channels > 2) {
 
581
    GValue pos_val_arr = { 0 }
 
582
    , pos_val_entry = {
 
583
    0};
 
584
    GstStructure *str;
 
585
    gint i;
 
586
 
 
587
    /* build gvaluearray from positions */
 
588
    g_value_init (&pos_val_arr, GST_TYPE_ARRAY);
 
589
    g_value_init (&pos_val_entry, GST_TYPE_AUDIO_CHANNEL_POSITION);
 
590
    for (i = 0; i < info->channels; i++) {
 
591
      /* if we have many many channels, all positions are NONE */
 
592
      if (info->channels <= 64)
 
593
        g_value_set_enum (&pos_val_entry, info->position[i]);
 
594
      else
 
595
        g_value_set_enum (&pos_val_entry, GST_AUDIO_CHANNEL_POSITION_NONE);
 
596
 
 
597
      gst_value_array_append_value (&pos_val_arr, &pos_val_entry);
 
598
    }
 
599
    g_value_unset (&pos_val_entry);
 
600
 
 
601
    /* add to structure */
 
602
    str = gst_caps_get_structure (caps, 0);
 
603
    gst_structure_set_value (str, "channel-positions", &pos_val_arr);
 
604
    g_value_unset (&pos_val_arr);
 
605
  }
 
606
 
 
607
  return caps;
 
608
}
 
609
 
 
610
/**
 
611
 * gst_audio_format_convert:
 
612
 * @info: a #GstAudioInfo
 
613
 * @src_format: #GstFormat of the @src_value
 
614
 * @src_value: value to convert
 
615
 * @dest_format: #GstFormat of the @dest_value
 
616
 * @dest_value: pointer to destination value
 
617
 *
 
618
 * Converts among various #GstFormat types.  This function handles
 
619
 * GST_FORMAT_BYTES, GST_FORMAT_TIME, and GST_FORMAT_DEFAULT.  For
 
620
 * raw audio, GST_FORMAT_DEFAULT corresponds to audio frames.  This
 
621
 * function can be used to handle pad queries of the type GST_QUERY_CONVERT.
 
622
 *
 
623
 * Returns: TRUE if the conversion was successful.
 
624
 *
 
625
 * Since: 0.10.36
 
626
 */
 
627
gboolean
 
628
gst_audio_info_convert (GstAudioInfo * info,
 
629
    GstFormat src_fmt, gint64 src_val, GstFormat dest_fmt, gint64 * dest_val)
 
630
{
 
631
  gboolean res = TRUE;
 
632
  gint bpf, rate;
 
633
 
 
634
  GST_DEBUG ("converting value %" G_GINT64_FORMAT " from %s (%d) to %s (%d)",
 
635
      src_val, gst_format_get_name (src_fmt), src_fmt,
 
636
      gst_format_get_name (dest_fmt), dest_fmt);
 
637
 
 
638
  if (src_fmt == dest_fmt || src_val == -1) {
 
639
    *dest_val = src_val;
 
640
    goto done;
 
641
  }
 
642
 
 
643
  /* get important info */
 
644
  bpf = GST_AUDIO_INFO_BPF (info);
 
645
  rate = GST_AUDIO_INFO_RATE (info);
 
646
 
 
647
  if (bpf == 0 || rate == 0) {
 
648
    GST_DEBUG ("no rate or bpf configured");
 
649
    res = FALSE;
 
650
    goto done;
 
651
  }
 
652
 
 
653
  switch (src_fmt) {
 
654
    case GST_FORMAT_BYTES:
 
655
      switch (dest_fmt) {
 
656
        case GST_FORMAT_TIME:
 
657
          *dest_val = GST_FRAMES_TO_CLOCK_TIME (src_val / bpf, rate);
 
658
          break;
 
659
        case GST_FORMAT_DEFAULT:
 
660
          *dest_val = src_val / bpf;
 
661
          break;
 
662
        default:
 
663
          res = FALSE;
 
664
          break;
 
665
      }
 
666
      break;
 
667
    case GST_FORMAT_DEFAULT:
 
668
      switch (dest_fmt) {
 
669
        case GST_FORMAT_TIME:
 
670
          *dest_val = GST_FRAMES_TO_CLOCK_TIME (src_val, rate);
 
671
          break;
 
672
        case GST_FORMAT_BYTES:
 
673
          *dest_val = src_val * bpf;
 
674
          break;
 
675
        default:
 
676
          res = FALSE;
 
677
          break;
 
678
      }
 
679
      break;
 
680
    case GST_FORMAT_TIME:
 
681
      switch (dest_fmt) {
 
682
        case GST_FORMAT_DEFAULT:
 
683
          *dest_val = GST_CLOCK_TIME_TO_FRAMES (src_val, rate);
 
684
          break;
 
685
        case GST_FORMAT_BYTES:
 
686
          *dest_val = GST_CLOCK_TIME_TO_FRAMES (src_val, rate);
 
687
          *dest_val *= bpf;
 
688
          break;
 
689
        default:
 
690
          res = FALSE;
 
691
          break;
 
692
      }
 
693
      break;
 
694
    default:
 
695
      res = FALSE;
 
696
      break;
 
697
  }
 
698
done:
 
699
  GST_DEBUG ("ret=%d result %" G_GINT64_FORMAT, res, *dest_val);
 
700
 
 
701
  return res;
 
702
}
 
703
 
271
704
/**
272
705
 * gst_audio_buffer_clip:
273
706
 * @buffer: The buffer to clip.
275
708
 * @rate: sample rate.
276
709
 * @frame_size: size of one audio frame in bytes.
277
710
 *
278
 
 * Clip the the buffer to the given %GstSegment.
 
711
 * Clip the buffer to the given %GstSegment.
279
712
 *
280
713
 * After calling this function the caller does not own a reference to 
281
714
 * @buffer anymore.