libs/gst/bytestream/: removing obsolete files
authorStefan Kost <ensonic@users.sourceforge.net>
Fri, 26 Aug 2005 13:17:54 +0000 (13:17 +0000)
committerStefan Kost <ensonic@users.sourceforge.net>
Fri, 26 Aug 2005 13:17:54 +0000 (13:17 +0000)
Original commit message from CVS:
* libs/gst/bytestream/.cvsignore:
* libs/gst/bytestream/Makefile.am:
* libs/gst/bytestream/adapter.c:
* libs/gst/bytestream/adapter.h:
* libs/gst/bytestream/bytestream.c:
* libs/gst/bytestream/bytestream.h:
* libs/gst/bytestream/filepad.c:
* libs/gst/bytestream/filepad.h:
removing obsolete files

ChangeLog
libs/gst/bytestream/.gitignore [deleted file]
libs/gst/bytestream/Makefile.am [deleted file]
libs/gst/bytestream/adapter.c [deleted file]
libs/gst/bytestream/adapter.h [deleted file]
libs/gst/bytestream/bytestream.c [deleted file]
libs/gst/bytestream/bytestream.h [deleted file]
libs/gst/bytestream/filepad.c [deleted file]
libs/gst/bytestream/filepad.h [deleted file]

index c6df6c7..ad98375 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2005-08-26  Stefan Kost  <ensonic@users.sf.net>
 
+       * libs/gst/bytestream/.cvsignore:
+       * libs/gst/bytestream/Makefile.am:
+       * libs/gst/bytestream/adapter.c:
+       * libs/gst/bytestream/adapter.h:
+       * libs/gst/bytestream/bytestream.c:
+       * libs/gst/bytestream/bytestream.h:
+       * libs/gst/bytestream/filepad.c:
+       * libs/gst/bytestream/filepad.h:
+         removing obsolete files
+
+2005-08-26  Stefan Kost  <ensonic@users.sf.net>
+
        * docs/gst/gstreamer-docs.sgml:
        * docs/libs/gstreamer-libs-docs.sgml:
          disabed additional index entries again, as this makes docs-gen just
