[asterisk-commits] file: branch group/media_formats r407437 - in /team/group/media_formats: code...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 5 12:27:46 CST 2014


Author: file
Date: Wed Feb  5 12:27:43 2014
New Revision: 407437

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407437
Log:
Add the beginnings of changes in the translation core. Codecs now transcode between, well, codecs.

Modified:
    team/group/media_formats/codecs/codec_adpcm.c
    team/group/media_formats/codecs/ex_adpcm.h
    team/group/media_formats/codecs/ex_alaw.h
    team/group/media_formats/include/asterisk/format_cache.h
    team/group/media_formats/include/asterisk/slin.h
    team/group/media_formats/include/asterisk/translate.h

Modified: team/group/media_formats/codecs/codec_adpcm.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/codecs/codec_adpcm.c?view=diff&rev=407437&r1=407436&r2=407437
==============================================================================
--- team/group/media_formats/codecs/codec_adpcm.c (original)
+++ team/group/media_formats/codecs/codec_adpcm.c Wed Feb  5 12:27:43 2014
@@ -320,26 +320,32 @@
 	res = ast_unregister_translator(&lintoadpcm);
 	res |= ast_unregister_translator(&adpcmtolin);
 
+	ao2_cleanup(adpcmtolin.src_codec);
+	ao2_cleanup(adpcmtolin.dst_codec);
+	ao2_cleanup(lintoadpcm.src_codec);
+	ao2_cleanup(lintoadpcm.dst_codec);
+
 	return res;
 }
 
 static int load_module(void)
 {
-	int res;
-
-	ast_format_set(&adpcmtolin.src_format, AST_FORMAT_ADPCM, 0);
-	ast_format_set(&adpcmtolin.dst_format, AST_FORMAT_SLINEAR, 0);
-
-	ast_format_set(&lintoadpcm.src_format, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&lintoadpcm.dst_format, AST_FORMAT_ADPCM, 0);
+	int res = 0;
+
+	adpcmtolin.src_codec = ast_codec_get("adpcm", AST_MEDIA_TYPE_AUDIO, 8000);
+	adpcmtolin.dst_codec = ast_codec_get("slin", AST_MEDIA_TYPE_AUDIO, 8000);
+
+	lintoadpcm.src_codec = ast_codec_get("slin", AST_MEDIA_TYPE_AUDIO, 8000);
+	lintoadpcm.dst_codec = ast_codec_get("adpcm", AST_MEDIA_TYPE_AUDIO, 8000);
 
 	res = ast_register_translator(&adpcmtolin);
-	if (!res)
-		res = ast_register_translator(&lintoadpcm);
-	else
-		ast_unregister_translator(&adpcmtolin);
-	if (res)
+	res |= ast_register_translator(&lintoadpcm);
+
+	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/group/media_formats/codecs/ex_adpcm.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/codecs/ex_adpcm.h?view=diff&rev=407437&r1=407436&r2=407437
==============================================================================
--- team/group/media_formats/codecs/ex_adpcm.h (original)
+++ team/group/media_formats/codecs/ex_adpcm.h Wed Feb  5 12:27:43 2014
@@ -26,7 +26,8 @@
 		.src = __PRETTY_FUNCTION__,
 		.data.ptr = ex_adpcm,
 	};
-	ast_format_set(&f.subclass.format, AST_FORMAT_ADPCM, 0);
+
+	f.subclass.format = ast_format_adpcm;
 
 	return &f;
 }

Modified: team/group/media_formats/codecs/ex_alaw.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/codecs/ex_alaw.h?view=diff&rev=407437&r1=407436&r2=407437
==============================================================================
--- team/group/media_formats/codecs/ex_alaw.h (original)
+++ team/group/media_formats/codecs/ex_alaw.h Wed Feb  5 12:27:43 2014
@@ -31,6 +31,6 @@
 		.src = __PRETTY_FUNCTION__,
 		.data.ptr = ex_alaw,
 	};
-	ast_format_set(&f.subclass.format, AST_FORMAT_ALAW, 0);
+	f.subclass.format = ast_format_ulaw;
 	return &f;
 }

Modified: team/group/media_formats/include/asterisk/format_cache.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_cache.h?view=diff&rev=407437&r1=407436&r2=407437
==============================================================================
--- team/group/media_formats/include/asterisk/format_cache.h (original)
+++ team/group/media_formats/include/asterisk/format_cache.h Wed Feb  5 12:27:43 2014
@@ -89,6 +89,11 @@
 extern struct ast_format *ast_format_gsm;
 
 /*!
+ * \brief Built-in cached adpcm format.
+ */
+extern struct ast_format *ast_format_adpcm;
+
+/*!
  * \brief Initialize format cache support within the core.
  *
  * \retval 0 success

Modified: team/group/media_formats/include/asterisk/slin.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/slin.h?view=diff&rev=407437&r1=407436&r2=407437
==============================================================================
--- team/group/media_formats/include/asterisk/slin.h (original)
+++ team/group/media_formats/include/asterisk/slin.h Wed Feb  5 12:27:43 2014
@@ -70,7 +70,8 @@
 		.data.ptr = ex_slin8,
 	};
 
-	ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR, 0);
+	f.subclass.format = ast_format_slin;
+
 	return &f;
 }
 
@@ -86,6 +87,7 @@
 		.data.ptr = ex_slin16,
 	};
 
-	ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR16, 0);
+	f.subclass.format = ast_format_slin16;
+
 	return &f;
 }

Modified: team/group/media_formats/include/asterisk/translate.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/translate.h?view=diff&rev=407437&r1=407436&r2=407437
==============================================================================
--- team/group/media_formats/include/asterisk/translate.h (original)
+++ team/group/media_formats/include/asterisk/translate.h Wed Feb  5 12:27:43 2014
@@ -32,6 +32,8 @@
 #include "asterisk/frame.h"
 #include "asterisk/plc.h"
 #include "asterisk/linkedlists.h"
+#include "asterisk/format_cap.h"
+#include "asterisk/format_cache.h"
 #endif
 
 struct ast_trans_pvt;	/* declared below */
@@ -134,8 +136,8 @@
  */
 struct ast_translator {
 	char name[80];                         /*!< Name of translator */
-	struct ast_format src_format;          /*!< Source format */
-	struct ast_format dst_format;          /*!< Destination format */
+	struct ast_codec *src_codec;		   /*!< Source codec */
+	struct ast_codec *dst_codec;		   /*!< Destination codec */
 
 	int table_cost;                        /*!< Cost value associated with this translator based
 	                                        *   on translation cost table. */




More information about the asterisk-commits mailing list