int x;
int capability;
+ int needaudio = FALSE;
int needvideo = FALSE;
int needtext = FALSE;
int debug = sip_debug_test_pvt(p);
}
#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) {
if (p->vrtp) {
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;
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 */
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);
{
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;
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)
/* 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;