gstafparse.c 14.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/* GStreamer
 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
 *                    2000 Wim Taymans <wtay@chello.be>
 *
 * gstafparse.c: 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


24 25 26
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
27 28
#include <gst/gst.h>
#include <gst/audio/audio.h>
29
#include <string.h>
30 31 32
#include "gstafparse.h"

/* AFParse signals and args */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
33 34
enum
{
35 36 37 38 39
  /* FILL ME */
  SIGNAL_HANDOFF,
  LAST_SIGNAL
};

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
40 41
enum
{
42
  ARG_0
43 44 45
};

/* added a src factory function to force audio/raw MIME type */
David Schleef's avatar
David Schleef committed
46
static GstStaticPadTemplate afparse_src_factory =
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
47 48 49 50
GST_STATIC_PAD_TEMPLATE ("src",
    GST_PAD_SRC,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("audio/x-raw-int, "
51 52 53 54
        "rate = (int) [ 1, MAX ], "
        "channels = (int) [ 1, MAX ], "
        "endianness = (int) BYTE_ORDER, "
        "width = (int) { 8, 16 }, "
55
        "depth = (int) { 8, 16 }, " "signed = (boolean) { true, false }")
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
56
    );
57

David Schleef's avatar
David Schleef committed
58
static GstStaticPadTemplate afparse_sink_factory =
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
59 60 61 62 63
    GST_STATIC_PAD_TEMPLATE ("sink",
    GST_PAD_SINK,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("audio/x-aiff; " "audio/x-wav; " "audio/x-au")
    );
64

Iain Holmes's avatar
Iain Holmes committed
65
static void gst_afparse_base_init (gpointer g_class);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
static void gst_afparse_class_init (GstAFParseClass * klass);
static void gst_afparse_init (GstAFParse * afparse);

static gboolean gst_afparse_open_file (GstAFParse * afparse);
static void gst_afparse_close_file (GstAFParse * afparse);

static void gst_afparse_loop (GstElement * element);
static void gst_afparse_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec);
static void gst_afparse_get_property (GObject * object, guint prop_id,
    GValue * value, GParamSpec * pspec);
static ssize_t gst_afparse_vf_read (AFvirtualfile * vfile, void *data,
    size_t nbytes);
static long gst_afparse_vf_length (AFvirtualfile * vfile);
static ssize_t gst_afparse_vf_write (AFvirtualfile * vfile, const void *data,
    size_t nbytes);
static void gst_afparse_vf_destroy (AFvirtualfile * vfile);
static long gst_afparse_vf_seek (AFvirtualfile * vfile, long offset,
    int is_relative);
static long gst_afparse_vf_tell (AFvirtualfile * vfile);
86 87

GType
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
88
gst_afparse_get_type (void)
89 90 91 92 93
{
  static GType afparse_type = 0;

  if (!afparse_type) {
    static const GTypeInfo afparse_info = {
Iain Holmes's avatar
Iain Holmes committed
94 95
      sizeof (GstAFParseClass),
      gst_afparse_base_init,
96 97 98 99 100 101 102 103
      NULL,
      (GClassInitFunc) gst_afparse_class_init,
      NULL,
      NULL,
      sizeof (GstAFParse),
      0,
      (GInstanceInitFunc) gst_afparse_init,
    };
104

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
105
    afparse_type =
106 107
        g_type_register_static (GST_TYPE_ELEMENT, "GstAFParse", &afparse_info,
        0);
108 109 110 111
  }
  return afparse_type;
}

Iain Holmes's avatar
Iain Holmes committed
112 113 114 115 116
static void
gst_afparse_base_init (gpointer g_class)
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);

David Schleef's avatar
David Schleef committed
117 118 119 120
  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&afparse_src_factory));
  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&afparse_sink_factory));
Iain Holmes's avatar
Iain Holmes committed
121

122
  gst_element_class_set_metadata (element_class, "Audiofile demuxer",
123 124 125
      "Codec/Demuxer/Audio",
      "Audiofile parser for audio/raw",
      "Steve Baker <stevebaker_org@yahoo.co.uk>");
Iain Holmes's avatar
Iain Holmes committed
126 127
}

128
static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
129
gst_afparse_class_init (GstAFParseClass * klass)
130 131 132 133
{
  GObjectClass *gobject_class;
  GstElementClass *gstelement_class;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
134 135
  gobject_class = (GObjectClass *) klass;
  gstelement_class = (GstElementClass *) klass;
136 137 138 139 140 141

  gobject_class->set_property = gst_afparse_set_property;
  gobject_class->get_property = gst_afparse_get_property;

}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
142 143
static void
gst_afparse_init (GstAFParse * afparse)
144
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
145 146
  afparse->srcpad =
      gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
