[farsight2/master] Use signal to do re-negotiation
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:22:46 PST 2008
---
gst/fsrtpconference/fs-rtp-marshal.list | 2 +-
gst/fsrtpconference/fs-rtp-session.c | 28 ++++++++++++++++++++++++++--
gst/fsrtpconference/fs-rtp-session.h | 5 -----
gst/fsrtpconference/fs-rtp-stream.c | 29 +++++++++++++++--------------
4 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-marshal.list b/gst/fsrtpconference/fs-rtp-marshal.list
index d99d569..f7d1e71 100644
--- a/gst/fsrtpconference/fs-rtp-marshal.list
+++ b/gst/fsrtpconference/fs-rtp-marshal.list
@@ -1,3 +1,3 @@
VOID:BOXED,BOXED
VOID:INT,STRING,STRING
-BOOLEAN:BOXED
+POINTER:BOXED
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 50d69be..b6952f7 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -189,6 +189,9 @@ static void fs_rtp_session_send_codec_changed (FsRtpSession *self);
static void _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
FsRtpSession *session);
+static GError* _stream_new_remote_codecs (FsRtpStream *stream, GList *codecs,
+ FsRtpSession *session);
+
static FsStreamTransmitter *fs_rtp_session_get_new_stream_transmitter (
FsRtpSession *self,
@@ -1093,6 +1096,9 @@ fs_rtp_session_new_stream (FsSession *session,
new_stream = FS_STREAM_CAST (fs_rtp_stream_new (self, rtpparticipant,
direction, st, error));
+ g_signal_connect (new_stream, "new-remote-codecs",
+ G_CALLBACK (_stream_new_remote_codecs), self);
+
FS_RTP_SESSION_LOCK (self);
self->priv->streams = g_list_append (self->priv->streams, new_stream);
FS_RTP_SESSION_UNLOCK (self);
@@ -1513,9 +1519,9 @@ fs_rtp_session_invalidate_pt (FsRtpSession *session, gint pt,
* Returns: TRUE if the negotiation succeeds, FALSE otherwise
*/
-gboolean
+static gboolean
fs_rtp_session_negotiate_codecs (FsRtpSession *session,
- gpointer stream,
+ FsRtpStream *stream,
GList *remote_codecs,
GError **error)
{
@@ -1672,6 +1678,24 @@ fs_rtp_session_negotiate_codecs (FsRtpSession *session,
}
+static GError *
+_stream_new_remote_codecs (FsRtpStream *stream,
+ GList *codecs,
+ FsRtpSession *session)
+{
+ GError *error = NULL;
+ gboolean rv;
+
+ rv = fs_rtp_session_negotiate_codecs (session, stream, codecs, &error);
+
+ if (!rv && !error)
+ error = g_error_new (FS_ERROR, FS_ERROR_INTERNAL,
+ "Unknown error while negotiating codecs");
+
+ return error;
+}
+
+
static void
_substream_error (FsRtpSubStream *substream,
gint errorno,
diff --git a/gst/fsrtpconference/fs-rtp-session.h b/gst/fsrtpconference/fs-rtp-session.h
index cdde4bd..b634fdc 100644
--- a/gst/fsrtpconference/fs-rtp-session.h
+++ b/gst/fsrtpconference/fs-rtp-session.h
@@ -92,11 +92,6 @@ GstCaps *fs_rtp_session_request_pt_map (FsRtpSession *session, guint pt);
void fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
guint32 ssrc, guint pt);
-gboolean fs_rtp_session_negotiate_codecs (FsRtpSession *session,
- gpointer stream,
- GList *remote_codecs,
- GError **error);
-
GstElement *fs_rtp_session_new_recv_codec_bin_locked (FsRtpSession *session,
guint32 ssrc,
guint pt,
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index e3f20e1..8df8d5b 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -113,7 +113,8 @@ static gboolean fs_rtp_stream_set_remote_codecs (FsStream *stream,
GError **error);
static gboolean
fs_rtp_stream_emit_new_remote_codecs (FsRtpStream *stream,
- GList *codecs);
+ GList *codecs,
+ GError **error);
static void _local_candidates_prepared (
FsStreamTransmitter *stream_transmitter,
@@ -189,10 +190,9 @@ fs_rtp_stream_class_init (FsRtpStreamClass *klass)
* @codecs: #GList of new remote #FsCodec
*
* This signal is emitted after a user does fs_stream_set_remote_codecs(),
- * with the new codecs. If the return value if %FALSE, then the codecs
- * have been ignored and nothing has changed. If it is true, the new remote
- * codecs have been set and the negotiation has completed
+ * with the new codecs.
*
+ * Returns: %NULL on success, or a #GError if an error occured
*/
signals[NEW_REMOTE_CODECS] = g_signal_new ("new-remote-codecs",
G_TYPE_FROM_CLASS (klass),
@@ -200,8 +200,8 @@ fs_rtp_stream_class_init (FsRtpStreamClass *klass)
0,
NULL,
NULL,
- _fs_rtp_marshal_BOOLEAN__BOXED,
- G_TYPE_BOOLEAN, 1, FS_TYPE_CODEC_LIST);
+ _fs_rtp_marshal_POINTER__BOXED,
+ G_TYPE_POINTER, 1, FS_TYPE_CODEC_LIST);
}
static void
@@ -559,10 +559,8 @@ fs_rtp_stream_set_remote_codecs (FsStream *stream,
}
}
- fs_rtp_stream_emit_new_remote_codecs (self, remote_codecs);
-
- if (fs_rtp_session_negotiate_codecs (self->priv->session, stream,
- remote_codecs, error)) {
+ if (fs_rtp_stream_emit_new_remote_codecs (self, remote_codecs, error))
+ {
if (self->remote_codecs)
fs_codec_list_destroy (self->remote_codecs);
self->remote_codecs = fs_codec_list_copy (remote_codecs);
@@ -917,11 +915,14 @@ fs_rtp_stream_remove_known_ssrc (FsRtpStream *stream,
static gboolean
fs_rtp_stream_emit_new_remote_codecs (FsRtpStream *stream,
- GList *codecs)
+ GList *codecs, GError **error)
{
- gboolean res = FALSE;
+ GError *myerror = NULL;
+
+ g_signal_emit (stream, signals[NEW_REMOTE_CODECS], 0, codecs, &myerror);
- g_signal_emit (stream, signals[NEW_REMOTE_CODECS], 0, codecs, &res);
+ if (myerror)
+ g_propagate_error (error, myerror);
- return res;
+ return !myerror;
}
--
1.5.6.5
More information about the farsight-commits
mailing list