From: <tho...@fr...> - 2005-07-11 15:06:40
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: thomasvs Date: Mon Jul 11 2005 08:06:39 PDT Log message: add num-buffers property to basesrc Modified files: . : ChangeLog docs/gst/tmpl : gstbasesrc.sgml gstfakesrc.sgml gst/base : gstbasesrc.c gstbasesrc.h gst/elements : gstfakesrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.1249&r2=1.1250 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/docs/gst/tmpl/gstbasesrc.sgml.diff?r1=1.9&r2=1.10 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/docs/gst/tmpl/gstfakesrc.sgml.diff?r1=1.25&r2=1.26 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/base/gstbasesrc.c.diff?r1=1.28&r2=1.29 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/base/gstbasesrc.h.diff?r1=1.14&r2=1.15 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/elements/gstfakesrc.c.diff?r1=1.100&r2=1.101 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.1249 retrieving revision 1.1250 diff -u -d -r1.1249 -r1.1250 --- ChangeLog 10 Jul 2005 12:03:12 -0000 1.1249 +++ ChangeLog 11 Jul 2005 15:06:25 -0000 1.1250 @@ -1,3 +1,19 @@ +2005-07-11 Thomas Vander Stichele <thomas at apestaart dot org> + + * docs/gst/tmpl/gstbasesrc.sgml: + * docs/gst/tmpl/gstfakesrc.sgml: + * gst/base/gstbasesrc.c: (gst_base_src_class_init), + (gst_base_src_init), (gst_base_src_set_property), + (gst_base_src_get_property), (gst_base_src_get_range), + (gst_base_src_start): + * gst/base/gstbasesrc.h: + add num-buffers property + * gst/elements/gstfakesrc.c: (gst_fakesrc_class_init), + (gst_fakesrc_init), (gst_fakesrc_set_property), + (gst_fakesrc_get_property), (gst_fakesrc_create), + (gst_fakesrc_start): + remove num-buffers property 2005-07-10 Thomas Vander Stichele <thomas at apestaart dot org> * docs/gst/gstreamer-sections.txt: Index: gstbasesrc.sgml RCS file: /cvs/gstreamer/gstreamer/docs/gst/tmpl/gstbasesrc.sgml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- gstbasesrc.sgml 10 Jul 2005 12:03:12 -0000 1.9 +++ gstbasesrc.sgml 11 Jul 2005 15:06:26 -0000 1.10 @@ -35,6 +35,8 @@ @segment_loop: @offset: @size: +@num_buffers: +@num_buffers_left: <!-- ##### ARG GstBaseSrc:blocksize ##### --> <para> @@ -51,6 +53,11 @@ </para> +<!-- ##### ARG GstBaseSrc:num-buffers ##### --> +<para> +</para> <!-- ##### STRUCT GstBaseSrcClass ##### --> Index: gstfakesrc.sgml RCS file: /cvs/gstreamer/gstreamer/docs/gst/tmpl/gstfakesrc.sgml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- gstfakesrc.sgml 8 Jul 2005 14:01:31 -0000 1.25 +++ gstfakesrc.sgml 11 Jul 2005 15:06:26 -0000 1.26 @@ -68,11 +68,6 @@ -<!-- ##### ARG GstFakeSrc:num-buffers ##### --> -<para> - -</para> <!-- ##### ARG GstFakeSrc:parentsize ##### --> Index: gstbasesrc.c RCS file: /cvs/gstreamer/gstreamer/gst/base/gstbasesrc.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- gstbasesrc.c 9 Jul 2005 23:33:24 -0000 1.28 +++ gstbasesrc.c 11 Jul 2005 15:06:26 -0000 1.29 @@ -33,6 +33,7 @@ #include <gst/gstmarshal.h> #define DEFAULT_BLOCKSIZE 4096 +#define DEFAULT_NUM_BUFFERS -1 GST_DEBUG_CATEGORY_STATIC (gst_base_src_debug); #define GST_CAT_DEFAULT gst_base_src_debug @@ -50,6 +51,7 @@ PROP_BLOCKSIZE, PROP_HAS_LOOP, PROP_HAS_GETRANGE, + PROP_NUM_BUFFERS, }; static GstElementClass *parent_class = NULL; @@ -150,6 +152,11 @@ "True if the element should expose a getrange function", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_NUM_BUFFERS, + g_param_spec_int ("num-buffers", "num-buffers", + "Number of buffers to output before sending EOS", -1, G_MAXINT, + DEFAULT_NUM_BUFFERS, G_PARAM_READWRITE)); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_base_src_change_state); @@ -165,6 +172,8 @@ basesrc->is_live = FALSE; basesrc->live_lock = g_mutex_new (); basesrc->live_cond = g_cond_new (); + basesrc->num_buffers = DEFAULT_NUM_BUFFERS; + basesrc->num_buffers_left = -1; pad_template = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src"); @@ -503,6 +512,9 @@ src->has_getrange = g_value_get_boolean (value); gst_base_src_set_dataflow_funcs (src); break; + case PROP_NUM_BUFFERS: + src->num_buffers = g_value_get_int (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -527,6 +539,9 @@ case PROP_HAS_GETRANGE: g_value_set_boolean (value, src->has_getrange); + g_value_set_int (value, src->num_buffers); @@ -579,6 +594,13 @@ if (length == 0) goto unexpected_length; + if (src->num_buffers_left == 0) { + goto reached_num_buffers; + } else { + if (src->num_buffers_left > 0) + src->num_buffers_left--; + } ret = bclass->create (src, offset, length, buf); return ret; @@ -599,6 +621,11 @@ GST_DEBUG_OBJECT (src, "unexpected length %u", length); return GST_FLOW_UNEXPECTED; } +reached_num_buffers: + { + GST_DEBUG_OBJECT (src, "sent all buffers"); + return GST_FLOW_UNEXPECTED; } static gboolean @@ -796,6 +823,8 @@ if (GST_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED)) return TRUE; + basesrc->num_buffers_left = basesrc->num_buffers; bclass = GST_BASE_SRC_GET_CLASS (basesrc); if (bclass->start) result = bclass->start (basesrc); Index: gstbasesrc.h RCS file: /cvs/gstreamer/gstreamer/gst/base/gstbasesrc.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- gstbasesrc.h 10 Jul 2005 12:03:12 -0000 1.14 +++ gstbasesrc.h 11 Jul 2005 15:06:26 -0000 1.15 @@ -95,6 +95,9 @@ guint64 offset; /* current offset in the resource */ guint64 size; /* total size of the resource */ + gint num_buffers; + gint num_buffers_left; /** Index: gstfakesrc.c RCS file: /cvs/gstreamer/gstreamer/gst/elements/gstfakesrc.c,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- gstfakesrc.c 8 Jul 2005 14:01:31 -0000 1.100 +++ gstfakesrc.c 11 Jul 2005 15:06:27 -0000 1.101 @@ -63,7 +63,6 @@ #define DEFAULT_DATARATE 0 #define DEFAULT_SYNC FALSE #define DEFAULT_PATTERN NULL -#define DEFAULT_NUM_BUFFERS -1 #define DEFAULT_EOS FALSE #define DEFAULT_SIGNAL_HANDOFFS FALSE #define DEFAULT_SILENT FALSE @@ -82,7 +81,6 @@ PROP_DATARATE, PROP_SYNC, PROP_PATTERN, - PROP_NUM_BUFFERS, PROP_EOS, PROP_SIGNAL_HANDOFFS, PROP_SILENT, @@ -262,10 +260,6 @@ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PATTERN, g_param_spec_string ("pattern", "pattern", "pattern", DEFAULT_PATTERN, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_NUM_BUFFERS, - g_param_spec_int ("num-buffers", "num-buffers", - "Number of buffers to output before sending EOS", -1, G_MAXINT, - DEFAULT_NUM_BUFFERS, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LAST_MESSAGE, g_param_spec_string ("last-message", "last-message", "The last status message", NULL, G_PARAM_READABLE)); @@ -311,8 +305,6 @@ fakesrc->output = FAKESRC_FIRST_LAST_LOOP; fakesrc->segment_start = -1; fakesrc->segment_end = -1; - fakesrc->num_buffers = DEFAULT_NUM_BUFFERS; - fakesrc->rt_num_buffers = -1; fakesrc->buffer_count = 0; fakesrc->silent = DEFAULT_SILENT; fakesrc->signal_handoffs = DEFAULT_SIGNAL_HANDOFFS; @@ -414,9 +406,6 @@ case PROP_PATTERN: - case PROP_NUM_BUFFERS: - src->num_buffers = g_value_get_int (value); - break; case PROP_SILENT: src->silent = g_value_get_boolean (value); @@ -486,9 +475,6 @@ g_value_set_string (value, src->pattern); - g_value_set_int (value, src->num_buffers); g_value_set_boolean (value, src->silent); @@ -669,13 +655,6 @@ - if (src->rt_num_buffers == 0) { - return GST_FLOW_UNEXPECTED; - } else { - if (src->rt_num_buffers > 0) - src->rt_num_buffers--; - } buf = gst_fakesrc_create_buffer (src); GST_BUFFER_OFFSET (buf) = src->buffer_count++; @@ -729,7 +708,6 @@ src->buffer_count = 0; src->pattern_byte = 0x00; src->bytes_sent = 0; - src->rt_num_buffers = src->num_buffers; return TRUE; |