diff --git a/daemon/call.c b/daemon/call.c index 8f8045c05..10bd8cb1a 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1482,11 +1482,11 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this struct call_media *other) { /* SDES options, which will be present in the outgoing offer */ - GQueue *cpq = &this->sdes_out; + sdes_q *cpq = &this->sdes_out; /* SDES options coming to us for processing */ - GQueue *cpq_in = &this->sdes_in; + sdes_q *cpq_in = &this->sdes_in; - GQueue *offered_cpq = other ? &other->sdes_in : NULL; + sdes_q *offered_cpq = other ? &other->sdes_in : NULL; if (!flags) return; @@ -1566,11 +1566,11 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this /* generate full set of params * re-create the entire list - steal for later flushing */ - GQueue cpq_orig = *cpq; + sdes_q cpq_orig = *cpq; /* re-initialize it, in order to fill it out later, taking into account * all the provided SDES flags and parameters */ - g_queue_init(cpq); + t_queue_init(cpq); /* if we were offered some crypto suites, copy those first into our offer */ @@ -1584,7 +1584,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this MEDIA_CLEAR(other, REORDER_FORCED); /* add offered crypto parameters */ - for (GList *l = offered_cpq ? offered_cpq->head : NULL; l; l = l->next) { + for (__auto_type l = offered_cpq ? offered_cpq->head : NULL; l; l = l->next) { struct crypto_params_sdes *offered_cps = l->data; if (!flags->sdes_nonew && @@ -1597,7 +1597,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this } struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps)); - g_queue_push_tail(cpq, cps); + t_queue_push_tail(cpq, cps); cps->tag = offered_cps->tag; /* our own offered tags will be higher than the ones we received */ @@ -1613,7 +1613,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this /* if we had any suites added before, re-add those that aren't there yet */ struct crypto_params_sdes *cps_orig; - while ((cps_orig = g_queue_pop_head(&cpq_orig))) { + while ((cps_orig = t_queue_pop_head(&cpq_orig))) { if ((types_offered & (1 << cps_orig->params.crypto_suite->idx))) { crypto_params_sdes_free(cps_orig); continue; @@ -1625,7 +1625,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this if (cps_orig->tag >= c_tag) c_tag = cps_orig->tag + 1; - g_queue_push_tail(cpq, cps_orig); + t_queue_push_tail(cpq, cps_orig); types_offered |= 1 << cps_orig->params.crypto_suite->idx; } @@ -1651,7 +1651,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this } struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps)); - g_queue_push_tail(cpq, cps); + t_queue_push_tail(cpq, cps); cps->tag = c_tag++; cps->params.crypto_suite = &crypto_suites[i]; @@ -1669,8 +1669,8 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this if (cpq_order && cpq_order->head) { ilog(LOG_DEBUG, "The crypto suites in the outbound SDP will be re-ordered."); - GQueue cpq_orig_list = *cpq; - g_queue_init(cpq); /* re-initialize sdes_out */ + sdes_q cpq_orig_list = *cpq; + t_queue_init(cpq); /* re-initialize sdes_out */ /* first add those mentioned in the order list, * but only, if they were previously generated/added to the sdes_out */ @@ -1679,7 +1679,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this str * cs_name = l->data; struct crypto_params_sdes * cps_order; - GList * elem = g_queue_find_custom(&cpq_orig_list, cs_name, crypto_params_sdes_cmp); + __auto_type elem = t_queue_find_custom(&cpq_orig_list, cs_name, crypto_params_sdes_cmp); if (!elem) continue; @@ -1689,17 +1689,17 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this ilog(LOG_DEBUG, "New suites order, adding: %s (cps tag: %d)", cps_order->params.crypto_suite->name, cps_order->tag); - g_queue_push_tail(cpq, cps_order); - g_queue_delete_link(&cpq_orig_list, elem); + t_queue_push_tail(cpq, cps_order); + t_queue_delete_link(&cpq_orig_list, elem); } /* now add the rest */ - while ((cps_orig = g_queue_pop_head(&cpq_orig_list))) + while ((cps_orig = t_queue_pop_head(&cpq_orig_list))) { ilog(LOG_DEBUG, "New suites order, adding: %s (cps tag: %d)", cps_orig->params.crypto_suite->name, cps_orig->tag); - g_queue_push_tail(cpq, cps_orig); + t_queue_push_tail(cpq, cps_orig); } } @@ -1708,14 +1708,14 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this ilog(LOG_DEBUG, "The crypto suites for the offerer will be re-ordered."); struct crypto_params_sdes * cps_found; - GQueue offered_cpq_orig_list = *offered_cpq; + sdes_q offered_cpq_orig_list = *offered_cpq; - g_queue_init(offered_cpq); /* re-initialize offered crypto suites */ + t_queue_init(offered_cpq); /* re-initialize offered crypto suites */ 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); + __auto_type elem = t_queue_find_custom(&offered_cpq_orig_list, cs_name, crypto_params_sdes_cmp); if (!elem) continue; @@ -1725,7 +1725,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this /* check sdes_only limitations */ if (crypto_params_sdes_check_limitations(flags->sdes_only, flags->sdes_no, cps_found->params.crypto_suite)) { - g_queue_delete_link(&offered_cpq_orig_list, elem); + t_queue_delete_link(&offered_cpq_orig_list, elem); crypto_params_sdes_free(cps_found); continue; } @@ -1737,12 +1737,12 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this * when sending processed answer to the media session originator */ MEDIA_SET(other, REORDER_FORCED); - g_queue_push_tail(offered_cpq, cps_found); - g_queue_delete_link(&offered_cpq_orig_list, elem); + t_queue_push_tail(offered_cpq, cps_found); + t_queue_delete_link(&offered_cpq_orig_list, elem); } /* now add the rest */ - while ((cps_found = g_queue_pop_head(&offered_cpq_orig_list))) + while ((cps_found = t_queue_pop_head(&offered_cpq_orig_list))) { ilog(LOG_DEBUG, "Reordering suites for offerer, adding: %s (cps tag: %d)", cps_found->params.crypto_suite->name, cps_found->tag); @@ -1754,7 +1754,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this continue; } - g_queue_push_tail(offered_cpq, cps_found); + t_queue_push_tail(offered_cpq, cps_found); } /* clear older data we are poiting using a copy now */ @@ -1775,7 +1775,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this /* reverse logic: instead of looking for a matching crypto suite to put in * our answer, we want to leave what we already had. however, this is only * valid if the currently present crypto suite matches the offer */ - for (GList *l = cpq_in->head; l; l = l->next) { + for (__auto_type l = cpq_in->head; l; l = l->next) { struct crypto_params_sdes *check_cps = l->data; if (check_cps->params.crypto_suite == cps->params.crypto_suite && check_cps->tag == cps->tag) { @@ -1793,7 +1793,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this offered_cps->params.crypto_suite->name); /* check if we can do SRTP<>SRTP passthrough. the crypto suite that was accepted * must have been present in what was offered to us */ - for (GList *l = cpq_in->head; l; l = l->next) { + for (__auto_type l = cpq_in->head; l; l = l->next) { struct crypto_params_sdes *check_cps = l->data; if (check_cps->params.crypto_suite == offered_cps->params.crypto_suite) { ilogs(crypto, LOG_DEBUG, "Found matching crypto suite %u:%s", check_cps->tag, @@ -1807,7 +1807,7 @@ cps_match: if (cps_in && (!cps || cps->params.crypto_suite != cps_in->params.crypto_suite)) { crypto_params_sdes_queue_clear(cpq); cps = g_slice_alloc0(sizeof(*cps)); - g_queue_push_tail(cpq, cps); + t_queue_push_tail(cpq, cps); cps->tag = cps_in->tag; cps->params.crypto_suite = cps_in->params.crypto_suite; @@ -1830,10 +1830,10 @@ cps_match: } // flush out crypto suites we ended up not using - leave only one - if (!g_queue_remove(cpq_in, cps_in)) + if (!t_queue_remove(cpq_in, cps_in)) ilogs(crypto, LOG_ERR, "BUG: incoming crypto suite not found in queue"); crypto_params_sdes_queue_clear(cpq_in); - g_queue_push_tail(cpq_in, cps_in); + t_queue_push_tail(cpq_in, cps_in); __sdes_flags(cps, flags); __sdes_flags(cps_in, flags); @@ -1860,7 +1860,7 @@ static void __sdes_accept(struct call_media *media, const sdp_ng_flags *flags) { /* if 'flags->sdes_nonew' is set, don't prune anything, just pass all coming. * 'flags->sdes_nonew' takes precedence over 'sdes_only' and 'sdes_no'. */ if (flags && (flags->sdes_only || flags->sdes_no) && !flags->sdes_nonew) { - GList *l = media->sdes_in.tail; + __auto_type l = media->sdes_in.tail; while (l) { struct crypto_params_sdes *offered_cps = l->data; @@ -1874,7 +1874,7 @@ static void __sdes_accept(struct call_media *media, const sdp_ng_flags *flags) { /* stop the iteration intentionally, if only one suite is left * this helps with a case, when the offerer left with no suites, * which can be allowed, but we need to still have at least something */ - if (g_list_length(l) == 1) { + if (l->next == NULL) { l = l->prev; break; } @@ -1883,8 +1883,8 @@ static void __sdes_accept(struct call_media *media, const sdp_ng_flags *flags) { offered_cps->params.crypto_suite->name, flags->sdes_only ? "not being in SDES-only" : "SDES-no"); - GList *prev = l->prev; - g_queue_delete_link(&media->sdes_in, l); + __auto_type prev = l->prev; + t_queue_delete_link(&media->sdes_in, l); crypto_params_sdes_free(offered_cps); l = prev; } @@ -1898,7 +1898,7 @@ static void __sdes_accept(struct call_media *media, const sdp_ng_flags *flags) { /* currently incoming suites */ struct crypto_params_sdes *cps_in = media->sdes_in.head->data; /* outgoing suites */ - GList *l = media->sdes_out.head; + __auto_type l = media->sdes_out.head; while (l) { struct crypto_params_sdes *cps_out = l->data; @@ -1913,8 +1913,8 @@ static void __sdes_accept(struct call_media *media, const sdp_ng_flags *flags) { del_next: /* mismatch, prune this one out */ crypto_params_sdes_free(cps_out); - GList *next = l->next; - g_queue_delete_link(&media->sdes_out, l); + __auto_type next = l->next; + t_queue_delete_link(&media->sdes_out, l); l = next; } } diff --git a/daemon/redis.c b/daemon/redis.c index a80b2a1cc..a0f014d35 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1345,7 +1345,7 @@ err: rlog(LOG_ERR, "Crypto params error: %s", err); return -1; } -static int redis_hash_get_sdes_params(GQueue *out, const struct redis_hash *h, const char *k) { +static int redis_hash_get_sdes_params(sdes_q *out, const struct redis_hash *h, const char *k) { char key[32], tagkey[64]; const char *kk = k; unsigned int tag; @@ -1365,7 +1365,7 @@ static int redis_hash_get_sdes_params(GQueue *out, const struct redis_hash *h, c return -1; } - g_queue_push_tail(out, cps); + t_queue_push_tail(out, cps); snprintf(key, sizeof(key), "%s-%u", k, iter++); kk = key; } @@ -2292,14 +2292,14 @@ static void json_update_crypto_params(JsonBuilder *builder, const char *key, str static int json_update_sdes_params(JsonBuilder *builder, const char *pref, unsigned int unique_id, - const char *k, GQueue *q) + const char *k, sdes_q *q) { char tmp[2048]; unsigned int iter = 0; char keybuf[32]; const char *key = k; - for (GList *l = q->head; l; l = l->next) { + for (__auto_type l = q->head; l; l = l->next) { struct crypto_params_sdes *cps = l->data; struct crypto_params *p = &cps->params; diff --git a/daemon/sdp.c b/daemon/sdp.c index 3be9af91f..be5ef5580 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -100,12 +100,14 @@ struct sdp_connection { TYPED_GQUEUE(attributes, struct sdp_attribute) TYPED_GHASHTABLE(attr_id_ht, enum attr_id, struct sdp_attribute, g_int_hash, g_int_equal, NULL, NULL) +TYPED_GHASHTABLE(attr_list_ht, enum attr_id, attributes_q, g_int_hash, g_int_equal, NULL, g_queue_free) +TYPED_GHASHTABLE_LOOKUP_INSERT(attr_list_ht, NULL, attributes_q_new) struct sdp_attributes { attributes_q list; /* GHashTable *name_hash; */ /* GHashTable *name_lists_hash; */ - GHashTable *id_lists_hash; + attr_list_ht id_lists_hash; attr_id_ht id_hash; }; @@ -377,8 +379,8 @@ static void append_attr_int_to_gstring(GString *s, char * value, const int * add INLINE struct sdp_attribute *attr_get_by_id(struct sdp_attributes *a, enum attr_id id) { return t_hash_table_lookup(a->id_hash, &id); } -INLINE GQueue *attr_list_get_by_id(struct sdp_attributes *a, enum attr_id id) { - return g_hash_table_lookup(a->id_lists_hash, &id); +INLINE attributes_q *attr_list_get_by_id(struct sdp_attributes *a, enum attr_id id) { + return t_hash_table_lookup(a->id_lists_hash, &id); } static struct sdp_attribute *attr_get_by_id_m_s(struct sdp_media *m, enum attr_id id) { @@ -508,8 +510,7 @@ static void attrs_init(struct sdp_attributes *a) { a->id_hash = attr_id_ht_new(); /* a->name_lists_hash = g_hash_table_new_full(str_hash, str_equal, NULL, (GDestroyNotify) g_queue_free); */ - a->id_lists_hash = g_hash_table_new_full(g_int_hash, g_int_equal, - NULL, (GDestroyNotify) g_queue_free); + a->id_lists_hash = attr_list_ht_new(); } static void attr_insert(struct sdp_attributes *attrs, struct sdp_attribute *attr) { @@ -518,10 +519,9 @@ static void attr_insert(struct sdp_attributes *attrs, struct sdp_attribute *attr if (!t_hash_table_lookup(attrs->id_hash, &attr->attr)) t_hash_table_insert(attrs->id_hash, &attr->attr, attr); - GQueue *attr_queue = g_hash_table_lookup_queue_new(attrs->id_lists_hash, &attr->attr, - NULL); + attributes_q *attr_queue = attr_list_ht_lookup_insert(attrs->id_lists_hash, &attr->attr); - g_queue_push_tail(attr_queue, attr); + t_queue_push_tail(attr_queue, attr); /* g_hash_table_insert(attrs->name_hash, &attr->name, attr); */ /* if (attr->key.s) @@ -1407,7 +1407,7 @@ static void free_attributes(struct sdp_attributes *a) { /* g_hash_table_destroy(a->name_hash); */ t_hash_table_destroy(a->id_hash); /* g_hash_table_destroy(a->name_lists_hash); */ - g_hash_table_destroy(a->id_lists_hash); + t_hash_table_destroy(a->id_lists_hash); t_queue_clear_full(&a->list, attr_free); } static void media_free(struct sdp_media *media) { @@ -1456,8 +1456,6 @@ static int fill_endpoint(struct endpoint *ep, const struct sdp_media *media, sdp static int __rtp_payload_types(struct stream_params *sp, struct sdp_media *media) { GHashTable *ht_rtpmap, *ht_fmtp, *ht_rtcp_fb; - GQueue *q; - GList *ql; struct sdp_attribute *attr; int ret = 0; @@ -1466,8 +1464,8 @@ static int __rtp_payload_types(struct stream_params *sp, struct sdp_media *media /* first go through a=rtpmap and build a hash table of attrs */ ht_rtpmap = g_hash_table_new(g_int_hash, g_int_equal); - q = attr_list_get_by_id(&media->attributes, ATTR_RTPMAP); - for (ql = q ? q->head : NULL; ql; ql = ql->next) { + attributes_q *q = attr_list_get_by_id(&media->attributes, ATTR_RTPMAP); + for (__auto_type ql = q ? q->head : NULL; ql; ql = ql->next) { struct rtp_payload_type *pt; attr = ql->data; pt = &attr->rtpmap.rtp_pt; @@ -1476,14 +1474,14 @@ static int __rtp_payload_types(struct stream_params *sp, struct sdp_media *media // do the same for a=fmtp ht_fmtp = g_hash_table_new(g_int_hash, g_int_equal); q = attr_list_get_by_id(&media->attributes, ATTR_FMTP); - for (ql = q ? q->head : NULL; ql; ql = ql->next) { + for (__auto_type ql = q ? q->head : NULL; ql; ql = ql->next) { attr = ql->data; g_hash_table_insert(ht_fmtp, &attr->fmtp.payload_type, &attr->fmtp.format_parms_str); } // do the same for a=rtcp-fb ht_rtcp_fb = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_queue_free); q = attr_list_get_by_id(&media->attributes, ATTR_RTCP_FB); - for (ql = q ? q->head : NULL; ql; ql = ql->next) { + for (__auto_type ql = q ? q->head : NULL; ql; ql = ql->next) { attr = ql->data; if (attr->rtcp_fb.payload_type == -1) continue; @@ -1492,7 +1490,7 @@ static int __rtp_payload_types(struct stream_params *sp, struct sdp_media *media } /* then go through the format list and associate */ - for (ql = media->format_list.head; ql; ql = ql->next) { + for (GList *ql = media->format_list.head; ql; ql = ql->next) { char *ep; str *s; unsigned int i; @@ -1556,8 +1554,6 @@ static void __sdp_ice(struct stream_params *sp, struct sdp_media *media) { struct sdp_attribute *attr; struct attribute_candidate *ac; struct ice_candidate *cand; - GQueue *q; - GList *ql; attr = attr_get_by_id_m_s(media, ATTR_ICE_UFRAG); if (!attr) @@ -1566,11 +1562,11 @@ static void __sdp_ice(struct stream_params *sp, struct sdp_media *media) { SP_SET(sp, ICE); - q = attr_list_get_by_id(&media->attributes, ATTR_CANDIDATE); + attributes_q *q = attr_list_get_by_id(&media->attributes, ATTR_CANDIDATE); if (!q) goto no_cand; - for (ql = q->head; ql; ql = ql->next) { + for (__auto_type ql = q->head; ql; ql = ql->next) { attr = ql->data; ac = &attr->candidate; if (!ac->parsed) @@ -1751,7 +1747,6 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f const char *errstr; unsigned int num = 0; struct sdp_attribute *attr; - GQueue *attrs; for (__auto_type l = sessions->head; l; l = l->next) { session = l->data; @@ -1798,11 +1793,11 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f goto error; /* a=crypto */ - attrs = attr_list_get_by_id(&media->attributes, ATTR_CRYPTO); - for (GList *ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { + attributes_q *attrs = attr_list_get_by_id(&media->attributes, ATTR_CRYPTO); + for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { attr = ll->data; struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps)); - g_queue_push_tail(&sp->sdes_params, cps); + t_queue_push_tail(&sp->sdes_params, cps); cps->params.crypto_suite = attr->crypto.crypto_suite; cps->params.mki_len = attr->crypto.mki_len; @@ -1830,7 +1825,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f { /* a=ssrc-group */ attrs = attr_list_get_by_id(&media->attributes, ATTR_SSRC_GROUP); - for (GList *ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { + for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { attr = ll->data; str * ret = str_dup(&attr->line_value); g_queue_push_tail(&sp->attributes, ret); @@ -1838,7 +1833,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f /* a=ssrc */ attrs = attr_list_get_by_id(&media->attributes, ATTR_SSRC); - for (GList *ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { + for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { attr = ll->data; str * ret = str_dup(&attr->line_value); g_queue_push_tail(&sp->attributes, ret); @@ -1846,7 +1841,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f /* a=msid */ attrs = attr_list_get_by_id(&media->attributes, ATTR_MSID); - for (GList *ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { + for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { attr = ll->data; str * ret = str_dup(&attr->line_value); g_queue_push_tail(&sp->attributes, ret); @@ -1855,7 +1850,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f /* a=extmap */ if (!flags->strip_extmap) { attrs = attr_list_get_by_id(&media->attributes, ATTR_EXTMAP); - for (GList *ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { + for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { attr = ll->data; str * ret = str_dup(&attr->line_value); g_queue_push_tail(&sp->attributes, ret); @@ -1864,7 +1859,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f /* ATTR_OTHER (unknown types) */ attrs = attr_list_get_by_id(&media->attributes, ATTR_OTHER); - for (GList *ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { + for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) { attr = ll->data; str * ret = str_dup(&attr->line_value); g_queue_push_tail(&sp->attributes, ret); @@ -2582,10 +2577,8 @@ strip_with_subst: static void new_priority(struct sdp_media *media, enum ice_candidate_type type, unsigned int *tprefp, unsigned int *lprefp) { - GQueue *cands; unsigned int lpref, tpref; uint32_t prio; - GList *l; struct sdp_attribute *a; struct attribute_candidate *c; @@ -2593,11 +2586,11 @@ static void new_priority(struct sdp_media *media, enum ice_candidate_type type, tpref = ice_type_preference(type); prio = ice_priority_pref(tpref, lpref, 1); - cands = attr_list_get_by_id(&media->attributes, ATTR_CANDIDATE); + attributes_q *cands = attr_list_get_by_id(&media->attributes, ATTR_CANDIDATE); if (!cands) goto out; - for (l = cands->head; l; l = l->next) { + for (__auto_type l = cands->head; l; l = l->next) { a = l->data; c = &a->candidate; if (c->cand_parsed.priority <= prio && c->cand_parsed.type == type @@ -2862,7 +2855,7 @@ static void insert_crypto1(GString *s, struct call_media *media, struct crypto_p static void insert_crypto(GString *s, struct call_media *media, sdp_ng_flags *flags) { if (!media->protocol || !media->protocol->srtp) return; - for (GList *l = media->sdes_out.head; l; l = l->next) + for (__auto_type l = media->sdes_out.head; l; l = l->next) insert_crypto1(s, media, l->data, flags); } static void insert_rtcp_attr(GString *s, struct packet_stream *ps, sdp_ng_flags *flags, @@ -3057,9 +3050,9 @@ struct packet_stream *print_rtcp(GString *s, struct call_media *media, GList *rt void sdp_copy_session_attributes(struct call_monologue * src, struct call_monologue * dst) { struct sdp_attribute *attr; struct sdp_session *src_session = src->last_in_sdp_parsed.head->data; - GQueue *src_attributes = attr_list_get_by_id(&src_session->attributes, ATTR_OTHER); + attributes_q *src_attributes = attr_list_get_by_id(&src_session->attributes, ATTR_OTHER); g_queue_clear_full(&dst->sdp_attributes, free); - for (GList *ll = src_attributes ? src_attributes->head : NULL; ll; ll = ll->next) { + for (__auto_type ll = src_attributes ? src_attributes->head : NULL; ll; ll = ll->next) { attr = ll->data; str * ret = str_dup(&attr->line_value); g_queue_push_tail(&dst->sdp_attributes, ret); @@ -3510,10 +3503,10 @@ err: int sdp_is_duplicate(sdp_sessions_q *sessions) { for (__auto_type l = sessions->head; l; l = l->next) { struct sdp_session *s = l->data; - GQueue *attr_list = attr_list_get_by_id(&s->attributes, ATTR_RTPENGINE); + attributes_q *attr_list = attr_list_get_by_id(&s->attributes, ATTR_RTPENGINE); if (!attr_list) return 0; - for (GList *ql = attr_list->head; ql; ql = ql->next) { + for (__auto_type ql = attr_list->head; ql; ql = ql->next) { struct sdp_attribute *attr = ql->data; if (!str_cmp_str(&attr->value, &rtpe_instance_id)) goto next; diff --git a/include/call.h b/include/call.h index 8502d80de..82672fc97 100644 --- a/include/call.h +++ b/include/call.h @@ -321,7 +321,7 @@ struct stream_params { str protocol_str; const struct transport_protocol *protocol; str format_str; - GQueue sdes_params; // slice-alloc'd + sdes_q sdes_params; // slice-alloc'd GQueue attributes; /* just some other attributes */ str direction[2]; sockfamily_t *desired_family; @@ -451,7 +451,7 @@ struct call_media { str media_id; str label; - GQueue sdes_in, sdes_out; + sdes_q sdes_in, sdes_out; struct dtls_fingerprint fingerprint; /* as received */ const struct dtls_hash_func *fp_hash_func; /* outgoing */ str tls_id; diff --git a/include/crypto.h b/include/crypto.h index 574b83bc6..6f433b6c1 100644 --- a/include/crypto.h +++ b/include/crypto.h @@ -8,6 +8,7 @@ #include "compat.h" #include "str.h" #include "helpers.h" +#include "containers.h" #define SRTP_MAX_MASTER_KEY_LEN 32 #define SRTP_MAX_MASTER_SALT_LEN 14 @@ -81,6 +82,8 @@ struct crypto_params_sdes { unsigned int tag; }; +TYPED_GQUEUE(sdes, struct crypto_params_sdes) + struct crypto_context { struct crypto_params params; @@ -116,10 +119,8 @@ char *crypto_params_sdes_dump(const struct crypto_params_sdes *, char **); * Recommended to be used in combination with: * g_queue_find_custom() or g_list_find_custom() */ -INLINE int crypto_params_sdes_cmp(gconstpointer a, gconstpointer b) +INLINE int crypto_params_sdes_cmp(const struct crypto_params_sdes *cs, gconstpointer b) { - const struct crypto_params_sdes * cs = a; - return str_cmp_str(&cs->params.crypto_suite->name_str, (str *) b); } @@ -213,17 +214,17 @@ INLINE void crypto_params_sdes_free(struct crypto_params_sdes *cps) { crypto_params_cleanup(&cps->params); g_slice_free1(sizeof(*cps), cps); } -INLINE void crypto_params_sdes_queue_clear(GQueue *q) { - g_queue_clear_full(q, (GDestroyNotify) crypto_params_sdes_free); +INLINE void crypto_params_sdes_queue_clear(sdes_q *q) { + t_queue_clear_full(q, crypto_params_sdes_free); } -INLINE void crypto_params_sdes_queue_copy(GQueue *dst, const GQueue *src) { - for (const GList *l = src->head; l; l = l->next) { +INLINE void crypto_params_sdes_queue_copy(sdes_q *dst, const sdes_q *src) { + for (__auto_type l = src->head; l; l = l->next) { struct crypto_params_sdes *cps = l->data; struct crypto_params_sdes *cpy = g_slice_alloc(sizeof(*cpy)); *cpy = *cps; cpy->params.mki = NULL; crypto_params_copy(&cpy->params, &cps->params, 1); - g_queue_push_tail(dst, cpy); + t_queue_push_tail(dst, cpy); } } /**