From e5ab3cc0a0d35652b987aae43f9f409b222a7498 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Mon, 26 Mar 2012 18:24:08 +0200 Subject: [PATCH] rtph264pay: ensure output caps are set when pushing output data ... even if some SPS/PPS has not passed by yet. --- gst/rtp/gstrtph264pay.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c index ede5701b57..c304f5f9ea 100644 --- a/gst/rtp/gstrtph264pay.c +++ b/gst/rtp/gstrtph264pay.c @@ -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 */