[sr-dev] git:master:8bf1935c: rtpengine: support new codec flags
Olle E. Johansson
oej at edvina.net
Thu Oct 22 18:04:51 CEST 2020
> On 22 Oct 2020, at 17:36, Richard Fuchs <rfuchs at sipwise.com> wrote:
>
> Yes I suppose so. I usually keep the rtpengine docs as the authoritative source, but since the other codecs flags are mentioned in the README, these should be too.
>
Thank you Richard!
/O
> Cheers
>
> On 22/10/2020 03.08, Olle E. Johansson wrote:
>> Just checking - do you need to update the README too?
>>
>> /O
>>
>>> On 21 Oct 2020, at 20:05, Richard Fuchs <rfuchs at sipwise.com> wrote:
>>>
>>> Module: kamailio
>>> Branch: master
>>> Commit: 8bf1935c4e9cb0081784dbd8bd951148b8865381
>>> URL: https://github.com/kamailio/kamailio/commit/8bf1935c4e9cb0081784dbd8bd951148b8865381
>>>
>>> Author: Richard Fuchs <rfuchs at sipwise.com>
>>> Committer: Richard Fuchs <rfuchs at sipwise.com>
>>> Date: 2020-10-21T14:05:20-04:00
>>>
>>> rtpengine: support new codec flags
>>>
>>> Adds explicit support for codec-set and codec-except.
>>>
>>> Also eliminates code redundancy.
>>>
>>> ---
>>>
>>> Modified: src/modules/rtpengine/rtpengine.c
>>>
>>> ---
>>>
>>> Diff: https://github.com/kamailio/kamailio/commit/8bf1935c4e9cb0081784dbd8bd951148b8865381.diff
>>> Patch: https://github.com/kamailio/kamailio/commit/8bf1935c4e9cb0081784dbd8bd951148b8865381.patch
>>>
>>> ---
>>>
>>> diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c
>>> index 95726fa4a1..c3e7e75601 100644
>>> --- a/src/modules/rtpengine/rtpengine.c
>>> +++ b/src/modules/rtpengine/rtpengine.c
>>> @@ -119,7 +119,8 @@ struct ng_flags_parse {
>>> int via, to, packetize, transport, directional;
>>> bencode_item_t *dict, *flags, *direction, *replace, *rtcp_mux, *sdes,
>>> *t38,
>>> - *codec, *codec_strip, *codec_offer, *codec_transcode, *codec_mask;
>>> + *codec, *codec_strip, *codec_offer, *codec_transcode, *codec_mask,
>>> + *codec_set, *codec_except;
>>> str call_id, from_tag, to_tag;
>>> };
>>>
>>> @@ -2082,6 +2083,29 @@ static const char *transports[] = {
>>> [0x06] = "UDP/TLS/RTP/SAVPF",
>>> };
>>>
>>> +static int parse_codec_flag(struct ng_flags_parse *ng_flags, const str *key, const str *val,
>>> + const char *cmp1, const char *cmp2,
>>> + bencode_item_t **dictp)
>>> +{
>>> + str s;
>>> +
>>> + if (!str_key_val_prefix(key, cmp1, val, &s)) {
>>> + if (!cmp2)
>>> + return 0;
>>> + if (!str_key_val_prefix(key, cmp2, val, &s))
>>> + return 0;
>>> + }
>>> +
>>> + if (!*dictp) {
>>> + *dictp = bencode_list(ng_flags->dict->buffer);
>>> + bencode_dictionary_add(ng_flags->codec, "transcode",
>>> + *dictp);
>>> + }
>>> + bencode_list_add_str(*dictp, &s);
>>> +
>>> + return 1;
>>> +}
>>> +
>>> static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg, enum rtpe_operation *op,
>>> const char *flags_str)
>>> {
>>> @@ -2135,47 +2159,18 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg, enu
>>> goto next;
>>> }
>>>
>>> - if (str_key_val_prefix(&key, "transcode", &val, &s)
>>> - || str_key_val_prefix(&key, "codec-transcode", &val, &s))
>>> - {
>>> - if (!ng_flags->codec_transcode) {
>>> - ng_flags->codec_transcode = bencode_list(ng_flags->dict->buffer);
>>> - bencode_dictionary_add(ng_flags->codec, "transcode",
>>> - ng_flags->codec_transcode);
>>> - }
>>> - bencode_list_add_str(ng_flags->codec_transcode, &s);
>>> + if (parse_codec_flag(ng_flags, &key, &val, "transcode", "codec-transcode", &ng_flags->codec_transcode))
>>> goto next;
>>> - }
>>> -
>>> - if (str_key_val_prefix(&key, "codec-strip", &val, &s)) {
>>> - if (!ng_flags->codec_strip) {
>>> - ng_flags->codec_strip = bencode_list(ng_flags->dict->buffer);
>>> - bencode_dictionary_add(ng_flags->codec, "strip",
>>> - ng_flags->codec_strip);
>>> - }
>>> - bencode_list_add_str(ng_flags->codec_strip, &s);
>>> + if (parse_codec_flag(ng_flags, &key, &val, "codec-strip", NULL, &ng_flags->codec_strip))
>>> goto next;
>>> - }
>>> -
>>> - if (str_key_val_prefix(&key, "codec-offer", &val, &s)) {
>>> - if (!ng_flags->codec_offer) {
>>> - ng_flags->codec_offer = bencode_list(ng_flags->dict->buffer);
>>> - bencode_dictionary_add(ng_flags->codec, "offer",
>>> - ng_flags->codec_offer);
>>> - }
>>> - bencode_list_add_str(ng_flags->codec_offer, &s);
>>> + if (parse_codec_flag(ng_flags, &key, &val, "codec-offer", NULL, &ng_flags->codec_offer))
>>> goto next;
>>> - }
>>> -
>>> - if (str_key_val_prefix(&key, "codec-mask", &val, &s)) {
>>> - if (!ng_flags->codec_mask) {
>>> - ng_flags->codec_mask = bencode_list(ng_flags->dict->buffer);
>>> - bencode_dictionary_add(ng_flags->codec, "mask",
>>> - ng_flags->codec_mask);
>>> - }
>>> - bencode_list_add_str(ng_flags->codec_mask, &s);
>>> + if (parse_codec_flag(ng_flags, &key, &val, "codec-mask", NULL, &ng_flags->codec_mask))
>>> + goto next;
>>> + if (parse_codec_flag(ng_flags, &key, &val, "codec-set", NULL, &ng_flags->codec_set))
>>> + goto next;
>>> + if (parse_codec_flag(ng_flags, &key, &val, "codec-except", NULL, &ng_flags->codec_except))
>>> goto next;
>>> - }
>>>
>>> /* check for specially handled items */
>>> switch (key.len) {
>>>
>>>
>>> _______________________________________________
>>> Kamailio (SER) - Development Mailing List
>>> sr-dev at lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
>>
>> _______________________________________________
>> Kamailio (SER) - Development Mailing List
>> sr-dev at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
>
> _______________________________________________
> Kamailio (SER) - Development Mailing List
> sr-dev at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
More information about the sr-dev
mailing list