147
          (afparse), "src"), "src");
148
  gst_pad_use_explicit_caps (afparse->srcpad);
149 150
  gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
151 152
  afparse->sinkpad =
      gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
153
          (afparse), "sink"), "sink");
154 155 156 157
  gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad);

  gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
158
  afparse->vfile = af_virtual_file_new ();
159 160 161 162 163 164 165 166
  afparse->vfile->closure = NULL;
  afparse->vfile->read = gst_afparse_vf_read;
  afparse->vfile->length = gst_afparse_vf_length;
  afparse->vfile->write = gst_afparse_vf_write;
  afparse->vfile->destroy = gst_afparse_vf_destroy;
  afparse->vfile->seek = gst_afparse_vf_seek;
  afparse->vfile->tell = gst_afparse_vf_tell;

167
  afparse->frames_per_read = 1024;
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
  afparse->curoffset = 0;
  afparse->seq = 0;

  afparse->file = NULL;
  /* default values, should never be needed */
  afparse->channels = 2;
  afparse->width = 16;
  afparse->rate = 44100;
  afparse->type = AF_FILE_WAVE;
  afparse->endianness_data = 1234;
  afparse->endianness_wanted = 1234;
  afparse->timestamp = 0LL;
}

static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
183
gst_afparse_loop (GstElement * element)
184 185 186
{
  GstAFParse *afparse;
  GstBuffer *buf;
Wim Taymans's avatar
Wim Taymans committed
187
  gint numframes = 0, frames_to_bytes, frames_per_read, bytes_per_read;
188
  guint8 *data;
189 190
  gboolean bypass_afread = TRUE;
  GstByteStream *bs;
191
  int s_format, v_format, s_width, v_width;
192

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
193
  afparse = GST_AFPARSE (element);
194

195
  afparse->vfile->closure = bs = gst_bytestream_new (afparse->sinkpad);
196 197

  /* just stop if we cannot open the file */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
198
  if (!gst_afparse_open_file (afparse)) {
199
    gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
200
    gst_pad_push (afparse->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
201 202 203 204 205 206 207
    gst_element_set_eos (GST_ELEMENT (afparse));
    return;
  }

  /* if audiofile changes the data in any way, we have to access
   * the audio data via afReadFrames. Otherwise we can just access
   * the data directly. */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
208 209 210 211 212
  afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK, &s_format, &s_width);
  afGetVirtualSampleFormat (afparse->file, AF_DEFAULT_TRACK, &v_format,
      &v_width);
  if (afGetCompression != AF_COMPRESSION_NONE
      || afGetByteOrder (afparse->file,
213 214
          AF_DEFAULT_TRACK) != afGetVirtualByteOrder (afparse->file,
          AF_DEFAULT_TRACK) || s_format != v_format || s_width != v_width) {
215
    bypass_afread = FALSE;
216
  }
217

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
218 219
  if (bypass_afread) {
    GST_DEBUG ("will bypass afReadFrames\n");
220
  }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
221

222 223 224 225
  frames_to_bytes = afparse->channels * afparse->width / 8;
  frames_per_read = afparse->frames_per_read;
  bytes_per_read = frames_per_read * frames_to_bytes;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
226 227 228 229 230 231
  afSeekFrame (afparse->file, AF_DEFAULT_TRACK, 0);

  if (bypass_afread) {
    GstEvent *event = NULL;
    guint32 waiting;
    guint32 got_bytes;
Steve Baker Baker's avatar
Steve Baker Baker committed
232

233 234
    do {

Steve Baker Baker's avatar
Steve Baker Baker committed
235 236
      got_bytes = gst_bytestream_read (bs, &buf, bytes_per_read);
      if (got_bytes == 0) {
237 238 239 240 241 242 243 244
        /* we need to check for an event. */
        gst_bytestream_get_status (bs, &waiting, &event);
        if (event && GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
          gst_pad_push (afparse->srcpad,
              GST_DATA (gst_event_new (GST_EVENT_EOS)));
          gst_element_set_eos (GST_ELEMENT (afparse));
          break;
        }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
245
      } else {
246 247 248 249 250 251 252 253 254
        GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
        gst_pad_push (afparse->srcpad, GST_DATA (buf));
        if (got_bytes != bytes_per_read) {
          /* this shouldn't happen very often */
          /* FIXME calculate the timestamps based on the fewer bytes received */

        } else {
          afparse->timestamp += frames_per_read * 1E9 / afparse->rate;
        }
255
      }
256 257 258
    }
    while (TRUE);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
259
  } else {
260
    do {
David Schleef's avatar
David Schleef committed
261
      buf = gst_buffer_new_and_alloc (bytes_per_read);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
262 263 264
      GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
      data = GST_BUFFER_DATA (buf);
      numframes =
265
          afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
266 267 268

      /* events are handled in gst_afparse_vf_read so if there are no
       * frames it must be EOS */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
269
      if (numframes < 1) {
270
        gst_buffer_unref (buf);
271

272 273 274 275
        gst_pad_push (afparse->srcpad,
            GST_DATA (gst_event_new (GST_EVENT_EOS)));
        gst_element_set_eos (GST_ELEMENT (afparse));
        break;
276
      }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
277
      GST_BUFFER_SIZE (buf) = numframes * frames_to_bytes;
278
      gst_pad_push (afparse->srcpad, GST_DATA (buf));
279 280 281
      afparse->timestamp += numframes * 1E9 / afparse->rate;
    }
    while (TRUE);
282
  }
283
  gst_afparse_close_file (afparse);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
284 285

  gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
286 287 288 289 290

}


