rtph264pay: ensure output caps are set when pushing output data
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Mon, 26 Mar 2012 16:24:08 +0000 (18:24 +0200)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Mon, 26 Mar 2012 16:38:34 +0000 (18:38 +0200)
... even if some SPS/PPS has not passed by yet.

gst/rtp/gstrtph264pay.c

index ede5701..c304f5f 100644 (file)
@@ -427,13 +427,17 @@ gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
     count++;
   }
 
-  /* profile is 24 bit. Force it to respect the limit */
-  profile = g_strdup_printf ("%06x", payloader->profile & 0xffffff);
-  /* combine into output caps */
-  res = gst_rtp_base_payload_set_outcaps (basepayload,
-      "sprop-parameter-sets", G_TYPE_STRING, sprops->str, NULL);
+  if (G_LIKELY (count)) {
+    /* profile is 24 bit. Force it to respect the limit */
+    profile = g_strdup_printf ("%06x", payloader->profile & 0xffffff);
+    /* combine into output caps */
+    res = gst_rtp_base_payload_set_outcaps (basepayload,
+        "sprop-parameter-sets", G_TYPE_STRING, sprops->str, NULL);
+    g_free (profile);
+  } else {
+    res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
+  }
   g_string_free (sprops, TRUE);
-  g_free (profile);
 
   return res;
 }
@@ -879,6 +883,12 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
   nalType = data[0] & 0x1f;
   GST_DEBUG_OBJECT (rtph264pay, "Processing Buffer with NAL TYPE=%d", nalType);
 
+  /* should set src caps before pushing stuff,
+   * and if we did not see enough SPS/PPS, that may not be the case */
+  if (G_UNLIKELY (!gst_pad_has_current_caps (GST_RTP_BASE_PAYLOAD_SRCPAD
+              (basepayload))))
+    gst_rtp_h264_pay_set_sps_pps (basepayload);
+
   send_spspps = FALSE;
 
   /* check if we need to emit an SPS/PPS now */