closedcaption: Use new API for converting GstVideoCaptionType from/to GstCaps
authorSebastian Dröge <sebastian@centricular.com>
Tue, 11 Dec 2018 12:12:13 +0000 (14:12 +0200)
committerSebastian Dröge <slomo@coaxion.net>
Sat, 15 Dec 2018 21:31:28 +0000 (21:31 +0000)
ext/closedcaption/gstcccombiner.c
ext/closedcaption/gstccextractor.c

index dd11920..4e6760e 100644 (file)
@@ -347,28 +347,7 @@ gst_cc_combiner_sink_event (GstAggregator * aggregator,
       s = gst_caps_get_structure (caps, 0);
 
       if (strcmp (GST_OBJECT_NAME (agg_pad), "caption") == 0) {
-        const gchar *format;
-
-        format = gst_structure_get_string (s, "format");
-        if (gst_structure_has_name (s, "closedcaption/x-cea-608")) {
-          if (strcmp (format, "raw") == 0) {
-            self->current_caption_type = GST_VIDEO_CAPTION_TYPE_CEA608_RAW;
-          } else if (strcmp (format, "s334-1a") == 0) {
-            self->current_caption_type = GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A;
-          } else {
-            g_assert_not_reached ();
-          }
-        } else if (gst_structure_has_name (s, "closedcaption/x-cea-708")) {
-          if (strcmp (format, "cc_data") == 0) {
-            self->current_caption_type = GST_VIDEO_CAPTION_TYPE_CEA708_RAW;
-          } else if (strcmp (format, "cdp") == 0) {
-            self->current_caption_type = GST_VIDEO_CAPTION_TYPE_CEA708_CDP;
-          } else {
-            g_assert_not_reached ();
-          }
-        } else {
-          g_assert_not_reached ();
-        }
+        self->current_caption_type = gst_video_caption_type_from_caps (caps);
       } else {
         if (!gst_structure_get_fraction (s, "framerate", &self->video_fps_n,
                 &self->video_fps_d))
index b18cfab..d693e18 100644 (file)
@@ -277,27 +277,7 @@ static GstCaps *
 create_caps_from_caption_type (GstVideoCaptionType caption_type,
     const GstVideoInfo * video_info)
 {
-  GstCaps *caption_caps = NULL;
-
-  switch (caption_type) {
-    case GST_VIDEO_CAPTION_TYPE_CEA608_RAW:
-      caption_caps = gst_caps_new_simple ("closedcaption/x-cea-608",
-          "format", G_TYPE_STRING, "raw", NULL);
-      break;
-    case GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A:
-      caption_caps = gst_caps_new_simple ("closedcaption/x-cea-608",
-          "format", G_TYPE_STRING, "s334-1a", NULL);
-      break;
-    case GST_VIDEO_CAPTION_TYPE_CEA708_RAW:
-      caption_caps = gst_caps_new_simple ("closedcaption/x-cea-708",
-          "format", G_TYPE_STRING, "cc_data", NULL);
-      break;
-    case GST_VIDEO_CAPTION_TYPE_CEA708_CDP:
-      caption_caps = gst_caps_new_simple ("closedcaption/x-cea-708",
-          "format", G_TYPE_STRING, "cdp", NULL);
-    default:
-      break;
-  }
+  GstCaps *caption_caps = gst_video_caption_type_to_caps (caption_type);
 
   gst_caps_set_simple (caption_caps, "framerate", GST_TYPE_FRACTION,
       video_info->fps_n, video_info->fps_d, NULL);