TT#50652 remove already enqueued packets when media is stopped

Change-Id: I0fd2a7100d331d341518888d2c591dbf84b2599d
changes/56/27856/1
Richard Fuchs 7 years ago
parent 7e85d1a935
commit 8d9a0d247c

@ -711,6 +711,7 @@ static void __output_rtp(struct media_packet *mp, struct codec_ssrc_handler *ch,
p->s.len = payload_len + sizeof(struct rtp_header);
payload_tracker_add(&ssrc_out->tracker, handler->dest_pt.payload_type);
p->free_func = free;
p->source = handler;
// this packet is dynamically allocated, so we're able to schedule it.
// determine scheduled time to send

@ -31,11 +31,42 @@ static struct timerthread send_timer_thread;
#ifdef WITH_TRANSCODING
// appropriate lock must be held
// called with call->master lock in W
static unsigned int send_timer_flush(struct send_timer *st, void *ptr) {
if (!st)
return 0;
unsigned int num = 0;
GList *l = st->packets.head;
while (l) {
GList *next = l->next;
struct codec_packet *p = l->data;
if (p->source != ptr)
goto next;
g_queue_delete_link(&st->packets, l);
codec_packet_free(p);
num++;
next:
l = next;
}
return num;
}
// called with call->master lock in W
static void media_player_shutdown(struct media_player *mp) {
ilog(LOG_DEBUG, "shutting down media_player");
timerthread_obj_deschedule(&mp->tt_obj);
avformat_close_input(&mp->fmtctx);
if (mp->sink) {
unsigned int num = send_timer_flush(mp->sink->send_timer, mp->handler);
ilog(LOG_DEBUG, "%u packets removed from send queue", num);
// roll back seq numbers already used
mp->ssrc_out->parent->seq_diff -= num;
}
mp->media = NULL;
if (mp->handler)
codec_handler_free(mp->handler);

@ -36,6 +36,7 @@ struct codec_handler {
struct codec_packet {
str s;
void *source; // opaque
void (*free_func)(void *);
struct timeval to_send;
};

Loading…
Cancel
Save