diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index ea5317812..c8d6e6e5e 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -55,9 +55,9 @@ INLINE int call_ng_flags_prefix(str *s_ori, const char *prefix, void (*cb)(str *, unsigned int, helper_arg), helper_arg); static void call_ng_flags_str_ht(str *s, unsigned int, helper_arg); static void call_ng_flags_str_q_multi(str *s, unsigned int, helper_arg); -static void call_ng_flags_str_list(ng_parser_ctx_t *, parser_arg list, +static void call_ng_flags_str_list(const ng_parser_t *, parser_arg list, void (*callback)(str *, unsigned int, helper_arg), helper_arg); -static void call_ng_flags_list(ng_parser_ctx_t *, parser_arg list, +static void call_ng_flags_list(const ng_parser_t *, parser_arg list, void (*str_callback)(str *, unsigned int, helper_arg), void (*item_callback)(const ng_parser_t *, parser_arg, helper_arg), helper_arg); @@ -650,7 +650,7 @@ err: ilog(LOG_WARN, "SDP manipulations: Ignoring invalid contents of string-pair list"); } -static void ng_sdp_attr_media_iter(ng_parser_ctx_t *ctx, str *command_type, parser_arg command_value, +static void ng_sdp_attr_media_iter(const ng_parser_t *parser, str *command_type, parser_arg command_value, helper_arg arg) { struct sdp_manipulations *sm = arg.sm; @@ -658,37 +658,37 @@ static void ng_sdp_attr_media_iter(ng_parser_ctx_t *ctx, str *command_type, pars switch (__csh_lookup(command_type)) { case CSH_LOOKUP("substitute"): - call_ng_flags_list(ctx, command_value, call_ng_flags_str_pair_ht, call_ng_flags_item_pair_ht, + call_ng_flags_list(parser, command_value, call_ng_flags_str_pair_ht, call_ng_flags_item_pair_ht, &sm->subst_commands); break; case CSH_LOOKUP("add"): - call_ng_flags_str_list(ctx, command_value, call_ng_flags_esc_str_list, &sm->add_commands); + call_ng_flags_str_list(parser, command_value, call_ng_flags_esc_str_list, &sm->add_commands); break; case CSH_LOOKUP("remove"): - call_ng_flags_str_list(ctx, command_value, call_ng_flags_str_ht, &sm->rem_commands); + call_ng_flags_str_list(parser, command_value, call_ng_flags_str_ht, &sm->rem_commands); break; default: ilog(LOG_WARN, "SDP manipulations: Unknown SDP manipulation command type."); } } -static void ng_sdp_attr_manipulations_iter(ng_parser_ctx_t *ctx, str *media_type, parser_arg command_action, +static void ng_sdp_attr_manipulations_iter(const ng_parser_t *parser, str *media_type, parser_arg command_action, helper_arg arg) { - struct sdp_manipulations *sm = sdp_manipulations_get_by_name(ctx->flags, media_type); + struct sdp_manipulations *sm = sdp_manipulations_get_by_name(arg.flags, media_type); if (!sm) { ilog(LOG_WARN, "SDP manipulations: unsupported SDP section '" STR_FORMAT "' targeted.", STR_FMT(media_type)); return; } - if (!ctx->parser->dict_iter(ctx, command_action, ng_sdp_attr_media_iter, sm)) + if (!parser->dict_iter(parser, command_action, ng_sdp_attr_media_iter, sm)) ilog(LOG_WARN, "SDP manipulations: Wrong content for SDP section."); } -INLINE void ng_sdp_attr_manipulations(ng_parser_ctx_t *ctx, parser_arg value) { - if (!ctx->parser->dict_iter(ctx, value, ng_sdp_attr_manipulations_iter, NULL)) +INLINE void ng_sdp_attr_manipulations(const ng_parser_t *parser, sdp_ng_flags *flags, parser_arg value) { + if (!parser->dict_iter(parser, value, ng_sdp_attr_manipulations_iter, flags)) ilog(LOG_WARN, "SDP manipulations: Wrong type for this type of command."); } @@ -771,12 +771,11 @@ INLINE void ng_t38_option(str *s, unsigned int idx, helper_arg arg) { #endif -static void call_ng_flags_list(ng_parser_ctx_t *ctx, parser_arg list, +static void call_ng_flags_list(const ng_parser_t *parser, parser_arg list, void (*str_callback)(str *, unsigned int, helper_arg), void (*item_callback)(const ng_parser_t *, parser_arg, helper_arg), helper_arg arg) { - const ng_parser_t *parser = ctx->parser; str s; if (!parser->is_list(list)) { if (parser->get_str(list, &s)) { @@ -788,12 +787,12 @@ static void call_ng_flags_list(ng_parser_ctx_t *ctx, parser_arg list, ilog(LOG_DEBUG, "Ignoring non-list non-string value"); return; } - parser->list_iter(ctx->parser, list, str_callback, item_callback, arg); + parser->list_iter(parser, list, str_callback, item_callback, arg); } -static void call_ng_flags_str_list(ng_parser_ctx_t *ctx, parser_arg list, +static void call_ng_flags_str_list(const ng_parser_t *parser, parser_arg list, void (*callback)(str *, unsigned int, helper_arg), helper_arg arg) { - call_ng_flags_list(ctx, list, callback, NULL, arg); + call_ng_flags_list(parser, list, callback, NULL, arg); } static void call_ng_flags_rtcp_mux(str *s, unsigned int idx, helper_arg arg) { @@ -1290,23 +1289,23 @@ static void call_ng_direction_flag_iter(str *s, unsigned int i, helper_arg arg) return; arg.flags->direction[i] = *s; } -void call_ng_direction_flag(ng_parser_ctx_t *ctx, parser_arg value) +void call_ng_direction_flag(const ng_parser_t *parser, sdp_ng_flags *flags, parser_arg value) { - if (!ctx->parser->is_list(value)) + if (!parser->is_list(value)) return; - ctx->parser->list_iter(ctx->parser, value, call_ng_direction_flag_iter, NULL, ctx->flags); + parser->list_iter(parser, value, call_ng_direction_flag_iter, NULL, flags); } -void call_ng_codec_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper_arg arg) { - sdp_ng_flags *out = ctx->flags; +void call_ng_codec_flags(const ng_parser_t *parser, str *key, parser_arg value, helper_arg arg) { + sdp_ng_flags *out = arg.flags; switch (__csh_lookup(key)) { case CSH_LOOKUP("except"): - call_ng_flags_str_list(ctx, value, call_ng_flags_str_ht, &out->codec_except); + call_ng_flags_str_list(parser, value, call_ng_flags_str_ht, &out->codec_except); return; case CSH_LOOKUP("offer"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, &out->codec_offer); + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->codec_offer); return; case CSH_LOOKUP("strip"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, &out->codec_strip); + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->codec_strip); return; } #ifdef WITH_TRANSCODING @@ -1315,19 +1314,19 @@ void call_ng_codec_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helpe { switch (__csh_lookup(key)) { case CSH_LOOKUP("accept"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, &out->codec_accept); + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->codec_accept); return; case CSH_LOOKUP("consume"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, &out->codec_consume); + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->codec_consume); return; case CSH_LOOKUP("mask"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, &out->codec_mask); + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->codec_mask); return; case CSH_LOOKUP("set"): - call_ng_flags_str_list(ctx, value, call_ng_flags_str_ht_split, &out->codec_set); + call_ng_flags_str_list(parser, value, call_ng_flags_str_ht_split, &out->codec_set); return; case CSH_LOOKUP("transcode"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->codec_transcode); return; } @@ -1400,9 +1399,9 @@ static void call_ng_flags_freqs(const ng_parser_t *parser, parser_arg value, sdp } } -static void call_ng_received_from_string(ng_parser_ctx_t *ctx, str *s) { - ctx->flags->received_from_family = STR_NULL; - ctx->flags->received_from_address = *s; +static void call_ng_received_from_string(sdp_ng_flags *flags, str *s) { + flags->received_from_family = STR_NULL; + flags->received_from_address = *s; } static void call_ng_received_from_iter(str *key, unsigned int i, helper_arg arg) { switch (i) { @@ -1414,10 +1413,9 @@ static void call_ng_received_from_iter(str *key, unsigned int i, helper_arg arg) break; } } -void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper_arg arg) { +void call_ng_main_flags(const ng_parser_t *parser, str *key, parser_arg value, helper_arg arg) { str s = STR_NULL; - sdp_ng_flags *out = ctx->flags; - const ng_parser_t *parser = ctx->parser; + sdp_ng_flags *out = arg.flags; parser->get_str(value, &s); @@ -1502,7 +1500,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper out->digit = s.s[0]; break; case CSH_LOOKUP("codec"): - parser->dict_iter(ctx, value, call_ng_codec_flags, NULL); + parser->dict_iter(parser, value, call_ng_codec_flags, out); break; case CSH_LOOKUP("command"): break; @@ -1510,7 +1508,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper out->db_id = parser->get_int_str(value, out->db_id); break; case CSH_LOOKUP("direction"): - call_ng_direction_flag(ctx, value); + call_ng_direction_flag(parser, out, value); break; case CSH_LOOKUP("drop-traffic"): case CSH_LOOKUP("drop traffic"): @@ -1611,7 +1609,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper #endif case CSH_LOOKUP("endpoint-learning"): case CSH_LOOKUP("endpoint learning"): - call_ng_flags_str_list(ctx, value, ng_el_option, out); + call_ng_flags_str_list(parser, value, ng_el_option, out); break; case CSH_LOOKUP("file"): @@ -1619,7 +1617,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper break; case CSH_LOOKUP("frequency"): case CSH_LOOKUP("frequencies"): - call_ng_flags_freqs(ctx->parser, value, out); + call_ng_flags_freqs(parser, value, out); break; case CSH_LOOKUP("from-interface"): out->direction[0] = s; @@ -1632,10 +1630,10 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper out->from_tag = s; break; case CSH_LOOKUP("from-tags"): - call_ng_flags_str_list(ctx, value, call_ng_flags_esc_str_list, &out->from_tags); + call_ng_flags_str_list(parser, value, call_ng_flags_esc_str_list, &out->from_tags); break; case CSH_LOOKUP("flags"): - call_ng_flags_str_list(ctx, value, call_ng_flags_flags, out); + call_ng_flags_str_list(parser, value, call_ng_flags_flags, out); break; case CSH_LOOKUP("generate RTCP"): case CSH_LOOKUP("generate-RTCP"): @@ -1744,7 +1742,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper break; case CSH_LOOKUP("OSRTP"): case CSH_LOOKUP("osrtp"): - call_ng_flags_str_list(ctx, value, ng_osrtp_option, out); + call_ng_flags_str_list(parser, value, ng_osrtp_option, out); break; case CSH_LOOKUP("output-destination"): case CSH_LOOKUP("output-dest"): @@ -1799,10 +1797,10 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper case CSH_LOOKUP("received from"): case CSH_LOOKUP("received-from"): if (!parser->is_list(value)) { - call_ng_received_from_string(ctx, &s); + call_ng_received_from_string(out, &s); break; } - parser->list_iter(ctx->parser, value, call_ng_received_from_iter, NULL, out); + parser->list_iter(parser, value, call_ng_received_from_iter, NULL, out); break; case CSH_LOOKUP("record call"): case CSH_LOOKUP("record-call"): @@ -1836,20 +1834,20 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper out->repeat_times = parser->get_int_str(value, out->repeat_times); break; case CSH_LOOKUP("replace"): - call_ng_flags_str_list(ctx, value, call_ng_flags_replace, out); + call_ng_flags_str_list(parser, value, call_ng_flags_replace, out); break; case CSH_LOOKUP("rtcp-mux"): case CSH_LOOKUP("RTCP-mux"): - call_ng_flags_str_list(ctx, value, call_ng_flags_rtcp_mux, out); + call_ng_flags_str_list(parser, value, call_ng_flags_rtcp_mux, out); break; case CSH_LOOKUP("rtpp-flags"): case CSH_LOOKUP("rtpp_flags"):; /* s - list of rtpp flags */ - parse_rtpp_flags(&s, ctx); + parse_rtpp_flags(&s, out); break; case CSH_LOOKUP("SDES"): case CSH_LOOKUP("sdes"): - call_ng_flags_str_list(ctx, value, ng_sdes_option, out); + call_ng_flags_str_list(parser, value, ng_sdes_option, out); break; case CSH_LOOKUP("SDP"): case CSH_LOOKUP("sdp"): @@ -1857,7 +1855,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper break; case CSH_LOOKUP("sdp-attr"): case CSH_LOOKUP("SDP-attr"): - ng_sdp_attr_manipulations(ctx, value); + ng_sdp_attr_manipulations(parser, out, value); break; case CSH_LOOKUP("set-label"): out->set_label = s; @@ -1882,7 +1880,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper out->start_pos = parser->get_int_str(value, out->start_pos); break; case CSH_LOOKUP("supports"): - call_ng_flags_str_list(ctx, value, call_ng_flags_supports, out); + call_ng_flags_str_list(parser, value, call_ng_flags_supports, out); break; #ifdef WITH_TRANSCODING @@ -1890,7 +1888,7 @@ void call_ng_main_flags(ng_parser_ctx_t *ctx, str *key, parser_arg value, helper case CSH_LOOKUP("T.38"): case CSH_LOOKUP("t38"): case CSH_LOOKUP("t.38"): - call_ng_flags_str_list(ctx, value, ng_t38_option, out); + call_ng_flags_str_list(parser, value, ng_t38_option, out); break; #endif case CSH_LOOKUP("to-interface"): @@ -1992,7 +1990,7 @@ static void call_ng_process_flags(sdp_ng_flags *out, ng_parser_ctx_t *ctx, enum call_ng_flags_init(out, opmode); ctx->opmode = opmode; ctx->flags = out; - ctx->parser->dict_iter(ctx, ctx->req, call_ng_main_flags, NULL); + ctx->parser->dict_iter(ctx->parser, ctx->req, call_ng_main_flags, out); } static void ng_sdp_attr_manipulations_free(struct sdp_manipulations * array[__MT_MAX]) { diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 0fe703c55..8edccd9af 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -79,8 +79,8 @@ typedef struct ng_ctx { } while (0) -static bool bencode_dict_iter(ng_parser_ctx_t *ctx, bencode_item_t *input, - void (*callback)(ng_parser_ctx_t *, str *key, bencode_item_t *value, helper_arg), +static bool bencode_dict_iter(const ng_parser_t *parser, bencode_item_t *input, + void (*callback)(const ng_parser_t *, str *key, bencode_item_t *value, helper_arg), helper_arg arg) { if (input->type != BENCODE_DICTIONARY) @@ -96,7 +96,7 @@ static bool bencode_dict_iter(ng_parser_ctx_t *ctx, bencode_item_t *input, if (!bencode_get_str(key, &k)) continue; - callback(ctx, &k, value, arg); + callback(parser, &k, value, arg); } return true; @@ -286,12 +286,12 @@ static bool json_dict_contains(JsonNode *on, const char *ele) { } static void json_dict_iter_fn(JsonObject *o, const char *key, JsonNode *val, void *arg) { void **ptrs = arg; - void (*callback)(ng_parser_ctx_t *, str *key, JsonNode *value, helper_arg) = ptrs[1]; + void (*callback)(const ng_parser_t *, str *key, JsonNode *value, helper_arg) = ptrs[1]; callback(ptrs[0], &STR(key), val, ptrs[2]); } -static bool json_dict_iter(ng_parser_ctx_t *ctx, JsonNode *input, - void (*callback)(ng_parser_ctx_t *, str *key, JsonNode *value, helper_arg), +static bool json_dict_iter(const ng_parser_t *parser, JsonNode *input, + void (*callback)(const ng_parser_t *, str *key, JsonNode *value, helper_arg), helper_arg arg) { if (json_node_get_node_type(input) != JSON_NODE_OBJECT) @@ -301,7 +301,7 @@ static bool json_dict_iter(ng_parser_ctx_t *ctx, JsonNode *input, if (!o) return false; - void *ptrs[3] = { ctx, callback, arg.generic }; + const void *ptrs[3] = { parser, callback, arg.generic }; json_object_foreach_member(o, json_dict_iter_fn, ptrs); return true; diff --git a/daemon/control_ng_flags_parser.c b/daemon/control_ng_flags_parser.c index f69f96ce4..63689a214 100644 --- a/daemon/control_ng_flags_parser.c +++ b/daemon/control_ng_flags_parser.c @@ -63,12 +63,21 @@ static bool str_key_val_prefix(const str * p, const char * q, return true; } -/** - * Work with bencode objects. - */ +static bool dummy_is_list(parser_arg a) { + return false; +} +static str *dummy_get_str(parser_arg a, str *b) { + *b = *a.str; + return b; +} + +const ng_parser_t dummy_parser = { + .is_list = dummy_is_list, + .get_str = dummy_get_str, +}; static bool parse_codec_to_dict(str * key, str * val, const char *cmp1, const char *cmp2, - const char * dictstr, ng_parser_ctx_t *ctx, bencode_buffer_t * buf) + const char * dictstr, sdp_ng_flags *flags) { str s; @@ -79,29 +88,27 @@ static bool parse_codec_to_dict(str * key, str * val, const char *cmp1, const ch return false; } - call_ng_codec_flags(ctx, &STR(dictstr), bencode_str(buf, &s), NULL); + call_ng_codec_flags(&dummy_parser, &STR(dictstr), &s, flags); return true; } /* parse codec related flags */ -static bool parse_codecs(ng_parser_ctx_t *ctx, - bencode_buffer_t * buf, str * key, str * val) -{ +static bool parse_codecs(sdp_ng_flags *flags, str * key, str * val) { if (parse_codec_to_dict(key, val, "transcode", - "codec-transcode", "transcode", ctx, buf) || + "codec-transcode", "transcode", flags) || parse_codec_to_dict(key, val, "codec-strip", - NULL, "strip", ctx, buf) || + NULL, "strip", flags) || parse_codec_to_dict(key, val, "codec-offer", - NULL, "offer", ctx, buf) || + NULL, "offer", flags) || parse_codec_to_dict(key, val, "codec-mask", - NULL, "mask", ctx, buf) || + NULL, "mask", flags) || parse_codec_to_dict(key, val, "codec-set", - NULL, "set", ctx, buf) || + NULL, "set", flags) || parse_codec_to_dict(key, val, "codec-accept", - NULL, "accept", ctx, buf) || + NULL, "accept", flags) || parse_codec_to_dict(key, val, "codec-except", - NULL, "except", ctx, buf)) + NULL, "except", flags)) { return true; } @@ -110,38 +117,23 @@ static bool parse_codecs(ng_parser_ctx_t *ctx, } /* prase transport, such as for example RTP/AVP */ -static void parse_transports(ng_parser_ctx_t *ctx, bencode_buffer_t *buf, - unsigned int transport) +static void parse_transports(unsigned int transport, sdp_ng_flags *out) { const char * val = transports[transport & 0x007]; if (!val) return; - call_ng_main_flags(ctx, &STR_CONST("transport-protocol"), bencode_string(buf, val), NULL); -} - -#if 0 -static bool parse_str_flag(str * key, str * val, const char * name, - bencode_item_t * root_dict) -{ - if(str_eq(key, name)) { - if (val->s) { - bencode_dictionary_str_add_str(root_dict, key, val); - return true; - } - } - return false; + call_ng_main_flags(&dummy_parser, &STR_CONST("transport-protocol"), &STR(val), out); } -#endif -static void rtpp_direction_flag(ng_parser_ctx_t *ctx, bencode_buffer_t *buf, unsigned int *flagnum, str *val) { +static void rtpp_direction_flag(sdp_ng_flags *flags, unsigned int *flagnum, str *val) { static const str keys[2] = {STR_CONST("from-interface"), STR_CONST("to-interface")}; if (*flagnum >= G_N_ELEMENTS(keys)) { ilog(LOG_WARN, "Too many 'direction=...' flags encountered"); return; } str key = keys[(*flagnum)++]; - call_ng_main_flags(ctx, &key, bencode_str(buf, val), NULL); + call_ng_main_flags(&dummy_parser, &key, val, flags); } /** @@ -151,12 +143,11 @@ static void rtpp_direction_flag(ng_parser_ctx_t *ctx, bencode_buffer_t *buf, uns * @param rtpp_flags - raw str rtpp_flags * @param dict - root dict to store encoded flags */ -void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx) +void parse_rtpp_flags(const str * rtpp_flags, sdp_ng_flags *out) { str remainder, key, val; unsigned int direction_flag = 0; unsigned int transport = 0; - bencode_buffer_t *buf = &ctx->ngbuf->buffer; if (!rtpp_flags->s) return; @@ -174,7 +165,7 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx) break; /* codecs have own specific parsing as well */ - if (parse_codecs(ctx, buf, &key, &val)) + if (parse_codecs(out, &key, &val)) goto next; /* parse other generic flags */ @@ -221,12 +212,12 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx) transport = 0x101; /* from-tag can be overriden, but originally has to be provided */ else if (val.s && str_eq(&key, "from-tag")) { - ctx->flags->directional = 1; /* explicitly add directional for this case */ + out->directional = 1; /* explicitly add directional for this case */ goto generic; } /* direction */ else if (str_eq(&key, "internal") || str_eq(&key, "external")) - rtpp_direction_flag(ctx, buf, &direction_flag, &key); + rtpp_direction_flag(out, &direction_flag, &key); /* other non-defined flags */ else goto generic; @@ -238,7 +229,7 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx) transport = 0x103; /* direction */ else if (str_eq(&key, "direction")) - rtpp_direction_flag(ctx, buf, &direction_flag, &val); + rtpp_direction_flag(out, &direction_flag, &val); else goto generic; goto next; @@ -264,15 +255,15 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx) generic: /* generic one key flags */ if (!val.s) - call_ng_flags_flags(&key, 0, ctx->flags); + call_ng_flags_flags(&key, 0, out); /* generic flags with value, but no particular processing */ else - call_ng_main_flags(ctx, &key, bencode_str(buf, &val), NULL); + call_ng_main_flags(&dummy_parser, &key, &val, out); next:; } /* define transport */ if (transport) - parse_transports(ctx, buf, transport); + parse_transports(transport, out); } diff --git a/include/call_interfaces.h b/include/call_interfaces.h index fcb46ce3c..66622790b 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -285,9 +285,9 @@ void call_interfaces_free(void); void call_interfaces_timer(void); void call_ng_flags_flags(str *s, unsigned int, helper_arg arg); -void call_ng_main_flags(ng_parser_ctx_t *, str *key, parser_arg value, helper_arg); -void call_ng_codec_flags(ng_parser_ctx_t *, str *key, parser_arg value, helper_arg); -void call_ng_direction_flag(ng_parser_ctx_t *, parser_arg value); +void call_ng_main_flags(const ng_parser_t *, str *key, parser_arg value, helper_arg); +void call_ng_codec_flags(const ng_parser_t *, str *key, parser_arg value, helper_arg); +void call_ng_direction_flag(const ng_parser_t *, sdp_ng_flags *, parser_arg value); INLINE struct sdp_manipulations *sdp_manipulations_get_by_id(const sdp_ng_flags *f, enum media_type id) { if (id < 0 || id >= G_N_ELEMENTS(f->sdp_manipulations)) diff --git a/include/control_ng.h b/include/control_ng.h index 996f0dd6b..54a025f8f 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -117,8 +117,8 @@ typedef union { struct ng_parser { str *(*collapse)(ng_parser_ctx_t *, parser_arg, str *out); - bool (*dict_iter)(ng_parser_ctx_t *, parser_arg, - void (*callback)(ng_parser_ctx_t *, str *, parser_arg, helper_arg), + bool (*dict_iter)(const ng_parser_t *, parser_arg, + void (*callback)(const ng_parser_t *, str *, parser_arg, helper_arg), helper_arg); bool (*is_list)(parser_arg); void (*list_iter)(const ng_parser_t *, parser_arg input, diff --git a/include/control_ng_flags_parser.h b/include/control_ng_flags_parser.h index c24df4580..e26d2fd66 100644 --- a/include/control_ng_flags_parser.h +++ b/include/control_ng_flags_parser.h @@ -14,6 +14,6 @@ * Syntax: * rtpp_flags: flag1=, flag2- ... */ -void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *); +void parse_rtpp_flags(const str * rtpp_flags, sdp_ng_flags *); #endif diff --git a/include/types.h b/include/types.h index 1c3ce179e..4d92f77fd 100644 --- a/include/types.h +++ b/include/types.h @@ -45,6 +45,7 @@ typedef struct bencode_item bencode_item_t; typedef union { bencode_item_t *benc; JsonNode *json; + str *str; void *gen; } parser_arg __attribute__ ((__transparent_union__));