diff --git a/daemon/call.c b/daemon/call.c index 266dcabf9..c1329f25d 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -606,6 +606,7 @@ struct call_media *call_media_new(call_t *call) { med->media_subscribers_ht = subscription_ht_new(); med->media_subscriptions_ht = subscription_ht_new(); mutex_init(&med->dtmf_lock); + med->sdp_attr_print = sdp_insert_media_attributes; return med; } @@ -4070,6 +4071,7 @@ struct call_monologue *__monologue_create(call_t *call) { ret->medias = medias_arr_new(); ret->media_ids = g_hash_table_new(str_hash, str_equal); ret->ssrc_hash = create_ssrc_hash_call(); + ret->sdp_attr_print = sdp_insert_monologue_attributes; gettimeofday(&ret->started, NULL); diff --git a/daemon/sdp.c b/daemon/sdp.c index 48502a9a0..39a9cca93 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2133,14 +2133,14 @@ static void insert_codec_parameters(GString *s, struct call_media *cm, } } -static void insert_media_attributes(GString *gs, struct call_media *cm, const sdp_ng_flags *flags) { - 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); +void sdp_insert_media_attributes(GString *gs, union sdp_attr_print_arg a, const sdp_ng_flags *flags) { + for (__auto_type l = a.cm->sdp_attributes.head; l; l = l->next) { + __auto_type s = l->data; + append_attr_to_gstring(gs, s->s, NULL, flags, a.cm->type_id); } } -static void insert_monologue_attributes(GString *gs, struct call_monologue *ml, const sdp_ng_flags *flags) { - for (__auto_type l = ml->sdp_attributes.head; l; l = l->next) { +void sdp_insert_monologue_attributes(GString *gs, union sdp_attr_print_arg a, const sdp_ng_flags *flags) { + for (__auto_type l = a.ml->sdp_attributes.head; l; l = l->next) { __auto_type s = l->data; append_attr_to_gstring(gs, s->s, NULL, flags, MT_UNKNOWN); } @@ -3054,7 +3054,7 @@ static struct packet_stream *print_sdp_media_section(GString *s, struct call_med /* all unknown type attributes will be added here */ if (print_other_attrs) - insert_media_attributes(s, media, flags); + media->sdp_attr_print(s, media, flags); /* print sendrecv */ if (!flags->original_sendrecv) @@ -3408,7 +3408,7 @@ int sdp_create(str *out, struct call_monologue *monologue, const sdp_ng_flags *f g_string_append(s, "t=0 0\r\n"); if (print_other_sess_attrs) - insert_monologue_attributes(s, monologue, flags); + monologue->sdp_attr_print(s, monologue, flags); for (unsigned int i = 0; i < monologue->medias->len; i++) { media = monologue->medias->pdata[i]; diff --git a/include/call.h b/include/call.h index 14cea1fa2..f5066f70b 100644 --- a/include/call.h +++ b/include/call.h @@ -267,6 +267,7 @@ enum block_dtmf_mode { #include "bencode.h" #include "crypto.h" #include "dtls.h" +#include "sdp.h" struct control_stream; @@ -469,6 +470,7 @@ struct call_media { struct codec_store codecs; str_q sdp_attributes; /* str_sprintf() */ + sdp_attr_print_f *sdp_attr_print; codec_handlers_ht codec_handlers; /* int payload type -> struct codec_handler XXX combine this with 'codecs' hash table? */ codec_handlers_q codec_handlers_store; /* storage for struct codec_handler */ @@ -574,6 +576,7 @@ struct call_monologue { /* carry `sdp_session` attributes into resulting call monologue SDP */ str_q sdp_attributes; + sdp_attr_print_f *sdp_attr_print; atomic64 ml_flags; }; diff --git a/include/sdp.h b/include/sdp.h index e377495ee..f3264f23b 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -39,6 +39,9 @@ extern const str rtpe_instance_id; void sdp_init(void); +sdp_attr_print_f sdp_insert_media_attributes; +sdp_attr_print_f sdp_insert_monologue_attributes; + int sdp_parse(str *body, sdp_sessions_q *sessions, const sdp_ng_flags *); int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_flags *); void sdp_streams_clear(sdp_streams_q *); diff --git a/include/types.h b/include/types.h index c0243f4cb..2b9f5d880 100644 --- a/include/types.h +++ b/include/types.h @@ -10,6 +10,12 @@ typedef struct call call_t; typedef struct stream_fd stream_fd; typedef struct rtp_payload_type rtp_payload_type; +union sdp_attr_print_arg { + struct call_media *cm; + struct call_monologue *ml; +} __attribute__ ((__transparent_union__)); +typedef void sdp_attr_print_f(GString *, union sdp_attr_print_arg, const sdp_ng_flags *flags); + #include "containers.h" struct sdp_session;