tsmux: Make sure to set srcpad caps under all conditions before outputting the first...
authorSebastian Dröge <sebastian@centricular.com>
Tue, 17 May 2022 11:15:40 +0000 (14:15 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 18 May 2022 12:19:07 +0000 (12:19 +0000)
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1218

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

subprojects/gst-plugins-bad/gst/mpegtsmux/gstbasetsmux.c

index 11c5acd..880d4d5 100644 (file)
@@ -2319,6 +2319,21 @@ gst_base_ts_mux_aggregate (GstAggregator * agg, gboolean timeout)
   GstBaseTsMux *mux = GST_BASE_TS_MUX (agg);
   GstFlowReturn ret = GST_FLOW_OK;
   GstBaseTsMuxPad *best = gst_base_ts_mux_find_best_pad (agg);
+  GstCaps *caps;
+
+  /* set caps on the srcpad if no caps were set yet */
+  if (!(caps = gst_pad_get_current_caps (agg->srcpad))) {
+    GstStructure *structure;
+
+    caps = gst_pad_get_pad_template_caps (GST_AGGREGATOR_SRC_PAD (mux));
+    caps = gst_caps_make_writable (caps);
+    structure = gst_caps_get_structure (caps, 0);
+    gst_structure_set (structure, "packetsize", G_TYPE_INT, mux->packet_size,
+        NULL);
+
+    gst_aggregator_set_src_caps (GST_AGGREGATOR (mux), caps);
+  }
+  gst_caps_unref (caps);
 
   if (best) {
     GstBuffer *buffer;