Skip to content

Commit

Permalink
MT#55283 selectively stop codec handlers
Browse files Browse the repository at this point in the history
If we're updating the handlers for one particular source -> sink flow,
only stop/reset the handlers matching this flow.

Change-Id: I1d046f47f8d26cac47c5d0f4318498eacb6c5677
(cherry picked from commit e24baca)
  • Loading branch information
rfuchs committed Oct 17, 2023
1 parent f0a6863 commit 4b0af91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion daemon/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -4418,7 +4418,7 @@ static void media_stop(struct call_media *m) {
return;
t38_gateway_stop(m->t38_gateway);
audio_player_stop(m);
codec_handlers_stop(&m->codec_handlers_store);
codec_handlers_stop(&m->codec_handlers_store, NULL);
rtcp_timer_stop(&m->rtcp_timer);
mqtt_timer_stop(&m->mqtt_timer);
}
Expand Down
9 changes: 6 additions & 3 deletions daemon/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ void __codec_handlers_update(struct call_media *receiver, struct call_media *sin
if (proto_is_not_rtp(receiver->protocol)) {
__generator_stop_all(receiver);
__generator_stop_all(sink);
codec_handlers_stop(&receiver->codec_handlers_store);
codec_handlers_stop(&receiver->codec_handlers_store, sink);
return;
}

Expand All @@ -1043,7 +1043,7 @@ void __codec_handlers_update(struct call_media *receiver, struct call_media *sin
// we're doing some kind of media passthrough - shut down local generators
__generator_stop(receiver);
__generator_stop(sink);
codec_handlers_stop(&receiver->codec_handlers_store);
codec_handlers_stop(&receiver->codec_handlers_store, sink);

bool is_transcoding = false;
receiver->rtcp_handler = NULL;
Expand Down Expand Up @@ -3582,10 +3582,13 @@ static void __ssrc_handler_stop(void *p, void *arg) {
dtx_buffer_stop(&ch->dtx_buffer);
}
}
void codec_handlers_stop(GQueue *q) {
void codec_handlers_stop(GQueue *q, struct call_media *sink) {
for (GList *l = q->head; l; l = l->next) {
struct codec_handler *h = l->data;

if (sink && h->sink != sink)
continue;

if (h->delay_buffer) {
mutex_lock(&h->delay_buffer->lock);
__delay_buffer_shutdown(h->delay_buffer, true);
Expand Down
4 changes: 2 additions & 2 deletions include/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch, struct ssrc_ctx *);
void codec_decoder_skip_pts(struct codec_ssrc_handler *ch, uint64_t);
uint64_t codec_decoder_unskip_pts(struct codec_ssrc_handler *ch);
void codec_tracker_update(struct codec_store *);
void codec_handlers_stop(GQueue *);
void codec_handlers_stop(GQueue *, struct call_media *sink);


void packet_encoded_packetize(AVPacket *pkt, struct codec_ssrc_handler *ch, struct media_packet *mp,
Expand Down Expand Up @@ -231,7 +231,7 @@ INLINE void __codec_handlers_update(struct call_media *receiver, struct call_med
}
INLINE void codec_handler_free(struct codec_handler **handler) { }
INLINE void codec_tracker_update(struct codec_store *cs) { }
INLINE void codec_handlers_stop(GQueue *q) { }
INLINE void codec_handlers_stop(GQueue *q, struct call_media *sink) { }
INLINE void ensure_codec_def(struct rtp_payload_type *pt, struct call_media *media) { }

#endif
Expand Down

0 comments on commit 4b0af91

Please sign in to comment.