[asterisk-commits] oej: trunk r103772 - in /trunk: channels/chan_sip.c main/channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 18 11:12:14 CST 2008
Author: oej
Date: Mon Feb 18 11:12:13 2008
New Revision: 103772
URL: http://svn.digium.com/view/asterisk?view=rev&rev=103772
Log:
Make sure we can set up calls without audio (text+video).
And ... it works!
Modified:
trunk/channels/chan_sip.c
trunk/main/channel.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=103772&r1=103771&r2=103772
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Feb 18 11:12:13 2008
@@ -7804,6 +7804,7 @@
int x;
int capability;
+ int needaudio = FALSE;
int needvideo = FALSE;
int needtext = FALSE;
int debug = sip_debug_test_pvt(p);
@@ -7846,6 +7847,10 @@
ast_str_append(&a_audio, 0, "a=rtpmap:%d %s/%d\r\n", 191, "t38", 8000);
}
#endif
+
+ /* Check if we need audio */
+ if (capability & AST_FORMAT_AUDIO_MASK)
+ needaudio = TRUE;
/* Check if we need video in this call */
if ((capability & AST_FORMAT_VIDEO_MASK) && !p->novideo) {
@@ -7941,7 +7946,7 @@
alreadysent |= codec;
}
- /* Start by sending our preferred audio codecs */
+ /* Start by sending our preferred audio/video codecs */
for (x = 0; x < 32; x++) {
int codec;
@@ -8008,14 +8013,17 @@
a_audio->len - a_audio->used < 2 || a_video->len - a_video->used < 2)
ast_log(LOG_WARNING, "SIP SDP may be truncated due to undersized buffer!!\n");
- ast_str_append(&m_audio, 0, "\r\n");
+ if (needaudio)
+ ast_str_append(&m_audio, 0, "\r\n");
if (needvideo)
ast_str_append(&m_video, 0, "\r\n");
if (needtext)
ast_str_append(&m_text, 0, "\r\n");
len = strlen(version) + strlen(subject) + strlen(owner) +
- strlen(connection) + strlen(stime) + m_audio->used + a_audio->used + strlen(hold);
+ strlen(connection) + strlen(stime);
+ if (needaudio)
+ len += m_audio->used + a_audio->used + strlen(hold);
if (needvideo) /* only if video response is appropriate */
len += m_video->used + a_video->used + strlen(bandwidth) + strlen(hold);
if (needtext) /* only if text response is appropriate */
@@ -8030,9 +8038,11 @@
if (needvideo) /* only if video response is appropriate */
add_line(resp, bandwidth);
add_line(resp, stime);
- add_line(resp, m_audio->str);
- add_line(resp, a_audio->str);
- add_line(resp, hold);
+ if (needaudio) {
+ add_line(resp, m_audio->str);
+ add_line(resp, a_audio->str);
+ add_line(resp, hold);
+ }
if (needvideo) { /* only if video response is appropriate */
add_line(resp, m_video->str);
add_line(resp, a_video->str);
Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=103772&r1=103771&r2=103772
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Mon Feb 18 11:12:13 2008
@@ -3094,6 +3094,9 @@
{
int native;
int res;
+
+ if (!fmt || !native) /* No audio requested */
+ return 0; /* Let's try a call without any sounds (video, text) */
/* Make sure we only consider audio */
fmt &= AST_FORMAT_AUDIO_MASK;
@@ -3337,12 +3340,17 @@
capabilities = chan->tech->capabilities;
fmt = format & AST_FORMAT_AUDIO_MASK;
- res = ast_translator_best_choice(&fmt, &capabilities);
- if (res < 0) {
- ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format);
- *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
- AST_RWLIST_UNLOCK(&channels);
- return NULL;
+ if (fmt) {
+ /* We have audio - is it possible to connect the various calls to each other?
+ (Avoid this check for calls without audio, like text+video calls)
+ */
+ res = ast_translator_best_choice(&fmt, &capabilities);
+ if (res < 0) {
+ ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format);
+ *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+ AST_RWLIST_UNLOCK(&channels);
+ return NULL;
+ }
}
AST_RWLIST_UNLOCK(&channels);
if (!chan->tech->requester)
@@ -3483,6 +3491,11 @@
/* Set up translation from the 'from' channel to the 'to' channel */
src = from->nativeformats;
dst = to->nativeformats;
+
+ /* If there's no audio in this call, don't bother with trying to find a translation path */
+ if ((src & AST_FORMAT_AUDIO_MASK) == 0 || (dst & AST_FORMAT_AUDIO_MASK) == 0)
+ return 0;
+
if (ast_translator_best_choice(&dst, &src) < 0) {
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", from->name, src, to->name, dst);
return -1;
More information about the asterisk-commits
mailing list