[farsight2/master] Implement the callback after a timeout if there is no rtcp
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:20:53 PST 2008
---
gst/fsrtpconference/fs-rtp-session.c | 50 ++++++++++++++++++++++++++++++++
gst/fsrtpconference/fs-rtp-session.h | 3 ++
gst/fsrtpconference/fs-rtp-substream.c | 31 +++++++++++++++++++
3 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 54ebdb2..3fb82c2 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -1712,6 +1712,12 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
FS_RTP_SESSION_LOCK (session);
stream = fs_rtp_session_get_stream_by_ssrc (session, ssrc);
+ /* Add the substream directly if the no_rtcp_timeout is 0 */
+ if (!stream &&
+ no_rtcp_timeout == 0 &&
+ g_list_length (session->priv->streams) == 1)
+ stream = g_object_ref (g_list_first (session->priv->streams)->data);
+
if (!stream)
session->priv->free_substreams =
g_list_prepend (session->priv->free_substreams, substream);
@@ -2434,3 +2440,47 @@ fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
error->message);
g_clear_error (&error);
}
+
+void
+fs_rtp_session_substream_timedout (FsRtpSession *session,
+ gpointer substream)
+{
+ GError *error = NULL;
+ FsRtpSubStream *realsubstream = substream;
+ FS_RTP_SESSION_LOCK (session);
+
+ if (g_list_length (session->priv->streams) != 1)
+ {
+ guint ssrc, pt;
+ gint timeout;
+ g_object_get (realsubstream,
+ "ssrc", &ssrc,
+ "pt", &pt,
+ "no-rtcp-timeout", &timeout,
+ NULL);
+ GST_WARNING ("The substream for SSRC %x and pt %u did not receive RTCP"
+ " for %d milliseconds, but we have more than one stream so we can"
+ " not associate it.", ssrc, pt, timeout);
+ goto done;
+ }
+
+ session->priv->free_substreams =
+ g_list_remove (session->priv->free_substreams,
+ realsubstream);
+
+ if (!fs_rtp_stream_add_substream (
+ g_list_first (session->priv->streams)->data,
+ realsubstream, &error))
+ {
+ fs_session_emit_error (FS_SESSION (session),
+ error ? error->code : FS_ERROR_INTERNAL,
+ "Could not link the substream to a stream",
+ error ? error->message : "No error message");
+ }
+ g_clear_error (&error);
+
+
+ done:
+
+ FS_RTP_SESSION_UNLOCK (session);
+}
diff --git a/gst/fsrtpconference/fs-rtp-session.h b/gst/fsrtpconference/fs-rtp-session.h
index 7445b2b..575c095 100644
--- a/gst/fsrtpconference/fs-rtp-session.h
+++ b/gst/fsrtpconference/fs-rtp-session.h
@@ -109,6 +109,9 @@ void fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
const gchar *cname);
+void fs_rtp_session_substream_timedout (FsRtpSession *session,
+ gpointer substream);
+
G_END_DECLS
#endif /* __FS_RTP_SESSION_H__ */
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 48fe2b4..5fcec23 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -237,6 +237,23 @@ fs_rtp_sub_stream_init (FsRtpSubStream *self)
self->priv->receiving = TRUE;
}
+static gboolean
+_no_rtcp_timeout (gpointer user_data)
+{
+ FsRtpSubStream *self = FS_RTP_SUB_STREAM (user_data);
+
+ FS_RTP_SESSION_LOCK (self->priv->session);
+
+ if (!self->priv->stream)
+ fs_rtp_session_substream_timedout (self->priv->session, self);
+
+ if (self->priv->no_rtcp_timeout_id)
+ self->priv->no_rtcp_timeout_id = 0;
+
+ FS_RTP_SESSION_UNLOCK (self->priv->session);
+
+ return FALSE;
+}
static void
fs_rtp_sub_stream_constructed (GObject *object)
@@ -279,6 +296,10 @@ fs_rtp_sub_stream_constructed (GObject *object)
self->priv->ssrc, self->priv->pt);
return;
}
+
+ if (self->priv->no_rtcp_timeout > 0)
+ self->priv->no_rtcp_timeout_id = g_timeout_add (self->priv->no_rtcp_timeout,
+ _no_rtcp_timeout, self);
}
@@ -290,6 +311,16 @@ fs_rtp_sub_stream_dispose (GObject *object)
if (self->priv->disposed)
return;
+
+ FS_RTP_SESSION_LOCK (self->priv->session);
+ if (self->priv->no_rtcp_timeout_id)
+ {
+ g_source_remove (self->priv->no_rtcp_timeout_id);
+ self->priv->no_rtcp_timeout_id = 0;
+ }
+ FS_RTP_SESSION_UNLOCK (self->priv->session);
+
+
if (self->priv->output_ghostpad) {
gst_element_remove_pad (GST_ELEMENT (self->priv->conference),
self->priv->output_ghostpad);
--
1.5.6.5
More information about the farsight-commits
mailing list