summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2013-02-08 17:05:27 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2013-02-08 17:05:27 +0100
commit2d5319c1fa4487c9e050931ce8a26e427626b763 (patch)
treefb7e52ed50c3cd8889fcdea43c36f92c34e6b7f3
parent2971ed44eeef9d910333122c393b3ecb6e281916 (diff)
rtpsession: delay RTCP until first RTP packet
Delay sending the first RTCP packet until we have sent the first RTP packet. Otherwise we will send out a Receiver Report instead of a sender report. See https://bugzilla.gnome.org/show_bug.cgi?id=691400
-rw-r--r--gst/rtpmanager/gstrtpsession.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index 6a99b49b0..03b9607bd 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -226,9 +226,13 @@ enum
#define GST_RTP_SESSION_LOCK(sess) g_mutex_lock (&(sess)->priv->lock)
#define GST_RTP_SESSION_UNLOCK(sess) g_mutex_unlock (&(sess)->priv->lock)
+#define GST_RTP_SESSION_WAIT(sess) g_cond_wait (&(sess)->priv->cond, &(sess)->priv->lock)
+#define GST_RTP_SESSION_SIGNAL(sess) g_cond_signal (&(sess)->priv->cond)
+
struct _GstRtpSessionPrivate
{
GMutex lock;
+ GCond cond;
GstClock *sysclock;
RTPSession *session;
@@ -238,6 +242,7 @@ struct _GstRtpSessionPrivate
gboolean stop_thread;
GThread *thread;
gboolean thread_stopped;
+ gboolean wait_send;
/* caps mapping */
GHashTable *ptmap;
@@ -622,6 +627,7 @@ gst_rtp_session_init (GstRtpSession * rtpsession)
{
rtpsession->priv = GST_RTP_SESSION_GET_PRIVATE (rtpsession);
g_mutex_init (&rtpsession->priv->lock);
+ g_cond_init (&rtpsession->priv->cond);
rtpsession->priv->sysclock = gst_system_clock_obtain ();
rtpsession->priv->session = rtp_session_new ();
rtpsession->priv->use_pipeline_clock = DEFAULT_USE_PIPELINE_CLOCK;
@@ -665,6 +671,7 @@ gst_rtp_session_finalize (GObject * object)
g_hash_table_destroy (rtpsession->priv->ptmap);
g_mutex_clear (&rtpsession->priv->lock);
+ g_cond_clear (&rtpsession->priv->cond);
g_object_unref (rtpsession->priv->sysclock);
g_object_unref (rtpsession->priv->session);
@@ -827,6 +834,12 @@ rtcp_thread (GstRtpSession * rtpsession)
GST_RTP_SESSION_LOCK (rtpsession);
+ while (rtpsession->priv->wait_send) {
+ GST_LOG_OBJECT (rtpsession, "waiting for RTP thread");
+ GST_RTP_SESSION_WAIT (rtpsession);
+ GST_LOG_OBJECT (rtpsession, "signaled...");
+ }
+
sysclock = rtpsession->priv->sysclock;
current_time = gst_clock_get_time (sysclock);
@@ -926,6 +939,8 @@ stop_rtcp_thread (GstRtpSession * rtpsession)
GST_RTP_SESSION_LOCK (rtpsession);
rtpsession->priv->stop_thread = TRUE;
+ rtpsession->priv->wait_send = FALSE;
+ GST_RTP_SESSION_SIGNAL (rtpsession);
if (rtpsession->priv->id)
gst_clock_id_unschedule (rtpsession->priv->id);
GST_RTP_SESSION_UNLOCK (rtpsession);
@@ -962,6 +977,9 @@ gst_rtp_session_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
+ GST_RTP_SESSION_LOCK (rtpsession);
+ rtpsession->priv->wait_send = TRUE;
+ GST_RTP_SESSION_UNLOCK (rtpsession);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
@@ -1059,6 +1077,11 @@ gst_rtp_session_send_rtp (RTPSession * sess, RTPSource * src,
GST_RTP_SESSION_LOCK (rtpsession);
if ((rtp_src = rtpsession->send_rtp_src))
gst_object_ref (rtp_src);
+ 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);
if (rtp_src) {