MT#55283 use str_q for parsed flags

Change-Id: I0aa11e77a7c995335d48a239515295dc4abcf5d2
pull/1776/head
Richard Fuchs 2 years ago
parent 404f264d73
commit 9810c501fd

@ -1491,9 +1491,9 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this
return;
/* requested order of crypto suites - generated offer */
const GQueue *cpq_order = &flags->sdes_order;
const str_q *cpq_order = &flags->sdes_order;
/* preferred crypto suites for the offerer - generated answer */
const GQueue *offered_order = &flags->sdes_offerer_pref;
const str_q *offered_order = &flags->sdes_offerer_pref;
bool is_offer = (flags->opmode == OP_OFFER || flags->opmode == OP_REQUEST);
@ -1674,7 +1674,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this
/* first add those mentioned in the order list,
* but only, if they were previously generated/added to the sdes_out */
for (GList *l = cpq_order->head; l; l = l->next)
for (__auto_type l = cpq_order->head; l; l = l->next)
{
str * cs_name = l->data;
struct crypto_params_sdes * cps_order;
@ -1712,7 +1712,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this
g_queue_init(offered_cpq); /* re-initialize offered crypto suites */
for (GList *l = offered_order->head; l; l = l->next)
for (__auto_type l = offered_order->head; l; l = l->next)
{
str * cs_name = l->data;
GList * elem = g_queue_find_custom(&offered_cpq_orig_list, cs_name, crypto_params_sdes_cmp);

@ -35,7 +35,7 @@
typedef union {
const struct sdp_attr_helper *attr_helper;
GQueue *q;
str_q *q;
GHashTable **htp;
void **generic;
} helper_arg __attribute__ ((__transparent_union__));
@ -655,7 +655,6 @@ INLINE void ng_sdp_attr_manipulations(sdp_ng_flags *flags, bencode_item_t *value
{
bencode_item_t *command_action = it->sibling ? it->sibling : NULL;
str media_type;
GQueue * q_ptr = NULL;
GHashTable ** ht = NULL;
if (!command_action) /* if no action, makes no sense to continue */
@ -693,9 +692,7 @@ INLINE void ng_sdp_attr_manipulations(sdp_ng_flags *flags, bencode_item_t *value
break;
case CSH_LOOKUP("add"):
q_ptr = &sm->add_commands;
call_ng_flags_str_list(NULL, command_value, call_ng_flags_esc_str_list, q_ptr);
call_ng_flags_str_list(NULL, command_value, call_ng_flags_esc_str_list, &sm->add_commands);
break;
/* CMD_REM commands */
@ -898,7 +895,7 @@ static str *str_dup_escape(const str *s) {
}
static void call_ng_flags_esc_str_list(sdp_ng_flags *out, str *s, helper_arg arg) {
str *s_copy = str_dup_escape(s);
g_queue_push_tail(arg.q, s_copy);
t_queue_push_tail(arg.q, s_copy);
}
/**
* Stores flag's value in the given GhashTable.
@ -917,7 +914,7 @@ static void call_ng_flags_str_ht(sdp_ng_flags *out, str *s, helper_arg arg) {
static void call_ng_flags_str_q_multi(sdp_ng_flags *out, str *s, helper_arg arg) {
str *s_copy = str_dup_escape(s);
str token;
GQueue *q = arg.q;
str_q *q = arg.q;
if (s_copy->len == 0)
ilog(LOG_DEBUG, "Hm, nothing to parse.");
@ -925,7 +922,7 @@ static void call_ng_flags_str_q_multi(sdp_ng_flags *out, str *s, helper_arg arg)
while (str_token_sep(&token, s_copy, ';') == 0)
{
str * ret = str_dup(&token);
g_queue_push_tail(q, ret);
t_queue_push_tail(q, ret);
}
free(s_copy);
@ -1862,7 +1859,7 @@ static void ng_sdp_attr_manipulations_free(struct sdp_manipulations * array[__MT
g_hash_table_destroy(sdp_manipulations->rem_commands);
if (sdp_manipulations->subst_commands)
g_hash_table_destroy(sdp_manipulations->subst_commands);
g_queue_clear_full(&sdp_manipulations->add_commands, free);
t_queue_clear_full(&sdp_manipulations->add_commands, str_free);
g_slice_free1(sizeof(*sdp_manipulations), sdp_manipulations);
@ -1882,15 +1879,15 @@ void call_ng_free_flags(sdp_ng_flags *flags) {
if (flags->frequencies)
g_array_free(flags->frequencies, true);
g_queue_clear_full(&flags->from_tags, free);
g_queue_clear_full(&flags->codec_offer, free);
g_queue_clear_full(&flags->codec_transcode, free);
g_queue_clear_full(&flags->codec_strip, free);
g_queue_clear_full(&flags->codec_accept, free);
g_queue_clear_full(&flags->codec_consume, free);
g_queue_clear_full(&flags->codec_mask, free);
g_queue_clear_full(&flags->sdes_order, free);
g_queue_clear_full(&flags->sdes_offerer_pref, free);
t_queue_clear_full(&flags->from_tags, str_free);
t_queue_clear_full(&flags->codec_offer, str_free);
t_queue_clear_full(&flags->codec_transcode, str_free);
t_queue_clear_full(&flags->codec_strip, str_free);
t_queue_clear_full(&flags->codec_accept, str_free);
t_queue_clear_full(&flags->codec_consume, str_free);
t_queue_clear_full(&flags->codec_mask, str_free);
t_queue_clear_full(&flags->sdes_order, str_free);
t_queue_clear_full(&flags->sdes_offerer_pref, str_free);
ng_sdp_attr_manipulations_free(flags->sdp_manipulations);
}
@ -2802,7 +2799,7 @@ static const char *media_block_match_mult(struct call **call, GQueue *medias,
}
/* handle from-tag list */
for (GList *l = flags->from_tags.head; l; l = l->next) {
for (__auto_type l = flags->from_tags.head; l; l = l->next) {
str *s = l->data;
struct call_monologue *mlf = call_get_monologue(*call, s);
if (!mlf) {

@ -5100,8 +5100,8 @@ void __codec_store_populate(struct codec_store *dst, struct codec_store *src, st
codec_store_cleanup(&orig_dst);
}
void codec_store_strip(struct codec_store *cs, GQueue *strip, GHashTable *except) {
for (GList *l = strip->head; l; l = l->next) {
void codec_store_strip(struct codec_store *cs, str_q *strip, GHashTable *except) {
for (__auto_type l = strip->head; l; l = l->next) {
str *codec = l->data;
if (!str_cmp(codec, "all") || !str_cmp(codec, "full")) {
if (!str_cmp(codec, "all"))
@ -5162,10 +5162,10 @@ void codec_store_strip(struct codec_store *cs, GQueue *strip, GHashTable *except
}
}
void codec_store_offer(struct codec_store *cs, GQueue *offer, struct codec_store *orig) {
void codec_store_offer(struct codec_store *cs, str_q *offer, struct codec_store *orig) {
// restore stripped codecs in order: codecs must be present in `orig` but not present
// in `cs`
for (GList *l = offer->head; l; l = l->next) {
for (__auto_type l = offer->head; l; l = l->next) {
str *codec = l->data;
GQueue *pts = g_hash_table_lookup(cs->codec_names, codec);
if (pts && pts->length) {
@ -5205,9 +5205,9 @@ void codec_store_offer(struct codec_store *cs, GQueue *offer, struct codec_store
}
}
void codec_store_accept(struct codec_store *cs, GQueue *accept, struct codec_store *orig) {
void codec_store_accept(struct codec_store *cs, str_q *accept, struct codec_store *orig) {
// mark codecs as `for transcoding`
for (GList *l = accept->head; l; l = l->next) {
for (__auto_type l = accept->head; l; l = l->next) {
str *codec = l->data;
g_auto(GQueue) pts_matched = G_QUEUE_INIT;
@ -5275,13 +5275,13 @@ void codec_store_accept(struct codec_store *cs, GQueue *accept, struct codec_sto
}
}
int codec_store_accept_one(struct codec_store *cs, GQueue *accept, bool accept_any) {
int codec_store_accept_one(struct codec_store *cs, str_q *accept, bool accept_any) {
// local codec-accept routine: accept first supported codec, or first from "accept" list
// if given
struct rtp_payload_type *accept_pt = NULL;
for (GList *l = accept->head; l; l = l->next) {
for (__auto_type l = accept->head; l; l = l->next) {
// iterate through list and look for the first supported codec
str *codec = l->data;
if (!str_cmp(codec, "any")) {
@ -5339,10 +5339,10 @@ int codec_store_accept_one(struct codec_store *cs, GQueue *accept, bool accept_a
return 0;
}
void codec_store_track(struct codec_store *cs, GQueue *q) {
void codec_store_track(struct codec_store *cs, str_q *q) {
#ifdef WITH_TRANSCODING
// just track all codecs from the list as "touched"
for (GList *l = q->head; l; l = l->next) {
for (__auto_type l = q->head; l; l = l->next) {
str *codec = l->data;
if (!str_cmp(codec, "all") || !str_cmp(codec, "full")) {
cs->tracker->all_touched = 1;
@ -5361,10 +5361,10 @@ void codec_store_track(struct codec_store *cs, GQueue *q) {
#endif
}
void codec_store_transcode(struct codec_store *cs, GQueue *offer, struct codec_store *orig) {
void codec_store_transcode(struct codec_store *cs, str_q *offer, struct codec_store *orig) {
#ifdef WITH_TRANSCODING
// special case of codec_store_offer(): synthesise codecs that were not already present
for (GList *l = offer->head; l; l = l->next) {
for (__auto_type l = offer->head; l; l = l->next) {
str *codec = l->data;
// parse out given codec string
AUTO_CLEANUP(struct rtp_payload_type *pt, payload_type_destroy)

@ -332,9 +332,9 @@ static void sdp_manipulations_add(struct sdp_chopper *chop,
if (!sdp_manipulations)
return;
GQueue * q_ptr = &sdp_manipulations->add_commands;
str_q * q_ptr = &sdp_manipulations->add_commands;
for (GList *l = q_ptr->head; l; l = l->next)
for (__auto_type l = q_ptr->head; l; l = l->next)
{
str * attr_value = l->data;

@ -20,7 +20,7 @@ struct sdp_ng_flags {
enum call_opmode opmode;
str call_id;
str from_tag;
GQueue from_tags;
str_q from_tags;
str to_tag;
str via_branch;
str sdp;
@ -44,20 +44,20 @@ struct sdp_ng_flags {
str address;
sockaddr_t xmlrpc_callback;
endpoint_t dtmf_log_dest;
GQueue codec_strip;
str_q codec_strip;
GHashTable *codec_except;
GQueue codec_offer;
GQueue codec_transcode;
GQueue codec_mask;
GQueue codec_accept;
GQueue codec_consume;
str_q codec_offer;
str_q codec_transcode;
str_q codec_mask;
str_q codec_accept;
str_q codec_consume;
GHashTable *codec_set;
int ptime,
rev_ptime;
GHashTable *sdes_no; /* individual crypto suites which are excluded */
GHashTable *sdes_only; /* individual crypto suites which are only accepted */
GQueue sdes_order; /* the order, in which crypto suites are being added to the SDP */
GQueue sdes_offerer_pref; /* preferred crypto suites to be selected for the offerer */
str_q sdes_order; /* the order, in which crypto suites are being added to the SDP */
str_q sdes_offerer_pref; /* preferred crypto suites to be selected for the offerer */
str dtls_fingerprint;
/* commands to manipulate attr lines in SDP */

@ -133,19 +133,19 @@ void __codec_store_populate_reuse(struct codec_store *, struct codec_store *, st
__attribute__((nonnull(1, 2)))
void codec_store_add_raw(struct codec_store *cs, struct rtp_payload_type *pt);
__attribute__((nonnull(1, 2)))
void codec_store_strip(struct codec_store *, GQueue *strip, GHashTable *except);
void codec_store_strip(struct codec_store *, str_q *strip, GHashTable *except);
__attribute__((nonnull(1, 2, 3)))
void codec_store_offer(struct codec_store *, GQueue *, struct codec_store *);
void codec_store_offer(struct codec_store *, str_q *, struct codec_store *);
__attribute__((nonnull(1, 2)))
void codec_store_check_empty(struct codec_store *, struct codec_store *);
__attribute__((nonnull(1, 2)))
void codec_store_accept(struct codec_store *, GQueue *, struct codec_store *);
void codec_store_accept(struct codec_store *, str_q *, struct codec_store *);
__attribute__((nonnull(1, 2)))
int codec_store_accept_one(struct codec_store *, GQueue *, bool accept_any);
int codec_store_accept_one(struct codec_store *, str_q *, bool accept_any);
__attribute__((nonnull(1, 2)))
void codec_store_track(struct codec_store *, GQueue *);
void codec_store_track(struct codec_store *, str_q *);
__attribute__((nonnull(1, 2, 3)))
void codec_store_transcode(struct codec_store *, GQueue *, struct codec_store *);
void codec_store_transcode(struct codec_store *, str_q *, struct codec_store *);
__attribute__((nonnull(1, 2, 3)))
void codec_store_answer(struct codec_store *dst, struct codec_store *src, sdp_ng_flags *flags);
__attribute__((nonnull(1, 2)))

@ -11,7 +11,7 @@
* session (global), media (audio/video). Works only on `a=` lines.
*/
struct sdp_manipulations {
GQueue add_commands;
str_q add_commands;
GHashTable * rem_commands;
GHashTable * subst_commands;
};

@ -53,12 +53,12 @@ static void __cleanup(void) {
g_hash_table_destroy(flags.codec_set);
if (flags.sdes_no)
g_hash_table_destroy(flags.sdes_no);
g_queue_clear_full(&flags.codec_offer, free);
g_queue_clear_full(&flags.codec_transcode, free);
g_queue_clear_full(&flags.codec_strip, free);
g_queue_clear_full(&flags.codec_accept, free);
g_queue_clear_full(&flags.codec_consume, free);
g_queue_clear_full(&flags.codec_mask, free);
t_queue_clear_full(&flags.codec_offer, str_free);
t_queue_clear_full(&flags.codec_transcode, str_free);
t_queue_clear_full(&flags.codec_strip, str_free);
t_queue_clear_full(&flags.codec_accept, str_free);
t_queue_clear_full(&flags.codec_consume, str_free);
t_queue_clear_full(&flags.codec_mask, str_free);
g_queue_clear(&call.monologues);
codec_store_cleanup(&rtp_types_sp.codecs);
@ -106,10 +106,10 @@ static void __start(const char *file, int line) {
__init();
}
#define transcode(codec) g_queue_push_tail(&flags.codec_transcode, sdup(#codec))
#define c_accept(codec) g_queue_push_tail(&flags.codec_accept, sdup(#codec))
#define c_consume(codec) g_queue_push_tail(&flags.codec_consume, sdup(#codec))
#define c_mask(codec) g_queue_push_tail(&flags.codec_mask, sdup(#codec))
#define transcode(codec) t_queue_push_tail(&flags.codec_transcode, sdup(#codec))
#define c_accept(codec) t_queue_push_tail(&flags.codec_accept, sdup(#codec))
#define c_consume(codec) t_queue_push_tail(&flags.codec_consume, sdup(#codec))
#define c_mask(codec) t_queue_push_tail(&flags.codec_mask, sdup(#codec))
#ifdef WITH_AMR_TESTS
static void codec_set(char *c) {

Loading…
Cancel
Save