[gst-cvs] CVS: gstreamer/gst/elements Makefile.am,1.28,1.28.4.1 gstdisksrc.c,1.36,1.36.4.1 gstdisksrc.h,1.9,1.9.4.1 gstfakesink.c,1.23.4.3,1.23.4.4 gstfakesrc.c,1.31.4.1,1.31.4.2 gstfilesrc.c,1.3.4.4,1.3.4.5

Wim Taymans wtay at users.sourceforge.net
Sun Sep 30 15:02:02 PDT 2001


Update of /cvsroot/gstreamer/gstreamer/gst/elements
In directory usw-pr-cvs1:/tmp/cvs-serv28927/elements

Modified Files:
      Tag: BRANCH-EVENTS1
	Makefile.am gstdisksrc.c gstdisksrc.h gstfakesink.c 
	gstfakesrc.c gstfilesrc.c 
Log Message:
Commit my pending changes.
- revert WHERE stuff
- added fast type checking
- add preliminary stack trace functionality
- minor fixes/cleanups.


Index: Makefile.am
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/Makefile.am,v
retrieving revision 1.28
retrieving revision 1.28.4.1
diff -u -d -r1.28 -r1.28.4.1
--- Makefile.am	2001/08/22 04:30:27	1.28
+++ Makefile.am	2001/09/30 22:01:14	1.28.4.1
@@ -41,7 +41,7 @@
 	gstaggregator.h		\
 	gstsinesrc.h
 
-CFLAGS += -O2 -Wall
+CFLAGS += -O2 -Wall -finstrument-functions -DGST_ENABLE_FUNC_INSTRUMENTATION
 LDFLAGS += -lm
 
 libgstelements_la_LIBADD = $(GHTTP_LIBS)

Index: gstdisksrc.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstdisksrc.c,v
retrieving revision 1.36
retrieving revision 1.36.4.1
diff -u -d -r1.36 -r1.36.4.1
--- gstdisksrc.c	2001/08/22 21:45:25	1.36
+++ gstdisksrc.c	2001/09/30 22:01:14	1.36.4.1
@@ -64,8 +64,8 @@
 static void		gst_disksrc_get_property	(GObject *object, guint prop_id, 
 							 GValue *value, GParamSpec *pspec);
 
-static GstBuffer *	gst_disksrc_get			(GstPad *pad);
-static GstBuffer *	gst_disksrc_get_region		(GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
+static GstBuffer*	gst_disksrc_get			(GstPad *pad);
+static GstBufferPool* 	gst_disksrc_get_bufferpool 	(GstPad *pad);
 
 static GstElementStateReturn	
                  	gst_disksrc_change_state	(GstElement *element);
@@ -73,7 +73,7 @@
 static gboolean		gst_disksrc_open_file		(GstDiskSrc *src);
 static void		gst_disksrc_close_file		(GstDiskSrc *src);
 
-static GstElementClass *parent_class = NULL;
+static GstElementClass* parent_class = NULL;
 //static guint gst_disksrc_signals[LAST_SIGNAL] = { 0 };
 
 GType
@@ -133,8 +133,8 @@
 //  GST_FLAG_SET (disksrc, GST_SRC_);
 
   disksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
-  gst_pad_set_get_function (disksrc->srcpad,gst_disksrc_get);
-  gst_pad_set_getregion_function (disksrc->srcpad,gst_disksrc_get_region);
+  gst_pad_set_get_function (disksrc->srcpad, gst_disksrc_get);
+  gst_pad_set_bufferpool_function (disksrc->srcpad, gst_disksrc_get_bufferpool);
   gst_element_add_pad (GST_ELEMENT (disksrc), disksrc->srcpad);
 
   disksrc->filename = NULL;
@@ -220,120 +220,97 @@
   }
 }
 
