shout2: advertise documentation caps properly
authorTim-Philipp Müller <tim@centricular.com>
Fri, 19 Jun 2020 09:32:45 +0000 (10:32 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 19 Jun 2020 09:32:45 +0000 (10:32 +0100)
shout2send caps depend on what the libshout2
version in question supports, but the
documentation caps should always be the same.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/635>

docs/gst_plugins_cache.json
ext/shout2/gstshout2.c

index a630651..792664c 100644 (file)
                 "long-name": "Icecast network sink",
                 "pad-templates": {
                     "sink": {
-                        "caps": "application/ogg:\naudio/ogg:\nvideo/ogg:\naudio/mpeg:\n    mpegversion: 1\n          layer: [ 1, 3 ]\n",
+                        "caps": "application/ogg:\naudio/ogg:\nvideo/ogg:\naudio/mpeg:\n    mpegversion: 1\n          layer: [ 1, 3 ]\nvideo/webm:\naudio/webm:\n",
                         "direction": "sink",
                         "presence": "always"
                     }
index 6acf2e8..b301bc8 100644 (file)
@@ -94,11 +94,18 @@ enum
 #else
 #define WEBM_CAPS ""
 #endif
+
+#define SHOUT2SEND_BASIC_CAPS "application/ogg; audio/ogg; video/ogg; "\
+    "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]"
+
+#define SHOUT2SEND_DOC_CAPS SHOUT2SEND_BASIC_CAPS "; video/webm; audio/webm"
+
+#define SHOUT2SEND_CAPS SHOUT2SEND_BASIC_CAPS WEBM_CAPS
+
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("application/ogg; audio/ogg; video/ogg; "
-        "audio/mpeg, mpegversion = (int) 1, layer = (int) [ 1, 3 ]" WEBM_CAPS));
+    GST_STATIC_CAPS (SHOUT2SEND_CAPS));
 
 static void gst_shout2send_finalize (GstShout2send * shout2send);
 
@@ -151,6 +158,8 @@ gst_shout2send_class_init (GstShout2sendClass * klass)
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
   GstBaseSinkClass *gstbasesink_class;
+  GstPadTemplate *tmpl;
+  GstCaps *doc_caps;
 
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
@@ -231,7 +240,13 @@ gst_shout2send_class_init (GstShout2sendClass * klass)
   gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_shout2send_event);
   gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_shout2send_setcaps);
 
-  gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
+  tmpl = gst_static_pad_template_get (&sink_template);
+  gst_element_class_add_pad_template (gstelement_class, tmpl);
+
+  /* our caps depend on the libshout2 version */
+  doc_caps = gst_caps_from_string (SHOUT2SEND_DOC_CAPS);
+  gst_pad_template_set_documentation_caps (tmpl, doc_caps);
+  gst_clear_caps (&doc_caps);
 
   gst_element_class_set_static_metadata (gstelement_class,
       "Icecast network sink",