static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
291 292
gst_afparse_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
293 294 295 296 297 298 299 300 301 302 303
{
  GstAFParse *afparse;

  afparse = GST_AFPARSE (object);

  switch (prop_id) {
    default:
      break;
  }
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
304 305 306
static void
gst_afparse_get_property (GObject * object, guint prop_id,
    GValue * value, GParamSpec * pspec)
307 308
{
  GstAFParse *afparse;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
309

310
  g_return_if_fail (GST_IS_AFPARSE (object));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
311

312
  afparse = GST_AFPARSE (object);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
313

314 315 316 317 318 319 320
  switch (prop_id) {
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}

Wim Taymans's avatar
Wim Taymans committed
321
gboolean
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
322
gst_afparse_plugin_init (GstPlugin * plugin)
323
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
324
  /* load audio support library */
325 326
  if (!gst_library_load ("gstaudio"))
    return FALSE;
327

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
328
  if (!gst_element_register (plugin, "afparse", GST_RANK_NONE,
329
          GST_TYPE_AFPARSE))
Iain Holmes's avatar
Iain Holmes committed
330 331
    return FALSE;

332 333 334 335 336
  return TRUE;
}

/* this is where we open the audiofile */
static gboolean
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
337
gst_afparse_open_file (GstAFParse * afparse)
338
{
339 340
  g_return_val_if_fail (!GST_OBJECT_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN),
      FALSE);
341 342 343


  /* open the file */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
344
  GST_DEBUG ("opening vfile %p\n", afparse->vfile);
345
  afparse->file = afOpenVirtualFile (afparse->vfile, "r", AF_NULL_FILESETUP);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
346
  if (afparse->file == AF_NULL_FILEHANDLE) {
347 348 349 350 351
    /* this should never happen */
    g_warning ("ERROR: gstafparse: Could not open virtual file for reading\n");
    return FALSE;
  }

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
352
  GST_DEBUG ("vfile opened\n");
353 354 355
  /* get the audiofile audio parameters */
  {
    int sampleFormat, sampleWidth;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
356

357
    afparse->channels = afGetChannels (afparse->file, AF_DEFAULT_TRACK);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
358
    afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK,
359
        &sampleFormat, &sampleWidth);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
360
    switch (sampleFormat) {
361
      case AF_SAMPFMT_TWOSCOMP:
362 363
        afparse->is_signed = TRUE;
        break;
364
      case AF_SAMPFMT_UNSIGNED:
365 366
        afparse->is_signed = FALSE;
        break;
367 368
      case AF_SAMPFMT_FLOAT:
      case AF_SAMPFMT_DOUBLE:
369
        GST_DEBUG ("ERROR: float data not supported yet !\n");
370 371 372
    }
    afparse->rate = (guint) afGetRate (afparse->file, AF_DEFAULT_TRACK);
    afparse->width = sampleWidth;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
373
    GST_DEBUG ("input file: %d channels, %d width, %d rate, signed %s\n",
374 375
        afparse->channels, afparse->width, afparse->rate,
        afparse->is_signed ? "yes" : "no");
376
  }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
377

378
  /* set caps on src */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
379 380 381
  /*FIXME: add all the possible formats, especially float ! */
  gst_pad_set_explicit_caps (afparse->srcpad,
      gst_caps_new_simple ("audio/x-raw-int",
382 383 384 385 386 387
          "endianness", G_TYPE_INT, G_BYTE_ORDER,
          "signed", G_TYPE_BOOLEAN, afparse->is_signed,
          "width", G_TYPE_INT, afparse->width,
          "depth", G_TYPE_INT, afparse->width,
          "rate", G_TYPE_INT, afparse->rate,
          "channels", G_TYPE_INT, afparse->channels, NULL));
388

389
  GST_OBJECT_FLAG_SET (afparse, GST_AFPARSE_OPEN);
