From 092465e94d9577a1f5d4807b7a013e97908d5ed6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Mon, 18 Jul 2016 19:18:58 -0400 Subject: [PATCH] rtpmp4adepay: Only declare a stream to be framed once a marker bit has been seen This may cause a few packets to be processed by the parser, but it's better than never pushing out buffers from a slightly broken stream where no marker bits are set. --- gst/rtp/gstrtpmp4adepay.c | 27 +++++++++++++++++++++++++-- gst/rtp/gstrtpmp4adepay.h | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gst/rtp/gstrtpmp4adepay.c b/gst/rtp/gstrtpmp4adepay.c index 0f50523269..5a5f341240 100644 --- a/gst/rtp/gstrtpmp4adepay.c +++ b/gst/rtp/gstrtpmp4adepay.c @@ -37,7 +37,7 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/mpeg," - "mpegversion = (int) 4," "framed = (boolean) true, " + "mpegversion = (int) 4," "framed = (boolean) { false, true }, " "stream-format = (string) raw") ); @@ -109,6 +109,7 @@ static void gst_rtp_mp4a_depay_init (GstRtpMP4ADepay * rtpmp4adepay) { rtpmp4adepay->adapter = gst_adapter_new (); + rtpmp4adepay->framed = FALSE; } static void @@ -142,6 +143,8 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) rtpmp4adepay = GST_RTP_MP4A_DEPAY (depayload); + rtpmp4adepay->framed = FALSE; + structure = gst_caps_get_structure (caps, 0); if (!gst_structure_get_int (structure, "clock-rate", &clock_rate)) @@ -153,7 +156,7 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) srccaps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 4, - "framed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, channels, + "framed", G_TYPE_BOOLEAN, FALSE, "channels", G_TYPE_INT, channels, "stream-format", G_TYPE_STRING, "raw", NULL); if ((str = gst_structure_get_string (structure, "config"))) { @@ -310,6 +313,25 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) outbuf = gst_rtp_buffer_get_payload_buffer (rtp); + if (!rtpmp4adepay->framed) { + if (gst_rtp_buffer_get_marker (rtp)) { + GstCaps *caps; + + rtpmp4adepay->framed = TRUE; + + gst_rtp_base_depayload_push (depayload, outbuf); + + caps = gst_pad_get_current_caps (depayload->srcpad); + caps = gst_caps_make_writable (caps); + gst_caps_set_simple (caps, "framed", G_TYPE_BOOLEAN, TRUE, NULL); + gst_pad_set_caps (depayload->srcpad, caps); + gst_caps_unref (caps); + return NULL; + } else { + return outbuf; + } + } + outbuf = gst_buffer_make_writable (outbuf); GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (rtp->buffer); gst_adapter_push (rtpmp4adepay->adapter, outbuf); @@ -422,6 +444,7 @@ gst_rtp_mp4a_depay_change_state (GstElement * element, gst_adapter_clear (rtpmp4adepay->adapter); rtpmp4adepay->frame_len = 0; rtpmp4adepay->numSubFrames = 0; + rtpmp4adepay->framed = FALSE; break; default: break; diff --git a/gst/rtp/gstrtpmp4adepay.h b/gst/rtp/gstrtpmp4adepay.h index b44349f8d0..31eaf560ed 100644 --- a/gst/rtp/gstrtpmp4adepay.h +++ b/gst/rtp/gstrtpmp4adepay.h @@ -45,6 +45,8 @@ struct _GstRtpMP4ADepay GstAdapter *adapter; guint8 numSubFrames; guint frame_len; + + gboolean framed; }; struct _GstRtpMP4ADepayClass -- 2.34.1