[farsight2/master] Invalidate recv codecs according to each streams config data when the config data is changed
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:22:58 PST 2008
---
gst/fsrtpconference/fs-rtp-session.c | 111 +++++++++++++++++---------------
gst/fsrtpconference/fs-rtp-stream.c | 26 --------
gst/fsrtpconference/fs-rtp-stream.h | 4 -
gst/fsrtpconference/fs-rtp-substream.c | 8 +--
gst/fsrtpconference/fs-rtp-substream.h | 3 +-
5 files changed, 64 insertions(+), 88 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 7156eff..45e8a72 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -237,6 +237,13 @@ fs_rtp_session_update_codecs (FsRtpSession *session,
GList *remote_codecs,
GError **error);
+static FsCodec *
+fs_rtp_session_get_recv_codec_locked (FsRtpSession *session,
+ guint pt,
+ FsRtpStream *stream,
+ CodecBlueprint **bp,
+ GError **error);
+
static void
fs_rtp_session_start_codec_param_gathering (FsRtpSession *session);
static void
@@ -1629,32 +1636,63 @@ fs_rtp_session_get_stream_by_ssrc (FsRtpSession *self,
}
/**
- * fs_rtp_session_invalidate_pt:
+ * fs_rtp_session_verify_substream
+ *
+ * Verifies that a substream still has the right codec and resets it if its not
+ *
+ * MUST hold the FsRtpSession lock while calling it
+ */
+
+static void
+fs_rtp_session_verify_substream_locked (FsRtpSession *session,
+ FsRtpSubStream *substream)
+{
+ FsCodec *codec = NULL;
+ guint pt;
+
+ g_object_get (substream, "pt", &pt, NULL);
+
+ codec = fs_rtp_session_get_recv_codec_locked (session, pt, NULL, NULL, NULL);
+
+ if (!codec)
+ return;
+
+ fs_rtp_sub_stream_verify_codec_locked (substream, codec);
+
+ fs_codec_destroy (codec);
+}
+
+/**
+ * fs_rtp_session_verify_recv_codecs
* @session: A #FsRtpSession
- * @pt: the PT to invalidate
- * @codec: the new codec
*
- * Invalidates all codec bins for the selected payload type, because its
- * definition has changed
+ * Verifies that the various substreams still have the right codec, otherwise
+ * re-sets it.
*/
static void
-fs_rtp_session_invalidate_pt (FsRtpSession *session, gint pt,
- const FsCodec *codec)
+fs_rtp_session_verify_recv_codecs (FsRtpSession *session)
{
- GList *item;
+ GList *item, *item2;
+
FS_RTP_SESSION_LOCK (session);
for (item = g_list_first (session->priv->free_substreams);
item;
item = g_list_next (item))
- fs_rtp_sub_stream_invalidate_codec_locked (item->data, pt, codec);
-
+ fs_rtp_session_verify_substream_locked (session, item->data);
for (item = g_list_first (session->priv->streams);
item;
item = g_list_next (item))
- fs_rtp_stream_invalidate_codec_locked (item->data, pt, codec);
+ {
+ FsRtpStream *stream = item->data;
+
+ for (item2 = g_list_first (stream->substreams);
+ item2;
+ item2 = g_list_next (item2))
+ fs_rtp_session_verify_substream_locked (session, item2->data);
+ }
FS_RTP_SESSION_UNLOCK (session);
}
@@ -1821,59 +1859,29 @@ fs_rtp_session_update_codecs (FsRtpSession *session,
if (old_negotiated_codec_associations)
{
- gboolean clear_pts = FALSE;
- int pt;
-
- is_new = !codec_associations_list_are_equal (
+ is_new = ! codec_associations_list_are_equal (
old_negotiated_codec_associations,
new_negotiated_codec_associations);
- /* Lets remove the codec bin for any PT that has changed type */
- for (pt = 0; pt < 128; pt++)
- {
- CodecAssociation *old_codec_association =
- lookup_codec_association_by_pt (
- old_negotiated_codec_associations, pt);
- CodecAssociation *new_codec_association =
- lookup_codec_association_by_pt (
- new_negotiated_codec_associations, pt);
-
- if (old_codec_association == NULL && new_codec_association == NULL)
- continue;
-
- if (old_codec_association == NULL || new_codec_association == NULL)
- {
- fs_rtp_session_invalidate_pt (session, pt, NULL);
- clear_pts = TRUE;
- continue;
- }
-
- if (!fs_codec_are_equal (old_codec_association->codec,
- new_codec_association->codec))
- {
- fs_rtp_session_invalidate_pt (session, pt,
- new_codec_association->codec);
- clear_pts = TRUE;
- continue;
- }
- }
-
- if (clear_pts)
- g_signal_emit_by_name (session->priv->conference->gstrtpbin,
- "clear-pt-map");
+ codec_association_list_destroy (old_negotiated_codec_associations);
}
- if (old_negotiated_codec_associations)
- codec_association_list_destroy (old_negotiated_codec_associations);
+ if (is_new)
+ g_signal_emit_by_name (session->priv->conference->gstrtpbin,
+ "clear-pt-map");
fs_rtp_session_start_codec_param_gathering (session);
+ fs_rtp_session_verify_recv_codecs (session);
+
if (has_remotes)
+ {
if (!fs_rtp_session_verify_send_codec_bin_locked (session, error))
{
FS_RTP_SESSION_UNLOCK (session);
return FALSE;
}
+ }
FS_RTP_SESSION_UNLOCK (session);
@@ -2343,7 +2351,8 @@ fs_rtp_session_get_recv_codec_locked (FsRtpSession *session,
fs_codec_list_destroy (remote_codecs);
}
- *bp = ca->blueprint;
+ if (bp)
+ *bp = ca->blueprint;
return recv_codec;
}
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index e811a41..90e6fae 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -767,32 +767,6 @@ fs_rtp_stream_knows_ssrc_locked (FsRtpStream *stream, guint32 ssrc)
return FALSE;
}
-/**
- * fs_rtp_stream_invalidate_codec_locked:
- * @stream: A #FsRtpStream
- * @pt: The payload type to invalidate (does nothing if it does not match)
- * @codec: The new fscodec (the substream is invalidated if it not using this
- * codec). You can pass NULL to match any codec.
- *
- * This function will start the process that invalidates the codec
- * for this rtpbin, if it doesnt match the passed codec
- *
- * You must hold the session lock to call it.
- */
-
-void
-fs_rtp_stream_invalidate_codec_locked (FsRtpStream *stream,
- gint pt,
- const FsCodec *codec)
-{
- GList *item;
-
- for (item = g_list_first (stream->substreams);
- item;
- item = g_list_next (item))
- fs_rtp_sub_stream_invalidate_codec_locked (item->data, pt, codec);
-}
-
/**
* _substream_codec_changed
diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h
index bc9ad08..eeafce0 100644
--- a/gst/fsrtpconference/fs-rtp-stream.h
+++ b/gst/fsrtpconference/fs-rtp-stream.h
@@ -95,10 +95,6 @@ gboolean fs_rtp_stream_add_substream (FsRtpStream *stream,
gboolean fs_rtp_stream_knows_ssrc_locked (FsRtpStream *stream,
guint32 ssrc);
-void fs_rtp_stream_invalidate_codec_locked (FsRtpStream *stream,
- gint pt,
- const FsCodec *codec);
-
void fs_rtp_stream_add_known_ssrc (FsRtpStream *stream,
guint32 ssrc);
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 7bcc196..65d4278 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -1056,9 +1056,8 @@ _rtpbin_pad_have_data_callback (GstPad *pad, GstMiniObject *miniobj,
}
/**
- * fs_rtp_sub_stream_invalidate_codec_locked:
+ * fs_rtp_sub_stream_verify_codec_locked:
* @substream: A #FsRtpSubStream
- * @pt: The payload type to invalidate (does nothing if it does not match)
* @codec: The new fscodec (the substream is invalidated if it not using this
* codec). You can pass NULL to match any codec.
*
@@ -1069,11 +1068,10 @@ _rtpbin_pad_have_data_callback (GstPad *pad, GstMiniObject *miniobj,
*/
void
-fs_rtp_sub_stream_invalidate_codec_locked (FsRtpSubStream *substream, gint pt,
+fs_rtp_sub_stream_verify_codec_locked (FsRtpSubStream *substream,
const FsCodec *codec)
{
- if (substream->priv->pt == pt &&
- substream->priv->codec &&
+ if (substream->priv->codec &&
!substream->priv->blocking_id &&
(!codec || !fs_codec_are_equal (substream->priv->codec, codec)))
substream->priv->blocking_id = gst_pad_add_data_probe (
diff --git a/gst/fsrtpconference/fs-rtp-substream.h b/gst/fsrtpconference/fs-rtp-substream.h
index 04e5852..36b18fd 100644
--- a/gst/fsrtpconference/fs-rtp-substream.h
+++ b/gst/fsrtpconference/fs-rtp-substream.h
@@ -91,8 +91,7 @@ gboolean fs_rtp_sub_stream_add_output_ghostpad_locked (
FsRtpSubStream *substream,
GError **error);
-void fs_rtp_sub_stream_invalidate_codec_locked (FsRtpSubStream *substream,
- gint pt,
+void fs_rtp_sub_stream_verify_codec_locked (FsRtpSubStream *substream,
const FsCodec *codec);
--
1.5.6.5
More information about the farsight-commits
mailing list