diff --git a/libs/gst/bytestream/.gitignore b/libs/gst/bytestream/.gitignore
deleted file mode 100644 (file)
index 1d74972..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-*.bb
-*.bbg
-*.da
-*.def
-*.gcno
diff --git a/libs/gst/bytestream/Makefile.am b/libs/gst/bytestream/Makefile.am
deleted file mode 100644 (file)
index a108536..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-plugin_LTLIBRARIES = libgstbytestream.la
-
-libgstbytestreamincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/bytestream
-libgstbytestreaminclude_HEADERS = bytestream.h adapter.h filepad.h
-
-libgstbytestream_la_SOURCES = bytestream.c adapter.c filepad.c
-libgstbytestream_la_CFLAGS = $(GST_OBJ_CFLAGS)
-libgstbytestream_la_LIBS = $(GST_OBJ_LIBS)
-libgstbytestream_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
diff --git a/libs/gst/bytestream/adapter.c b/libs/gst/bytestream/adapter.c
deleted file mode 100644 (file)
index 87fb5f8..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/* GStreamer
- * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
- *
- * 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.
- */
-
-#include "adapter.h"
-#include <string.h>
-
-/* default size for the assembled data buffer */
-#define DEFAULT_SIZE 16
-
-GST_DEBUG_CATEGORY_STATIC (gst_adapter_debug);
-#define GST_CAT_DEFAULT gst_adapter_debug
-
-#define _do_init(thing) \
-  GST_DEBUG_CATEGORY_INIT (gst_adapter_debug, "GstAdapter", 0, "object to splice and merge buffers to desired size")
-GST_BOILERPLATE_FULL (GstAdapter, gst_adapter, GObject, G_TYPE_OBJECT, _do_init)
-
-     static void gst_adapter_dispose (GObject * object);
-     static void gst_adapter_finalize (GObject * object);
-
-     static void gst_adapter_base_init (gpointer g_class)
-{
-}
-
-static void
-gst_adapter_class_init (GstAdapterClass * klass)
-{
-  GObjectClass *object = G_OBJECT_CLASS (klass);
-
-  object->dispose = gst_adapter_dispose;
-  object->finalize = gst_adapter_finalize;
-}
-
-static void
-gst_adapter_init (GstAdapter * adapter)
-{
-  adapter->assembled_data = g_malloc (DEFAULT_SIZE);
-  adapter->assembled_size = DEFAULT_SIZE;
-}
-
-static void
-gst_adapter_dispose (GObject * object)
-{
-  GstAdapter *adapter = GST_ADAPTER (object);
-
-  gst_adapter_clear (adapter);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_adapter_finalize (GObject * object)
-{
-  GstAdapter *adapter = GST_ADAPTER (object);
-
-  g_free (adapter->assembled_data);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-/**
- * gst_adapter_new:
- *
- * Creates a new #GstAdapter.
- *
- * Returns: a new #GstAdapter
- */
-GstAdapter *
-gst_adapter_new (void)
-{
-  return g_object_new (GST_TYPE_ADAPTER, NULL);
-}
-
-/**
- * gst_adapter_clear:
- * @adapter: the #GstAdapter to clear
- *
- * Removes all buffers from the @adapter.
- */
-void
-gst_adapter_clear (GstAdapter * adapter)
-{
-  g_return_if_fail (GST_IS_ADAPTER (adapter));
-
-  g_slist_foreach (adapter->buflist, (GFunc) gst_data_unref, NULL);
-  g_slist_free (adapter->buflist);
-  adapter->buflist = NULL;
-  adapter->size = 0;
-  adapter->skip = 0;
-  adapter->assembled_len = 0;
-}
-
-/**
- * gst_adapter_push:
- * @adapter: a #GstAdapter
- * @buf: the #GstBuffer to queue into the adapter
- *
- * Adds the data from @buf to the data stored inside @adapter and takes 
- * ownership of the buffer.
- */
-void
-gst_adapter_push (GstAdapter * adapter, GstBuffer * buf)
-{
-  g_return_if_fail (GST_IS_ADAPTER (adapter));
-  g_return_if_fail (GST_IS_BUFFER (buf));
-
-  adapter->size += GST_BUFFER_SIZE (buf);
-  adapter->buflist = g_slist_append (adapter->buflist, buf);
-}
-
-/**
- * gst_adapter_peek:
- * @adapter: a #GstAdapter
- * @size: number of bytes to peek
- *
- * Gets the first @size bytes stored in the @adapter. If this many bytes are
- * not available, it returns NULL. The returned pointer is valid until the next
- * function is called on the adapter.
- *
- * Returns: a pointer to the first @size bytes of data or NULL
- */
-const guint8 *
-gst_adapter_peek (GstAdapter * adapter, guint size)
-{
-  GstBuffer *cur;
-  GSList *cur_list;
-  guint copied;
-
-  g_return_val_if_fail (GST_IS_ADAPTER (adapter), NULL);
-  g_return_val_if_fail (size > 0, NULL);
-
-  if (size > adapter->size)
-    return NULL;
-
-  if (adapter->assembled_len >= size)
-    return adapter->assembled_data;
-
-  cur = adapter->buflist->data;
-  if (GST_BUFFER_SIZE (cur) >= size + adapter->skip)
-    return GST_BUFFER_DATA (cur) + adapter->skip;
-
-  if (adapter->assembled_size < size) {
-    adapter->assembled_size = (size / DEFAULT_SIZE + 1) * DEFAULT_SIZE;
-    GST_DEBUG_OBJECT (adapter, "setting size of internal buffer to %u\n",
-        adapter->assembled_size);
-    adapter->assembled_data =
-        g_realloc (adapter->assembled_data, adapter->assembled_size);
-  }
-  adapter->assembled_len = size;
-  copied = GST_BUFFER_SIZE (cur) - adapter->skip;
-  memcpy (adapter->assembled_data, GST_BUFFER_DATA (cur) + adapter->skip,
-      copied);
-  cur_list = g_slist_next (adapter->buflist);
-  while (copied < size) {
-    g_assert (cur_list);
-    cur = cur_list->data;
-    cur_list = g_slist_next (cur_list);
-    memcpy (adapter->assembled_data + copied, GST_BUFFER_DATA (cur),
-        MIN (GST_BUFFER_SIZE (cur), size - copied));
-    copied = MIN (size, copied + GST_BUFFER_SIZE (cur));
-  }
-
-  return adapter->assembled_data;
-}
-
-/**
- * gst_adapter_flush:
- * @adapter: a #GstAdapter
- * @flush: number of bytes to flush
- *
- * Flushes the first @flush bytes of the @adapter.
- */
-void
-gst_adapter_flush (GstAdapter * adapter, guint flush)
-{
-  GstBuffer *cur;
-
-  g_return_if_fail (GST_IS_ADAPTER (adapter));
-  g_return_if_fail (flush > 0);
-  g_return_if_fail (flush <= adapter->size);
-
-  GST_LOG_OBJECT (adapter, "flushing %u bytes\n", flush);
-  adapter->size -= flush;
-  adapter->assembled_len = 0;
-  while (flush > 0) {
-    cur = adapter->buflist->data;
-    if (GST_BUFFER_SIZE (cur) <= flush + adapter->skip) {
-      /* can skip whole buffer */
-      flush -= GST_BUFFER_SIZE (cur) - adapter->skip;
-      adapter->skip = 0;
-      adapter->buflist = g_slist_remove (adapter->buflist, cur);
-      gst_data_unref (GST_DATA (cur));
-    } else {
-      adapter->skip += flush;
-      break;
-    }
-  }
-}
-
-/**
- * gst_adapter_available:
- * @adapter: a #GstAdapter
- *
- * Gets the maximum amount of bytes available, that is it returns the maximum 
- * value that can be supplied to gst_adapter_peek() without that function 
- * returning NULL.
- *
- * Returns: amount of bytes available in @adapter
- */
-guint
-gst_adapter_available (GstAdapter * adapter)
-{
-  g_return_val_if_fail (GST_IS_ADAPTER (adapter), 0);
-
-  return adapter->size;
-}
-
-/**
- * gst_adapter_available_fast:
- * @adapter: a #GstAdapter
- *
- * Gets the maximum amount of bytes available without the need to do expensive
- * operations (like copying the data into a temporary buffer).
- *
- * Returns: amount of bytes available in @adapter without expensive operations
- */
-guint
-gst_adapter_available_fast (GstAdapter * adapter)
-{
-  g_return_val_if_fail (GST_IS_ADAPTER (adapter), 0);
-
-  if (!adapter->buflist)
-    return 0;
-  if (adapter->assembled_len)
-    return adapter->assembled_len;
-  g_assert (GST_BUFFER_SIZE (adapter->buflist->data) > adapter->skip);
-  return GST_BUFFER_SIZE (adapter->buflist->data) - adapter->skip;
-}
diff --git a/libs/gst/bytestream/adapter.h b/libs/gst/bytestream/adapter.h
deleted file mode 100644 (file)
index 4257cf5..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* GStreamer
- * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
- *
- * 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.
- */
-
-#include <gst/gst.h>
-
-#ifndef __GST_ADAPTER_H__
-#define __GST_ADAPTER_H__
-
-G_BEGIN_DECLS
-
-
-#define GST_TYPE_ADAPTER \
-  (gst_adapter_get_type())
-#define GST_ADAPTER(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ADAPTER,GstAdapter))
-#define GST_ADAPTER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ADAPTER,GstAdapterClass))
-#define GST_IS_ADAPTER(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ADAPTER))
-#define GST_IS_ADAPTER_CLASS(obj) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ADAPTER))
-
-typedef struct _GstAdapter GstAdapter;
-typedef struct _GstAdapterClass GstAdapterClass;
-
-struct _GstAdapter {
-  GObject      object;
-
-  GSList *     buflist;
-  guint                size;
-  guint                skip;
-
-  /* we keep state of assembled pieces */
-  guint8 *     assembled_data;
-  guint                assembled_size;
-  guint                assembled_len;
-
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-struct _GstAdapterClass {
-  GObjectClass parent_class;
-
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-GstAdapter *           gst_adapter_new                 (void);
-
-void                   gst_adapter_clear               (GstAdapter *adapter);
-void                   gst_adapter_push                (GstAdapter *adapter, GstBuffer* buf);
-const guint8 *         gst_adapter_peek                (GstAdapter *adapter, guint size);
-void                   gst_adapter_flush               (GstAdapter *adapter, guint flush);
-guint                  gst_adapter_available           (GstAdapter *adapter);
-guint                  gst_adapter_available_fast      (GstAdapter *adapter);
-
-
-G_END_DECLS
-
-#endif /* __GST_ADAPTER_H__ */
diff --git a/libs/gst/bytestream/bytestream.c b/libs/gst/bytestream/bytestream.c
deleted file mode 100644 (file)
index 760d04a..0000000
+++ /dev/null
@@ -1,774 +0,0 @@
-/* GStreamer
- * Copyright (C) 2001 Erik Walthinsen <omega@temple-baptist.com>
- *
- * gstbytestream.c: adds a convenient bytestream based API to a pad.
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <gst/gstinfo.h>
-#include <gst/gstplugin.h>
-#include <gst/gstversion.h>
-#include <gst/gstutils.h>
-#include "bytestream.h"
-
-GST_DEBUG_CATEGORY_STATIC (debug_bs);
-#define GST_CAT_DEFAULT debug_bs
-
-static guint8 *gst_bytestream_assemble (GstByteStream * bs, guint32 len);
-
-static inline void
-gst_bytestream_init (GstByteStream * bs)
-{
-  bs->event = NULL;
-  bs->buflist = NULL;
-  bs->headbufavail = 0;
-  bs->listavail = 0;
-  bs->assembled = NULL;
-  bs->offset = 0LL;
-  bs->in_seek = FALSE;
-}
-static inline void
-gst_bytestream_exit (GstByteStream * bs)
-{
-  GSList *walk;
-
-  if (bs->event)
-    gst_event_unref (bs->event);
-
-  walk = bs->buflist;
-  while (walk) {
-    gst_buffer_unref (GST_BUFFER (walk->data));
-    walk = g_slist_next (walk);
-  }
-  g_slist_free (bs->buflist);
-
-  g_free (bs->assembled);
-}
-
-/**
- * gst_bytestream_new:
- * @pad: the pad to attach the bytestream to
- *
- * creates a bytestream from the given pad
- *
- * Returns: a new #GstByteStream object.
- */
-GstByteStream *
-gst_bytestream_new (GstPad * pad)
-{
-  GstByteStream *bs = g_new (GstByteStream, 1);
-
-  bs->pad = pad;
-  gst_bytestream_init (bs);
-
-  return bs;
-}
-
-/**
- * gst_bytestream_destroy:
- * @bs: the bytestream object to destroy
- *
- * destroy the bytestream object and free its resources.
- */
-void
-gst_bytestream_destroy (GstByteStream * bs)
-{
-  gst_bytestream_exit (bs);
-  g_free (bs);
-}
-
-void
-gst_bytestream_reset (GstByteStream * bs)
-{
-  /* free all data */
-  gst_bytestream_exit (bs);
-  /* reset data to clean state */
-  gst_bytestream_init (bs);
-}
-
-/* HOW THIS WORKS:
- *
- * The fundamental structure is a singly-linked list of buffers.  The
- * buffer on the front is the oldest, and thus the first to read data
- * from.  The number of bytes left to be read in this buffer is stored
- * in bs->headbufavail.  The number of bytes available in the entire
- * list (including the head buffer) is in bs->listavail.
- *
- * When a request is made for data (peek), _fill_bytes is called with
- * the number of bytes needed, but only if the listavail indicates
- * that there aren't already enough.  This calls _get_next_buf until
- * the listavail is sufficient to satisfy the demand.
- *
- * _get_next_buf pulls a buffer from the pad the bytestream is attached
- * to, and shoves it in the list.  There are actually two things it can
- * do.  If there's already a buffer in the list, and the _is_span_fast()
- * test returns true, it will merge it with that last buffer.  Otherwise
- * it will simply tack it onto the end of the list.
- *
- * The _peek itself first checks the simple case of the request fitting
- * within the head buffer, and if so creates a subbuffer and returns.
- * Otherwise, it creates a new buffer and allocates space for the request
- * and calls _assemble to fill it.  We know we have to copy because this
- * case only happens when the _merge wasn't feasible during _get_next_buf.
- *
- * The _flush method repeatedly inspects the head buffer and flushes as
- * much data from it as it needs to, up to the size of the buffer.  If
- * the flush decimates the buffer, it's stripped, unref'd, and removed.
- */
-
-
-/* get the next buffer
- * if the buffer can be merged with the head buffer, do so
- * else add it onto the head of the 
- */
-static gboolean
-gst_bytestream_get_next_buf (GstByteStream * bs)
-{
-  GstBuffer *nextbuf, *lastbuf, *headbuf;
-  GSList *end;
-
-  /* if there is an event pending, return FALSE */
-  if (bs->event)
-    return FALSE;
-
-  GST_DEBUG ("get_next_buf: pulling buffer");
-  gst_pad_pull (bs->pad, &nextbuf);
-
-  if (!nextbuf)
-    return FALSE;
-
-  if (GST_IS_EVENT (nextbuf)) {
-    bs->event = GST_EVENT (nextbuf);
-    return FALSE;
-  }
-
-  if (GST_BUFFER_TIMESTAMP_IS_VALID (nextbuf))
-    bs->last_ts = GST_BUFFER_TIMESTAMP (nextbuf);
-
-  GST_DEBUG ("get_next_buf: got buffer of %d bytes", GST_BUFFER_SIZE (nextbuf));
-
-  /* first see if there are any buffers in the list at all */
-  if (bs->buflist) {
-    GST_DEBUG ("gst_next_buf: there is at least one buffer in the list");
-    /* now find the end of the list */
-    end = g_slist_last (bs->buflist);
-    /* get the buffer that's there */
-    lastbuf = GST_BUFFER (end->data);
-
-    /* see if we can marge cheaply */
-    if (gst_buffer_is_span_fast (lastbuf, nextbuf)) {
-      GST_DEBUG ("get_next_buf: merging new buffer with last buf on list");
-      /* it is, let's merge them (this is really an append, but...) */
-      end->data = gst_buffer_merge (lastbuf, nextbuf);
-      /* add to the length of the list */
-      bs->listavail += GST_BUFFER_SIZE (nextbuf);
-
-      /* have to check to see if we merged with the head buffer */
-      if (end == bs->buflist) {
-        bs->headbufavail += GST_BUFFER_SIZE (nextbuf);
-      }
-
-      gst_buffer_unref (lastbuf);
-      gst_buffer_unref (nextbuf);
-
-      /* if we can't, we just append this buffer */
-    } else {
-      GST_DEBUG ("get_next_buf: adding new buffer to the end of the list");
-      end = g_slist_append (end, nextbuf);
-      /* also need to increment length of list and buffer count */
-      bs->listavail += GST_BUFFER_SIZE (nextbuf);
-    }
-
-    /* if there are no buffers in the list */
-  } else {
-    GST_DEBUG ("get_next_buf: buflist is empty, adding new buffer to list");
-    /* put this on the end of the list */
-    bs->buflist = g_slist_append (bs->buflist, nextbuf);
-    /* and increment the number of bytes in the list */
-    bs->listavail = GST_BUFFER_SIZE (nextbuf);
-    /* set the head buffer avail to the size */
-    bs->headbufavail = GST_BUFFER_SIZE (nextbuf);
-  }
-
-  /* a zero offset is a indication that we might need to set the timestamp */
-  if (bs->offset == 0LL) {
-    headbuf = GST_BUFFER (bs->buflist->data);
-    bs->offset = GST_BUFFER_OFFSET (headbuf);
-  }
-
-  return TRUE;
-}
-
-static gboolean
-gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len)
-{
-  /* as long as we don't have enough, we get more buffers */
-  while (bs->listavail < len) {
-    GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d",
-        bs->listavail, len);
-    if (!gst_bytestream_get_next_buf (bs))
-      return FALSE;
-  }
-
-  return TRUE;
-}
-
-/**
- * gst_bytestream_peek:
- * @bs: the bytestream to peek
- * @buf: pointer to a variable that can hold a buffer pointer.
- * @len: the number of bytes to peek
- *
- * Peeks len bytes into the bytestream, the result is returned as
- * a #GstBuffer. Unref the buffer after usage.
- * This function can return less bytes than requested. In that case,
- * an event might have happened which you can retrieve with
- * gst_bytestream_get_status().
- *
- * Returns: The number of bytes successfully peeked.
- */
-guint32
-gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len)
-{
-  GstBuffer *headbuf, *retbuf = NULL;
-
-  g_return_val_if_fail (bs != NULL, 0);
-  g_return_val_if_fail (buf != NULL, 0);
-
-  if (len == 0)
-    return 0;
-
-  GST_DEBUG ("peek: asking for %d bytes", len);
-
-  /* make sure we have enough */
-  GST_DEBUG ("peek: there are %d bytes in the list", bs->listavail);
-  if (len > bs->listavail) {
-    if (!gst_bytestream_fill_bytes (bs, len)) {
-      /* we must have an event coming up */
-      if (bs->listavail > 0) {
-        /* we have some data left, len will be shrunk to the amount of data available */
-        len = bs->listavail;
-      } else {
-        /* there is no data */
-        *buf = retbuf;
-        return 0;
-      }
-    }
-    GST_DEBUG ("peek: there are now %d bytes in the list", bs->listavail);
-  }
-  gst_bytestream_print_status (bs);
-
-  /* extract the head buffer */
-  headbuf = GST_BUFFER (bs->buflist->data);
-
-  /* if the requested bytes are in the current buffer */
-  GST_DEBUG ("peek: headbufavail is %d", bs->headbufavail);
-  if (len <= bs->headbufavail) {
-    GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)",
-        len, bs->headbufavail);
-    /* create a sub-buffer of the headbuf */
-    retbuf =
-        gst_buffer_create_sub (headbuf,
-        GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len);
-    GST_BUFFER_OFFSET (retbuf) =
-        GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) -
-        bs->headbufavail;
-
-  }
-  /* otherwise we need to figure out how to assemble one */
-  else {
-    GST_DEBUG ("peek: current buffer is not big enough for len %d", len);
-
-    retbuf = gst_buffer_new ();
-    GST_BUFFER_SIZE (retbuf) = len;
-    GST_BUFFER_DATA (retbuf) = gst_bytestream_assemble (bs, len);
-    GST_BUFFER_TIMESTAMP (retbuf) = bs->last_ts;
-  }
-
-  *buf = retbuf;
-  return len;
-}
-
-/**
- * gst_bytestream_peek_bytes:
- * @bs: the bytestream to peek
- * @data: pointer to a variable that can hold a guint8 pointer.
- * @len: the number of bytes to peek
- *
- * Peeks len bytes into the bytestream, the result is returned as
- * a pointer to a guint8*. The data pointed to be data should not
- * be freed and will become invalid after performing the next bytestream
- * operation.
- * This function can return less bytes than requested. In that case,
- * an event might have happened which you can retrieve with
- * gst_bytestream_get_status().
- *
- * Returns: The number of bytes successfully peeked.
- */
-guint32
-gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data, guint32 len)
-{
-  GstBuffer *headbuf;
-
-  g_return_val_if_fail (bs != NULL, 0);
-  g_return_val_if_fail (data != NULL, 0);
-  g_return_val_if_fail (len > 0, 0);
-
-  GST_DEBUG ("peek_bytes: asking for %d bytes", len);
-  if (bs->assembled) {
-    if (bs->assembled_len >= len) {
-      *data = bs->assembled;
-      return len;
-    }
-    g_free (bs->assembled);
-    bs->assembled = NULL;
-  }
-
-  /* make sure we have enough */
-  GST_DEBUG ("peek_bytes: there are %d bytes in the list", bs->listavail);
-  if (len > bs->listavail) {
-    if (!gst_bytestream_fill_bytes (bs, len)) {
-      /* we must have an event coming up */
-      if (bs->listavail > 0) {
-        /* we have some data left, len will be shrunk to the amount of data available */
-        len = bs->listavail;
-      } else {
-        /* there is no data */
-        *data = NULL;
-        return 0;
-      }
-    }
-    GST_DEBUG ("peek_bytes: there are now %d bytes in the list", bs->listavail);
-  }
-  gst_bytestream_print_status (bs);
-
-  /* extract the head buffer */
-  headbuf = GST_BUFFER (bs->buflist->data);
-
-  /* if the requested bytes are in the current buffer */
-  GST_DEBUG ("peek_bytes: headbufavail is %d", bs->headbufavail);
-  if (len <= bs->headbufavail) {
-    GST_DEBUG
-        ("peek_bytes: there are enough bytes in headbuf (need %d, have %d)",
-        len, bs->headbufavail);
-    /* create a sub-buffer of the headbuf */
-    *data =
-        GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) -
-        bs->headbufavail);
-
-  }
-  /* otherwise we need to figure out how to assemble one */
-  else {
-    GST_DEBUG ("peek_bytes: current buffer is not big enough for len %d", len);
-
-    *data = gst_bytestream_assemble (bs, len);
-    bs->assembled = *data;
-    bs->assembled_len = len;
-  }
-
-  return len;
-}
-
-static guint8 *
-gst_bytestream_assemble (GstByteStream * bs, guint32 len)
-{
-  guint8 *data = g_malloc (len);
-  GSList *walk;
-  guint32 copied = 0;
-  GstBuffer *buf;
-
-  /* copy the data from the curbuf */
-  buf = GST_BUFFER (bs->buflist->data);
-  GST_DEBUG ("assemble: copying %d bytes from curbuf at %d to *data",
-      bs->headbufavail, GST_BUFFER_SIZE (buf) - bs->headbufavail);
-  memcpy (data,
-      GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf) - bs->headbufavail,
-      bs->headbufavail);
-  copied += bs->headbufavail;
-
-  /* asumption is made that the buffers all exist in the list */
-  walk = g_slist_next (bs->buflist);
-  while (copied < len) {
-    buf = GST_BUFFER (walk->data);
-    if (GST_BUFFER_SIZE (buf) < (len - copied)) {
-      GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d",
-          GST_BUFFER_SIZE (buf), copied);
-      memcpy (data + copied, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
-      copied += GST_BUFFER_SIZE (buf);
-    } else {
-      GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d",
-          len - copied, copied);
-      memcpy (data + copied, GST_BUFFER_DATA (buf), len - copied);
-      copied = len;
-    }
-    walk = g_slist_next (walk);
-  }
-
-  return data;
-}
-
-/**
- * gst_bytestream_flush:
- * @bs: the bytestream to flush
- * @len: the number of bytes to flush
- *
- * Flush len bytes from the bytestream.
- * This function can return FALSE when the number of
- * bytes could not be flushed due to an event. In that case,
- * you can get the number of available bytes before the event
- * with gst_bytestream_get_status().
- *
- * Returns: TRUE if the number of bytes could be flushed.
- */
-gboolean
-gst_bytestream_flush (GstByteStream * bs, guint32 len)
-{
-  GST_DEBUG ("flush: flushing %d bytes", len);
-
-  if (len == 0)
-    return TRUE;
-
-  /* make sure we have enough */
-  GST_DEBUG ("flush: there are %d bytes in the list", bs->listavail);
-  if (len > bs->listavail) {
-    if (!gst_bytestream_fill_bytes (bs, len)) {
-      return FALSE;
-    }
-    GST_DEBUG ("flush: there are now %d bytes in the list", bs->listavail);
-  }
-
-  gst_bytestream_flush_fast (bs, len);
-
-  return TRUE;
-}
-
-/**
- * gst_bytestream_flush_fast:
- * @bs: the bytestream to flush
- * @len: the number of bytes to flush
- *
- * Flushes len bytes from the bytestream. This function
- * is faster than gst_bytestream_flush() but only works
- * when you have recently peeked no less than len bytes
- * with gst_bytestream_peek() or gst_bytestream_peek_bytes().
- */
-void
-gst_bytestream_flush_fast (GstByteStream * bs, guint32 len)
-{
-  GstBuffer *headbuf;
-
-  if (len == 0)
-    return;
-
-  g_assert (len <= bs->listavail);
-
-  if (bs->assembled) {
-    g_free (bs->assembled);
-    bs->assembled = NULL;
-  }
-
-  /* update the byte offset */
-  bs->offset += len;
-
-  /* repeat until we've flushed enough data */
-  while (len > 0) {
-    headbuf = GST_BUFFER (bs->buflist->data);
-
-    GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %"
-        G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf),
-        GST_BUFFER_OFFSET (headbuf));
-
-    /* if there's enough to complete the flush */
-    if (bs->headbufavail > len) {
-      /* just trim it off */
-      GST_DEBUG ("flush: trimming %d bytes off end of headbuf", len);
-      bs->headbufavail -= len;
-      bs->listavail -= len;
-      len = 0;
-
-      /* otherwise we have to trim the whole buffer */
-    } else {
-      GST_DEBUG ("flush: removing head buffer completely");
-      /* remove it from the list */
-      bs->buflist = g_slist_delete_link (bs->buflist, bs->buflist);
-      /* trim it from the avail size */
-      bs->listavail -= bs->headbufavail;
-      /* record that we've trimmed this many bytes */
-      len -= bs->headbufavail;
-      /* unref it */
-      gst_buffer_unref (headbuf);
-
-      /* record the new headbufavail */
-      if (bs->buflist) {
-        bs->headbufavail = GST_BUFFER_SIZE (GST_BUFFER (bs->buflist->data));
-        GST_DEBUG ("flush: next headbuf is %d bytes", bs->headbufavail);
-      } else {
-        GST_DEBUG ("flush: no more bytes at all");
-      }
-    }
-
-    GST_DEBUG ("flush: bottom of while(), len is now %d", len);
-  }
-}
-
-/**
- * gst_bytestream_seek:
- * @bs: the bytestream to seek
- * @offset: the byte offset to seek to
- * @method: the seek method.
- *
- * Perform a seek on the bytestream to the given offset.
- * The method can be one of GST_SEEK_METHOD_CUR, GST_SEEK_METHOD_SET,
- * GST_SEEK_METHOD_END.
- * This seek will also flush any pending data in the bytestream or
- * peer elements.
- *
- * Returns: TRUE when the seek succeeded.
- */
-gboolean
-gst_bytestream_seek (GstByteStream * bs, gint64 offset, GstSeekType method)
-{
-  GstRealPad *peer;
-
-  g_return_val_if_fail (bs != NULL, FALSE);
-
-  peer = GST_RPAD_PEER (bs->pad);
-
-  GST_DEBUG ("bs: send event");
-  if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek (GST_FORMAT_BYTES |
-              (method & GST_SEEK_METHOD_MASK) |
-              GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) {
-    gst_bytestream_flush_fast (bs, bs->listavail);
-
-    /* we set the seek flag here. We cannot pull the pad here
-     * bacause a seek might occur outisde of the pads cothread context */
-    bs->in_seek = TRUE;
-
-    return TRUE;
-  }
-  GST_DEBUG ("bs: send event failed\n");
-  return FALSE;
-}
-
-/**
- * gst_bytestream_tell
- * @bs: a bytestream
- *
- * Get the current byteoffset in the bytestream.
- *
- * Returns: the offset or -1 on error.
- */
-guint64
-gst_bytestream_tell (GstByteStream * bs)
-{
-  GstFormat format;
-  gint64 value;
-
-  g_return_val_if_fail (bs != NULL, -1);
-
-  format = GST_FORMAT_BYTES;
-
-  if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format,
-          &value)) {
-    return value - bs->listavail;
-  }
-
-  return -1;
-}
-
-/**
- * gst_bytestream_length
- * @bs: a bytestream
- *
- * Get the total length of the bytestream.
- *
- * Returns: the total length or -1 on error.
- */
-guint64
-gst_bytestream_length (GstByteStream * bs)
-{
-  GstFormat format;
-  gint64 value;
-
-  g_return_val_if_fail (bs != NULL, -1);
-
-  format = GST_FORMAT_BYTES;
-
-  if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_TOTAL, &format, &value))
-    return value;
-
-  return -1;
-}
-
-/**
- * gst_bytestream_read:
- * @bs: the bytestream to read
- * @buf: pointer to a variable that can hold a buffer pointer.
- * @len: the number of bytes to read
- *
- * Read len bytes from the bytestream, the result is returned as
- * a #GstBuffer. Unref the buffer after usage.
- * This function can return less bytes than requested. In that case,
- * an event might have happened which you can retrieve with
- * gst_bytestream_get_status().
- *
- * Returns: The number of bytes successfully read.
- */
-guint32
-gst_bytestream_read (GstByteStream * bs, GstBuffer ** buf, guint32 len)
-{
-  guint32 len_peeked;
-
-  g_return_val_if_fail (bs != NULL, -1);
-
-  len_peeked = gst_bytestream_peek (bs, buf, len);
-  if (len_peeked == 0)
-    return 0;
-
-  gst_bytestream_flush_fast (bs, len_peeked);
-
-  return len_peeked;
-}
-
-/**
- * gst_bytestream_size_hint
- * @bs: a bytestream
- * @size: the size to hint
- *
- * Give a hint that we are going to read chunks of the given size.
- * Giving size hints to the peer element might improve performance
- * since less buffers need to be merged.
- *
- * Returns: TRUE if the hint was accepted.
- */
-gboolean
-gst_bytestream_size_hint (GstByteStream * bs, guint32 size)
-{
-  GstEvent *event;
-
-  g_return_val_if_fail (bs != NULL, FALSE);
-
-  event = gst_event_new_size (GST_FORMAT_BYTES, size);
-
-  return gst_pad_send_event (GST_PAD_PEER (bs->pad), event);
-}
-
-/**
- * gst_bytestream_get_status
- * @bs: a bytestream
- * @avail_out: total number of bytes buffered
- * @event_out: an event
- *
- * When an event occurs, the bytestream operations return a value less
- * than the requested length. You must retrieve the event using this API 
- * before reading more bytes from the stream.
- */
-void
-gst_bytestream_get_status (GstByteStream * bs,
-    guint32 * avail_out, GstEvent ** event_out)
-{
-  if (avail_out)
-    *avail_out = bs->listavail;
-
-  if (event_out) {
-    *event_out = bs->event;
-    bs->event = NULL;
-  }
-}
-
-/**
- * gst_bytestream_get_timestamp
- * @bs: a bytestream
- *
- * Get the timestamp of the first data in the bytestream.  If no data
- * exists 1 byte is read to load a new buffer.
- *
- * This function will not check input buffer boundries.  It is  possible
- * the next read could span two or more input buffers with different
- * timestamps.
- *
- * Returns: a timestamp.
- */
-guint64
-gst_bytestream_get_timestamp (GstByteStream * bs)
-{
-  GstBuffer *headbuf;
-
-  g_return_val_if_fail (bs != NULL, 0);
-
-  GST_DEBUG ("get_timestamp: getting timestamp");
-
-  /* make sure we have a buffer */
-  if (bs->listavail == 0) {
-    GST_DEBUG ("gst_timestamp: fetching a buffer");
-    if (!gst_bytestream_fill_bytes (bs, 1))
-      return 0;
-  }
-
-  /* extract the head buffer */
-  headbuf = GST_BUFFER (bs->buflist->data);
-
-  return GST_BUFFER_TIMESTAMP (headbuf);
-}
-
-/**
- * gst_bytestream_print_status
- * @bs: a bytestream
- *
- * Print the current status of the bytestream object. mainly
- * used for debugging purposes.
- */
-void
-gst_bytestream_print_status (GstByteStream * bs)
-{
-  GSList *walk;
-  GstBuffer *buf;
-
-  GST_DEBUG ("STATUS: head buffer has %d bytes available", bs->headbufavail);
-  GST_DEBUG ("STATUS: list has %d bytes available", bs->listavail);
-  walk = bs->buflist;
-  while (walk) {
-    buf = GST_BUFFER (walk->data);
-    walk = g_slist_next (walk);
-
-    GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT
-        " and is %d bytes long", GST_BUFFER_OFFSET (buf),
-        GST_BUFFER_SIZE (buf));
-  }
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (debug_bs, "bytestream", 0, "bytestream library");
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    "gstbytestream",
-    "a byte-oriented layer on top of buffer-passing",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/libs/gst/bytestream/bytestream.h b/libs/gst/bytestream/bytestream.h
deleted file mode 100644 (file)
index a3dcc61..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* GStreamer
- * Copyright (C) 2001 Erik Walthinsen <omega@temple-baptist.com>
- *
- * 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.
- */
-
-#ifndef __GST_BYTESTREAM_H__
-#define __GST_BYTESTREAM_H__
-
-#include <glib.h>
-#include <gst/gstpad.h>
-#include <gst/gstevent.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GstByteStream GstByteStream;
-
-struct _GstByteStream {
-  GstPad       *pad;
-
-  GstEvent     *event;
-
-  GSList       *buflist;
-  guint32       headbufavail;
-  guint32       listavail;
-
-  /* we keep state of assembled pieces */
-  guint8       *assembled;
-  guint32       assembled_len; /* only valid when assembled != NULL */
-
-  /* this is needed for gst_bytestream_tell */
-  guint64       offset;
-  guint64       last_ts;
-
-  /* if we are in the seek state (waiting for DISCONT) */
-  gboolean      in_seek;
-
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-GstByteStream*         gst_bytestream_new              (GstPad *pad);
-void                   gst_bytestream_destroy          (GstByteStream *bs);
-
-void                   gst_bytestream_reset            (GstByteStream *bs);
-guint32                        gst_bytestream_read             (GstByteStream *bs, GstBuffer** buf, guint32 len);
-guint64                        gst_bytestream_tell             (GstByteStream *bs);
-guint64                        gst_bytestream_length           (GstByteStream *bs);
-gboolean               gst_bytestream_size_hint        (GstByteStream *bs, guint32 size);
-gboolean               gst_bytestream_seek             (GstByteStream *bs, gint64 offset, GstSeekType method);
-
-guint32                        gst_bytestream_peek             (GstByteStream *bs, GstBuffer** buf, guint32 len);
-guint32                        gst_bytestream_peek_bytes       (GstByteStream *bs, guint8** data, guint32 len);
-gboolean               gst_bytestream_flush            (GstByteStream *bs, guint32 len);
-void                    gst_bytestream_flush_fast       (GstByteStream *bs, guint32 len);
-void                    gst_bytestream_get_status      (GstByteStream *bs, guint32 *avail_out, GstEvent **event_out);
-guint64                        gst_bytestream_get_timestamp    (GstByteStream *bs);
-
-void                   gst_bytestream_print_status     (GstByteStream *bs);
-
-G_END_DECLS
-
-#endif /* __GST_BYTESTREAM_H__ */
diff --git a/libs/gst/bytestream/filepad.c b/libs/gst/bytestream/filepad.c
deleted file mode 100644 (file)
index 588e4f3..0000000
+++ /dev/null
@@ -1,482 +0,0 @@
-/* GStreamer
- * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
- *
- * 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.
- */
-
-#include "filepad.h"
-#include <string.h>             /* memcpy */
-
-#define RETURN_IF_FAIL(pad,check,error) G_STMT_START { \
-  if (!(check)) { \
-    GST_LOG_OBJECT (pad, "setting error to %d: " #error, error); \
-    pad->error_number = error; \
-    return -error; \
-  } \
-} G_STMT_END
-
-GST_DEBUG_CATEGORY_STATIC (gst_file_pad_debug);
-#define GST_CAT_DEFAULT gst_file_pad_debug
-
-#define _do_init(thing) \
-  GST_DEBUG_CATEGORY_INIT (gst_file_pad_debug, "GstFilePad", 0, "object to splice and merge buffers to dewsired size")
-GST_BOILERPLATE_FULL (GstFilePad, gst_file_pad, GstRealPad, GST_TYPE_REAL_PAD,
-    _do_init)
-
-     static void gst_file_pad_dispose (GObject * object);
-     static void gst_file_pad_finalize (GObject * object);
-
-     //static void gst_file_pad_chain (GstPad * pad, GstData * data);
-     static void gst_file_pad_parent_set (GstObject * object,
-    GstObject * parent);
-
-
-     static void gst_file_pad_base_init (gpointer g_class)
-{
-}
-
-static void
-gst_file_pad_class_init (GstFilePadClass * klass)
-{
-  GstObjectClass *gst = GST_OBJECT_CLASS (klass);
-  GObjectClass *object = G_OBJECT_CLASS (klass);
-
-  object->dispose = gst_file_pad_dispose;
-  object->finalize = gst_file_pad_finalize;
-
-  gst->parent_set = gst_file_pad_parent_set;
-}
-
-static void
-gst_file_pad_init (GstFilePad * pad)
-{
-  GstRealPad *real = GST_REAL_PAD (pad);
-
-  /* must do this for set_chain_function to work */
-  real->direction = GST_PAD_SINK;
-
-  //gst_pad_set_chain_function (GST_PAD (real), gst_file_pad_chain);
-
-  pad->adapter = gst_adapter_new ();
-  pad->in_seek = FALSE;
-  pad->eos = FALSE;
-
-  pad->iterate_func = NULL;
-  pad->event_func = gst_pad_event_default;
-}
-
-static void
-gst_file_pad_dispose (GObject * object)
-{
-  GstFilePad *file_pad = GST_FILE_PAD (object);
-
-  gst_adapter_clear (file_pad->adapter);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_file_pad_finalize (GObject * object)
-{
-  GstFilePad *file_pad = GST_FILE_PAD (object);
-
-  g_object_unref (file_pad->adapter);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-#if 0
-static void
-gst_file_pad_chain (GstPad * gst_pad, GstData * data)
-{
-  GstFilePad *pad = GST_FILE_PAD (gst_pad);
-  gboolean got_value;
-  gint64 value;
-
-  if (GST_IS_EVENT (data)) {
-    GstEvent *event = GST_EVENT (data);
-
-    /* INSERT ME */
-    switch (GST_EVENT_TYPE (event)) {
-      case GST_EVENT_DISCONTINUOUS:
-        got_value =
-            gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value);
-        if (!got_value)
-          got_value =
-              gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value);
-        if (pad->in_seek) {
-          /* discard broken disconts */
-          if ((pad->position >= 0) && got_value && (value != pad->position)) {
-            GST_DEBUG_OBJECT (pad,
-                "unexpected discont during seek (want %" G_GINT64_FORMAT
-                ", got %" G_GINT64_FORMAT "), discarding", pad->position,
-                value);
-            break;
-          }
-          if (got_value) {
-            GST_INFO_OBJECT (pad, "got discont to %" G_GINT64_FORMAT, value);
-            pad->position = value;
-          } else {
-            GST_ERROR_OBJECT (pad, "got discont without position");
-            if (pad->position == -1) {
-              GST_WARNING_OBJECT (pad,
-                  "need to reset position to 0 because we have no position info");
-              pad->position = 0;
-            }
-          }
-          pad->in_seek = FALSE;
-        } else {
-          /* we're not seeking, what does the event want from us? */
-          if (!got_value ||
-              value != pad->position + gst_adapter_available (pad->adapter)) {
-            /* discont doesn't match position */
-            GST_WARNING_OBJECT (pad, "DISCONT arrived to %" G_GINT64_FORMAT
-                ", we're expecting %" G_GINT64_FORMAT " though", value,
-                pad->position + gst_adapter_available (pad->adapter));
-            /* off to event function, let the user decide */
-            break;
-          }
-        }
-        gst_event_unref (event);
-        return;
-      case GST_EVENT_EOS:
-        pad->eos = TRUE;
-        gst_event_unref (event);
-        g_return_if_fail (pad->iterate_func);
-        pad->iterate_func (pad);
-        return;
-      default:
-        break;
-    }
-
-    g_return_if_fail (pad->event_func);
-    pad->event_func (gst_pad, event);
-  } else {
-    if (pad->in_seek) {
-      GST_DEBUG_OBJECT (pad, "discarding buffer %p, we're seeking", data);
-      gst_data_unref (data);
-    } else {
-      gst_adapter_push (pad->adapter, GST_BUFFER (data));
-      g_return_if_fail (pad->iterate_func);
-      pad->iterate_func (pad);
-    }
-  }
-}
-#endif
-
-static void
-gst_file_pad_parent_set (GstObject * object, GstObject * parent)
-{
-  GstElement *element;
-
-  /* FIXME: we can only be added to elements, right? */
-  element = GST_ELEMENT (parent);
-
-  //if (element->loopfunc)
-  //  g_warning ("attempt to add a GstFilePad to a loopbased element.");
-
-  GST_CALL_PARENT (GST_OBJECT_CLASS, parent_set, (object, parent));
-}
-
-/**
- * gst_file_pad_new:
- * @templ: the #GstPadTemplate to use
- * @name: name of the pad
- *
- * creates a new file pad. Note that the template must be a sink template.
- *
- * Returns: the new file pad.
- */
-GstPad *
-gst_file_pad_new (GstPadTemplate * templ, gchar * name)
-{
-  g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
-  g_return_val_if_fail (GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SINK,
-      NULL);
-  g_return_val_if_fail (name != NULL, NULL);
-
-  return gst_pad_custom_new_from_template (GST_TYPE_FILE_PAD, templ, name);
-}
-
-/**
- * gst_file_pad_set_event_function:
- * @pad: a #GstFilePad
- * @event: the #GstPadEventFunction to use
- *
- * sets the function to use for handling events arriving on the pad, that aren't 
- * intercepted by the pad. The pad intercepts EOS and DISCONT events for its own
- * usage. An exception are unexpected DISCONT events that signal discontinuities 
- * in the data stream. So when your event function receives a DISCONT event, it has
- * to decide what to do with a hole of data coming up.
- * If you don't set one, gst_pad_event_default() will be used.
- */
-void
-gst_file_pad_set_event_function (GstFilePad * pad, GstPadEventFunction event)
-{
-  g_return_if_fail (GST_IS_FILE_PAD (pad));
-  g_return_if_fail (event != NULL);
-
-  pad->event_func = event;
-}
-
-/**
- * gst_file_pad_set_iterate_function:
- * @pad: a #GstFilePad
- * @iterate: the #GstFilePadIterateFunction to use
- *
- * Sets the iterate function of the pad. Don't use chain functions with file 
- * pads, they are used internally. The iteration function is called whenever 
- * there is new data to process. You can then use operations like 
- * gst_file_pad_read() to get the data.
- */
-void
-gst_file_pad_set_iterate_function (GstFilePad * pad,
-    GstFilePadIterateFunction iterate)
-{
-  g_return_if_fail (GST_IS_FILE_PAD (pad));
-  g_return_if_fail (iterate != NULL);
-
-  pad->iterate_func = iterate;
-}
-
-/**
- * gst_file_pad_read:
- * @pad: a #GstFilePad
- * @buf: buffer to fill
- * @count: number of bytes to put into buffer
- *
- * read @count bytes from the @pad into the buffer starting at @buf.
- * Note that this function does not return less bytes even in the EOS case.
- *
- * Returns: On success, @count is returned, and the file position is 
- *         advanced by this number. 0 indicates end of stream.
- *         On error, -errno is returned, and the errno of the pad is set 
- *         appropriately. In this case the file position will not change.
- */
-gint64
-gst_file_pad_read (GstFilePad * pad, void *buf, gint64 count)
-{
-  const guint8 *data;
-
-  /* FIXME: set pad's errno? */
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), -EBADF);
-  g_return_val_if_fail (buf != NULL, -EFAULT);
-  g_return_val_if_fail (count >= 0, -EINVAL);
-
-  if (gst_file_pad_eof (pad))
-    return 0;
-  data = gst_adapter_peek (pad->adapter, count);
-  RETURN_IF_FAIL (pad, data != NULL, EAGAIN);
-
-  memcpy (buf, data, count);
-  gst_adapter_flush (pad->adapter, count);
-  pad->position += count;
-
-  return count;
-}
-
-/**
- * gst_file_pad_try_read:
- * @pad: a #GstFilePad
- * @buf: buffer to fill
- * @count: number of bytes to put into buffer
- *
- * Attempts to read up to @count bytes into the buffer pointed to by @buf.
- * This function is modeled after the libc read() function.
- *
- * Returns: On success, the number of bytes read is returned, and the file 
- *         position is advanced by this number. 0 indicates end of stream.
- *         On error, -errno is returned, and the errno of the pad is set 
- *         appropriately. In this case the file position will not change.
- *         Note that the number of bytes read may and often will be 
- *         smaller then @count. If you don't want this behaviour, use 
- *         gst_file_pad_read() instead.
- **/
-gint64
-gst_file_pad_try_read (GstFilePad * pad, void *buf, gint64 count)
-{
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), -EBADF);
-  g_return_val_if_fail (buf != NULL, -EFAULT);
-  g_return_val_if_fail (count >= 0, -EINVAL);
-
-  count = MIN (count, (gint64) gst_adapter_available (pad->adapter));
-  return gst_file_pad_read (pad, buf, count);
-}
-
-/**
- * gst_file_pad_seek:
- * @pad: a #GstFilePad
- * @offset: new offset to start reading from
- * @whence: specifies relative to which position @offset should be interpreted
- *
- * Sets the new position to read from to @offset bytes relative to @whence. This 
- * function is modelled after the fseek() libc function.
- *
- * Returns: 0 on success, a negative error number on failure.
- */
-int
-gst_file_pad_seek (GstFilePad * pad, gint64 offset, GstSeekType whence)
-{
-  GstEvent *event;
-
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), -EBADF);
-  g_return_val_if_fail ((whence & (GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_SET |
-              GST_SEEK_METHOD_END)) == whence, -EINVAL);
-  g_return_val_if_fail (whence != 0, -EINVAL);
-
-  RETURN_IF_FAIL (pad, GST_PAD_PEER (pad), EBADF);      /* FIXME: better return val? */
-  /* adjust offset by number of bytes buffered */
-  if (whence & GST_SEEK_METHOD_CUR)
-    offset -= gst_adapter_available (pad->adapter);
-  event =
-      gst_event_new_seek (whence | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE
-      | GST_FORMAT_BYTES, offset);
-  RETURN_IF_FAIL (pad, gst_pad_send_event (GST_PAD_PEER (pad), event), EBADF);
-  GST_DEBUG_OBJECT (pad,
-      "seeking to position %" G_GINT64_FORMAT " relative to %s", offset,
-      whence == GST_SEEK_METHOD_CUR ? "start" : whence ==
-      GST_SEEK_METHOD_SET ? "current" : "end");
-  switch (whence) {
-    case GST_SEEK_METHOD_SET:
-      pad->position = offset;
-      break;
-    case GST_SEEK_METHOD_CUR:
-      pad->position += offset + gst_adapter_available (pad->adapter);
-      break;
-    case GST_SEEK_METHOD_END:
-      /* FIXME: query length and use that */
-      pad->position = -1;
-      break;
-    default:
-      g_assert_not_reached ();
-      break;
-  }
-  gst_adapter_clear (pad->adapter);
-  pad->in_seek = TRUE;
-  pad->eos = FALSE;
-
-  return 0;
-}
-
-/**
- * gst_file_pad_tell:
- * @pad: a #GstFilePad
- *
- * gets the current position inside the stream if the position is available. If
- * the position is not available due to a pending seek, it returns -EAGAIN. If 
- * the stream does not provide this information, -EBADF is returned. The @pad's 
- * errno is set apropriatly. This function is modeled after the ftell() libc 
- * function.
- *
- * Returns: The position or a negative error code.
- */
-gint64
-gst_file_pad_tell (GstFilePad * pad)
-{
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), -EBADF);
-
-  RETURN_IF_FAIL (pad, !(pad->position < 0 && pad->in_seek), EAGAIN);
-  RETURN_IF_FAIL (pad, pad->position >= 0, EBADF);
-
-  return pad->position;
-}
-
-/**
- * gst_file_pad_error:
- * @pad: a #GstFilePad
- *
- * Gets the last error. This is modeled after the ferror() function from libc.
- *
- * Returns: Number of the last error or 0 if there hasn't been an error yet.
- */
-int
-gst_file_pad_error (GstFilePad * pad)
-{
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), 0);
-
-  return pad->error_number;
-}
-
-/**
- * gst_file_pad_eof:
- * @pad: a #GstFilePad
- *
- * Checks if the EOS has been reached. This function is modeled after the 
- * function feof() from libc.
- *
- * Returns: non-zero if EOS has been reached, zero if not.
- **/
-int
-gst_file_pad_eof (GstFilePad * pad)
-{
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), 0);
-
-  if (pad->in_seek)
-    return 0;
-  if (gst_adapter_available (pad->adapter))
-    return 0;
-  if (!pad->eos)
-    return 0;
-
-  return 1;
-}
-
-/**
- * gst_file_pad_available:
- * @pad: a #GstFilePad
- *
- * Use this function to figure out the maximum number of bytes that can be read
- * via gst_file_pad_read() without that function returning -EAGAIN.
- * 
- * Returns: the number of bytes available in the file pad.
- */
-guint
-gst_file_pad_available (GstFilePad * pad)
-{
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), 0);
-
-  return gst_adapter_available (pad->adapter);
-}
-
-/**
- * gst_file_pad_get_length:
- * @pad: a #GstFilePad
- *
- * Gets the length in bytes of the @pad.
- *
- * Returns: length in bytes or -1 if not available
- */
-gint64
-gst_file_pad_get_length (GstFilePad * pad)
-{
-  GstFormat format = GST_FORMAT_BYTES;
-  gint64 length;
-  GstPad *peer;
-
-  g_return_val_if_fail (GST_IS_FILE_PAD (pad), -1);
-
-  /* we query the length every time to avoid issues with changing lengths */
-  peer = GST_PAD_PEER (pad);
-  if (!peer)
-    return -1;
-  if (gst_pad_query (peer, GST_QUERY_TOTAL, &format, &length))
-    return length;
-  format = GST_FORMAT_DEFAULT;
-  if (gst_pad_query (peer, GST_QUERY_TOTAL, &format, &length))
-    return length;
-
-  return -1;
-}
diff --git a/libs/gst/bytestream/filepad.h b/libs/gst/bytestream/filepad.h
deleted file mode 100644 (file)
index 02f198d..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* GStreamer
- * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
- *
- * 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.
- */
-
-#include <gst/gst.h>
-#include <gst/bytestream/adapter.h>
-
-#ifndef __GST_FILE_PAD_H__
-#define __GST_FILE_PAD_H__
-
-G_BEGIN_DECLS
-
-
-#define GST_TYPE_FILE_PAD \
-  (gst_file_pad_get_type())
-#define GST_FILE_PAD(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FILE_PAD,GstFilePad))
-#define GST_FILE_PAD_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILE_PAD,GstFilePadClass))
-#define GST_IS_FILE_PAD(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILE_PAD))
-#define GST_IS_FILE_PAD_CLASS(obj) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILE_PAD))
-
-typedef struct _GstFilePad GstFilePad;
-typedef struct _GstFilePadClass GstFilePadClass;
-
-typedef void (* GstFilePadIterateFunction) (GstFilePad *pad);
-
-struct _GstFilePad {
-  GstRealPad   pad;
-
-  GstAdapter * adapter;
-  gint64       position; /* FIXME: add to adapter? */
-  gboolean     in_seek;
-  gboolean     eos;
-  int          error_number;
-
-  GstFilePadIterateFunction iterate_func;
-  GstPadEventFunction event_func;
-
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-struct _GstFilePadClass {
-  GstRealPadClass      parent_class;
-
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-GType                  gst_file_pad_get_type           (void);
-
-/* FIXME: need this? */
-GstPad *               gst_file_pad_new                (GstPadTemplate* templ,
-                                                        gchar *name);
-
-void                   gst_file_pad_set_event_function (GstFilePad *file_pad,
-                                                        GstPadEventFunction event);
-void                   gst_file_pad_set_iterate_function (GstFilePad *file_pad,
-                                                        GstFilePadIterateFunction iterate);
-
-guint                  gst_file_pad_available          (GstFilePad *pad);
-gint64                 gst_file_pad_get_length         (GstFilePad *pad);
-/* this is a file like interface */
-/* FIXME: is gint64 the correct type? (it must be signed to get error return vals */
-gint64                 gst_file_pad_read               (GstFilePad *pad, 
-                                                        void *buf,
-                                                        gint64 count);
-gint64                 gst_file_pad_try_read           (GstFilePad *pad, 
-                                                        void *buf,
-                                                        gint64 count);
-int                    gst_file_pad_seek               (GstFilePad *pad, 
-                                                        gint64 offset,
-                                                        GstSeekType whence);
-gint64                 gst_file_pad_tell               (GstFilePad *pad);
-int                    gst_file_pad_error              (GstFilePad *pad);
-int                    gst_file_pad_eof                (GstFilePad *pad);
-
-
-G_END_DECLS
-
-#endif /* __GST_FILE_PAD_H__ */