From 14031f1c638630c9b541022fabef08a658c285d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 4 Sep 2018 11:55:03 +0300 Subject: [PATCH] discoverer: Consider closedcaption/ as subtitles and improve subtitle caps detection Generally all subtitle/, subpicture/, text/, closedcaption/ and application/x-subtitle caps instead of hardcoding a small set of caps. https://bugzilla.gnome.org/show_bug.cgi?id=797072 --- gst-libs/gst/pbutils/gstdiscoverer.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/pbutils/gstdiscoverer.c b/gst-libs/gst/pbutils/gstdiscoverer.c index b15b522447..da2745034b 100644 --- a/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/gst-libs/gst/pbutils/gstdiscoverer.c @@ -544,17 +544,30 @@ _event_probe (GstPad * pad, GstPadProbeInfo * info, PrivateStream * ps) return GST_PAD_PROBE_OK; } -static GstStaticCaps subtitle_caps = GST_STATIC_CAPS ("text/x-raw; " - "subpicture/x-pgs; subpicture/x-dvb; subpicture/x-dvd; " - "application/x-subtitle-unknown; application/x-ssa; application/x-ass; " - "subtitle/x-kate; application/x-kate; subpicture/x-xsub"); +static GstStaticCaps subtitle_caps = + GST_STATIC_CAPS + ("application/x-ssa; application/x-ass; application/x-kate"); static gboolean is_subtitle_caps (const GstCaps * caps) { GstCaps *subs_caps; + GstStructure *s; + const gchar *name; gboolean ret; + s = gst_caps_get_structure (caps, 0); + if (!s) + return FALSE; + + name = gst_structure_get_name (s); + if (g_str_has_prefix (name, "text/") || + g_str_has_prefix (name, "subpicture/") || + g_str_has_prefix (name, "subtitle/") || + g_str_has_prefix (name, "closedcaption/") || + g_str_has_prefix (name, "application/x-subtitle")) + return TRUE; + subs_caps = gst_static_caps_get (&subtitle_caps); ret = gst_caps_can_intersect (caps, subs_caps); gst_caps_unref (subs_caps);