diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index 2c3ebdc..441ce2a 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -235,7 +235,9 @@ #include "gstscreenshot.h" #include "gstinputselector.h" #include "gstsubtitleoverlay.h" +#include "gstrawcaps.h" +static GstStaticCaps default_raw_caps = GST_STATIC_CAPS (DEFAULT_RAW_CAPS); GST_DEBUG_CATEGORY_STATIC (gst_play_bin_debug); #define GST_CAT_DEFAULT gst_play_bin_debug @@ -362,6 +364,7 @@ struct _GstPlayBin GstPipeline parent; GMutex *lock; /* to protect group switching */ + GstCaps *caps; /* the groups, we use a double buffer to switch between current and next */ GstSourceGroup groups[2]; /* array with group info */ @@ -446,6 +449,7 @@ struct _GstPlayBinClass #define DEFAULT_URI NULL #define DEFAULT_SUBURI NULL #define DEFAULT_SOURCE NULL +#define DEFAULT_CAPS (gst_static_caps_get (&default_raw_caps)) #define DEFAULT_FLAGS GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_TEXT | \ GST_PLAY_FLAG_SOFT_VOLUME #define DEFAULT_N_VIDEO 0 @@ -473,6 +477,7 @@ enum PROP_URI, PROP_SUBURI, PROP_SOURCE, + PROP_CAPS, PROP_FLAGS, PROP_N_VIDEO, PROP_CURRENT_VIDEO, @@ -640,6 +645,11 @@ gst_play_bin_class_init (GstPlayBinClass * klass) g_param_spec_object ("source", "Source", "Source element", GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_klass, PROP_CAPS, + g_param_spec_boxed ("caps", "Caps", + "The caps on which to stop decoding. (NULL = default)", + GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** * GstPlayBin2:flags * @@ -1142,6 +1152,7 @@ gst_play_bin_init (GstPlayBin * playbin) /* assume we can create a selector */ playbin->have_selector = TRUE; + playbin->caps = DEFAULT_CAPS; /* init groups */ playbin->curr_group = &playbin->groups[0]; @@ -1723,6 +1734,46 @@ gst_play_bin_set_encoding (GstPlayBin * playbin, const gchar * encoding) GST_PLAY_BIN_UNLOCK (playbin); } +/* _set_caps + * Changes the caps on which decodebin will stop decoding. + * Will unref the previously set one. The refcount of the given caps will be + * increased. + * @caps can be NULL. + * + * MT-safe + */ +static void +gst_play_bin_set_caps (GstPlayBin * playbin, GstCaps * caps) +{ + GST_DEBUG_OBJECT (playbin, "Setting new caps: %" GST_PTR_FORMAT, caps); + + GST_OBJECT_LOCK (playbin); + gst_caps_replace (&playbin->caps, caps); + GST_OBJECT_UNLOCK (playbin); +} + +/* _get_caps + * Returns the currently configured caps on which decodebin will stop decoding. + * The returned caps (if not NULL), will have its refcount incremented. + * + * MT-safe + */ +static GstCaps * +gst_play_bin_get_caps (GstPlayBin * playbin) +{ + GstCaps *caps; + + GST_DEBUG_OBJECT (playbin, "Getting currently set caps"); + + GST_OBJECT_LOCK (playbin); + caps = playbin->caps; + if (caps) + gst_caps_ref (caps); + GST_OBJECT_UNLOCK (playbin); + + return caps; +} + static void gst_play_bin_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -1736,6 +1787,9 @@ gst_play_bin_set_property (GObject * object, guint prop_id, case PROP_SUBURI: gst_play_bin_set_suburi (playbin, g_value_get_string (value)); break; + case PROP_CAPS: + gst_play_bin_set_caps (playbin, g_value_get_boxed (value)); + break; case PROP_FLAGS: gst_play_bin_set_flags (playbin, g_value_get_flags (value)); break; @@ -1852,6 +1906,10 @@ gst_play_bin_get_property (GObject * object, guint prop_id, GValue * value, GST_OBJECT_UNLOCK (playbin); break; } + case PROP_CAPS: + g_value_take_boxed (value, gst_play_bin_get_caps (playbin)); + break; + case PROP_FLAGS: g_value_set_flags (value, gst_play_bin_get_flags (playbin)); break; @@ -3175,6 +3233,9 @@ activate_group (GstPlayBin * playbin, GstSourceGroup * group, GstState target) goto no_decodebin; gst_bin_add (GST_BIN_CAST (playbin), uridecodebin); group->uridecodebin = gst_object_ref (uridecodebin); + if(playbin->caps) { + g_object_set(uridecodebin, "caps", playbin->caps, NULL); + } } /* configure connection speed */