[farsight2/master] Don't try to build a send or receive pipeline if there is no blueprint for it
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:21:34 PST 2008
---
gst/fsrtpconference/fs-rtp-session.c | 92 ++++++++++++++++++++++++++++++----
1 files changed, 81 insertions(+), 11 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 21ca1b0..dac777e 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -1855,6 +1855,17 @@ _create_codec_bin (CodecBlueprint *blueprint, const FsCodec *codec,
else
pipeline_factory = blueprint->receive_pipeline_factory;
+ if (!pipeline_factory)
+ {
+ g_set_error (error, FS_ERROR, FS_ERROR_UNKNOWN_CODEC,
+ "The %s codec %s does not have a pipeline,"
+ " its probably a special codec",
+ fs_media_type_to_string (codec->media_type),
+ codec->encoding_name);
+ return NULL;
+ }
+
+
GST_DEBUG ("creating %s codec bin for id %d, pipeline_factory %p",
direction_str, codec->id, pipeline_factory);
codec_bin = gst_bin_new (name);
@@ -2034,6 +2045,39 @@ fs_rtp_session_new_recv_codec_bin_locked (FsRtpSession *session,
return codec_bin;
}
+/**
+ * fs_rtp_session_is_valid_send_codec:
+ * @session: a #FsRtpSession
+ * @codec: a #FsCodec to check
+ * @blueprint: %NULL or the address of a pointer where a CodecBlueprint can be
+ * stored
+ *
+ * Verifies if a codec is a valid send codec for which a pipeline exists,
+ * if it is, it will return the CodecBlueprint.
+ *
+ * Returns: %TRUE if it is a valid send codec, %FALSE otherwise
+ */
+
+static gboolean
+fs_rtp_session_is_valid_send_codec (FsRtpSession *session,
+ FsCodec *codec,
+ CodecBlueprint **blueprint)
+{
+ CodecAssociation *codec_association = NULL;
+
+ codec_association = g_hash_table_lookup (
+ session->priv->negotiated_codec_associations,
+ GINT_TO_POINTER (codec->id));
+ g_assert (codec_association);
+
+ if (codec_association->blueprint->send_pipeline_factory == NULL)
+ return FALSE;
+
+ if (blueprint)
+ *blueprint = codec_association->blueprint;
+
+ return TRUE;
+}
/**
* fs_rtp_session_select_send_codec_locked:
@@ -2054,6 +2098,7 @@ fs_rtp_session_select_send_codec_locked (FsRtpSession *session,
GError **error)
{
FsCodec *codec = NULL;
+ GList *codec_e = NULL;
if (!session->priv->negotiated_codecs)
{
@@ -2074,7 +2119,21 @@ fs_rtp_session_select_send_codec_locked (FsRtpSession *session,
if (elem)
{
- codec = fs_codec_copy (session->priv->requested_send_codec);
+ if (!fs_rtp_session_is_valid_send_codec (session,
+ session->priv->requested_send_codec, blueprint))
+ {
+ fs_codec_destroy (session->priv->requested_send_codec);
+ session->priv->requested_send_codec = NULL;
+
+ GST_DEBUG_OBJECT (session->priv->conference,
+ "The current requested codec is not a valid main send codec,"
+ " ignoring");
+ }
+ else
+ {
+ codec = session->priv->requested_send_codec;
+ goto out;
+ }
}
else
{
@@ -2082,25 +2141,36 @@ fs_rtp_session_select_send_codec_locked (FsRtpSession *session,
fs_codec_destroy (session->priv->requested_send_codec);
session->priv->requested_send_codec = NULL;
- GST_DEBUG ("The current requested codec no longer exists, resetting");
+ GST_WARNING_OBJECT (session->priv->conference,
+ "The current requested codec no longer exists, resetting");
}
}
- if (codec == NULL)
- codec = fs_codec_copy (
- g_list_first (session->priv->negotiated_codecs)->data);
+ for (codec_e = g_list_first (session->priv->negotiated_codecs);
+ codec_e;
+ codec_e = g_list_next (codec_e))
+ {
+ codec = codec_e->data;
- if (blueprint)
+ if (fs_rtp_session_is_valid_send_codec (session, codec, blueprint))
+ break;
+ }
+
+
+ if (codec_e == NULL)
{
- CodecAssociation *codec_association = g_hash_table_lookup (
- session->priv->negotiated_codec_associations,
- GINT_TO_POINTER (codec->id));
- g_assert (codec_association);
- *blueprint = codec_association->blueprint;
+ g_set_error (error, FS_ERROR, FS_ERROR_NEGOTIATION_FAILED,
+ "Could not get a valid send codec");
+ codec = NULL;
}
+out:
+
FS_RTP_SESSION_UNLOCK (session);
+ if (codec)
+ codec = fs_codec_copy (codec);
+
return codec;
}
--
1.5.6.5
More information about the farsight-commits
mailing list