rtpmp4gdepay: factor out pushing of output buffer

This commit is contained in:
Tim-Philipp Müller 2018-09-21 18:17:25 +01:00
parent d51139ad16
commit f255ea99f4

View file

@ -324,11 +324,31 @@ gst_rtp_mp4g_depay_reset (GstRtpMP4GDepay * rtpmp4gdepay)
gst_rtp_mp4g_depay_clear_queue (rtpmp4gdepay); gst_rtp_mp4g_depay_clear_queue (rtpmp4gdepay);
} }
static void
gst_rtp_mp4g_depay_push_outbuf (GstRtpMP4GDepay * rtpmp4gdepay,
GstBuffer * outbuf, guint AU_index)
{
gboolean discont = FALSE;
if (AU_index != rtpmp4gdepay->next_AU_index) {
GST_DEBUG_OBJECT (rtpmp4gdepay, "discont, expected AU_index %u",
rtpmp4gdepay->next_AU_index);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
discont = TRUE;
}
GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing %sAU_index %u",
discont ? "" : "expected ", AU_index);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0);
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
rtpmp4gdepay->next_AU_index = AU_index + 1;
}
static void static void
gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay) gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
{ {
GstBuffer *outbuf; GstBuffer *outbuf;
gboolean discont = FALSE;
guint AU_index; guint AU_index;
while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets))) { while ((outbuf = g_queue_pop_head (rtpmp4gdepay->packets))) {
@ -336,21 +356,7 @@ gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index); GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
if (rtpmp4gdepay->next_AU_index != AU_index) { gst_rtp_mp4g_depay_push_outbuf (rtpmp4gdepay, outbuf, AU_index);
GST_DEBUG_OBJECT (rtpmp4gdepay, "discont, expected AU_index %u",
rtpmp4gdepay->next_AU_index);
discont = TRUE;
}
if (discont) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
discont = FALSE;
}
GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0);
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
rtpmp4gdepay->next_AU_index = AU_index + 1;
} }
} }
@ -369,9 +375,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
/* we received the expected packet, push it and flush as much as we can from /* we received the expected packet, push it and flush as much as we can from
* the queue */ * the queue */
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0); gst_rtp_mp4g_depay_push_outbuf (rtpmp4gdepay, outbuf, AU_index);
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
rtpmp4gdepay->next_AU_index++;
while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) { while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) {
AU_index = GST_BUFFER_OFFSET (outbuf); AU_index = GST_BUFFER_OFFSET (outbuf);
@ -379,13 +383,8 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index); GST_DEBUG_OBJECT (rtpmp4gdepay, "next available AU_index %u", AU_index);
if (rtpmp4gdepay->next_AU_index == AU_index) { if (rtpmp4gdepay->next_AU_index == AU_index) {
GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u",
AU_index);
outbuf = g_queue_pop_head (rtpmp4gdepay->packets); outbuf = g_queue_pop_head (rtpmp4gdepay->packets);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0); gst_rtp_mp4g_depay_push_outbuf (rtpmp4gdepay, outbuf, AU_index);
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay),
outbuf);
rtpmp4gdepay->next_AU_index++;
} else { } else {
GST_DEBUG_OBJECT (rtpmp4gdepay, "waiting for next AU_index %u", GST_DEBUG_OBJECT (rtpmp4gdepay, "waiting for next AU_index %u",
rtpmp4gdepay->next_AU_index); rtpmp4gdepay->next_AU_index);