CVS Root: /cvs/gstreamer
Module: gst-plugins-base
Changes by: msmith
Date: Mon Nov 24 2008 20:25:39 UTC
Log message:
* gst/playback/gstplaybin2.c:
Add notification of current stream. Add ability to configure buffer
sizes.
* gst/playback/gsturidecodebin.c:
Add ability to configure buffer sizes for streaming mode.
Bug #561734.
Modified files:
. : ChangeLog
gst/playback : gstplaybin2.c gsturidecodebin.c
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4212&r2=1.4213
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gstplaybin2.c.diff?r1=1.26&r2=1.27
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gsturidecodebin.c.diff?r1=1.20&r2=1.21
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
retrieving revision 1.4212
retrieving revision 1.4213
diff -u -d -r1.4212 -r1.4213
--- ChangeLog 24 Nov 2008 20:11:51 -0000 1.4212
+++ ChangeLog 24 Nov 2008 20:25:23 -0000 1.4213
@@ -1,3 +1,12 @@
+2008-11-24 Michael Smith <[email protected]>
+
+ * gst/playback/gstplaybin2.c:
+ Add notification of current stream. Add ability to configure buffer
+ sizes.
+ * gst/playback/gsturidecodebin.c:
+ Add ability to configure buffer sizes for streaming mode.
+ Bug #561734.
2008-11-24 Stefan Kost <[email protected]>
* gst-libs/gst/audio/gstbaseaudiosink.c:
Index: gstplaybin2.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gstplaybin2.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- gstplaybin2.c 13 Nov 2008 17:27:37 -0000 1.26
+++ gstplaybin2.c 24 Nov 2008 20:25:24 -0000 1.27
@@ -336,6 +336,9 @@
gint current_text; /* the currently selected stream */
gchar *encoding; /* subtitle encoding */
+ guint64 buffer_duration; /* When buffering, the max buffer duration (ns) */
+ guint buffer_size; /* When buffering, the max buffer size (bytes) */
/* our play sink */
GstPlaySink *playsink;
@@ -393,6 +396,8 @@
#define DEFAULT_FRAME NULL
#define DEFAULT_FONT_DESC NULL
#define DEFAULT_CONNECTION_SPEED 0
+#define DEFAULT_BUFFER_DURATION -1
+#define DEFAULT_BUFFER_SIZE -1
enum
{
@@ -415,7 +420,9 @@
PROP_MUTE,
PROP_FRAME,
PROP_FONT_DESC,
- PROP_CONNECTION_SPEED
+ PROP_CONNECTION_SPEED,
+ PROP_BUFFER_SIZE,
+ PROP_BUFFER_DURATION
};
/* signals */
@@ -696,6 +703,18 @@
"Network connection speed in kbps (0 = unknown)",
0, G_MAXUINT, DEFAULT_CONNECTION_SPEED,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_klass, PROP_BUFFER_SIZE,
+ g_param_spec_int ("buffer-size", "Buffer size (bytes)",
+ "Buffer size when buffering network streams",
+ -1, G_MAXINT, DEFAULT_BUFFER_SIZE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_klass, PROP_BUFFER_DURATION,
+ g_param_spec_int64 ("buffer-duration", "Buffer duration (ns)",
+ "Buffer duration when buffering network streams",
+ -1, G_MAXINT64, DEFAULT_BUFFER_DURATION,
/**
* GstPlayBin2::about-to-finish
* @playbin: a #GstPlayBin2
@@ -955,6 +974,9 @@
playbin->current_video = DEFAULT_CURRENT_VIDEO;
playbin->current_audio = DEFAULT_CURRENT_AUDIO;
playbin->current_text = DEFAULT_CURRENT_TEXT;
+ playbin->buffer_duration = DEFAULT_BUFFER_DURATION;
+ playbin->buffer_size = DEFAULT_BUFFER_SIZE;
}
static void
@@ -1160,6 +1182,34 @@
return result;
+/* Returns current stream number, or -1 if none has been selected yet */
+static int
+get_current_stream_number (GstPlayBin * playbin, GPtrArray * channels)
+{
+ /* Internal API cleanup would make this easier... */
+ int i;
+ GstPad *pad, *current;
+ GstObject *selector = NULL;
+ int ret = -1;
+ for (i = 0; i < channels->len; i++) {
+ pad = g_ptr_array_index (channels, i);
+ if ((selector = gst_pad_get_parent (pad))) {
+ g_object_get (selector, "active-pad", ¤t, NULL);
+ if (pad == current) {
+ ret = i;
+ break;
+ }
+ }
+ }
+ if (selector)
+ gst_object_unref (selector);
+ return ret;
+}
static gboolean
gst_play_bin_set_current_video_stream (GstPlayBin * playbin, gint stream)
@@ -1365,6 +1415,12 @@
playbin->connection_speed = g_value_get_uint (value) * 1000;
GST_PLAY_BIN_UNLOCK (playbin);
break;
+ case PROP_BUFFER_SIZE:
+ playbin->buffer_size = g_value_get_int (value);
+ break;
+ case PROP_BUFFER_DURATION:
+ playbin->buffer_duration = g_value_get_int64 (value);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1496,6 +1552,16 @@
g_value_set_uint (value, playbin->connection_speed / 1000);
+ GST_OBJECT_LOCK (playbin);
+ g_value_set_int (value, playbin->buffer_size);
+ GST_OBJECT_UNLOCK (playbin);
+ g_value_set_int64 (value, playbin->buffer_duration);
@@ -1530,6 +1596,51 @@
+selector_active_pad_changed (GObject * selector, GParamSpec * pspec,
+ GstPlayBin * playbin)
+ gchar *property;
+ GstSourceGroup *group;
+ GstSourceSelect *select = NULL;
+ GST_PLAY_BIN_LOCK (playbin);
+ group = get_group (playbin);
+ for (i = 0; i < GST_PLAY_SINK_TYPE_LAST; i++) {
+ if (selector == G_OBJECT (group->selector[i].selector)) {
+ select = &group->selector[i];
+ switch (select->type) {
+ case GST_PLAY_SINK_TYPE_VIDEO:
+ case GST_PLAY_SINK_TYPE_VIDEO_RAW:
+ property = "current-video";
+ playbin->current_video = get_current_stream_number (playbin,
+ group->video_channels);
+ case GST_PLAY_SINK_TYPE_AUDIO:
+ case GST_PLAY_SINK_TYPE_AUDIO_RAW:
+ property = "current-audio";
+ playbin->current_audio = get_current_stream_number (playbin,
+ group->audio_channels);
+ case GST_PLAY_SINK_TYPE_TEXT:
+ property = "current-text";
+ playbin->current_text = get_current_stream_number (playbin,
+ group->text_channels);
+ default:
+ property = NULL;
+ GST_PLAY_BIN_UNLOCK (playbin);
+ if (property)
+ g_object_notify (G_OBJECT (playbin), property);
+static void
selector_blocked (GstPad * pad, gboolean blocked, gpointer user_data)
/* no nothing */
@@ -1537,7 +1648,7 @@
/* this function is called when a new pad is added to decodebin. We check the
- * type of the pad and add it to the selecter element of the group.
+ * type of the pad and add it to the selector element of the group.
*/
pad_added_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
@@ -1550,6 +1661,7 @@
GstPadLinkReturn res;
GstSourceSelect *select = NULL;
gint i;
+ gboolean changed = FALSE;
playbin = group->playbin;
@@ -1581,6 +1693,9 @@
if (select->selector == NULL)
goto no_selector;
+ g_signal_connect (select->selector, "notify::active-pad",
+ G_CALLBACK (selector_active_pad_changed), playbin);
GST_DEBUG_OBJECT (playbin, "adding new selector %p", select->selector);
gst_bin_add (GST_BIN_CAST (playbin), select->selector);
gst_element_set_state (select->selector, GST_STATE_PAUSED);
@@ -1612,11 +1727,35 @@
/* store selector pad so we can release it */
g_object_set_data (G_OBJECT (pad), "playbin2.sinkpad", sinkpad);
+ changed = TRUE;
}
GST_DEBUG_OBJECT (playbin, "linked pad %s:%s to selector %p",
GST_DEBUG_PAD_NAME (pad), select->selector);
GST_SOURCE_GROUP_UNLOCK (group);
+ if (changed) {
+ int signal;
+ switch (select->type) {
+ case GST_PLAY_SINK_TYPE_VIDEO:
+ case GST_PLAY_SINK_TYPE_VIDEO_RAW:
+ signal = SIGNAL_VIDEO_CHANGED;
+ case GST_PLAY_SINK_TYPE_AUDIO:
+ case GST_PLAY_SINK_TYPE_AUDIO_RAW:
+ signal = SIGNAL_AUDIO_CHANGED;
+ case GST_PLAY_SINK_TYPE_TEXT:
+ signal = SIGNAL_TEXT_CHANGED;
+ default:
+ signal = -1;
+ if (signal >= 0)
+ g_signal_emit (G_OBJECT (playbin), gst_play_bin_signals[signal], 0, NULL);
return;
/* ERRORS */
@@ -1992,6 +2131,8 @@
g_object_set (uridecodebin, "subtitle-encoding", playbin->encoding, NULL);
/* configure uri */
g_object_set (uridecodebin, "uri", group->uri, NULL);
+ g_object_set (uridecodebin, "buffer-time", playbin->buffer_duration, NULL);
+ g_object_set (uridecodebin, "buffer-size", playbin->buffer_size, NULL);
/* connect pads and other things */
g_signal_connect (uridecodebin, "pad-added", G_CALLBACK (pad_added_cb),
Index: gsturidecodebin.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gsturidecodebin.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- gsturidecodebin.c 7 Aug 2008 15:58:58 -0000 1.20
+++ gsturidecodebin.c 24 Nov 2008 20:25:24 -0000 1.21
@@ -74,6 +74,9 @@
gchar *encoding;
gboolean is_stream;
+ guint64 buffer_duration; /* When streaming, buffer duration (ns) */
+ guint buffer_size; /* When streaming, buffer size (bytes) */
GstElement *source;
GstElement *typefind;
guint have_type_id; /* have-type signal id from typefind */
@@ -141,6 +144,8 @@
#define DEFAULT_CONNECTION_SPEED 0
#define DEFAULT_CAPS NULL
#define DEFAULT_SUBTITLE_ENCODING NULL
+#define DEFAULT_BUFFER_DURATION -1
+#define DEFAULT_BUFFER_SIZE -1
@@ -150,6 +155,8 @@
PROP_CONNECTION_SPEED,
PROP_CAPS,
PROP_SUBTITLE_ENCODING,
+ PROP_BUFFER_DURATION,
PROP_LAST
@@ -289,6 +296,17 @@
"ISO-8859-15 will be assumed.", NULL,
+ g_object_class_install_property (gobject_class, PROP_BUFFER_SIZE,
+ g_object_class_install_property (gobject_class, PROP_BUFFER_DURATION,
* GstURIDecodeBin::unknown-type:
* @pad: the new pad containing caps that cannot be resolved to a 'final'
@@ -401,6 +419,9 @@
dec->connection_speed = DEFAULT_CONNECTION_SPEED;
dec->caps = DEFAULT_CAPS;
dec->encoding = g_strdup (DEFAULT_SUBTITLE_ENCODING);
+ dec->buffer_duration = DEFAULT_BUFFER_DURATION;
+ dec->buffer_size = DEFAULT_BUFFER_SIZE;
@@ -465,6 +486,12 @@
case PROP_SUBTITLE_ENCODING:
gst_uri_decode_bin_set_encoding (dec, g_value_get_string (value));
+ dec->buffer_size = g_value_get_int (value);
+ dec->buffer_duration = g_value_get_int64 (value);
@@ -503,6 +530,16 @@
g_value_set_string (value, dec->encoding);
GST_OBJECT_UNLOCK (dec);
+ GST_OBJECT_LOCK (dec);
+ g_value_set_int (value, dec->buffer_size);
+ GST_OBJECT_UNLOCK (dec);
+ g_value_set_int64 (value, dec->buffer_duration);
@@ -1102,6 +1139,17 @@
g_object_set (G_OBJECT (queue), "use-buffering", TRUE, NULL);
// g_object_set (G_OBJECT (queue), "temp-location", "temp", NULL);
+ /* Disable max-size-buffers */
+ g_object_set (G_OBJECT (queue), "max-size-buffers", 0, NULL);
+ /* If buffer size or duration are set, set them on the queue2 element */
+ if (decoder->buffer_size != -1)
+ g_object_set (G_OBJECT (queue), "max-size-bytes",
+ decoder->buffer_size, NULL);
+ if (decoder->buffer_duration != -1)
+ g_object_set (G_OBJECT (queue), "max-size-time",
+ decoder->buffer_duration, NULL);
gst_bin_add (GST_BIN_CAST (decoder), queue);
if (!gst_element_link (typefind, queue))
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.