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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 25 08:03:45 CST 2014


Author: file
Date: Sat Jan 25 08:03:38 2014
New Revision: 406484

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406484
Log:
Add the ability to retrieve a codec using the identifier, which provides an easy iteration method.

Modified:
    team/group/media_formats/include/asterisk/codec.h
    team/group/media_formats/main/codec.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=406484&r1=406483&r2=406484
==============================================================================
--- team/group/media_formats/include/asterisk/codec.h (original)
+++ team/group/media_formats/include/asterisk/codec.h Sat Jan 25 08:03:38 2014
@@ -120,6 +120,21 @@
 struct ast_codec *ast_codec_get(const char *name, enum ast_media_type type, unsigned int sample_rate);
 
 /*!
+ * \brief Retrieve a codec given the unique identifier
+ *
+ * \param id The unique identifier
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ *
+ * \note Identifiers start at 1 so if iterating don't start at 0.
+ *
+ * \note The returned codec is reference counted and ao2_ref or ao2_cleanup
+ * must be used to release the reference.
+ */
+struct ast_codec *ast_codec_get_by_id(int id);
+
+/*!
  * \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=406484&r1=406483&r2=406484
==============================================================================
--- team/group/media_formats/main/codec.c (original)
+++ team/group/media_formats/main/codec.c Sat Jan 25 08:03:38 2014
@@ -299,6 +299,11 @@
 	return ao2_find(codecs, &codec, OBJ_SEARCH_OBJECT);
 }
 
+struct ast_codec *ast_codec_get_by_id(int id)
+{
+	return ao2_callback(codecs, 0, codec_id_cmp, &id);
+}
+
 const char *ast_codec_media_type2str(enum ast_media_type type)
 {
 	switch (type) {




More information about the asterisk-commits mailing list