summaryrefslogtreecommitdiff
path: root/channels/chan_motif.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2012-07-10 14:00:05 +0000
committerJoshua Colp <jcolp@digium.com>2012-07-10 14:00:05 +0000
commit74ebe6d5aba740c5586ee13dba9b8e0b778fd76a (patch)
tree16981b167d687f9f67c0cdcec221520e4071cf94 /channels/chan_motif.c
parent6416a246edb7aca07a595098515591af7a92fb94 (diff)
Respect codec preference order when adding codecs to a media description.
This change allows an endpoint in motif.conf to be configured with a preference of G.722 and fallback of ulaw. With Google this allows communication with Google Talk clients to use G.722 while when using Google Voice ulaw will be used. (closes issue ASTERISK-20114) Reported by: Malcolm Davenport git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_motif.c')
-rw-r--r--channels/chan_motif.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/channels/chan_motif.c b/channels/chan_motif.c
index d8e332049..0a816a5c8 100644
--- a/channels/chan_motif.c
+++ b/channels/chan_motif.c
@@ -1119,22 +1119,28 @@ static void jingle_send_transport_info(struct jingle_session *session, const cha
static int jingle_add_payloads_to_description(struct jingle_session *session, struct ast_rtp_instance *rtp, iks *description, iks **payloads, enum ast_format_type type)
{
struct ast_format format;
- int i = 0, res = 0;
+ int x = 0, i = 0, res = 0;
- ast_format_cap_iter_start(session->jointcap);
- while (!(ast_format_cap_iter_next(session->jointcap, &format)) && (i < (session->maxpayloads - 2))) {
+ for (x = 0; (x < AST_CODEC_PREF_SIZE) && (i < (session->maxpayloads - 2)); x++) {
int rtp_code;
iks *payload;
char tmp[32];
+ if (!ast_codec_pref_index(&session->prefs, x, &format)) {
+ break;
+ }
+
if (AST_FORMAT_GET_TYPE(format.id) != type) {
continue;
}
+ if (!ast_format_cap_iscompatible(session->jointcap, &format)) {
+ continue;
+ }
+
if (((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(rtp), 1, &format, 0)) == -1) ||
(!(payload = iks_new("payload-type")))) {
- res = -1;
- goto end;
+ return -1;
}
if (session->transport == JINGLE_TRANSPORT_GOOGLE_V1) {
@@ -1195,9 +1201,6 @@ static int jingle_add_payloads_to_description(struct jingle_session *session, st
}
}
-end:
- ast_format_cap_iter_end(session->jointcap);
-
return res;
}