[Asterisk-code-review] translate: Provide translation modules the result of SDP neg... (asterisk[13])

Alexander Traud asteriskteam at digium.com
Wed Nov 11 06:37:52 CST 2015


Alexander Traud has uploaded a new change for review.

  https://gerrit.asterisk.org/1599

Change subject: translate: Provide translation modules the result of SDP negotiation.
......................................................................

translate: Provide translation modules the result of SDP negotiation.

Previously, a trancoding module did not have access to the joint but cached
format. Therefore, the module did not have access to the attributes negotiated
via SDP (line fmtp). Now, a translation module receives the joint format.

ASTERISK-25545 #close

Change-Id: Id6878a989b50573298dab115d3371ea369e1a718
---
M main/translate.c
1 file changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/99/1599/1

diff --git a/main/translate.c b/main/translate.c
index 6d92777..4ffe1cc 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -306,7 +306,7 @@
  * \brief Allocate the descriptor, required outbuf space,
  * and possibly desc.
  */
-static struct ast_trans_pvt *newpvt(struct ast_translator *t)
+static struct ast_trans_pvt *newpvt(struct ast_translator *t, struct ast_format *format)
 {
 	struct ast_trans_pvt *pvt;
 	int len;
@@ -332,6 +332,7 @@
 	if (t->buf_size) {/* finally buffer and header */
 		pvt->outbuf.c = ofs + AST_FRIENDLY_OFFSET;
 	}
+	pvt->f.subclass.format = ao2_bump(format);
 
 	ast_module_ref(t->module);
 
@@ -484,7 +485,12 @@
 			AST_RWLIST_UNLOCK(&translators);
 			return NULL;
 		}
-		if (!(cur = newpvt(t))) {
+		if ((t->dst_codec.sample_rate != ast_format_get_sample_rate(dst)) || (strcmp(t->dst_codec.name, ast_format_get_name(dst)))) {
+			cur = newpvt(t, NULL);
+		} else {
+			cur = newpvt(t, dst);
+		}
+		if (!cur) {
 			ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n",
 				ast_format_get_name(src), ast_format_get_name(dst));
 			if (head) {
@@ -638,7 +644,7 @@
 		return;
 	}
 
-	pvt = newpvt(t);
+	pvt = newpvt(t, NULL);
 	if (!pvt) {
 		ast_log(LOG_WARNING, "Translator '%s' appears to be broken and will probably fail.\n", t->name);
 		t->comp_cost = 999999;

-- 
To view, visit https://gerrit.asterisk.org/1599
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6878a989b50573298dab115d3371ea369e1a718
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>



More information about the asterisk-code-review mailing list