diff --git a/daemon/call.c b/daemon/call.c index a59f7ae19..9e7f96c89 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -228,7 +228,7 @@ next: media_update_stats(media); ssrc_collect_metrics(media); } - if (MEDIA_ISSET(media, TRANSCODE)) + if (media->monologue->transcoding) hlp->transcoded_media++; } @@ -2739,6 +2739,19 @@ unsigned int proto_num_ports(unsigned int sp_ports, struct call_media *media, st return sp_ports; } + +static int __sub_is_transcoding(gconstpointer p, gconstpointer dummy) { + const struct call_subscription *cs = p; + return cs->attrs.transcoding ? 0 : 1; +} +// set transcoding flag if any media flows are transcoding, otherwise unset it +static void set_monologue_flags_per_subscribers(struct call_monologue *ml) { + ml->transcoding = 0; + + if (g_queue_find_custom(&ml->subscribers, __sub_is_transcoding, NULL)) + ml->transcoding = 1; +} + /* called with call->master_lock held in W */ int monologue_offer_answer(struct call_subscription *dialogue[2], GQueue *streams, struct sdp_ng_flags *flags) @@ -2878,6 +2891,9 @@ int monologue_offer_answer(struct call_subscription *dialogue[2], GQueue *stream } } + set_monologue_flags_per_subscribers(monologue); + set_monologue_flags_per_subscribers(other_ml); + __update_init_subscribers(other_ml, streams, flags, flags ? flags->opmode : OP_OFFER); __update_init_subscribers(monologue, NULL, NULL, flags ? flags->opmode : OP_OFFER); @@ -3255,6 +3271,7 @@ int monologue_subscribe_answer(struct call_monologue *dst_ml, struct sdp_ng_flag for (GList *l = dst_ml->subscriptions.head; l; l = l->next) { struct call_subscription *cs = l->data; struct call_monologue *src_ml = cs->monologue; + set_monologue_flags_per_subscribers(src_ml); __update_init_subscribers(src_ml, NULL, NULL, flags->opmode); dialogue_unkernelize(src_ml, "subscribe answer event"); } diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 7c8569fe0..9dd0c4383 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2290,7 +2290,6 @@ static void ng_stats_media(bencode_item_t *list, const struct call_media *m, BF_M("ICE-lite peer", ICE_LITE_PEER); BF_M("unidirectional", UNIDIRECTIONAL); BF_M("loop check", LOOP_CHECK); - BF_M("transcoding", TRANSCODE); BF_M("generator/sink", GENERATOR); stats: diff --git a/daemon/codec.c b/daemon/codec.c index d5ed35c3d..a953b00d4 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1010,7 +1010,6 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, if (sub) sub->attrs.transcoding = 0; - MEDIA_CLEAR(receiver, TRANSCODE); MEDIA_CLEAR(receiver, GENERATOR); MEDIA_CLEAR(sink, GENERATOR); @@ -1388,7 +1387,6 @@ next: if (is_transcoding) { if (sub) sub->attrs.transcoding = 1; - MEDIA_SET(receiver, TRANSCODE); if (!use_audio_player) { // we have to translate RTCP packets diff --git a/include/call.h b/include/call.h index e4ab98045..0e36cce28 100644 --- a/include/call.h +++ b/include/call.h @@ -179,7 +179,6 @@ enum { #define MEDIA_FLAG_ICE_LITE_PEER SHARED_FLAG_ICE_LITE_PEER #define MEDIA_FLAG_ICE_CONTROLLING 0x00200000 #define MEDIA_FLAG_LOOP_CHECK 0x00400000 -#define MEDIA_FLAG_TRANSCODE 0x00800000 #define MEDIA_FLAG_PTIME_OVERRIDE 0x01000000 #define MEDIA_FLAG_RTCP_FB SHARED_FLAG_RTCP_FB #define MEDIA_FLAG_GENERATOR 0x02000000 @@ -541,6 +540,7 @@ struct call_monologue { unsigned int dtmf_injection_active:1; unsigned int detect_dtmf:1; unsigned int no_recording:1; + unsigned int transcoding:1; }; struct call_iterator_list { diff --git a/t/auto-daemon-tests-redis.pl b/t/auto-daemon-tests-redis.pl index 2f763fe55..da1cfad9d 100755 --- a/t/auto-daemon-tests-redis.pl +++ b/t/auto-daemon-tests-redis.pl @@ -1579,8 +1579,8 @@ a=rtcp:PORT SDP -$json_exp->{'media-0'}{media_flags} = '10682380'; -$json_exp->{'media-1'}{media_flags} = '8454156'; +$json_exp->{'media-0'}{media_flags} = '2293772'; +$json_exp->{'media-1'}{media_flags} = '65548'; $json_exp->{'media-2'}{format_str} = '8'; $json_exp->{'media-2'}{media_flags} = '2162692'; $json_exp->{'media-3'}{format_str} = '8'; diff --git a/t/test-transcode.c b/t/test-transcode.c index 5d12c786d..4b9dda49d 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -260,7 +260,7 @@ static void __packet_seq_ts(const char *file, int line, struct call_media *media .sfd = &sfd, }; // from __stream_ssrc() - if (!MEDIA_ISSET(media, TRANSCODE)) + if (!media->monologue->transcoding) mp.ssrc_in->ssrc_map_out = ntohl(ssrc); mp.ssrc_out = get_ssrc_ctx(mp.ssrc_in->ssrc_map_out, other_media->monologue->ssrc_hash, SSRC_DIR_OUTPUT, NULL); payload_tracker_add(&mp.ssrc_in->tracker, pt_in & 0x7f);