[farsight2/master] Implement fs_stream_add_id in RTP plugin
Olivier Crête
olivier.crete at collabora.co.uk
Wed May 20 16:07:14 PDT 2009
---
docs/plugins/farsight2-plugins-sections.txt | 1 +
gst/fsrtpconference/fs-rtp-session.c | 39 ++++++++++++++++++++++++---
gst/fsrtpconference/fs-rtp-stream.c | 21 ++++++++++++++
gst/fsrtpconference/fs-rtp-stream.h | 3 ++
4 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/docs/plugins/farsight2-plugins-sections.txt b/docs/plugins/farsight2-plugins-sections.txt
index 484f226..fbe6f79 100644
--- a/docs/plugins/farsight2-plugins-sections.txt
+++ b/docs/plugins/farsight2-plugins-sections.txt
@@ -190,6 +190,7 @@ fs_rtp_stream_new
fs_rtp_stream_add_substream_unlock
fs_rtp_stream_set_negotiated_codecs_unlock
stream_sending_changed_locked_cb
+stream_ssrc_added_cb
</SECTION>
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 23f9256..1048594 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -188,6 +188,7 @@ struct _FsRtpSessionPrivate
/* This is a ht of ssrc->streams
* It is protected by the session mutex */
GHashTable *ssrc_streams;
+ GHashTable *ssrc_streams_manual;
GError *construction_error;
@@ -397,6 +398,8 @@ fs_rtp_session_init (FsRtpSession *self)
self->priv->no_rtcp_timeout = DEFAULT_NO_RTCP_TIMEOUT;
self->priv->ssrc_streams = g_hash_table_new (g_direct_hash, g_direct_equal);
+ self->priv->ssrc_streams_manual = g_hash_table_new (g_direct_hash,
+ g_direct_equal);
}
static gboolean
@@ -673,6 +676,7 @@ fs_rtp_session_dispose (GObject *object)
self->priv->streams = NULL;
self->priv->streams_cookie++;
g_hash_table_remove_all (self->priv->ssrc_streams);
+ g_hash_table_remove_all (self->priv->ssrc_streams_manual);
/* MAKE sure dispose does not run twice. */
self->priv->disposed = TRUE;
@@ -706,6 +710,9 @@ fs_rtp_session_finalize (GObject *object)
if (self->priv->ssrc_streams)
g_hash_table_destroy (self->priv->ssrc_streams);
+ if (self->priv->ssrc_streams_manual)
+ g_hash_table_destroy (self->priv->ssrc_streams_manual);
+
g_mutex_free (self->priv->send_pad_blocked_mutex);
g_mutex_free (self->priv->discovery_pad_blocked_mutex);
@@ -1431,6 +1438,22 @@ _stream_sending_changed_locked (FsRtpStream *stream, gboolean sending,
}
+static void
+_stream_ssrc_added_cb (FsRtpStream *stream, guint32 ssrc, gpointer user_data)
+{
+ FsRtpSession *self = user_data;
+
+ FS_RTP_SESSION_LOCK (self);
+ g_hash_table_insert (self->priv->ssrc_streams, GUINT_TO_POINTER (ssrc),
+ stream);
+ g_hash_table_insert (self->priv->ssrc_streams_manual, GUINT_TO_POINTER (ssrc),
+ stream);
+ FS_RTP_SESSION_UNLOCK (self);
+
+ fs_rtp_session_associate_free_substreams (self, stream, ssrc);
+}
+
+
static gboolean
_remove_stream_from_ht (gpointer key, gpointer value, gpointer user_data)
{
@@ -1453,6 +1476,8 @@ _remove_stream (gpointer user_data,
g_hash_table_foreach_remove (self->priv->ssrc_streams, _remove_stream_from_ht,
where_the_object_was);
+ g_hash_table_foreach_remove (self->priv->ssrc_streams_manual,
+ _remove_stream_from_ht, where_the_object_was);
FS_RTP_SESSION_UNLOCK (self);
fs_rtp_session_has_disposed_exit (self);
@@ -1510,7 +1535,9 @@ fs_rtp_session_new_stream (FsSession *session,
new_stream = FS_STREAM_CAST (fs_rtp_stream_new (self, rtpparticipant,
direction, st, _stream_new_remote_codecs,
_stream_known_source_packet_received,
- _stream_sending_changed_locked, self, error));
+ _stream_sending_changed_locked,
+ _stream_ssrc_added_cb,
+ self, error));
FS_RTP_SESSION_LOCK (self);
self->priv->streams = g_list_append (self->priv->streams, new_stream);
@@ -3782,8 +3809,10 @@ fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
return;
}
- g_hash_table_insert (session->priv->ssrc_streams, GUINT_TO_POINTER (ssrc),
- stream);
+ if (!g_hash_table_lookup (session->priv->ssrc_streams,
+ GUINT_TO_POINTER (ssrc)))
+ g_hash_table_insert (session->priv->ssrc_streams, GUINT_TO_POINTER (ssrc),
+ stream);
FS_RTP_SESSION_UNLOCK (session);
@@ -3862,7 +3891,9 @@ fs_rtp_session_bye_ssrc (FsRtpSession *session,
/* First remove it from the known SSRCs */
FS_RTP_SESSION_LOCK (session);
- g_hash_table_remove (session->priv->ssrc_streams, GUINT_TO_POINTER (ssrc));
+ if (!g_hash_table_lookup (session->priv->ssrc_streams_manual,
+ GUINT_TO_POINTER (ssrc)))
+ g_hash_table_remove (session->priv->ssrc_streams, GUINT_TO_POINTER (ssrc));
FS_RTP_SESSION_UNLOCK (session);
/*
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index 6d0eb4c..fc9b0db 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -74,6 +74,7 @@ struct _FsRtpStreamPrivate
stream_new_remote_codecs_cb new_remote_codecs_cb;
stream_known_source_packet_receive_cb known_source_packet_received_cb;
stream_sending_changed_locked_cb sending_changed_locked_cb;
+ stream_ssrc_added_cb ssrc_added_cb;
gpointer user_data_for_cb;
GMutex *mutex;
@@ -110,6 +111,8 @@ static gboolean fs_rtp_stream_set_remote_codecs (FsStream *stream,
GList *remote_codecs,
GError **error);
+static void fs_rtp_stream_add_id (FsStream *stream, guint id);
+
static void _local_candidates_prepared (
FsStreamTransmitter *stream_transmitter,
gpointer user_data);
@@ -162,6 +165,7 @@ fs_rtp_stream_class_init (FsRtpStreamClass *klass)
stream_class->set_remote_candidates = fs_rtp_stream_set_remote_candidates;
stream_class->set_remote_codecs = fs_rtp_stream_set_remote_codecs;
stream_class->force_remote_candidates = fs_rtp_stream_force_remote_candidates;
+ stream_class->add_id = fs_rtp_stream_add_id;
g_type_class_add_private (klass, sizeof (FsRtpStreamPrivate));
@@ -685,6 +689,7 @@ fs_rtp_stream_new (FsRtpSession *session,
stream_new_remote_codecs_cb new_remote_codecs_cb,
stream_known_source_packet_receive_cb known_source_packet_received_cb,
stream_sending_changed_locked_cb sending_changed_locked_cb,
+ stream_ssrc_added_cb ssrc_added_cb,
gpointer user_data_for_cb,
GError **error)
{
@@ -706,6 +711,7 @@ fs_rtp_stream_new (FsRtpSession *session,
self->priv->new_remote_codecs_cb = new_remote_codecs_cb;
self->priv->known_source_packet_received_cb = known_source_packet_received_cb;
self->priv->sending_changed_locked_cb = sending_changed_locked_cb;
+ self->priv->ssrc_added_cb = ssrc_added_cb;
self->priv->user_data_for_cb = user_data_for_cb;
FS_RTP_SESSION_LOCK (session);
@@ -1068,3 +1074,18 @@ fs_rtp_stream_set_negotiated_codecs_unlock (FsRtpStream *stream,
g_object_unref (session);
}
+
+static void
+fs_rtp_stream_add_id (FsStream *stream, guint id)
+{
+ FsRtpStream *self = FS_RTP_STREAM (stream);
+ FsRtpSession *session = fs_rtp_stream_get_session (self, NULL);
+
+ if (!session)
+ return;
+
+ if (self->priv->ssrc_added_cb)
+ self->priv->ssrc_added_cb (self, id, self->priv->user_data_for_cb);
+
+ g_object_unref (session);
+}
diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h
index d58a80f..d74d9a6 100644
--- a/gst/fsrtpconference/fs-rtp-stream.h
+++ b/gst/fsrtpconference/fs-rtp-stream.h
@@ -92,6 +92,8 @@ typedef void (*stream_known_source_packet_receive_cb) (FsRtpStream *stream,
guint component, GstBuffer *buffer, gpointer user_data);
typedef void (*stream_sending_changed_locked_cb) (FsRtpStream *stream,
gboolean sending, gpointer user_data);
+typedef void (*stream_ssrc_added_cb) (FsRtpStream *stream, guint32 ssrc,
+ gpointer user_data);
FsRtpStream *fs_rtp_stream_new (FsRtpSession *session,
FsRtpParticipant *participant,
@@ -100,6 +102,7 @@ FsRtpStream *fs_rtp_stream_new (FsRtpSession *session,
stream_new_remote_codecs_cb new_remote_codecs_cb,
stream_known_source_packet_receive_cb known_source_packet_received_cb,
stream_sending_changed_locked_cb sending_changed_locked_cb,
+ stream_ssrc_added_cb ssrc_added_cb,
gpointer user_data_for_cb,
GError **error);
--
1.5.6.5
More information about the farsight-commits
mailing list