diff --git a/daemon/call.c b/daemon/call.c index 29cc5e219..eb701f7dc 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1368,8 +1368,8 @@ void __add_sink_handler(GQueue *q, struct packet_stream *sink, bool rtcp_only, b struct sink_handler *sh = g_slice_alloc0(sizeof(*sh)); sh->sink = sink; sh->kernel_output_idx = -1; - sh->rtcp_only = rtcp_only ? 1 : 0; - sh->transcoding = transcoding ? 1 : 0; + sh->attrs.rtcp_only = rtcp_only ? 1 : 0; + sh->attrs.transcoding = transcoding ? 1 : 0; g_queue_push_tail(q, sh); } @@ -2410,7 +2410,7 @@ static void set_transcoding_flag(struct call_monologue *ml, struct call_monologu struct call_subscription *cs = find_subscription(ml, sub); if (!cs) return; - cs->transcoding = flag ? 1 : 0; + cs->attrs.transcoding = flag ? 1 : 0; } void codecs_offer_answer(struct call_media *media, struct call_media *other_media, @@ -2549,9 +2549,9 @@ static void __update_init_subscribers(struct call_monologue *ml, GQueue *streams // skip into correct media section for multi-ml subscriptions for (unsigned int offset = cs->media_offset; offset && sub_medias[num_subs]; offset--) sub_medias[num_subs] = sub_medias[num_subs]->next; - subs_rtcp_only[num_subs] = cs->rtcp_only ? true : false; - subs_tc[num_subs] = cs->transcoding ? true : false; - subs_egress[num_subs] = cs->egress ? true : false; + subs_rtcp_only[num_subs] = cs->attrs.rtcp_only ? true : false; + subs_tc[num_subs] = cs->attrs.transcoding ? true : false; + subs_egress[num_subs] = cs->attrs.egress ? true : false; num_subs++; } // keep num_subs as shortcut to ml->subscribers.length @@ -2987,7 +2987,7 @@ static bool __unsubscribe_one(struct call_monologue *which, struct call_monologu static void __unsubscribe_all_offer_answer_subscribers(struct call_monologue *ml) { for (GList *l = ml->subscribers.head; l; ) { struct call_subscription *cs = l->data; - if (!cs->offer_answer) { + if (!cs->attrs.offer_answer) { l = l->next; continue; } @@ -3021,8 +3021,8 @@ void __add_subscription(struct call_monologue *which, struct call_monologue *to, to_rev_cs->monologue = which; which_cs->media_offset = offset; to_rev_cs->media_offset = offset; - which_cs->rtcp_only = rtcp_only ? 1 : 0; - to_rev_cs->rtcp_only = rtcp_only ? 1 : 0; + which_cs->attrs.rtcp_only = rtcp_only ? 1 : 0; + to_rev_cs->attrs.rtcp_only = rtcp_only ? 1 : 0; // keep offer-answer subscriptions first in the list if (!offer_answer) { g_queue_push_tail(&which->subscriptions, which_cs); @@ -3036,10 +3036,10 @@ void __add_subscription(struct call_monologue *which, struct call_monologue *to, which_cs->link = to->subscribers.head; to_rev_cs->link = which->subscriptions.head; } - which_cs->offer_answer = offer_answer ? 1 : 0; - to_rev_cs->offer_answer = which_cs->offer_answer; - which_cs->egress = egress ? 1 : 0; - to_rev_cs->egress = which_cs->egress; + which_cs->attrs.offer_answer = offer_answer ? 1 : 0; + to_rev_cs->attrs.offer_answer = which_cs->attrs.offer_answer; + which_cs->attrs.egress = egress ? 1 : 0; + to_rev_cs->attrs.egress = which_cs->attrs.egress; g_hash_table_insert(which->subscriptions_ht, to, to_rev_cs->link); g_hash_table_insert(to->subscribers_ht, which, which_cs->link); } @@ -4112,7 +4112,7 @@ static int call_get_monologue_new(struct call_monologue *dialogue[2], struct cal if (totag && totag->s) { for (GList *sub = ret->subscribers.head; sub; sub = sub->next) { struct call_subscription *cs = sub->data; - if (!cs->offer_answer) + if (!cs->attrs.offer_answer) continue; struct call_monologue *csm = cs->monologue; if (str_cmp_str(&csm->tag, totag)) { @@ -4166,7 +4166,7 @@ new_branch: ok_check_tag: for (GList *sub = ret->subscriptions.head; sub; sub = sub->next) { struct call_subscription *cs = sub->data; - if (!cs->offer_answer) + if (!cs->attrs.offer_answer) continue; struct call_monologue *csm = cs->monologue; if (!os) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 953aa661b..25cbe1921 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2044,14 +2044,14 @@ static void ng_stats_monologue(bencode_item_t *dict, const struct call_monologue struct call_subscription *cs = l->data; bencode_item_t *sub1 = bencode_list_add_dictionary(subs); bencode_dictionary_add_str(sub1, "tag", &cs->monologue->tag); - bencode_dictionary_add_string(sub1, "type", cs->offer_answer ? "offer/answer" : "pub/sub"); + bencode_dictionary_add_string(sub1, "type", cs->attrs.offer_answer ? "offer/answer" : "pub/sub"); } subs = bencode_dictionary_add_list(sub, "subscribers"); for (GList *l = ml->subscribers.head; l; l = l->next) { struct call_subscription *cs = l->data; bencode_item_t *sub1 = bencode_list_add_dictionary(subs); bencode_dictionary_add_str(sub1, "tag", &cs->monologue->tag); - bencode_dictionary_add_string(sub1, "type", cs->offer_answer ? "offer/answer" : "pub/sub"); + bencode_dictionary_add_string(sub1, "type", cs->attrs.offer_answer ? "offer/answer" : "pub/sub"); } ng_stats_ssrc(ssrc, ml->ssrc_hash); diff --git a/daemon/codec.c b/daemon/codec.c index 1908f5fbb..223a7b71f 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1453,7 +1453,7 @@ struct codec_handler *codec_handler_get(struct call_media *m, int payload_type, out: if (ret) return ret; - if (sh && sh->transcoding) + if (sh && sh->attrs.transcoding) return &codec_handler_stub_ssrc; #endif return &codec_handler_stub; diff --git a/daemon/dtmf.c b/daemon/dtmf.c index d541bd65c..a8f09420a 100644 --- a/daemon/dtmf.c +++ b/daemon/dtmf.c @@ -494,7 +494,7 @@ static const char *dtmf_inject_pcm(struct call_media *media, struct call_media * if (!seq) continue; - struct ssrc_ctx *ssrc_out = get_ssrc_ctx(sh->transcoding ? + struct ssrc_ctx *ssrc_out = get_ssrc_ctx(sh->attrs.transcoding ? ssrc_in->ssrc_map_out : ssrc_in->parent->h.ssrc, sink_ml->ssrc_hash, SSRC_DIR_OUTPUT, monologue); diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 3a58d85eb..484a321c2 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1287,7 +1287,7 @@ static const char *kernelize_one(struct rtpengine_target_info *reti, GQueue *out g_list_free(values); } else { - if (sink_handler && sink_handler->transcoding) + if (sink_handler && sink_handler->attrs.transcoding) return NULL; } @@ -1307,7 +1307,7 @@ output: if (MEDIA_ISSET(media, ECHO)) redi->output.ssrc_subst = 1; - if (sink_handler && sink_handler->transcoding) { + if (sink_handler && sink_handler->attrs.transcoding) { redi->output.ssrc_subst = 1; reti->pt_filter = 1; } @@ -1325,7 +1325,7 @@ output: handler->out->kernel(&redi->output.encrypt, sink); - redi->output.rtcp_only = sink_handler ? (sink_handler->rtcp_only ? 1 : 0) : 0; + redi->output.rtcp_only = sink_handler ? (sink_handler->attrs.rtcp_only ? 1 : 0) : 0; mutex_unlock(&sink->out_lock); @@ -1649,7 +1649,7 @@ static const struct streamhandler *__determine_handler(struct packet_stream *in, must_recrypt = true; else if (MEDIA_ISSET(in->media, DTLS) || (out && MEDIA_ISSET(out->media, DTLS))) must_recrypt = true; - else if (sh->transcoding) + else if (sh->attrs.transcoding) must_recrypt = true; else if (in->call->recording) must_recrypt = true; @@ -1917,12 +1917,12 @@ static void media_packet_rtp_out(struct packet_handler_ctx *phc, struct sink_han if (G_LIKELY(!phc->rtcp && phc->mp.rtp)) { unkern = __stream_ssrc_out(phc->out_srtp, phc->mp.rtp->ssrc, phc->mp.ssrc_in, &phc->mp.ssrc_out, phc->mp.media_out->monologue->ssrc_hash, - sh->transcoding ? true : false); + sh->attrs.transcoding ? true : false); } else if (phc->rtcp && phc->mp.rtcp) { unkern = __stream_ssrc_out(phc->out_srtp, phc->mp.rtcp->ssrc, phc->mp.ssrc_in, &phc->mp.ssrc_out, phc->mp.media_out->monologue->ssrc_hash, - sh->transcoding ? true : false); + sh->attrs.transcoding ? true : false); } if (unkern) @@ -2466,7 +2466,7 @@ static int stream_packet(struct packet_handler_ctx *phc) { goto next; } else { - if (sh->rtcp_only) + if (sh->attrs.rtcp_only) goto next; } diff --git a/daemon/redis.c b/daemon/redis.c index 5b8175d97..e7cc383d5 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1772,9 +1772,9 @@ static int json_link_streams(struct call *c, struct redis_list *streams, if (!sink) return -1; struct call_subscription *cs = __find_subscriber(ps_ml, sink); - if (cs && cs->egress) + if (cs && cs->attrs.egress) continue; - __add_sink_handler(&ps->rtp_sinks, sink, cs ? cs->rtcp_only : false, false); + __add_sink_handler(&ps->rtp_sinks, sink, cs ? cs->attrs.rtcp_only : false, false); } g_queue_clear(&q); @@ -2558,9 +2558,9 @@ char* redis_encode_json(struct call *c) { JSON_ADD_STRING("%u/%u/%u/%u/%u", cs->monologue->unique_id, cs->media_offset, - cs->offer_answer, - cs->rtcp_only, - cs->egress); + cs->attrs.offer_answer, + cs->attrs.rtcp_only, + cs->attrs.egress); } json_builder_end_array(builder); } diff --git a/include/call.h b/include/call.h index 2af403da7..73b821967 100644 --- a/include/call.h +++ b/include/call.h @@ -429,10 +429,7 @@ struct call_subscription { struct call_monologue *monologue; GList *link; // link into the corresponding opposite list unsigned int media_offset; // 0 if media indexes match up - unsigned int offer_answer:1; // bidirectional, exclusive - unsigned int rtcp_only:1; - unsigned int transcoding:1; - unsigned int egress:1; + struct sink_attrs attrs; }; /* half a dialogue */ diff --git a/include/media_socket.h b/include/media_socket.h index 06c681d93..0f637dc37 100644 --- a/include/media_socket.h +++ b/include/media_socket.h @@ -127,12 +127,17 @@ struct stream_fd { int error_strikes; struct poller *poller; }; +struct sink_attrs { + unsigned int offer_answer:1; // bidirectional, exclusive + unsigned int rtcp_only:1; + unsigned int transcoding:1; + unsigned int egress:1; +}; struct sink_handler { struct packet_stream *sink; const struct streamhandler *handler; int kernel_output_idx; - unsigned int rtcp_only:1; - unsigned int transcoding:1; + struct sink_attrs attrs; }; struct media_packet { str raw;