aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_sip.c22
-rw-r--r--main/channel.c25
2 files changed, 35 insertions, 12 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 9d755c684..6f4ed046b 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -7804,6 +7804,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
int x;
int capability;
+ int needaudio = FALSE;
int needvideo = FALSE;
int needtext = FALSE;
int debug = sip_debug_test_pvt(p);
@@ -7847,6 +7848,10 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
}
#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) {
@@ -7941,7 +7946,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
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 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
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 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
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);
diff --git a/main/channel.c b/main/channel.c
index f8f1fe637..bbfcfdd4a 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3094,6 +3094,9 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
{
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 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c
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 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
/* 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;