[asterisk-commits] branch oej/t38passthrough r12500 - in
/team/oej/t38passthrough: channels/ con...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Mar 11 04:46:11 MST 2006
Author: oej
Date: Sat Mar 11 05:46:08 2006
New Revision: 12500
URL: http://svn.digium.com/view/asterisk?rev=12500&view=rev
Log:
Hopefully fixing t38 settings per peer/user
Modified:
team/oej/t38passthrough/channels/chan_sip.c
team/oej/t38passthrough/configs/sip.conf.sample
Modified: team/oej/t38passthrough/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/channels/chan_sip.c?rev=12500&r1=12499&r2=12500&view=diff
==============================================================================
--- team/oej/t38passthrough/channels/chan_sip.c (original)
+++ team/oej/t38passthrough/channels/chan_sip.c Sat Mar 11 05:46:08 2006
@@ -469,18 +469,13 @@
#define T38FAX_RATE_9600 (1 << 11) /*!< 9600 bps t38FaxRate */
#define T38FAX_RATE_12000 (1 << 12) /*!< 12000 bps t38FaxRate */
#define T38FAX_RATE_14400 (1 << 13) /*!< 14400 bps t38FaxRate */
+
+static int global_t38_capability = T38FAX_VERSION_0 | T38FAX_RATE_2400 | T38FAX_RATE_4800 | T38FAX_RATE_7200 | T38FAX_RATE_9600; /*!< This is default: NO MMR and JBIG trancoding, NO fill bit removal, transfered TCF, UDP FEC, Version 0 and 9600 max fax rate */
#endif
/*! \brief Codecs that we support by default: */
static struct sched_context *sched; /*!< The scheduling context */
static struct io_context *io; /*!< The IO context */
-
-#if defined(T38_SUPPORT)
-static int global_t38_capability = T38FAX_VERSION_0 | T38FAX_RATE_2400 | T38FAX_RATE_4800 | T38FAX_RATE_7200 | T38FAX_RATE_9600; /*!< This is default: NO MMR and JBIG trancoding, NO fill bit removal, transfered TCF, UDP FEC, Version 0 and 9600 max fax rate */
-static int global_t38udptl_support = 0;
-static int global_t38rtp_support = 0;
-static int global_t38tcp_support = 0;
-#endif
#define DEC_CALL_LIMIT 0
#define INC_CALL_LIMIT 1
@@ -659,7 +654,7 @@
#define SIP_PAGE2_T38SUPPORT_TCP (2 << 15) /*!< 17: T38 Fax Passthrough Support */
#define SIP_PAGE2_FLAGS_TO_COPY \
- (SIP_PAGE2_T38SUPPORT_RTP | SIP_PAGE2_T38SUPPORT_UDPTL | SIP_PAGE2_T38SUPPORT_TCP)
+ (SIP_PAGE2_T38SUPPORT)
/* SIP packet flags */
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
@@ -2996,22 +2991,25 @@
#ifdef T38_SUPPORT
/*! \brief SIP bridge
-\note Because attempt to do a native RTP bridge between peers happens before T38 re-invites
+\note Because attempt to do a native RTP bridge between peers happens before T38 re-invites
and that one time only, and at that moment neither peers have T38 enabled, this will
lead to the native RTP bridge always (if canreinvite is set to yes).
Since this is not good for T38 bridging, we have to disable native bridging entirely if
t38 support is enabled - not good, but working.
- XXX: It would be better to have user/peer configuration flag for t38support. :XXX
*/
static int sip_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms) {
-
- /* OEJ: We need to check for peer support here */
- if (!global_t38udptl_support) {
- return ast_rtp_bridge(c0, c1, flags, fo, rc, timeoutms);
- } else {
+ struct sip_pvt *p0 = c0->tech_pvt;
+ struct sip_pvt *p1 = c1->tech_pvt;
+
+ /* If both legs of the call support UDPTL, disable native RTP bridge */
+ /* XXXX Should we check for TCP and RTP as well here ???? */
+ if (ast_test_flag(&p0->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && ast_test_flag(&p1->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL)) {
ast_log(LOG_NOTICE, "T38 UDPTL support enabled, native RTP bridging disabled\n");
return AST_BRIDGE_FAILED_NOWARN;
- }
+ }
+
+ /* We can't do T38 passthrough, so go ahead with RTP bridge and possibly reinvites */
+ return ast_rtp_bridge(c0, c1, flags, fo, rc, timeoutms);
}
#endif
@@ -3294,7 +3292,7 @@
f = ast_dsp_process(p->owner, p->vad, f);
if (f && (f->frametype == AST_FRAME_DTMF)) {
#if defined(T38_SUPPORT)
- if (global_t38udptl_support && f->subclass == 'f') {
+ if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
/* Fax tone */
if (option_debug)
ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
@@ -3330,7 +3328,7 @@
#if defined(T38_SUPPORT)
/* If we are NOT bridged to another channel, and we have detected fax tone we issue T38 re-invite to a peer */
/* If we are bridged then it is responsibility of the SIP device to issue T38 re-invite if it detects CNG or fax preabmle */
- if (faxdetected && global_t38udptl_support && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
+ if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
if (!ast_test_flag(p, SIP_GOTREFER)) {
if (!p->pendinginvite) {
if (option_debug > 2)
@@ -3440,7 +3438,7 @@
if (global_videosupport)
p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
#if defined(T38_SUPPORT)
- if (global_t38udptl_support)
+ if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) )
p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr.sin_addr);
/* TODO: Need to check for error - or ?? */
#endif
@@ -3874,7 +3872,7 @@
}
}
#if defined(T38_SUPPORT)
- if (p->udptl && global_t38udptl_support && (sscanf(m, "image %d udptl t38 %n", &x, &len) == 1)) {
+ if (p->udptl && (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL)) && (sscanf(m, "image %d udptl t38 %n", &x, &len) == 1)) {
if (debug)
ast_verbose("Got T.38 offer in SDP\n");
found = 1;
@@ -3975,7 +3973,7 @@
#if defined(T38_SUPPORT)
/* Setup UDPTL port number */
sin.sin_port = htons(udptlportno);
- if (p->udptl && global_t38udptl_support && sin.sin_port) {
+ if (p->udptl && (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL)) && sin.sin_port) {
ast_udptl_set_peer(p->udptl, &sin);
if (debug) {
ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
@@ -5111,7 +5109,7 @@
alreadysent |= p->prefcodec;
}
#if defined(T38_SUPPORT)
- if (global_t38rtp_support) {
+ if ((ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_RTP))) {
/* TODO: Improve this */
len = snprintf(a_audio_next, a_audio_left, " %d", 191);
a_audio_next += len;
@@ -7756,6 +7754,7 @@
/* Find user based on user name in the from header */
if (user && ast_apply_ha(user->ha, sin)) {
ast_copy_flags(p, user, SIP_FLAGS_TO_COPY);
+ ast_copy_flags(p, &user->flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
/* copy channel vars */
for (v = user->chanvars ; v ; v = v->next) {
if ((tmpvar = ast_variable_new(v->name, v->value))) {
@@ -12801,14 +12800,7 @@
user->ha = NULL;
ast_copy_flags(user, &global_flags, SIP_FLAGS_TO_COPY);
-#ifdef T38_SUPPORT
- if(global_t38udptl_support)
- ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
- if(global_t38rtp_support)
- ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_RTP);
- if(global_t38tcp_support)
- ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
-#endif
+ ast_copy_flags(&user->flags_page2, &global_flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
user->capability = global_capability;
user->prefs = default_prefs;
/* set default context */
@@ -12871,6 +12863,20 @@
user->callingpres = ast_parse_caller_presentation(v->value);
if (user->callingpres == -1)
user->callingpres = atoi(v->value);
+#if defined(T38_SUPPORT)
+ } else if (!strcasecmp(v->name, "t38pt_udptl")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
+ }
+ } else if (!strcasecmp(v->name, "t38pt_rtp")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_RTP);
+ }
+ } else if (!strcasecmp(v->name, "t38pt_tcp")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
+ }
+#endif
}
}
ast_copy_flags(user, &userflags, mask.flags);
@@ -12915,15 +12921,6 @@
peer->pickupgroup = 0;
peer->maxms = default_qualify;
peer->prefs = default_prefs;
-#ifdef T38_SUPPORT
- /* This needs to move completely into flags... */
- if(global_t38udptl_support)
- ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
- if(global_t38rtp_support)
- ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_RTP);
- if(global_t38tcp_support)
- ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
-#endif
}
/*! \brief Create temporary peer (used in autocreatepeer mode) */
@@ -13131,6 +13128,20 @@
ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d. Using default.\n", v->value, v->lineno);
peer->rtpkeepalive = global_rtpkeepalive;
}
+#if defined(T38_SUPPORT)
+ } else if (!strcasecmp(v->name, "t38pt_udptl")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
+ }
+ } else if (!strcasecmp(v->name, "t38pt_rtp")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_RTP);
+ }
+ } else if (!strcasecmp(v->name, "t38pt_tcp")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
+ }
+#endif
} else if (!strcasecmp(v->name, "setvar")) {
/* Set peer channel variable */
varname = ast_strdupa(v->value);
@@ -13234,11 +13245,6 @@
ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime));
ast_copy_string(global_realm, DEFAULT_REALM, sizeof(global_realm));
ast_copy_string(default_callerid, DEFAULT_CALLERID, sizeof(default_callerid));
-#if defined(T38_SUPPORT)
- global_t38udptl_support = 0;
- global_t38rtp_support = 0;
- global_t38tcp_support = 0;
-#endif
global_videosupport = DEFAULT_VIDEOSUPPORT;
compactheaders = DEFAULT_COMPACTHEADERS;
global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;
@@ -13331,19 +13337,16 @@
} else if (!strcasecmp(v->name, "videosupport")) {
global_videosupport = ast_true(v->value);
#if defined(T38_SUPPORT)
- } else if (!strcasecmp(v->name, "global_t38udptl_support")) {
+ } else if (!strcasecmp(v->name, "t38pt_udptl")) {
if (ast_true(v->value)) {
- global_t38udptl_support = TRUE;
ast_set_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
}
- } else if (!strcasecmp(v->name, "global_t38rtp_support")) {
+ } else if (!strcasecmp(v->name, "t38pt_rtp")) {
if (ast_true(v->value)) {
- global_t38rtp_support = TRUE;
ast_set_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_RTP);
}
- } else if (!strcasecmp(v->name, "global_t38tcp_support")) {
+ } else if (!strcasecmp(v->name, "t38pt_tcp")) {
if (ast_true(v->value)) {
- global_t38tcp_support = TRUE;
ast_set_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
}
#endif
Modified: team/oej/t38passthrough/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/configs/sip.conf.sample?rev=12500&r1=12499&r2=12500&view=diff
==============================================================================
--- team/oej/t38passthrough/configs/sip.conf.sample (original)
+++ team/oej/t38passthrough/configs/sip.conf.sample Sat Mar 11 05:46:08 2006
@@ -122,9 +122,11 @@
;
;---------------------------- T.38 FAX PASSTHROUGH SUPPORT ------------------------------------
;
-; t38udptlsupport = yes ; Default false
-; t38rtpsupport = yes ; Default false
-; t38tcpsupport = yes ; Default false, not yet used
+; These settings are available in the [general] section as well as in device configurations
+;
+; t38pt_udptl = yes ; Default false
+; t38pt_rtp = yes ; Default false
+; t38pt_tcp = yes ; Default false, not yet used
;
;----------------------------------------- OUTBOUND SIP REGISTRATIONS ------------------------
; Asterisk can register as a SIP user agent to a SIP proxy (provider)
More information about the asterisk-commits
mailing list