-/**
- * gst_disksrc_get:
- * @pad: #GstPad to push a buffer from
- *
- * Push a new buffer from the disksrc at the current offset.
- */
-static GstBuffer *
-gst_disksrc_get (GstPad *pad)
+static GstBuffer*
+gst_disksrc_buffer_new (GstBufferPool *pool, gint64 location, gint size, gpointer user_data)
 {
   GstDiskSrc *src;
   GstBuffer *buf;
-
-  g_return_val_if_fail (pad != NULL, NULL);
-  src = GST_DISKSRC (gst_pad_get_parent (pad));
-  g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
 
+  src = GST_DISKSRC (user_data);
 
-  /* deal with EOF state */
-  if (src->curoffset >= src->size) {
-    GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size);
-    gst_pad_event(pad, GST_EVENT_EOS, 0LL, 0);
-    buf =  gst_buffer_new();
-    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
-    return buf;
-  }
-
-  /* create the buffer */
-  // FIXME: should eventually use a bufferpool for this
   buf = gst_buffer_new ();
-
   g_return_val_if_fail (buf != NULL, NULL);
 
   /* simply set the buffer to point to the correct region of the file */
-  GST_BUFFER_DATA (buf) = src->map + src->curoffset;
-  GST_BUFFER_OFFSET (buf) = src->curoffset;
+  GST_BUFFER_DATA (buf) = src->map + location;
+  GST_BUFFER_OFFSET (buf) = location;
   GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
 
-  if ((src->curoffset + src->bytes_per_read) > src->size) {
-    GST_BUFFER_SIZE (buf) = src->size - src->curoffset;
-    // FIXME: set the buffer's EOF bit here
-  } else
-    GST_BUFFER_SIZE (buf) = src->bytes_per_read;
+  if ((location + size) > src->size) 
+    GST_BUFFER_SIZE (buf) = src->size - location;
+  else
+    GST_BUFFER_SIZE (buf) = size;
 
   GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
              src->map + src->curoffset, GST_BUFFER_SIZE (buf));
 
-  //gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  return buf;
+}
 
-  src->curoffset += GST_BUFFER_SIZE (buf);
+static void
+gst_disksrc_buffer_free (GstBuffer *buf)
+{
+  // FIXME do something here
+}
 
-  if (src->new_seek) {
-    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH);
-    GST_DEBUG (0,"new seek\n");
-    src->new_seek = FALSE;
+static GstBufferPool*
+gst_disksrc_get_bufferpool (GstPad *pad)
+{
+  GstDiskSrc *src;
+  
+  src = GST_DISKSRC (gst_pad_get_parent (pad));
+
+  if (!src->bufferpool) {
+    src->bufferpool = gst_buffer_pool_new ();
+    gst_buffer_pool_set_buffer_new_function 	(src->bufferpool, gst_disksrc_buffer_new);
+    gst_buffer_pool_set_buffer_free_function 	(src->bufferpool, gst_disksrc_buffer_free);
+    gst_buffer_pool_set_user_data 		(src->bufferpool, src);
   }
 
-  /* we're done, return the buffer */
-  return buf;
+  return src->bufferpool;
 }
 
 /**
- * gst_disksrc_get_region:
- * @src: #GstSrc to push a buffer from
- * @offset: offset in file
- * @size: number of bytes
+ * gst_disksrc_get:
+ * @pad: #GstPad to push a buffer from
  *
- * Push a new buffer from the disksrc of given size at given offset.
+ * Push a new buffer from the disksrc at the current offset.
  */
 static GstBuffer *
