[farsight2/master] Properly filter the h263* pipelines
Olivier Crête
olivier.crete at collabora.co.uk
Mon Jan 5 13:24:05 PST 2009
---
gst/fsrtpconference/fs-rtp-discover-codecs.c | 45 ++++++++++++++++++++++---
1 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-discover-codecs.c b/gst/fsrtpconference/fs-rtp-discover-codecs.c
index 456041a..1899bdb 100644
--- a/gst/fsrtpconference/fs-rtp-discover-codecs.c
+++ b/gst/fsrtpconference/fs-rtp-discover-codecs.c
@@ -318,6 +318,33 @@ create_codec_lists (FsMediaType media_type,
return TRUE;
}
+static gboolean
+struct_field_has_line (GstStructure *s, const gchar *field, const gchar *value)
+{
+ const gchar *tmp = gst_structure_get_string (s, field);
+ const GValue *v = NULL;
+ gint i;
+
+ if (tmp)
+ return !strcmp (value, tmp);
+
+ if (!gst_structure_has_field_typed (s, field, GST_TYPE_LIST))
+ return FALSE;
+
+ v = gst_structure_get_value (s, field);
+
+ for (i=0; i < gst_value_list_get_size (v); i++)
+ {
+ const GValue *listval = gst_value_list_get_value (v, i);
+
+ if (G_VALUE_HOLDS_STRING(listval) &&
+ !strcmp (value, g_value_get_string (listval)))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/*
* This function returns TRUE if the codec_cap should be accepted,
* FALSE otherwise
@@ -329,7 +356,6 @@ validate_h263_codecs (CodecCap *codec_cap)
/* we assume we have just one structure per caps as it should be */
GstStructure *media_struct = gst_caps_get_structure (codec_cap->caps, 0);
const gchar *name = gst_structure_get_name (media_struct);
- const gchar *h263version;
GstStructure *rtp_struct;
const gchar *encoding_name;
@@ -340,29 +366,36 @@ validate_h263_codecs (CodecCap *codec_cap)
if (strcmp (name, "video/x-h263"))
return TRUE;
- h263version = gst_structure_get_string (media_struct, "h263version");
+ /* If we don't have a h263version field, accept everything */
+ if (!gst_structure_has_field (media_struct, "h263version"))
+ return TRUE;
+
rtp_struct = gst_caps_get_structure (codec_cap->rtp_caps, 0);
if (!rtp_struct)
return FALSE;
+
+ /* If there no h263version, we accept everything */
encoding_name = gst_structure_get_string (rtp_struct, "encoding-name");
- if (!h263version || !encoding_name)
+ /* If there is no encoding name, we have a problem, lets refuse it */
+ if (!encoding_name)
return FALSE;
- if ( !strcmp (h263version, "h263"))
+ if (struct_field_has_line (media_struct, "h263version", "h263"))
{
/* baseline H263 can only be encoding name H263 or H263-1998 */
+
if (strcmp (encoding_name, "H263") &&
strcmp (encoding_name, "H263-1998"))
return FALSE;
}
- else if (!strcmp (h263version, "h263p"))
+ else if (struct_field_has_line (media_struct, "h263version", "h263p"))
{
/* has to be H263-1998 */
if (strcmp (encoding_name, "H263-1998"))
return FALSE;
}
- else if (!strcmp (h263version, "h263pp"))
+ else if (struct_field_has_line (media_struct, "h263version", "h263pp"))
{
/* has to be H263-2000 */
if (strcmp (encoding_name, "H263-2000"))
--
1.5.6.5
More information about the farsight-commits
mailing list