mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
rtp: Use running_time instead of PTS for config-interval calculations
PTS can start again from a different offset while the running time is increasing. The only thing that matters here is the running time. https://bugzilla.gnome.org/show_bug.cgi?id=796807
This commit is contained in:
parent
cc38469f04
commit
f3631e6837
6 changed files with 72 additions and 39 deletions
|
@ -573,7 +573,8 @@ gst_rtp_gst_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_gst_pay_send_config (GstRtpGSTPay * rtpgstpay, GstClockTime timestamp)
|
gst_rtp_gst_pay_send_config (GstRtpGSTPay * rtpgstpay,
|
||||||
|
GstClockTime running_time)
|
||||||
{
|
{
|
||||||
GstPad *pad = GST_RTP_BASE_PAYLOAD_SINKPAD (rtpgstpay);
|
GstPad *pad = GST_RTP_BASE_PAYLOAD_SINKPAD (rtpgstpay);
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
|
@ -601,7 +602,7 @@ gst_rtp_gst_pay_send_config (GstRtpGSTPay * rtpgstpay, GstClockTime timestamp)
|
||||||
gst_rtp_gst_pay_send_caps (rtpgstpay, rtpgstpay->current_CV, caps);
|
gst_rtp_gst_pay_send_caps (rtpgstpay, rtpgstpay->current_CV, caps);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
rtpgstpay->last_config = timestamp;
|
rtpgstpay->last_config = running_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -610,25 +611,28 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
{
|
{
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstRtpGSTPay *rtpgstpay;
|
GstRtpGSTPay *rtpgstpay;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp, running_time;
|
||||||
|
|
||||||
rtpgstpay = GST_RTP_GST_PAY (basepayload);
|
rtpgstpay = GST_RTP_GST_PAY (basepayload);
|
||||||
|
|
||||||
timestamp = GST_BUFFER_PTS (buffer);
|
timestamp = GST_BUFFER_PTS (buffer);
|
||||||
|
running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
timestamp);
|
||||||
|
|
||||||
/* check if we need to send the caps and taglist now */
|
/* check if we need to send the caps and taglist now */
|
||||||
if (rtpgstpay->config_interval > 0) {
|
if (rtpgstpay->config_interval > 0) {
|
||||||
GST_DEBUG_OBJECT (rtpgstpay,
|
GST_DEBUG_OBJECT (rtpgstpay,
|
||||||
"timestamp %" GST_TIME_FORMAT ", last config %" GST_TIME_FORMAT,
|
"running time %" GST_TIME_FORMAT ", last config %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (rtpgstpay->last_config));
|
GST_TIME_ARGS (running_time), GST_TIME_ARGS (rtpgstpay->last_config));
|
||||||
|
|
||||||
if (timestamp != GST_CLOCK_TIME_NONE &&
|
if (running_time != GST_CLOCK_TIME_NONE &&
|
||||||
rtpgstpay->last_config != GST_CLOCK_TIME_NONE) {
|
rtpgstpay->last_config != GST_CLOCK_TIME_NONE) {
|
||||||
guint64 diff;
|
guint64 diff;
|
||||||
|
|
||||||
/* calculate diff between last SPS/PPS in milliseconds */
|
/* calculate diff between last SPS/PPS in milliseconds */
|
||||||
if (timestamp > rtpgstpay->last_config)
|
if (running_time > rtpgstpay->last_config)
|
||||||
diff = timestamp - rtpgstpay->last_config;
|
diff = running_time - rtpgstpay->last_config;
|
||||||
else
|
else
|
||||||
diff = 0;
|
diff = 0;
|
||||||
|
|
||||||
|
@ -637,9 +641,9 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
/* bigger than interval, queue SPS/PPS */
|
/* bigger than interval, queue SPS/PPS */
|
||||||
if (GST_TIME_AS_SECONDS (diff) >= rtpgstpay->config_interval)
|
if (GST_TIME_AS_SECONDS (diff) >= rtpgstpay->config_interval)
|
||||||
gst_rtp_gst_pay_send_config (rtpgstpay, timestamp);
|
gst_rtp_gst_pay_send_config (rtpgstpay, running_time);
|
||||||
} else {
|
} else {
|
||||||
gst_rtp_gst_pay_send_config (rtpgstpay, timestamp);
|
gst_rtp_gst_pay_send_config (rtpgstpay, running_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -717,7 +717,9 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
|
||||||
|
|
||||||
/* remember when we last saw SPS */
|
/* remember when we last saw SPS */
|
||||||
if (updated && pts != -1)
|
if (updated && pts != -1)
|
||||||
payloader->last_spspps = pts;
|
payloader->last_spspps =
|
||||||
|
gst_segment_to_running_time (&GST_RTP_BASE_PAYLOAD_CAST
|
||||||
|
(payloader)->segment, GST_FORMAT_TIME, pts);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG ("NAL: %x %x %x Len = %u", (header >> 7),
|
GST_DEBUG ("NAL: %x %x %x Len = %u", (header >> 7),
|
||||||
(header >> 5) & 3, type, size);
|
(header >> 5) & 3, type, size);
|
||||||
|
@ -769,7 +771,9 @@ gst_rtp_h264_pay_send_sps_pps (GstRTPBasePayload * basepayload,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pts != -1 && sent_all_sps_pps)
|
if (pts != -1 && sent_all_sps_pps)
|
||||||
rtph264pay->last_spspps = pts;
|
rtph264pay->last_spspps =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
pts);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -816,14 +820,18 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
|
||||||
if (nalType == IDR_TYPE_ID && rtph264pay->spspps_interval > 0) {
|
if (nalType == IDR_TYPE_ID && rtph264pay->spspps_interval > 0) {
|
||||||
if (rtph264pay->last_spspps != -1) {
|
if (rtph264pay->last_spspps != -1) {
|
||||||
guint64 diff;
|
guint64 diff;
|
||||||
|
GstClockTime running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
pts);
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtph264pay,
|
GST_LOG_OBJECT (rtph264pay,
|
||||||
"now %" GST_TIME_FORMAT ", last SPS/PPS %" GST_TIME_FORMAT,
|
"now %" GST_TIME_FORMAT ", last SPS/PPS %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (pts), GST_TIME_ARGS (rtph264pay->last_spspps));
|
GST_TIME_ARGS (running_time),
|
||||||
|
GST_TIME_ARGS (rtph264pay->last_spspps));
|
||||||
|
|
||||||
/* calculate diff between last SPS/PPS in milliseconds */
|
/* calculate diff between last SPS/PPS in milliseconds */
|
||||||
if (pts > rtph264pay->last_spspps)
|
if (running_time > rtph264pay->last_spspps)
|
||||||
diff = pts - rtph264pay->last_spspps;
|
diff = running_time - rtph264pay->last_spspps;
|
||||||
else
|
else
|
||||||
diff = 0;
|
diff = 0;
|
||||||
|
|
||||||
|
|
|
@ -802,7 +802,9 @@ gst_rtp_h265_pay_decode_nal (GstRtpH265Pay * payloader,
|
||||||
|
|
||||||
/* remember when we last saw VPS */
|
/* remember when we last saw VPS */
|
||||||
if (updated && pts != -1)
|
if (updated && pts != -1)
|
||||||
payloader->last_vps_sps_pps = pts;
|
payloader->last_vps_sps_pps =
|
||||||
|
gst_segment_to_running_time (&GST_RTP_BASE_PAYLOAD_CAST
|
||||||
|
(payloader)->segment, GST_FORMAT_TIME, pts);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (payloader, "NALU type 0x%x, size %u", type, size);
|
GST_DEBUG_OBJECT (payloader, "NALU type 0x%x, size %u", type, size);
|
||||||
}
|
}
|
||||||
|
@ -856,7 +858,9 @@ gst_rtp_h265_pay_send_vps_sps_pps (GstRTPBasePayload * basepayload,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pts != -1 && sent_all_vps_sps_pps)
|
if (pts != -1 && sent_all_vps_sps_pps)
|
||||||
rtph265pay->last_vps_sps_pps = pts;
|
rtph265pay->last_vps_sps_pps =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
pts);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -929,15 +933,18 @@ gst_rtp_h265_pay_payload_nal (GstRTPBasePayload * basepayload,
|
||||||
if (rtph265pay->vps_sps_pps_interval > 0) {
|
if (rtph265pay->vps_sps_pps_interval > 0) {
|
||||||
if (rtph265pay->last_vps_sps_pps != -1) {
|
if (rtph265pay->last_vps_sps_pps != -1) {
|
||||||
guint64 diff;
|
guint64 diff;
|
||||||
|
GstClockTime running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment,
|
||||||
|
GST_FORMAT_TIME, pts);
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtph265pay,
|
GST_LOG_OBJECT (rtph265pay,
|
||||||
"now %" GST_TIME_FORMAT ", last VPS/SPS/PPS %" GST_TIME_FORMAT,
|
"now %" GST_TIME_FORMAT ", last VPS/SPS/PPS %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (pts),
|
GST_TIME_ARGS (running_time),
|
||||||
GST_TIME_ARGS (rtph265pay->last_vps_sps_pps));
|
GST_TIME_ARGS (rtph265pay->last_vps_sps_pps));
|
||||||
|
|
||||||
/* calculate diff between last SPS/PPS in milliseconds */
|
/* calculate diff between last SPS/PPS in milliseconds */
|
||||||
if (pts > rtph265pay->last_vps_sps_pps)
|
if (running_time > rtph265pay->last_vps_sps_pps)
|
||||||
diff = pts - rtph265pay->last_vps_sps_pps;
|
diff = running_time - rtph265pay->last_vps_sps_pps;
|
||||||
else
|
else
|
||||||
diff = 0;
|
diff = 0;
|
||||||
|
|
||||||
|
|
|
@ -472,23 +472,32 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
size = gst_buffer_get_size (buffer);
|
size = gst_buffer_get_size (buffer);
|
||||||
} else {
|
} else {
|
||||||
|
GstClockTime running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
timestamp);
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtpmp4vpay, "found config in stream");
|
GST_LOG_OBJECT (rtpmp4vpay, "found config in stream");
|
||||||
rtpmp4vpay->last_config = timestamp;
|
rtpmp4vpay->last_config = running_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* there is a config request, see if we need to insert it */
|
/* there is a config request, see if we need to insert it */
|
||||||
if (vopi && (rtpmp4vpay->config_interval > 0) && rtpmp4vpay->config) {
|
if (vopi && (rtpmp4vpay->config_interval > 0) && rtpmp4vpay->config) {
|
||||||
|
GstClockTime running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
timestamp);
|
||||||
|
|
||||||
if (rtpmp4vpay->last_config != -1) {
|
if (rtpmp4vpay->last_config != -1) {
|
||||||
guint64 diff;
|
guint64 diff;
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtpmp4vpay,
|
GST_LOG_OBJECT (rtpmp4vpay,
|
||||||
"now %" GST_TIME_FORMAT ", last VOP-I %" GST_TIME_FORMAT,
|
"now %" GST_TIME_FORMAT ", last VOP-I %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (rtpmp4vpay->last_config));
|
GST_TIME_ARGS (running_time),
|
||||||
|
GST_TIME_ARGS (rtpmp4vpay->last_config));
|
||||||
|
|
||||||
/* calculate diff between last config in milliseconds */
|
/* calculate diff between last config in milliseconds */
|
||||||
if (timestamp > rtpmp4vpay->last_config) {
|
if (running_time > rtpmp4vpay->last_config) {
|
||||||
diff = timestamp - rtpmp4vpay->last_config;
|
diff = running_time - rtpmp4vpay->last_config;
|
||||||
} else {
|
} else {
|
||||||
diff = 0;
|
diff = 0;
|
||||||
}
|
}
|
||||||
|
@ -497,7 +506,6 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
||||||
|
|
||||||
/* bigger than interval, queue config */
|
/* bigger than interval, queue config */
|
||||||
/* FIXME should convert timestamps to running time */
|
|
||||||
if (GST_TIME_AS_SECONDS (diff) >= rtpmp4vpay->config_interval) {
|
if (GST_TIME_AS_SECONDS (diff) >= rtpmp4vpay->config_interval) {
|
||||||
GST_DEBUG_OBJECT (rtpmp4vpay, "time to send config");
|
GST_DEBUG_OBJECT (rtpmp4vpay, "time to send config");
|
||||||
send_config = TRUE;
|
send_config = TRUE;
|
||||||
|
@ -518,8 +526,8 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GST_BUFFER_PTS (buffer) = timestamp;
|
GST_BUFFER_PTS (buffer) = timestamp;
|
||||||
size = gst_buffer_get_size (buffer);
|
size = gst_buffer_get_size (buffer);
|
||||||
|
|
||||||
if (timestamp != -1) {
|
if (running_time != -1) {
|
||||||
rtpmp4vpay->last_config = timestamp;
|
rtpmp4vpay->last_config = running_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -819,17 +819,21 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
if (keyframe && (rtptheorapay->config_interval > 0) &&
|
if (keyframe && (rtptheorapay->config_interval > 0) &&
|
||||||
rtptheorapay->config_data) {
|
rtptheorapay->config_data) {
|
||||||
gboolean send_config = FALSE;
|
gboolean send_config = FALSE;
|
||||||
|
GstClockTime running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
timestamp);
|
||||||
|
|
||||||
if (rtptheorapay->last_config != -1) {
|
if (rtptheorapay->last_config != -1) {
|
||||||
guint64 diff;
|
guint64 diff;
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtptheorapay,
|
GST_LOG_OBJECT (rtptheorapay,
|
||||||
"now %" GST_TIME_FORMAT ", last VOP-I %" GST_TIME_FORMAT,
|
"now %" GST_TIME_FORMAT ", last VOP-I %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (rtptheorapay->last_config));
|
GST_TIME_ARGS (running_time),
|
||||||
|
GST_TIME_ARGS (rtptheorapay->last_config));
|
||||||
|
|
||||||
/* calculate diff between last config in milliseconds */
|
/* calculate diff between last config in milliseconds */
|
||||||
if (timestamp > rtptheorapay->last_config) {
|
if (running_time > rtptheorapay->last_config) {
|
||||||
diff = timestamp - rtptheorapay->last_config;
|
diff = running_time - rtptheorapay->last_config;
|
||||||
} else {
|
} else {
|
||||||
diff = 0;
|
diff = 0;
|
||||||
}
|
}
|
||||||
|
@ -838,7 +842,6 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
||||||
|
|
||||||
/* bigger than interval, queue config */
|
/* bigger than interval, queue config */
|
||||||
/* FIXME should convert timestamps to running time */
|
|
||||||
if (GST_TIME_AS_SECONDS (diff) >= rtptheorapay->config_interval) {
|
if (GST_TIME_AS_SECONDS (diff) >= rtptheorapay->config_interval) {
|
||||||
GST_DEBUG_OBJECT (rtptheorapay, "time to send config");
|
GST_DEBUG_OBJECT (rtptheorapay, "time to send config");
|
||||||
send_config = TRUE;
|
send_config = TRUE;
|
||||||
|
@ -856,8 +859,8 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
NULL, rtptheorapay->config_data, rtptheorapay->config_size,
|
NULL, rtptheorapay->config_data, rtptheorapay->config_size,
|
||||||
timestamp, GST_CLOCK_TIME_NONE, rtptheorapay->config_extra_len);
|
timestamp, GST_CLOCK_TIME_NONE, rtptheorapay->config_extra_len);
|
||||||
|
|
||||||
if (timestamp != -1) {
|
if (running_time != -1) {
|
||||||
rtptheorapay->last_config = timestamp;
|
rtptheorapay->last_config = running_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -829,17 +829,21 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
/* there is a config request, see if we need to insert it */
|
/* there is a config request, see if we need to insert it */
|
||||||
if (rtpvorbispay->config_interval > 0 && rtpvorbispay->config_data) {
|
if (rtpvorbispay->config_interval > 0 && rtpvorbispay->config_data) {
|
||||||
gboolean send_config = FALSE;
|
gboolean send_config = FALSE;
|
||||||
|
GstClockTime running_time =
|
||||||
|
gst_segment_to_running_time (&basepayload->segment, GST_FORMAT_TIME,
|
||||||
|
timestamp);
|
||||||
|
|
||||||
if (rtpvorbispay->last_config != -1) {
|
if (rtpvorbispay->last_config != -1) {
|
||||||
guint64 diff;
|
guint64 diff;
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtpvorbispay,
|
GST_LOG_OBJECT (rtpvorbispay,
|
||||||
"now %" GST_TIME_FORMAT ", last config %" GST_TIME_FORMAT,
|
"now %" GST_TIME_FORMAT ", last config %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (rtpvorbispay->last_config));
|
GST_TIME_ARGS (running_time),
|
||||||
|
GST_TIME_ARGS (rtpvorbispay->last_config));
|
||||||
|
|
||||||
/* calculate diff between last config in milliseconds */
|
/* calculate diff between last config in milliseconds */
|
||||||
if (timestamp > rtpvorbispay->last_config) {
|
if (running_time > rtpvorbispay->last_config) {
|
||||||
diff = timestamp - rtpvorbispay->last_config;
|
diff = running_time - rtpvorbispay->last_config;
|
||||||
} else {
|
} else {
|
||||||
diff = 0;
|
diff = 0;
|
||||||
}
|
}
|
||||||
|
@ -848,7 +852,6 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
||||||
|
|
||||||
/* bigger than interval, queue config */
|
/* bigger than interval, queue config */
|
||||||
/* FIXME should convert timestamps to running time */
|
|
||||||
if (GST_TIME_AS_SECONDS (diff) >= rtpvorbispay->config_interval) {
|
if (GST_TIME_AS_SECONDS (diff) >= rtpvorbispay->config_interval) {
|
||||||
GST_DEBUG_OBJECT (rtpvorbispay, "time to send config");
|
GST_DEBUG_OBJECT (rtpvorbispay, "time to send config");
|
||||||
send_config = TRUE;
|
send_config = TRUE;
|
||||||
|
@ -866,8 +869,8 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
NULL, rtpvorbispay->config_data, rtpvorbispay->config_size,
|
NULL, rtpvorbispay->config_data, rtpvorbispay->config_size,
|
||||||
timestamp, GST_CLOCK_TIME_NONE, rtpvorbispay->config_extra_len);
|
timestamp, GST_CLOCK_TIME_NONE, rtpvorbispay->config_extra_len);
|
||||||
|
|
||||||
if (timestamp != -1) {
|
if (running_time != -1) {
|
||||||
rtpvorbispay->last_config = timestamp;
|
rtpvorbispay->last_config = running_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue