Browse Source

MT#55283 use typed GQueue for attributes

Change-Id: Ie26f6050461bda8cd863d6ce0d7703952979c362
pull/1776/head
Richard Fuchs 2 years ago
parent
commit
74b8a6cce4
4 changed files with 31 additions and 30 deletions
  1. +6
    -6
      daemon/call.c
  2. +11
    -11
      daemon/sdp.c
  3. +10
    -10
      daemon/t38.c
  4. +4
    -3
      include/call.h

+ 6
- 6
daemon/call.c View File

@ -2635,7 +2635,7 @@ static void __media_init_from_flags(struct call_media *other_media, struct call_
struct stream_params *sp, sdp_ng_flags *flags)
{
struct call *call = other_media->call;
GQueue *additional_attributes = &sp->attributes; /* attributes in str format */
str_q *additional_attributes = &sp->attributes; /* attributes in str format */
if (flags && flags->opmode == OP_OFFER && flags->reset) {
if (media)
@ -2726,11 +2726,11 @@ static void __media_init_from_flags(struct call_media *other_media, struct call_
* other (unknown type)
*/
if (media && additional_attributes && additional_attributes->head) {
g_queue_clear_full(&media->sdp_attributes, free);
for (const GList *l = additional_attributes->head; l; l = l->next) {
t_queue_clear_full(&media->sdp_attributes, str_free);
for (__auto_type l = additional_attributes->head; l; l = l->next) {
str *source_attr = l->data;
str * destination_attr = str_dup(source_attr);
g_queue_push_tail(&media->sdp_attributes, destination_attr);
t_queue_push_tail(&media->sdp_attributes, destination_attr);
}
}
@ -3863,7 +3863,7 @@ void call_media_free(struct call_media **mdp) {
codec_handlers_free(md);
codec_handler_free(&md->t38_handler);
t38_gateway_put(&md->t38_gateway);
g_queue_clear_full(&md->sdp_attributes, free);
t_queue_clear_full(&md->sdp_attributes, str_free);
g_queue_clear_full(&md->dtmf_recv, dtmf_event_free);
g_queue_clear_full(&md->dtmf_send, dtmf_event_free);
g_hash_table_destroy(md->media_subscribers_ht);
@ -3884,7 +3884,7 @@ void __monologue_free(struct call_monologue *m) {
g_string_free(m->last_out_sdp, TRUE);
str_free_dup(&m->last_in_sdp);
sdp_sessions_clear(&m->last_in_sdp_parsed);
g_queue_clear_full(&m->sdp_attributes, free);
t_queue_clear_full(&m->sdp_attributes, str_free);
sdp_streams_clear(&m->last_in_sdp_streams);
g_slice_free1(sizeof(*m), m);
}


+ 11
- 11
daemon/sdp.c View File

@ -1654,7 +1654,7 @@ static void sp_free(struct stream_params *s) {
codec_store_cleanup(&s->codecs);
ice_candidates_free(&s->ice_candidates);
crypto_params_sdes_queue_clear(&s->sdes_params);
g_queue_clear_full(&s->attributes, free);
t_queue_clear_full(&s->attributes, str_free);
g_slice_free1(sizeof(*s), s);
}
@ -1828,7 +1828,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
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);
t_queue_push_tail(&sp->attributes, ret);
}
/* a=ssrc */
@ -1836,7 +1836,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
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);
t_queue_push_tail(&sp->attributes, ret);
}
/* a=msid */
@ -1844,7 +1844,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
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);
t_queue_push_tail(&sp->attributes, ret);
}
/* a=extmap */
@ -1853,7 +1853,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
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);
t_queue_push_tail(&sp->attributes, ret);
}
}
@ -1862,7 +1862,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
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);
t_queue_push_tail(&sp->attributes, ret);
}
}
@ -2173,7 +2173,7 @@ static void insert_codec_parameters(GString *s, struct call_media *cm,
}
static void insert_sdp_attributes(GString *gs, struct call_media *cm, sdp_ng_flags *flags) {
for (GList *l = cm->sdp_attributes.head; l; l = l->next) {
for (__auto_type l = cm->sdp_attributes.head; l; l = l->next) {
str *s = l->data;
append_attr_to_gstring(gs, s->s, NULL, flags, cm->type_id);
}
@ -3051,11 +3051,11 @@ void sdp_copy_session_attributes(struct call_monologue * src, struct call_monolo
struct sdp_attribute *attr;
struct sdp_session *src_session = src->last_in_sdp_parsed.head->data;
attributes_q *src_attributes = attr_list_get_by_id(&src_session->attributes, ATTR_OTHER);
g_queue_clear_full(&dst->sdp_attributes, free);
t_queue_clear_full(&dst->sdp_attributes, str_free);
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);
t_queue_push_tail(&dst->sdp_attributes, ret);
}
}
static void print_sdp_session_section(GString *s, sdp_ng_flags *flags,
@ -3417,7 +3417,7 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags,
{
const char *err = NULL;
GString *s = NULL;
GQueue * extra_sdp_attributes = &monologue->sdp_attributes;
str_q * extra_sdp_attributes = &monologue->sdp_attributes;
err = "Need at least one media";
if (!monologue->medias->len)
@ -3450,7 +3450,7 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags,
if (print_other_sess_attrs) {
/* `sdp_session`, if `->attributes` given, print on the session level */
for (GList *l = extra_sdp_attributes->head; l; l = l->next)
for (__auto_type l = extra_sdp_attributes->head; l; l = l->next)
{
str * attr_value = l->data;
append_attr_to_gstring(s, attr_value->s, NULL, flags, MT_UNKNOWN);


+ 10
- 10
daemon/t38.c View File

@ -427,21 +427,21 @@ int t38_gateway_pair(struct call_media *t38_media, struct call_media *pcm_media,
pcm_media->t38_gateway = obj_get(tg);
// add SDP options for T38
g_queue_clear_full(&t38_media->sdp_attributes, free);
t_queue_clear_full(&t38_media->sdp_attributes, str_free);
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxVersion:%i", tg->options.version));
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38MaxBitRate:14400"));
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxRateManagement:%s",
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxVersion:%i", tg->options.version));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38MaxBitRate:14400"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxRateManagement:%s",
tg->options.local_tcf ? "localTFC" : "transferredTCF"));
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxMaxBuffer:1800"));
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxMaxDatagram:512"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxMaxBuffer:1800"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxMaxDatagram:512"));
if (tg->options.max_ec_entries == 0)
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPNoEC"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPNoEC"));
else if (tg->options.fec_span > 1)
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPFEC"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPFEC"));
else
g_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPRedundancy"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPRedundancy"));
// XXX more options possible here
return 0;
@ -775,7 +775,7 @@ void t38_gateway_stop(struct t38_gateway *tg) {
if (tg->pcm_player)
media_player_stop(tg->pcm_player);
if (tg->t38_media)
g_queue_clear_full(&tg->t38_media->sdp_attributes, free);
t_queue_clear_full(&tg->t38_media->sdp_attributes, str_free);
}


