ignore transcoding options in non-offer messages

part of the fixes for #681 (and encountered elsewhere)

Change-Id: I15752ad3183cc55d677eca80e11b000e0b069290
changes/74/25974/3
Richard Fuchs 6 years ago
parent 744d6a46ff
commit e1d6c83319

@ -1470,7 +1470,7 @@ Optionally included keys are:
* `codec` * `codec`
Contains a dictionary controlling various aspects of codecs (or RTP payload types). Contains a dictionary controlling various aspects of codecs (or RTP payload types).
Most of these options should only be used in an `offer` message. These options are only processed in `offer` messages and ignored otherwise.
These options can also be put into the `flags` list using a prefix of `codec-`. For example, These options can also be put into the `flags` list using a prefix of `codec-`. For example,
to set the codec options for two variants of Opus when they're implicitly accepted, (see to set the codec options for two variants of Opus when they're implicitly accepted, (see

@ -701,33 +701,40 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) {
return; return;
if (call_ng_flags_prefix(out, s, "SDES-", ng_sdes_option, NULL)) if (call_ng_flags_prefix(out, s, "SDES-", ng_sdes_option, NULL))
return; return;
if (call_ng_flags_prefix(out, s, "codec-strip-", call_ng_flags_str_ht, &out->codec_strip)) if (out->opmode == OP_OFFER) {
if (call_ng_flags_prefix(out, s, "codec-strip-", call_ng_flags_str_ht,
&out->codec_strip))
return; return;
if (call_ng_flags_prefix(out, s, "codec-offer-", call_ng_flags_codec_list, &out->codec_offer)) if (call_ng_flags_prefix(out, s, "codec-offer-", call_ng_flags_codec_list,
&out->codec_offer))
return; return;
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
if (call_ng_flags_prefix(out, s, "transcode-", call_ng_flags_codec_list, &out->codec_transcode)) if (call_ng_flags_prefix(out, s, "transcode-", call_ng_flags_codec_list,
&out->codec_transcode))
return; return;
if (call_ng_flags_prefix(out, s, "codec-transcode-", call_ng_flags_codec_list, if (call_ng_flags_prefix(out, s, "codec-transcode-", call_ng_flags_codec_list,
&out->codec_transcode)) &out->codec_transcode))
return; return;
if (call_ng_flags_prefix(out, s, "codec-mask-", call_ng_flags_str_ht, &out->codec_mask)) if (call_ng_flags_prefix(out, s, "codec-mask-", call_ng_flags_str_ht,
&out->codec_mask))
return; return;
if (call_ng_flags_prefix(out, s, "codec-set-", call_ng_flags_str_ht_split, if (call_ng_flags_prefix(out, s, "codec-set-", call_ng_flags_str_ht_split,
&out->codec_set)) &out->codec_set))
return; return;
#endif #endif
}
ilog(LOG_WARN, "Unknown flag encountered: '" STR_FORMAT "'", ilog(LOG_WARN, "Unknown flag encountered: '" STR_FORMAT "'",
STR_FMT(s)); STR_FMT(s));
} }
} }
static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *input) { static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *input, enum call_opmode opmode) {
bencode_item_t *list, *it, *dict; bencode_item_t *list, *it, *dict;
int diridx; int diridx;
str s; str s;
ZERO(*out); ZERO(*out);
out->opmode = opmode;
out->trust_address = trust_address_def; out->trust_address = trust_address_def;
out->dtls_passive = dtls_passive_def; out->dtls_passive = dtls_passive_def;
@ -805,7 +812,7 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu
STR_FMT(&s)); STR_FMT(&s));
} }
if ((dict = bencode_dictionary_get_expect(input, "codec", BENCODE_DICTIONARY))) { if (opmode == OP_OFFER && (dict = bencode_dictionary_get_expect(input, "codec", BENCODE_DICTIONARY))) {
call_ng_flags_list(out, dict, "strip", call_ng_flags_str_ht, &out->codec_strip); call_ng_flags_list(out, dict, "strip", call_ng_flags_str_ht, &out->codec_strip);
call_ng_flags_list(out, dict, "offer", call_ng_flags_codec_list, &out->codec_offer); call_ng_flags_list(out, dict, "offer", call_ng_flags_codec_list, &out->codec_offer);
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
@ -910,8 +917,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input,
bencode_dictionary_get_str(input, "via-branch", &viabranch); bencode_dictionary_get_str(input, "via-branch", &viabranch);
bencode_dictionary_get_str(input, "label", &label); bencode_dictionary_get_str(input, "label", &label);
call_ng_process_flags(&flags, input); call_ng_process_flags(&flags, input, opmode);
flags.opmode = opmode;
if (opmode == OP_OFFER) { if (opmode == OP_OFFER) {
enum load_limit_reasons limit = call_offer_session_limit(); enum load_limit_reasons limit = call_offer_session_limit();
@ -1545,7 +1551,7 @@ const char *call_unblock_dtmf_ng(bencode_item_t *input, bencode_item_t *output)
if (errstr) if (errstr)
goto out; goto out;
call_ng_process_flags(&flags, input); call_ng_process_flags(&flags, input, OP_OTHER);
if (monologue) { if (monologue) {
ilog(LOG_INFO, "Unblocking directional DTMF (tag '" STR_FORMAT ")", ilog(LOG_INFO, "Unblocking directional DTMF (tag '" STR_FORMAT ")",
@ -1614,7 +1620,7 @@ const char *call_unblock_media_ng(bencode_item_t *input, bencode_item_t *output)
if (errstr) if (errstr)
goto out; goto out;
call_ng_process_flags(&flags, input); call_ng_process_flags(&flags, input, OP_OTHER);
if (monologue) { if (monologue) {
ilog(LOG_INFO, "Unblocking directional media (tag '" STR_FORMAT ")", ilog(LOG_INFO, "Unblocking directional media (tag '" STR_FORMAT ")",

Loading…
Cancel
Save