rtpsession: Only warn once if configured latency needs to be known but isn't yet

Otherwise we would warn about this once for every single packet until
the LATENCY event is received.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5874>
This commit is contained in:
Sebastian Dröge 2023-12-22 12:56:33 +02:00 committed by Tim-Philipp Müller
parent ba04085ba4
commit a4dc820899

View file

@ -274,6 +274,9 @@ struct _GstRtpSessionPrivate
GHashTable *ptmap;
GstClockTime send_latency;
/* Set if we warned once already that no latency is configured yet but we
* need it to calculate correct send running time of the packets */
gboolean warned_latency_once;
gboolean use_pipeline_clock;
GstRtpNtpTimeSource ntp_time_source;
@ -1337,6 +1340,7 @@ gst_rtp_session_change_state (GstElement * element, GstStateChange transition)
GST_RTP_SESSION_LOCK (rtpsession);
rtpsession->priv->wait_send = TRUE;
rtpsession->priv->send_latency = GST_CLOCK_TIME_NONE;
rtpsession->priv->warned_latency_once = FALSE;
GST_RTP_SESSION_UNLOCK (rtpsession);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
@ -2432,8 +2436,14 @@ gst_rtp_session_chain_send_rtp_common (GstRtpSession * rtpsession,
if (priv->send_latency != GST_CLOCK_TIME_NONE) {
running_time += priv->send_latency;
} else {
GST_WARNING_OBJECT (rtpsession,
"Can't determine running time for this packet without knowing configured latency");
if (!priv->warned_latency_once) {
priv->warned_latency_once = TRUE;
GST_WARNING_OBJECT (rtpsession,
"Can't determine running time for this packet without knowing configured latency");
} else {
GST_LOG_OBJECT (rtpsession,
"Can't determine running time for this packet without knowing configured latency");
}
running_time = -1;
}
}