[asterisk-commits] kharwell: branch kharwell/media_formats_translation_core r413539 - /team/khar...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 8 12:11:26 CDT 2014


Author: kharwell
Date: Thu May  8 12:11:18 2014
New Revision: 413539

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413539
Log:
moar review feedback changes

Modified:
    team/kharwell/media_formats_translation_core/main/codec.c
    team/kharwell/media_formats_translation_core/main/translate.c

Modified: team/kharwell/media_formats_translation_core/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/media_formats_translation_core/main/codec.c?view=diff&rev=413539&r1=413538&r2=413539
==============================================================================
--- team/kharwell/media_formats_translation_core/main/codec.c (original)
+++ team/kharwell/media_formats_translation_core/main/codec.c Thu May  8 12:11:18 2014
@@ -357,7 +357,7 @@
 	const struct ast_codec *left = obj;
 	const struct ast_codec *right = arg;
 
-	if (left->original_id == right->original_id) {
+	if (left == right) {
 		ast_str_append(buf, 0, "%s|", left->name);
 	}
 	return 0;

Modified: team/kharwell/media_formats_translation_core/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/media_formats_translation_core/main/translate.c?view=diff&rev=413539&r1=413538&r2=413539
==============================================================================
--- team/kharwell/media_formats_translation_core/main/translate.c (original)
+++ team/kharwell/media_formats_translation_core/main/translate.c Thu May  8 12:11:18 2014
@@ -299,6 +299,7 @@
 static void *newpvt(struct ast_translator *t, struct ast_format *explicit_dst)
 {
 	struct ast_trans_pvt *pvt;
+	struct ast_format *dst_format = NULL;
 	int len;
 	char *ofs;
 
@@ -333,6 +334,30 @@
 		ast_free(pvt);
 		return NULL;
 	}
+
+	if (!ast_strlen_zero(pvt->t->format)) {
+		dst_format = ast_format_cache_get(pvt->t->format);
+	}
+
+	if (!dst_format) {
+		struct ast_codec *codec = ast_codec_get(t->dst_codec.name,
+			t->dst_codec.type, t->dst_codec.sample_rate);
+		if (!codec) {
+			ast_log(LOG_ERROR, "Unable to get destination codec\n");
+			ast_free(pvt);
+			return NULL;
+		}
+		dst_format = ast_format_create(codec);
+		ao2_ref(codec, -1);
+	}
+
+	pvt->f.subclass.format = dst_format;
+	pvt->f.frametype = AST_FRAME_VOICE;
+	pvt->f.mallocd = 0;
+	pvt->f.offset = AST_FRIENDLY_OFFSET;
+	pvt->f.src = pvt->t->name;
+	pvt->f.data.ptr = pvt->outbuf.c;
+
 	ast_module_ref(t->module);
 	return pvt;
 }
@@ -394,7 +419,6 @@
 struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt,
 	int datalen, int samples)
 {
-	struct ast_codec *codec;
 	struct ast_frame *f = &pvt->f;
 
 	if (samples) {
@@ -412,21 +436,6 @@
 		f->datalen = pvt->datalen;
 		pvt->datalen = 0;
 	}
-
-
-	if (!(codec = ast_codec_get(pvt->t->dst_codec.name,
-				    pvt->t->dst_codec.type,
-				    pvt->t->dst_codec.sample_rate))) {
-		return NULL;
-	}
-	f->subclass.format = ast_format_create(codec);
-	ao2_ref(codec, -1);
-
-	f->frametype = AST_FRAME_VOICE;
-	f->mallocd = 0;
-	f->offset = AST_FRIENDLY_OFFSET;
-	f->src = pvt->t->name;
-	f->data.ptr = pvt->outbuf.c;
 
 	return ast_frisolate(f);
 }




More information about the asterisk-commits mailing list