playsink: only compare against the media type we expect

ie, audio/x-raw- for audio, video/x-raw- for video.

Add a trailing - to be more specific. I doubt there's anything
like audio/x-rawhide or something, but you never know.

https://bugzilla.gnome.org/show_bug.cgi?id=661262
This commit is contained in:
Vincent Penquerc'h 2011-10-17 17:29:50 +00:00 committed by Sebastian Dröge
parent fd27e34582
commit 69d98d08c1

View file

@ -45,18 +45,18 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS_ANY); GST_STATIC_CAPS_ANY);
static gboolean static gboolean
is_raw_caps (GstCaps * caps) is_raw_caps (GstCaps * caps, gboolean audio)
{ {
gint i, n; gint i, n;
GstStructure *s; GstStructure *s;
const gchar *name; const gchar *name;
const gchar *prefix = audio ? "audio/x-raw-" : "video/x-raw-";
n = gst_caps_get_size (caps); n = gst_caps_get_size (caps);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
s = gst_caps_get_structure (caps, i); s = gst_caps_get_structure (caps, i);
name = gst_structure_get_name (s); name = gst_structure_get_name (s);
if (!g_str_has_prefix (name, "audio/x-raw") if (!g_str_has_prefix (name, prefix))
&& !g_str_has_prefix (name, "video/x-raw"))
return FALSE; return FALSE;
} }
@ -200,7 +200,7 @@ pad_blocked_cb (GstPad * pad, gboolean blocked, GstPlaySinkConvertBin * self)
caps = gst_pad_get_caps_reffed (peer); caps = gst_pad_get_caps_reffed (peer);
gst_object_unref (peer); gst_object_unref (peer);
raw = is_raw_caps (caps); raw = is_raw_caps (caps, self->audio);
GST_DEBUG_OBJECT (self, "Caps %" GST_PTR_FORMAT " are raw: %d", caps, raw); GST_DEBUG_OBJECT (self, "Caps %" GST_PTR_FORMAT " are raw: %d", caps, raw);
gst_caps_unref (caps); gst_caps_unref (caps);