+ 4
- 3
include/call.h View File

@ -310,6 +310,7 @@ struct codec_store {
strip_full:1; // set by codec_store_strip
};
struct stream_params {
unsigned int index; /* starting with 1 */
str type;
@ -322,7 +323,7 @@ struct stream_params {
const struct transport_protocol *protocol;
str format_str;
sdes_q sdes_params; // slice-alloc'd
GQueue attributes; /* just some other attributes */
str_q attributes; /* just some other attributes */
str direction[2];
sockfamily_t *desired_family;
struct dtls_fingerprint fingerprint;
@ -460,7 +461,7 @@ struct call_media {
GQueue endpoint_maps;
struct codec_store codecs;
GQueue sdp_attributes; /* str_sprintf() */
str_q sdp_attributes; /* str_sprintf() */
GHashTable *codec_handlers; /* int payload type -> struct codec_handler
XXX combine this with 'codecs' hash table? */
GQueue codec_handlers_store; /* storage for struct codec_handler */
@ -561,7 +562,7 @@ struct call_monologue {
unsigned int dtmf_delay;
/* carry `sdp_session` attributes into resulting call monologue SDP */
GQueue sdp_attributes;
str_q sdp_attributes;
volatile unsigned int ml_flags;
};


Loading…
Cancel
Save