[farsight2/master] Make the special codec negotiation use the codec associations
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:22:40 PST 2008
---
gst/fsrtpconference/fs-rtp-codec-negotiation.c | 22 +++++++++
gst/fsrtpconference/fs-rtp-codec-negotiation.h | 7 +++
gst/fsrtpconference/fs-rtp-dtmf-event-source.c | 33 +++++++++-----
gst/fsrtpconference/fs-rtp-dtmf-sound-source.c | 57 ++++++++++++------------
gst/fsrtpconference/fs-rtp-session.c | 2 +-
gst/fsrtpconference/fs-rtp-special-source.c | 2 +-
tests/rtp/Makefile.am | 4 +-
7 files changed, 84 insertions(+), 43 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.c b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
index dd98d9e..9b5fbfb 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.c
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
@@ -705,3 +705,25 @@ codec_association_is_valid_for_sending (CodecAssociation *ca)
else
return FALSE;
}
+
+
+CodecAssociation *
+codec_association_find_custom (GList *codec_associations,
+ CAFindFunc func, gpointer user_data)
+{
+ GList *item;
+
+ for (item = codec_associations;
+ item;
+ item = g_list_next (item))
+ {
+ CodecAssociation *ca = item->data;
+ if (ca->disable)
+ continue;
+
+ if (func (ca, user_data))
+ return ca;
+ }
+
+ return NULL;
+}
diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.h b/gst/fsrtpconference/fs-rtp-codec-negotiation.h
index 2ce6642..16c1c12 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.h
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.h
@@ -88,6 +88,13 @@ codec_associations_to_codecs (GList *codec_associations);
void
codec_association_list_destroy (GList *list);
+typedef gboolean (*CAFindFunc) (CodecAssociation *ca, gpointer user_data);
+
+CodecAssociation *
+codec_association_find_custom (GList *codec_associations,
+ CAFindFunc func, gpointer user_data);
+
+
G_END_DECLS
#endif /* __FS_RTP_CODEC_NEGOTIATION_H__ */
diff --git a/gst/fsrtpconference/fs-rtp-dtmf-event-source.c b/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
index 2d6328a..2b6fd97 100644
--- a/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
+++ b/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
@@ -31,6 +31,7 @@
#include "fs-rtp-conference.h"
#include "fs-rtp-discover-codecs.h"
+#include "fs-rtp-codec-negotiation.h"
#include "fs-rtp-dtmf-event-source.h"
@@ -190,6 +191,19 @@ fs_rtp_dtmf_event_source_class_add_blueprint (FsRtpSpecialSourceClass *klass,
return blueprints;
}
+static gboolean
+_is_telephony_codec (CodecAssociation *ca, gpointer user_data)
+{
+ guint clock_rate = GPOINTER_TO_UINT (user_data);
+
+ if (ca->codec->media_type == FS_MEDIA_TYPE_AUDIO &&
+ !g_ascii_strcasecmp (ca->codec->encoding_name, "telephone-event") &&
+ ca->codec->clock_rate == clock_rate)
+ return TRUE;
+ else
+ return FALSE;
+}
+
/**
* get_telephone_event_codec:
* @codecs: a #GList of #FsCodec
@@ -203,20 +217,15 @@ fs_rtp_dtmf_event_source_class_add_blueprint (FsRtpSpecialSourceClass *klass,
static FsCodec *
get_telephone_event_codec (GList *codecs, guint clock_rate)
{
- GList *item = NULL;
- for (item = g_list_first (codecs);
- item;
- item = g_list_next (item))
- {
- FsCodec *codec = item->data;
+ CodecAssociation *ca = NULL;
- if (codec->media_type == FS_MEDIA_TYPE_AUDIO &&
- !g_ascii_strcasecmp (codec->encoding_name, "telephone-event") &&
- codec->clock_rate == clock_rate)
- return codec;
- }
+ ca = codec_association_find_custom (codecs, _is_telephony_codec,
+ GUINT_TO_POINTER (clock_rate));
- return NULL;
+ if (ca)
+ return ca->codec;
+ else
+ return NULL;
}
static gboolean
diff --git a/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c b/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
index a0c08eb..e05b46d 100644
--- a/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
+++ b/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
@@ -31,6 +31,7 @@
#include "fs-rtp-conference.h"
#include "fs-rtp-discover-codecs.h"
+#include "fs-rtp-codec-negotiation.h"
#include "fs-rtp-dtmf-sound-source.h"
@@ -94,6 +95,14 @@ fs_rtp_dtmf_sound_source_init (FsRtpDtmfSoundSource *self)
source->order = 2;
}
+static gboolean
+_is_law_codec (CodecAssociation *ca, gpointer user_data)
+{
+ if (ca->codec->id == 0 || ca->codec->id == 8)
+ return TRUE;
+ else return FALSE;
+}
+
/**
* get_telephone_sound_codec:
* @codecs: a #GList of #FsCodec
@@ -107,37 +116,29 @@ get_pcm_law_sound_codec (GList *codecs,
gchar **encoder_name,
gchar **payloader_name)
{
- GList *item = NULL;
- for (item = g_list_first (codecs);
- item;
- item = g_list_next (item))
+ CodecAssociation *ca = NULL;
+
+ ca = codec_association_find_custom (codecs, _is_law_codec, NULL);
+
+ if (!ca)
+ return NULL;
+
+ if (ca->codec->id == 0)
{
- FsCodec *codec = item->data;
-
- if (codec->media_type == FS_MEDIA_TYPE_AUDIO &&
- (codec->id == 0 || codec->id == 8))
- {
-
- if (codec->id == 0)
- {
- if (encoder_name)
- *encoder_name = "mulawenc";
- if (payloader_name)
- *payloader_name = "rtppcmupay";
- }
- else if (codec->id == 8)
- {
- if (encoder_name)
- *encoder_name = "alawenc";
- if (payloader_name)
- *payloader_name = "rtppcmapay";
- }
-
- return codec;
- }
+ if (encoder_name)
+ *encoder_name = "mulawenc";
+ if (payloader_name)
+ *payloader_name = "rtppcmupay";
+ }
+ else if (ca->codec->id == 8)
+ {
+ if (encoder_name)
+ *encoder_name = "alawenc";
+ if (payloader_name)
+ *payloader_name = "rtppcmapay";
}
- return NULL;
+ return ca->codec;
}
static gboolean
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index f2fc3a7..659c1df 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -2404,7 +2404,7 @@ fs_rtp_session_verify_send_codec_bin_locked (FsRtpSession *self, GError **error)
self->priv->extra_sources = fs_rtp_special_sources_update (
self->priv->extra_sources,
- self->priv->negotiated_codecs, ca->codec,
+ self->priv->negotiated_codec_associations, ca->codec,
GST_ELEMENT (self->priv->conference),
self->priv->rtpmuxer, error);
if (local_gerror)
diff --git a/gst/fsrtpconference/fs-rtp-special-source.c b/gst/fsrtpconference/fs-rtp-special-source.c
index 9c42958..2ab7900 100644
--- a/gst/fsrtpconference/fs-rtp-special-source.c
+++ b/gst/fsrtpconference/fs-rtp-special-source.c
@@ -384,7 +384,7 @@ _source_order_compare_func (gconstpointer item1,gconstpointer item2)
/**
* fs_rtp_special_sources_update:
* @current_extra_sources: The #GList returned by previous calls to this function
- * @negotiated_codecs: A #GList of current negotiated #FsCodec
+ * @negotiated_codecs: A #GList of current negotiated #CodecAssociation
* @error: NULL or the local of a #GError
*
* This function checks which extra sources are currently being used and
diff --git a/tests/rtp/Makefile.am b/tests/rtp/Makefile.am
index 0608f5a..92e5d3d 100644
--- a/tests/rtp/Makefile.am
+++ b/tests/rtp/Makefile.am
@@ -6,7 +6,9 @@ codec_discovery_SOURCES = codec-discovery.c \
$(top_srcdir)/gst/fsrtpconference/fs-rtp-codec-cache.c \
$(top_srcdir)/gst/fsrtpconference/fs-rtp-special-source.c \
$(top_srcdir)/gst/fsrtpconference/fs-rtp-dtmf-event-source.c \
- $(top_srcdir)/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
+ $(top_srcdir)/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c \
+ $(top_srcdir)/gst/fsrtpconference/fs-rtp-codec-negotiation.c \
+ $(top_srcdir)/gst/fsrtpconference/fs-rtp-specific-nego.c
codec_discovery_CFLAGS = \
-I$(top_srcdir)/gst/fsrtpconference/ \
$(FS2_INTERNAL_CFLAGS) \
--
1.5.6.5
More information about the farsight-commits
mailing list