--- res/res_format_attr_celt.c +++ res/res_format_attr_celt.c @@ -31,4 +31,10 @@ +#include /* for tolower */ + #include "asterisk/module.h" #include "asterisk/format.h" +#include "asterisk/astobj2.h" /* for ao2_ref */ +#include "asterisk/logger.h" /* for ast_log, LOG_WARNING */ +#include "asterisk/strings.h" /* for ast_str_append */ +#include "asterisk/utils.h" /* for MIN */ @@ -70,6 +76,7 @@ static int celt_clone(const struct ast_format *src, struct ast_format *dst) static struct ast_format *celt_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; struct ast_format *cloned; struct celt_attr *attr; unsigned int val; @@ -80,7 +87,12 @@ static struct ast_format *celt_parse_sdp_fmtp(const struct ast_format *format, c } attr = ast_format_get_attribute_data(cloned); + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - if (sscanf(attributes, "framesize=%30u", &val) == 1) { + if (sscanf(attribs, "framesize=%30u", &val) == 1) { attr->framesize = val; } --- res/res_format_attr_h263.c +++ res/res_format_attr_h263.c @@ -35,4 +35,8 @@ +#include /* for toupper */ + #include "asterisk/module.h" #include "asterisk/format.h" +#include "asterisk/strings.h" /* for ast_str_append */ +#include "asterisk/utils.h" /* for ast_strip */ @@ -154,2 +158,6 @@ static struct ast_format *h263_parse_sdp_fmtp(const struct ast_format *format, c attr = ast_format_get_attribute_data(cloned); + /* upper-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = toupper(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ --- res/res_format_attr_ilbc.c +++ res/res_format_attr_ilbc.c @@ -33,6 +33,8 @@ +#include /* for tolower */ + #include "asterisk/module.h" #include "asterisk/format.h" #include "asterisk/strings.h" /* for ast_str_append */ -#include "asterisk/utils.h" /* for ast_calloc, ast_free */ +#include "asterisk/utils.h" /* for ast_free */ @@ -71,6 +73,7 @@ static int ilbc_clone(const struct ast_format *src, struct ast_format *dst) static struct ast_format *ilbc_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; struct ast_format *cloned; struct ilbc_attr *attr; const char *kvp; @@ -82,7 +85,12 @@ static struct ast_format *ilbc_parse_sdp_fmtp(const struct ast_format *format, c } attr = ast_format_get_attribute_data(cloned); + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - if ((kvp = strstr(attributes, "mode")) && sscanf(kvp, "mode=%30u", &val) == 1) { + if ((kvp = strstr(attribs, "mode")) && sscanf(kvp, "mode=%30u", &val) == 1) { attr->mode = val; } else { attr->mode = 30; /* optional attribute; 30 is default value */ --- res/res_format_attr_opus.c +++ res/res_format_attr_opus.c @@ -31,4 +31,7 @@ +#include + #include "asterisk/module.h" #include "asterisk/format.h" +#include "asterisk/astobj2.h" #include "asterisk/logger.h" @@ -135,6 +138,7 @@ static void sdp_fmtp_get(const char *attributes, const char *name, int *attr) static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; struct ast_format *cloned; struct opus_attr *attr; @@ -146,20 +150,25 @@ static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, c attr = ast_format_get_attribute_data(cloned); + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, &attr->maxplayrate); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, &attr->maxplayrate); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH, + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH, &attr->maxplayrate); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, &attr->spropmaxcapturerate); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_PTIME, &attr->maxptime); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_MAX_PTIME, &attr->maxptime); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_PTIME, &attr->ptime); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_PTIME, &attr->ptime); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, &attr->maxbitrate); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, &attr->maxbitrate); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_STEREO, &attr->stereo); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_STEREO, &attr->stereo); if (attr->stereo) { ast_format_set_channel_count(cloned, 2); } - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_SPROP_STEREO, &attr->spropstereo); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_SPROP_STEREO, &attr->spropstereo); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_CBR, &attr->cbr); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_CBR, &attr->cbr); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_FEC, &attr->fec); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_FEC, &attr->fec); - sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_DTX, &attr->dtx); + sdp_fmtp_get(attribs, CODEC_OPUS_ATTR_DTX, &attr->dtx); return cloned; --- res/res_format_attr_silk.c +++ res/res_format_attr_silk.c @@ -31,4 +31,9 @@ +#include /* for tolower */ + #include "asterisk/module.h" #include "asterisk/format.h" +#include "asterisk/logger.h" /* for ast_log, LOG_WARNING */ +#include "asterisk/strings.h" /* for ast_str_append */ +#include "asterisk/utils.h" /* for MAX, MIN */ @@ -78,6 +83,7 @@ static int silk_clone(const struct ast_format *src, struct ast_format *dst) static struct ast_format *silk_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; struct ast_format *cloned; struct silk_attr *attr; unsigned int val; @@ -88,13 +94,18 @@ static struct ast_format *silk_parse_sdp_fmtp(const struct ast_format *format, c } attr = ast_format_get_attribute_data(cloned); + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - if (sscanf(attributes, "maxaveragebitrate=%30u", &val) == 1) { + if (sscanf(attribs, "maxaveragebitrate=%30u", &val) == 1) { attr->maxbitrate = val; } - if (sscanf(attributes, "usedtx=%30u", &val) == 1) { + if (sscanf(attribs, "usedtx=%30u", &val) == 1) { attr->dtx = val; } - if (sscanf(attributes, "useinbandfec=%30u", &val) == 1) { + if (sscanf(attribs, "useinbandfec=%30u", &val) == 1) { attr->fec = val; } --- res/res_format_attr_siren14.c +++ res/res_format_attr_siren14.c @@ -31,4 +31,9 @@ +#include /* for tolower */ + #include "asterisk/module.h" #include "asterisk/format.h" +#include "asterisk/astobj2.h" /* for ao2_bump */ +#include "asterisk/logger.h" /* for ast_log, LOG_WARNING */ +#include "asterisk/strings.h" /* for ast_str_append */ @@ -45,9 +50,15 @@ static int siren14_clone(const struct ast_format *src, struct ast_format *dst) static struct ast_format *siren14_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; unsigned int val; + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - if (sscanf(attributes, "bitrate=%30u", &val) == 1) { + if (sscanf(attribs, "bitrate=%30u", &val) == 1) { if (val != 48000) { ast_log(LOG_WARNING, "Got siren14 offer at %u bps, but only 48000 bps supported; ignoring.\n", val); return NULL; --- res/res_format_attr_siren7.c +++ res/res_format_attr_siren7.c @@ -31,4 +31,9 @@ +#include /* for tolower */ + #include "asterisk/module.h" #include "asterisk/format.h" +#include "asterisk/astobj2.h" /* for ao2_bump */ +#include "asterisk/logger.h" /* for ast_log, LOG_WARNING */ +#include "asterisk/strings.h" /* for ast_str_append */ @@ -45,9 +50,15 @@ static int siren7_clone(const struct ast_format *src, struct ast_format *dst) static struct ast_format *siren7_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; unsigned int val; + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - if (sscanf(attributes, "bitrate=%30u", &val) == 1) { + if (sscanf(attribs, "bitrate=%30u", &val) == 1) { if (val != 32000) { ast_log(LOG_WARNING, "Got Siren7 offer at %u bps, but only 32000 bps supported; ignoring.\n", val); return NULL; --- res/res_format_attr_vp8.c +++ res/res_format_attr_vp8.c @@ -33,2 +33,4 @@ +#include /* for tolower */ + #include "asterisk/module.h" @@ -76,6 +78,7 @@ static int vp8_clone(const struct ast_format *src, struct ast_format *dst) static struct ast_format *vp8_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) { + char *attribs = ast_strdupa(attributes), *attrib; struct ast_format *cloned; struct vp8_attr *attr; const char *kvp; @@ -87,13 +90,18 @@ static struct ast_format *vp8_parse_sdp_fmtp(const struct ast_format *format, co } attr = ast_format_get_attribute_data(cloned); + /* lower-case everything, so we are case-insensitive */ + for (attrib = attribs; *attrib; ++attrib) { + *attrib = tolower(*attrib); + } /* based on channels/chan_sip.c:process_a_sdp_image() */ + - if ((kvp = strstr(attributes, "max-fr")) && sscanf(kvp, "max-fr=%30u", &val) == 1) { + if ((kvp = strstr(attribs, "max-fr")) && sscanf(kvp, "max-fr=%30u", &val) == 1) { attr->maximum_frame_rate = val; } else { attr->maximum_frame_rate = UINT_MAX; } - if ((kvp = strstr(attributes, "max-fs")) && sscanf(kvp, "max-fs=%30u", &val) == 1) { + if ((kvp = strstr(attribs, "max-fs")) && sscanf(kvp, "max-fs=%30u", &val) == 1) { attr->maximum_frame_size = val; } else { attr->maximum_frame_size = UINT_MAX;