From 65b01d5f02ade1c1b79aeb87a7a28a8a3e0d20a2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 18 Dec 2018 12:50:40 -0500 Subject: [PATCH] rtph265depay: Factor out the code that push This will be needed to implement draining on EOS. --- gst/rtp/gstrtph265depay.c | 54 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/gst/rtp/gstrtph265depay.c b/gst/rtp/gstrtph265depay.c index 4832b9d82b..812b847ca5 100644 --- a/gst/rtp/gstrtph265depay.c +++ b/gst/rtp/gstrtph265depay.c @@ -1057,6 +1057,35 @@ gst_rtp_h265_complete_au (GstRtpH265Depay * rtph265depay, #define NAL_TYPE_IS_KEY(nt) (NAL_TYPE_IS_PARAMETER_SET(nt) || NAL_TYPE_IS_IRAP(nt)) +static void +gst_rtp_h265_depay_push (GstRtpH265Depay * rtph265depay, GstBuffer * outbuf, + gboolean keyframe, GstClockTime timestamp, gboolean marker) +{ + /* prepend codec_data */ + if (rtph265depay->codec_data) { + GST_DEBUG_OBJECT (rtph265depay, "prepending codec_data"); + gst_rtp_copy_video_meta (rtph265depay, rtph265depay->codec_data, outbuf); + outbuf = gst_buffer_append (rtph265depay->codec_data, outbuf); + rtph265depay->codec_data = NULL; + keyframe = TRUE; + } + outbuf = gst_buffer_make_writable (outbuf); + + gst_rtp_drop_non_video_meta (rtph265depay, outbuf); + + GST_BUFFER_PTS (outbuf) = timestamp; + + if (keyframe) + GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT); + else + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT); + + if (marker) + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_MARKER); + + gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtph265depay), outbuf); +} + static void gst_rtp_h265_depay_handle_nal (GstRtpH265Depay * rtph265depay, GstBuffer * nal, GstClockTime in_timestamp, gboolean marker) @@ -1151,29 +1180,8 @@ gst_rtp_h265_depay_handle_nal (GstRtpH265Depay * rtph265depay, GstBuffer * nal, } if (outbuf) { - /* prepend codec_data */ - if (rtph265depay->codec_data) { - GST_DEBUG_OBJECT (depayload, "prepending codec_data"); - gst_rtp_copy_video_meta (rtph265depay, rtph265depay->codec_data, outbuf); - outbuf = gst_buffer_append (rtph265depay->codec_data, outbuf); - rtph265depay->codec_data = NULL; - out_keyframe = TRUE; - } - outbuf = gst_buffer_make_writable (outbuf); - - gst_rtp_drop_non_video_meta (rtph265depay, outbuf); - - GST_BUFFER_PTS (outbuf) = out_timestamp; - - if (out_keyframe) - GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT); - else - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT); - - if (marker) - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_MARKER); - - gst_rtp_base_depayload_push (depayload, outbuf); + gst_rtp_h265_depay_push (rtph265depay, outbuf, out_keyframe, out_timestamp, + marker); } return;