aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-05 16:51:59 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-05 16:51:59 +0000
commit34d93204194ddf3e8cbe2139cc3225d972b56cdd (patch)
tree71ac6e580f21452b27138c9957e903daab098ad5
parentc3ecb6a1532fbddc64348b23dd46b88adbf9b70b (diff)
A couple of changes to T.38 SDP attribute handling
There are some boolean attributes for T.38 such as T38FaxFillBitRemoval, T38FaxTranscodingMMR, and T38FaxTranscodingJBIG. By simply being present, we should treat these as a "true" value. The current code, however, was requiring a 1 or 0 as the value of the attribute in order to parse it. This is due to the fact that there are some T.38 endpoints and gateways that also transmit this information incorrectly. This patch follows the "be liberal in what you accept and strict in what you send" philosophy by accepting both the correctly- and incorrectly-formatted attributes, but only sending information as it is supposed to be sent. It was also discovered that a particular type of T.38 gateway sends some non-standard T.38 SDP attributes. Instead of using T38FaxMaxDatagram and T38MaxBitRate, it used T38MaxDatagram and T38FaxMaxRate respectively. We now will properly accept these attributes as well. Note that there are a lot of patches cited in the below commit message template. This is because the person who submitted these patches is an awesome person and wrote 1.4, 1.6.0, and 1.6.1 variants. (closes issue #13976) Reported by: linulin Patches: chan_sip.c.1.4-update1.diff uploaded by arcivanov (license 648) chan_sip.c.1.6.0-update1.diff uploaded by arcivanov (license 648) chan_sip.c.1.6.1-update1.diff uploaded by arcivanov (license 648) chan_sip.c.1.4-relaxedT38_update1.diff uploaded by arcivanov (license 648) chan_sip.c.1.6.0-relaxedT38_update1.diff uploaded by arcivanov (license 648) chan_sip.c.1.6.1-relaxedT38_update1.diff uploaded by arcivanov (license 648) Tested by: arcivanov git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@167179 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c76
1 files changed, 48 insertions, 28 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 284670ad1..93c949bb9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -5436,7 +5436,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
found = 1;
if (option_debug > 2)
ast_log(LOG_DEBUG, "MaxBufferSize:%d\n",x);
- } else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
+ } else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1) || (sscanf(a, "T38FaxMaxRate:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
ast_log(LOG_DEBUG,"T38MaxBitRate: %d\n",x);
@@ -5468,31 +5468,48 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
peert38capability |= T38FAX_VERSION_0;
else if (x == 1)
peert38capability |= T38FAX_VERSION_1;
- } else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
+ } else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1) || (sscanf(a, "T38MaxDatagram:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
ast_log(LOG_DEBUG, "FaxMaxDatagram: %d\n",x);
ast_udptl_set_far_max_datagram(p->udptl, x);
ast_udptl_set_local_max_datagram(p->udptl, x);
- } else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
+ } else if ((strncmp(a, "T38FaxFillBitRemoval", 20) == 0)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
- if (x == 1)
- peert38capability |= T38FAX_FILL_BIT_REMOVAL;
- } else if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
+ if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
+ if (x == 1)
+ peert38capability |= T38FAX_FILL_BIT_REMOVAL;
+ } else {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "FillBitRemoval\n");
+ peert38capability |= T38FAX_FILL_BIT_REMOVAL;
+ }
+ } else if ((strncmp(a, "T38FaxTranscodingMMR", 20) == 0)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
- if (x == 1)
- peert38capability |= T38FAX_TRANSCODING_MMR;
- }
- if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
+ if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
+ if (x == 1)
+ peert38capability |= T38FAX_TRANSCODING_MMR;
+ } else {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "Transcoding MMR\n");
+ peert38capability |= T38FAX_TRANSCODING_MMR;
+ }
+ } else if ((strncmp(a, "T38FaxTranscodingJBIG", 21) == 0)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
- if (x == 1)
- peert38capability |= T38FAX_TRANSCODING_JBIG;
+ if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
+ if (x == 1)
+ peert38capability |= T38FAX_TRANSCODING_JBIG;
+ } else {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "Transcoding JBIG\n");
+ peert38capability |= T38FAX_TRANSCODING_JBIG;
+ }
} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
found = 1;
if (option_debug > 2)
@@ -6354,31 +6371,31 @@ static int t38_get_rate(int t38cap)
if (maxrate & T38FAX_RATE_14400) {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 14400 found\n");
+ ast_log(LOG_DEBUG, "T38MaxBitRate 14400 found\n");
return 14400;
} else if (maxrate & T38FAX_RATE_12000) {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 12000 found\n");
+ ast_log(LOG_DEBUG, "T38MaxBitRate 12000 found\n");
return 12000;
} else if (maxrate & T38FAX_RATE_9600) {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 9600 found\n");
+ ast_log(LOG_DEBUG, "T38MaxBitRate 9600 found\n");
return 9600;
} else if (maxrate & T38FAX_RATE_7200) {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 7200 found\n");
+ ast_log(LOG_DEBUG, "T38MaxBitRate 7200 found\n");
return 7200;
} else if (maxrate & T38FAX_RATE_4800) {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 4800 found\n");
+ ast_log(LOG_DEBUG, "T38MaxBitRate 4800 found\n");
return 4800;
} else if (maxrate & T38FAX_RATE_2400) {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 2400 found\n");
+ ast_log(LOG_DEBUG, "T38MaxBitRate 2400 found\n");
return 2400;
} else {
if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
+ ast_log(LOG_DEBUG, "Strange, T38MaxBitRate NOT found in peers T38 SDP.\n");
return 0;
}
}
@@ -6453,9 +6470,12 @@ static int add_t38_sdp(struct sip_request *resp, struct sip_pvt *p)
ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxVersion:1\r\n");
if ((x = t38_get_rate(p->t38.jointcapability)))
ast_build_string(&a_modem_next, &a_modem_left, "a=T38MaxBitRate:%d\r\n",x);
- ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxFillBitRemoval:%d\r\n", (p->t38.jointcapability & T38FAX_FILL_BIT_REMOVAL) ? 1 : 0);
- ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxTranscodingMMR:%d\r\n", (p->t38.jointcapability & T38FAX_TRANSCODING_MMR) ? 1 : 0);
- ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxTranscodingJBIG:%d\r\n", (p->t38.jointcapability & T38FAX_TRANSCODING_JBIG) ? 1 : 0);
+ if ((p->t38.jointcapability & T38FAX_FILL_BIT_REMOVAL) == T38FAX_FILL_BIT_REMOVAL)
+ ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxFillBitRemoval\r\n");
+ if ((p->t38.jointcapability & T38FAX_TRANSCODING_MMR) == T38FAX_TRANSCODING_MMR)
+ ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxTranscodingMMR\r\n");
+ if ((p->t38.jointcapability & T38FAX_TRANSCODING_JBIG) == T38FAX_TRANSCODING_JBIG)
+ ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxTranscodingJBIG\r\n");
ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxRateManagement:%s\r\n", (p->t38.jointcapability & T38FAX_RATE_MANAGEMENT_LOCAL_TCF) ? "localTCF" : "transferredTCF");
x = ast_udptl_get_local_max_datagram(p->udptl);
ast_build_string(&a_modem_next, &a_modem_left, "a=T38FaxMaxBuffer:%d\r\n",x);