[asterisk-commits] file: branch group/media_formats r406636 - in /team/group/media_formats: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 27 09:28:47 CST 2014


Author: file
Date: Mon Jan 27 09:28:44 2014
New Revision: 406636

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406636
Log:
Implement ast_format_cap_add_all_by_type.

Modified:
    team/group/media_formats/include/asterisk/codec.h
    team/group/media_formats/main/codec.c
    team/group/media_formats/main/format_cap_ng.c

Modified: team/group/media_formats/include/asterisk/codec.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/codec.h?view=diff&rev=406636&r1=406635&r2=406636
==============================================================================
--- team/group/media_formats/include/asterisk/codec.h (original)
+++ team/group/media_formats/include/asterisk/codec.h Mon Jan 27 09:28:44 2014
@@ -135,6 +135,13 @@
 struct ast_codec *ast_codec_get_by_id(int id);
 
 /*!
+ * \brief Retrieve the current maximum identifier for codec iteration
+ *
+ * \return Maximum codec identifier
+ */
+int ast_codec_get_max(void);
+
+/*!
  * \brief Conversion function to take a media type and turn it into a string
  *
  * \param type The media type

Modified: team/group/media_formats/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/codec.c?view=diff&rev=406636&r1=406635&r2=406636
==============================================================================
--- team/group/media_formats/main/codec.c (original)
+++ team/group/media_formats/main/codec.c Mon Jan 27 09:28:44 2014
@@ -304,6 +304,11 @@
 	return ao2_callback(codecs, 0, codec_id_cmp, &id);
 }
 
+int ast_codec_get_max(void)
+{
+	return codec_id;
+}
+
 const char *ast_codec_media_type2str(enum ast_media_type type)
 {
 	switch (type) {

Modified: team/group/media_formats/main/format_cap_ng.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format_cap_ng.c?view=diff&rev=406636&r1=406635&r2=406636
==============================================================================
--- team/group/media_formats/main/format_cap_ng.c (original)
+++ team/group/media_formats/main/format_cap_ng.c Mon Jan 27 09:28:44 2014
@@ -154,7 +154,39 @@
 
 int ast_format_cap_add_all_by_type(struct ast_format_cap *cap, enum ast_media_type type)
 {
-	return -1;
+	int id;
+
+	for (id = 0; id < ast_codec_get_max(); ++id) {
+		struct ast_codec *codec = ast_codec_get_by_id(id);
+		struct ast_format *format;
+		int res;
+
+		if (!codec) {
+			continue;
+		}
+
+		if (codec->type != type) {
+			ao2_ref(codec, -1);
+			continue;
+		}
+
+		format = ast_format_create(codec);
+		ao2_ref(codec, -1);
+
+		if (!format) {
+			return -1;
+		}
+
+		/* Use the global framing or default framing of the codec */
+		res = ast_format_cap_add(cap, format, 0);
+		ao2_ref(format, -1);
+
+		if (res) {
+			return -1;
+		}
+	}
+
+	return 0;
 }
 
 int ast_format_cap_append(struct ast_format_cap *dst, const struct ast_format_cap *src)




More information about the asterisk-commits mailing list