-gst_disksrc_get_region (GstPad *pad, GstRegionType type,guint64 offset,guint64 len)
+gst_disksrc_get (GstPad *pad)
 {
   GstDiskSrc *src;
   GstBuffer *buf;
 
   g_return_val_if_fail (pad != NULL, NULL);
-  g_return_val_if_fail (type == GST_REGION_OFFSET_LEN, NULL);
-
   src = GST_DISKSRC (gst_pad_get_parent (pad));
-
-  g_return_val_if_fail (GST_IS_DISKSRC (src), NULL);
   g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
 
+
   /* deal with EOF state */
-  if (offset >= src->size) {
-    gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
-    GST_DEBUG (0,"map offset %lld >= size %ld --> eos\n", offset, src->size);
-    //FIXME
+  if (src->curoffset >= src->size) {
+    GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size);
+    gst_pad_event(pad, GST_EVENT_EOS, 0LL, 0);
     buf =  gst_buffer_new();
     GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
     return buf;
   }
-
-  /* create the buffer */
-  // FIXME: should eventually use a bufferpool for this
-  buf = gst_buffer_new ();
-  g_return_val_if_fail (buf != NULL, NULL);
 
-  /* simply set the buffer to point to the correct region of the file */
-  GST_BUFFER_DATA (buf) = src->map + offset;
-  GST_BUFFER_OFFSET (buf) = offset;
-  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
+  // FIXME use a bufferpool
+  buf = gst_disksrc_buffer_new (NULL, src->curoffset, src->bytes_per_read, src);
 
-  if ((offset + len) > src->size) {
-    GST_BUFFER_SIZE (buf) = src->size - offset;
-    // FIXME: set the buffer's EOF bit here
-  } else
-    GST_BUFFER_SIZE (buf) = len;
+  //gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  src->curoffset += GST_BUFFER_SIZE (buf);
 
-  GST_DEBUG (0,"map %p, offset %lld, size %d\n", src->map, offset, GST_BUFFER_SIZE (buf));
+  if (src->new_seek) {
+    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH);
+    GST_DEBUG (0,"new seek\n");
+    src->new_seek = FALSE;
+  }
 
-  /* we're done, return the buffer off now */
+  /* we're done, return the buffer */
   return buf;
 }
-
 
 /* open the file and mmap it, necessary to go to READY state */
 static gboolean 

Index: gstdisksrc.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstdisksrc.h,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -u -d -r1.9 -r1.9.4.1
--- gstdisksrc.h	2001/06/25 01:20:08	1.9
+++ gstdisksrc.h	2001/09/30 22:01:14	1.9.4.1
@@ -64,6 +64,7 @@
   gchar *filename;
   /* fd */
   gint fd;
+  GstBufferPool *bufferpool;
 
   /* mapping parameters */
   gulong size;				/* how long is the file? */

Index: gstfakesink.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstfakesink.c,v
retrieving revision 1.23.4.3
retrieving revision 1.23.4.4
diff -u -d -r1.23.4.3 -r1.23.4.4
--- gstfakesink.c	2001/09/23 22:52:32	1.23.4.3
+++ gstfakesink.c	2001/09/30 22:01:14	1.23.4.4
@@ -225,6 +225,7 @@
 
   if (GST_IS_EVENT(buf)) {
     g_print("fakesink: have event!\n");
+    gst_element_set_state (GST_ELEMENT (fakesink), GST_STATE_PAUSED);
     return;
   }
 

Index: gstfakesrc.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstfakesrc.c,v
retrieving revision 1.31.4.1
retrieving revision 1.31.4.2
diff -u -d -r1.31.4.1 -r1.31.4.2
--- gstfakesrc.c	2001/09/11 09:58:16	1.31.4.1
+++ gstfakesrc.c	2001/09/30 22:01:14	1.31.4.2
@@ -335,7 +335,8 @@
 
   if (src->num_buffers == 0) {
     g_print("fakesrc: sending EOS\n");
-    return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
+    gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
+    return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
   }
   else {
     if (src->num_buffers > 0)
@@ -345,7 +346,7 @@
   if (src->eos) {
     GST_INFO (0, "fakesrc is setting eos on pad");
     g_print("fakesrc: sending EOS\n");
-    return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
+    return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
   }
 
   buf = gst_buffer_new();
@@ -397,7 +398,7 @@
 
       if (src->eos) {
         GST_INFO (0, "fakesrc is setting eos on pad");
-        gst_pad_push(pad, GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS)));
+        gst_pad_push(pad, GST_BUFFER(gst_event_new (GST_EVENT_EOS)));
       }
 
       buf = gst_buffer_new();

Index: gstfilesrc.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstfilesrc.c,v
retrieving revision 1.3.4.4
retrieving revision 1.3.4.5
diff -u -d -r1.3.4.4 -r1.3.4.5
--- gstfilesrc.c	2001/09/29 03:28:52	1.3.4.4
+++ gstfilesrc.c	2001/09/30 22:01:14	1.3.4.5
@@ -596,6 +596,7 @@
 {
   g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN));
 
+  g_print ("close\n");
   /* close the file */
   close (src->fd);
 





More information about the Gstreamer-commits mailing list