playbin2: uridecodebin: add property to configure ring buffer size

This commit is contained in:
Robert Swain 2010-06-17 09:10:11 +02:00 committed by Wim Taymans
parent f70587e802
commit 268270d35e
2 changed files with 59 additions and 2 deletions

View file

@ -402,6 +402,8 @@ struct _GstPlayBin
GstFormat format;
gint64 duration;
} duration[5]; /* cached durations */
guint64 ring_buffer_max_size; /* 0 means disabled */
};
struct _GstPlayBinClass
@ -460,6 +462,7 @@ struct _GstPlayBinClass
#define DEFAULT_CONNECTION_SPEED 0
#define DEFAULT_BUFFER_DURATION -1
#define DEFAULT_BUFFER_SIZE -1
#define DEFAULT_RING_BUFFER_MAX_SIZE 0
enum
{
@ -487,6 +490,7 @@ enum
PROP_BUFFER_SIZE,
PROP_BUFFER_DURATION,
PROP_AV_OFFSET,
PROP_RING_BUFFER_MAX_SIZE,
PROP_LAST
};
@ -792,6 +796,21 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
G_MININT64, G_MAXINT64, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstQueue2:ring-buffer-max-size
*
* The maximum size of the ring buffer in bytes. If set to 0, the ring
* buffer is disabled. Default 0.
*
* Since: 0.10.31
*/
g_object_class_install_property (gobject_klass, PROP_RING_BUFFER_MAX_SIZE,
g_param_spec_uint64 ("ring-buffer-max-size",
"Max. ring buffer size (bytes)",
"Max. amount of data in the ring buffer (bytes, 0 = ring buffer disabled)",
0, G_MAXUINT, DEFAULT_RING_BUFFER_MAX_SIZE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPlayBin2::about-to-finish
* @playbin: a #GstPlayBin2
@ -1164,6 +1183,7 @@ gst_play_bin_init (GstPlayBin * playbin)
playbin->buffer_duration = DEFAULT_BUFFER_DURATION;
playbin->buffer_size = DEFAULT_BUFFER_SIZE;
playbin->ring_buffer_max_size = DEFAULT_RING_BUFFER_MAX_SIZE;
}
static void
@ -1786,6 +1806,9 @@ gst_play_bin_set_property (GObject * object, guint prop_id,
gst_play_sink_set_av_offset (playbin->playsink,
g_value_get_int64 (value));
break;
case PROP_RING_BUFFER_MAX_SIZE:
playbin->ring_buffer_max_size = g_value_get_uint64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1958,6 +1981,9 @@ gst_play_bin_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_int64 (value,
gst_play_sink_get_av_offset (playbin->playsink));
break;
case PROP_RING_BUFFER_MAX_SIZE:
g_value_set_uint64 (value, playbin->ring_buffer_max_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -2822,8 +2848,8 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps,
GstPad *text_sinkpad = NULL;
text_sink =
(group->playbin->text_sink) ? gst_object_ref (group->playbin->
text_sink) : NULL;
(group->playbin->text_sink) ? gst_object_ref (group->
playbin->text_sink) : NULL;
if (text_sink)
text_sinkpad = gst_element_get_static_pad (text_sink, "sink");
@ -3057,6 +3083,8 @@ activate_group (GstPlayBin * playbin, GstSourceGroup * group, GstState target)
g_object_set (uridecodebin, "buffer-duration", playbin->buffer_duration,
NULL);
g_object_set (uridecodebin, "buffer-size", playbin->buffer_size, NULL);
g_object_set (uridecodebin, "ring-buffer-max-size",
playbin->ring_buffer_max_size, NULL);
/* connect pads and other things */
group->pad_added_id = g_signal_connect (uridecodebin, "pad-added",

View file

@ -103,6 +103,8 @@ struct _GstURIDecodeBin
gboolean async_pending; /* async-start has been emited */
gboolean expose_allstreams; /* Whether to expose unknow type streams or not */
guint64 ring_buffer_max_size; /* 0 means disabled */
};
struct _GstURIDecodeBinClass
@ -158,6 +160,7 @@ enum
#define DEFAULT_DOWNLOAD FALSE
#define DEFAULT_USE_BUFFERING FALSE
#define DEFAULT_EXPOSE_ALL_STREAMS TRUE
#define DEFAULT_RING_BUFFER_MAX_SIZE 0
enum
{
@ -172,6 +175,7 @@ enum
PROP_DOWNLOAD,
PROP_USE_BUFFERING,
PROP_EXPOSE_ALL_STREAMS,
PROP_RING_BUFFER_MAX_SIZE,
PROP_LAST
};
@ -385,6 +389,22 @@ gst_uri_decode_bin_class_init (GstURIDecodeBinClass * klass)
"Expose all streams, including those of unknown type or that don't match the 'caps' property",
DEFAULT_EXPOSE_ALL_STREAMS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstQueue2:ring-buffer-max-size
*
* The maximum size of the ring buffer in kilobytes. If set to 0, the ring
* buffer is disabled. Default is 0.
*
* Since: 0.10.31
*/
g_object_class_install_property (gobject_class, PROP_RING_BUFFER_MAX_SIZE,
g_param_spec_uint64 ("ring-buffer-max-size",
"Max. ring buffer size (bytes)",
"Max. amount of data in the ring buffer (bytes, 0 = ring buffer disabled)",
0, G_MAXUINT, DEFAULT_RING_BUFFER_MAX_SIZE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstURIDecodeBin::unknown-type:
* @bin: The uridecodebin
@ -524,6 +544,7 @@ gst_uri_decode_bin_init (GstURIDecodeBin * dec, GstURIDecodeBinClass * klass)
dec->download = DEFAULT_DOWNLOAD;
dec->use_buffering = DEFAULT_USE_BUFFERING;
dec->expose_allstreams = DEFAULT_EXPOSE_ALL_STREAMS;
dec->ring_buffer_max_size = DEFAULT_RING_BUFFER_MAX_SIZE;
}
static void
@ -609,6 +630,9 @@ gst_uri_decode_bin_set_property (GObject * object, guint prop_id,
case PROP_EXPOSE_ALL_STREAMS:
dec->expose_allstreams = g_value_get_boolean (value);
break;
case PROP_RING_BUFFER_MAX_SIZE:
dec->ring_buffer_max_size = g_value_get_uint64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -666,6 +690,9 @@ gst_uri_decode_bin_get_property (GObject * object, guint prop_id,
case PROP_EXPOSE_ALL_STREAMS:
g_value_set_boolean (value, dec->expose_allstreams);
break;
case PROP_RING_BUFFER_MAX_SIZE:
g_value_set_uint64 (value, dec->ring_buffer_max_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1461,6 +1488,8 @@ type_found (GstElement * typefind, guint probability,
goto no_queue2;
g_object_set (queue, "use-buffering", TRUE, NULL);
g_object_set (queue, "ring-buffer-max-size", decoder->ring_buffer_max_size,
NULL);
GST_DEBUG_OBJECT (decoder, "check media-type %s, %d", media_type,
decoder->download);