rtpsession: Also start the RTCP send thread when receiving RTP or RTCP

Before we only started it when either:
- there is no send RTP stream
or
- we received an RTP packet for sending

This could mean that if the send RTP pads are connected but never receive any
RTP data, and the same session is also used for receiving RTP/RTCP, we would
never start the RTCP thread and would never send RTCP for the receiving part
of the session.

This can be reproduced with a pipeline like:

gst-launch-1.0 rtpbin name=rtpbin \
udpsrc port=5000 ! "application/x-rtp, media=video, clock-rate=90000, encoding-name=H264" ! rtpbin.recv_rtp_sink_0 \
udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0 \
rtpbin.send_rtcp_src_0 ! fakesink name=rtcp_fakesink silent=false async=false sync=false \
rtpbin.recv_rtp_src_0_2553225531_96 ! decodebin ! xvimagesink \
fakesrc ! valve drop=true ! rtpbin.send_rtp_sink_0 \
rtpbin.send_rtp_src_0 ! fakesink name=rtp_fakesink silent=false async=false sync=false -v

Before this change the rtcp_fakesink would never send RTCP for the receiving
part of the session (i.e. no receiver reports!), after the change it does.

And before and after this change it would send RTCP for the receiving part of
the session if the sender part was omitted (the last two lines).
This commit is contained in:
Sebastian Dröge 2015-03-21 17:18:47 +01:00
parent 1018aacb35
commit 17d90b453f

View file

@ -911,7 +911,7 @@ rtcp_thread (GstRtpSession * rtpsession)
GST_RTP_SESSION_LOCK (rtpsession);
while (rtpsession->priv->wait_send) {
GST_LOG_OBJECT (rtpsession, "waiting for RTP thread");
GST_LOG_OBJECT (rtpsession, "waiting for getting started");
GST_RTP_SESSION_WAIT (rtpsession);
GST_LOG_OBJECT (rtpsession, "signaled...");
}
@ -1721,6 +1721,14 @@ gst_rtp_session_chain_recv_rtp (GstPad * pad, GstObject * parent,
GST_LOG_OBJECT (rtpsession, "received RTP packet");
GST_RTP_SESSION_LOCK (rtpsession);
if (rtpsession->priv->wait_send) {
GST_LOG_OBJECT (rtpsession, "signal RTCP thread");
rtpsession->priv->wait_send = FALSE;
GST_RTP_SESSION_SIGNAL (rtpsession);
}
GST_RTP_SESSION_UNLOCK (rtpsession);
/* get NTP time when this packet was captured, this depends on the timestamp. */
timestamp = GST_BUFFER_TIMESTAMP (buffer);
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
@ -1790,6 +1798,14 @@ gst_rtp_session_chain_recv_rtcp (GstPad * pad, GstObject * parent,
GST_LOG_OBJECT (rtpsession, "received RTCP packet");
GST_RTP_SESSION_LOCK (rtpsession);
if (rtpsession->priv->wait_send) {
GST_LOG_OBJECT (rtpsession, "signal RTCP thread");
rtpsession->priv->wait_send = FALSE;
GST_RTP_SESSION_SIGNAL (rtpsession);
}
GST_RTP_SESSION_UNLOCK (rtpsession);
current_time = gst_clock_get_time (priv->sysclock);
get_current_times (rtpsession, NULL, &ntpnstime);