MT#58535 Add opmode to processing of flags

Add operation mode to the flags parsing functions.

Change-Id: I49147b39ebccd43dfa703ba7857f1902bdad976b
pull/1809/head
Donat Zenichev 1 year ago
parent 31641efe06
commit f60139cf0d

@ -1272,7 +1272,8 @@ void call_ng_flags_init(sdp_ng_flags *out, enum call_opmode opmode) {
} }
static void call_ng_dict_iter(sdp_ng_flags *out, bencode_item_t *input, static void call_ng_dict_iter(sdp_ng_flags *out, bencode_item_t *input,
void (*callback)(sdp_ng_flags *, str *key, bencode_item_t *value)) enum call_opmode opmode,
void (*callback)(sdp_ng_flags *, str *key, bencode_item_t *value, enum call_opmode _opmode))
{ {
if (input->type != BENCODE_DICTIONARY) if (input->type != BENCODE_DICTIONARY)
return; return;
@ -1287,11 +1288,13 @@ static void call_ng_dict_iter(sdp_ng_flags *out, bencode_item_t *input,
if (!bencode_get_str(key, &k)) if (!bencode_get_str(key, &k))
continue; continue;
callback(out, &k, value); callback(out, &k, value, opmode);
} }
} }
static void call_ng_codec_flags(sdp_ng_flags *out, str *key, bencode_item_t *value) { static void call_ng_codec_flags(sdp_ng_flags *out, str *key, bencode_item_t *value,
enum call_opmode opmode)
{
switch (__csh_lookup(key)) { switch (__csh_lookup(key)) {
case CSH_LOOKUP("except"): case CSH_LOOKUP("except"):
call_ng_flags_str_list(out, value, call_ng_flags_str_ht, &out->codec_except); call_ng_flags_str_list(out, value, call_ng_flags_str_ht, &out->codec_except);
@ -1395,7 +1398,9 @@ static void call_ng_flags_freqs(sdp_ng_flags *out, bencode_item_t *value) {
} }
} }
static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *value) { static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *value,
enum call_opmode opmode)
{
str s = STR_NULL; str s = STR_NULL;
bencode_item_t *it; bencode_item_t *it;
@ -1480,7 +1485,7 @@ static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *valu
out->digit = s.s[0]; out->digit = s.s[0];
break; break;
case CSH_LOOKUP("codec"): case CSH_LOOKUP("codec"):
call_ng_dict_iter(out, value, call_ng_codec_flags); call_ng_dict_iter(out, value, opmode, call_ng_codec_flags);
break; break;
case CSH_LOOKUP("command"): case CSH_LOOKUP("command"):
break; break;
@ -1830,9 +1835,9 @@ static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *valu
assert(dict != NULL); assert(dict != NULL);
/* s - parse rtpp flags */ /* s - parse rtpp flags */
parse_rtpp_flags(&s, dict); parse_rtpp_flags(&s, dict, opmode, out);
if (dict && dict->child) if (dict && dict->child)
call_ng_dict_iter(out, dict, call_ng_main_flags); /* recursive */ call_ng_dict_iter(out, dict, opmode, call_ng_main_flags); /* recursive */
break; break;
case CSH_LOOKUP("SDES"): case CSH_LOOKUP("SDES"):
@ -1977,7 +1982,7 @@ static void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *valu
static void call_ng_process_flags(sdp_ng_flags *out, bencode_item_t *input, enum call_opmode opmode) { static void call_ng_process_flags(sdp_ng_flags *out, bencode_item_t *input, enum call_opmode opmode) {
call_ng_flags_init(out, opmode); call_ng_flags_init(out, opmode);
call_ng_dict_iter(out, input, call_ng_main_flags); call_ng_dict_iter(out, input, opmode, call_ng_main_flags);
} }
static void ng_sdp_attr_manipulations_free(struct sdp_manipulations * array[__MT_MAX]) { static void ng_sdp_attr_manipulations_free(struct sdp_manipulations * array[__MT_MAX]) {

@ -254,7 +254,8 @@ static bool parse_str_flag(str * key, str * val, const char * name,
* @param rtpp_flags - raw str rtpp_flags * @param rtpp_flags - raw str rtpp_flags
* @param dict - root dict to store encoded flags * @param dict - root dict to store encoded flags
*/ */
void parse_rtpp_flags(const str * rtpp_flags, bencode_item_t * root_dict) void parse_rtpp_flags(const str * rtpp_flags, bencode_item_t * root_dict,
enum call_opmode opmode, sdp_ng_flags * out)
{ {
char * start, * end, * eptr, c; char * start, * end, * eptr, c;
str key, val, s; str key, val, s;

@ -6,12 +6,15 @@
#include "bencode.h" #include "bencode.h"
#include "obj.h" #include "obj.h"
#include "str.h" #include "str.h"
#include "call.h"
#include "call_interfaces.h"
/** /**
* Parse flags in raw format and return bencode. * Parse flags in raw format and return bencode.
* Syntax: * Syntax:
* rtpp_flags: flag1=<value>, flag2-<value> ... * rtpp_flags: flag1=<value>, flag2-<value> ...
*/ */
void parse_rtpp_flags(const str * rtpp_flags, bencode_item_t * dict); void parse_rtpp_flags(const str * rtpp_flags, bencode_item_t * dict,
enum call_opmode opmode, sdp_ng_flags * out);
#endif #endif
Loading…
Cancel
Save