390 391 392 393 394

  return TRUE;
}

static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
395
gst_afparse_close_file (GstAFParse * afparse)
396
{
397
  g_return_if_fail (GST_OBJECT_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
398
  if (afCloseFile (afparse->file) != 0) {
399
    g_warning ("afparse: oops, error closing !\n");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
400
  } else {
401
    GST_OBJECT_FLAG_UNSET (afparse, GST_AFPARSE_OPEN);
402 403 404
  }
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
405 406
static ssize_t
gst_afparse_vf_read (AFvirtualfile * vfile, void *data, size_t nbytes)
407
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
408 409 410 411 412 413 414 415 416 417 418
  GstByteStream *bs = (GstByteStream *) vfile->closure;
  guint8 *bytes = NULL;
  GstEvent *event = NULL;
  guint32 waiting;
  guint32 got_bytes;

  /*gchar        *debug_str; */

  got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);

  while (got_bytes != nbytes) {
419
    /* handle events */
420
    gst_bytestream_get_status (bs, &waiting, &event);
421

Steve Baker Baker's avatar
Steve Baker Baker committed
422
    /* FIXME this event handling isn't right yet */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
423 424
    if (!event) {
      /*g_print("no event found with %u bytes\n", got_bytes); */
Steve Baker Baker's avatar
Steve Baker Baker committed
425 426
      return 0;
    }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
427
    switch (GST_EVENT_TYPE (event)) {
428
      case GST_EVENT_EOS:
429
        return 0;
430
      case GST_EVENT_FLUSH:
431 432
        GST_DEBUG ("flush");
        break;
433
      case GST_EVENT_DISCONTINUOUS:
434 435 436
        GST_DEBUG ("seek done");
        got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
        break;
437
      default:
438 439
        g_warning ("unknown event %d", GST_EVENT_TYPE (event));
        got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
440
    }
441
  }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
442 443 444

  memcpy (data, bytes, got_bytes);
  gst_bytestream_flush_fast (bs, got_bytes);
445

Steve Baker Baker's avatar
Steve Baker Baker committed
446
  /*  debug_str = g_strndup((gchar*)bytes, got_bytes);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
447 448
     g_print("read %u bytes: %s\n", got_bytes, debug_str);
   */
Steve Baker Baker's avatar
Steve Baker Baker committed
449
  return got_bytes;
450 451
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
452 453
static long
gst_afparse_vf_seek (AFvirtualfile * vfile, long offset, int is_relative)
454
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
455
  GstByteStream *bs = (GstByteStream *) vfile->closure;
Wim Taymans's avatar
Wim Taymans committed
456
  GstSeekType method;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
457
  guint64 current_offset = gst_bytestream_tell (bs);
458

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
459 460
  if (!is_relative) {
    if ((guint64) offset == current_offset) {
461 462 463 464
      /* this seems to happen before every read - bad audiofile */
      return offset;
    }

Wim Taymans's avatar
Wim Taymans committed
465
    method = GST_SEEK_METHOD_SET;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
466 467 468 469
  } else {
    if (offset == 0)
      return current_offset;
    method = GST_SEEK_METHOD_CUR;
470
  }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
471 472 473

  if (gst_bytestream_seek (bs, (gint64) offset, method)) {
    GST_DEBUG ("doing seek to %d", (gint) offset);
474 475 476 477 478
    return offset;
  }
  return 0;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
479 480
static long
gst_afparse_vf_length (AFvirtualfile * vfile)
481
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
482
  GstByteStream *bs = (GstByteStream *) vfile->closure;
483 484
  guint64 length;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
485 486
  length = gst_bytestream_length (bs);
  GST_DEBUG ("doing length: %" G_GUINT64_FORMAT, length);
487
  return length;
488 489
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
490 491
static ssize_t
gst_afparse_vf_write (AFvirtualfile * vfile, const void *data, size_t nbytes)
492
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
493 494
  /* GstByteStream *bs = (GstByteStream*)vfile->closure; */
  g_warning ("shouldn't write to a readonly pad");
495 496 497
  return 0;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
498 499
static void
gst_afparse_vf_destroy (AFvirtualfile * vfile)
500
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
501
  /* GstByteStream *bs = (GstByteStream*)vfile->closure; */
502

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
503
  GST_DEBUG ("doing destroy");
504 505
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
506 507
static long
gst_afparse_vf_tell (AFvirtualfile * vfile)
508
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
509
  GstByteStream *bs = (GstByteStream *) vfile->closure;
510 511
  guint64 offset;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
512 513
  offset = gst_bytestream_tell (bs);
  GST_DEBUG ("doing tell: %" G_GUINT64_FORMAT, offset);
514
  return offset;
515
}