playbin: add current-*uri properties

Make the uri property getter return the next uri, like it was configured in the
setter.
Make a new current-uri and current-suburi property that reflects the currently
playing uri and suburi.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=676665
This commit is contained in:
Wim Taymans 2012-05-25 15:12:53 +02:00
parent 9c29cd70ee
commit 29d24d4658
2 changed files with 84 additions and 0 deletions

View file

@ -482,7 +482,9 @@ enum
{
PROP_0,
PROP_URI,
PROP_CURRENT_URI,
PROP_SUBURI,
PROP_CURRENT_SUBURI,
PROP_SOURCE,
PROP_FLAGS,
PROP_N_VIDEO,
@ -663,6 +665,16 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
g_param_spec_string ("uri", "URI", "URI of the media to play",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPlayBin:current-uri
*
* The currently playing uri.
*/
g_object_class_install_property (gobject_klass, PROP_CURRENT_URI,
g_param_spec_string ("current-uri", "Current URI",
"The currently playing URI", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstPlayBin:suburi
*
@ -673,6 +685,16 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
g_param_spec_string ("suburi", ".sub-URI", "Optional URI of a subtitle",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPlayBin:current-suburi
*
* The currently playing subtitle uri.
*/
g_object_class_install_property (gobject_klass, PROP_CURRENT_SUBURI,
g_param_spec_string ("current-suburi", "Current .sub-URI",
"The currently playing URI of a subtitle",
NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_klass, PROP_SOURCE,
g_param_spec_object ("source", "Source", "Source element",
GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
@ -2067,6 +2089,17 @@ gst_play_bin_get_property (GObject * object, guint prop_id, GValue * value,
{
GstSourceGroup *group;
GST_PLAY_BIN_LOCK (playbin);
group = playbin->next_group;
g_value_set_string (value, group->uri);
GST_PLAY_BIN_UNLOCK (playbin);
break;
break;
}
case PROP_CURRENT_URI:
{
GstSourceGroup *group;
GST_PLAY_BIN_LOCK (playbin);
group = get_group (playbin);
g_value_set_string (value, group->uri);
@ -2077,6 +2110,16 @@ gst_play_bin_get_property (GObject * object, guint prop_id, GValue * value,
{
GstSourceGroup *group;
GST_PLAY_BIN_LOCK (playbin);
group = playbin->next_group;
g_value_set_string (value, group->suburi);
GST_PLAY_BIN_UNLOCK (playbin);
break;
}
case PROP_CURRENT_SUBURI:
{
GstSourceGroup *group;
GST_PLAY_BIN_LOCK (playbin);
group = get_group (playbin);
g_value_set_string (value, group->suburi);

View file

@ -35,6 +35,46 @@
static GType gst_red_video_src_get_type (void);
static GType gst_codec_src_get_type (void);
GST_START_TEST (test_uri)
{
GstElement *playbin, *fakesink;
gchar *uri;
fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
gst_red_video_src_get_type ()));
playbin = gst_element_factory_make ("playbin", "playbin");
fail_unless (playbin != NULL, "Failed to create playbin element");
fakesink = gst_element_factory_make ("fakesink", "fakesink");
fail_unless (fakesink != NULL, "Failed to create fakesink element");
g_object_set (playbin, "video-sink", fakesink, NULL);
g_object_set (playbin, "uri", "redvideo://", NULL);
g_object_get (playbin, "uri", &uri, NULL);
fail_unless_equals_string (uri, "redvideo://");
g_object_get (playbin, "current-uri", &uri, NULL);
fail_unless_equals_string (uri, NULL);
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
GST_STATE_CHANGE_ASYNC);
fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL, -1),
GST_STATE_CHANGE_SUCCESS);
g_object_get (playbin, "uri", &uri, NULL);
fail_unless_equals_string (uri, NULL);
g_object_get (playbin, "current-uri", &uri, NULL);
fail_unless_equals_string (uri, "redvideo://");
gst_element_set_state (playbin, GST_STATE_NULL);
gst_object_unref (playbin);
}
GST_END_TEST;
/* make sure the audio sink is not touched for video-only streams */
GST_START_TEST (test_sink_usage_video_only_stream)
{
@ -736,6 +776,7 @@ playbin_suite (void)
suite_add_tcase (s, tc_chain);
#ifndef GST_DISABLE_REGISTRY
tcase_add_test (tc_chain, test_uri);
tcase_add_test (tc_chain, test_sink_usage_video_only_stream);
tcase_add_test (tc_chain, test_suburi_error_wrongproto);
tcase_add_test (tc_chain, test_suburi_error_invalidfile);