parsebin: Use pbutils utils to identify more stream types
authorEdward Hervey <edward@centricular.com>
Tue, 20 Feb 2024 15:02:25 +0000 (16:02 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 22 Feb 2024 14:39:54 +0000 (14:39 +0000)
Handles all cases provided they are identified in the pbutils descriptions
list.

Fixes #1081

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6153>

subprojects/gst-plugins-base/gst/playback/gstparsebin.c

index 2440395c9a3bdee2db0aaaf1c006e4fcce2c3548..defacb665f5855975ae1d411c0bbf8608f6bc8ff 100644 (file)
@@ -3971,6 +3971,7 @@ guess_stream_type_from_caps (GstCaps * caps)
 {
   GstStructure *s;
   const gchar *name;
+  GstPbUtilsCapsDescriptionFlags desc;
 
   if (gst_caps_get_size (caps) < 1)
     return GST_STREAM_TYPE_UNKNOWN;
@@ -3993,7 +3994,19 @@ guess_stream_type_from_caps (GstCaps * caps)
       g_str_has_prefix (name, "closedcaption/"))
     return GST_STREAM_TYPE_TEXT;
 
-  return GST_STREAM_TYPE_UNKNOWN;
+  /* Use information from pbutils. Note that we only care about elementary
+   * streams which is why we check flag equality */
+  desc = gst_pb_utils_get_caps_description_flags (caps);
+  switch (desc) {
+    case GST_PBUTILS_CAPS_DESCRIPTION_FLAG_AUDIO:
+      return GST_STREAM_TYPE_AUDIO;
+    case GST_PBUTILS_CAPS_DESCRIPTION_FLAG_VIDEO:
+      return GST_STREAM_TYPE_VIDEO;
+    case GST_PBUTILS_CAPS_DESCRIPTION_FLAG_SUBTITLE:
+      return GST_STREAM_TYPE_TEXT;
+    default:
+      return GST_STREAM_TYPE_UNKNOWN;
+  }
 }
 
 static void