mpegtsmux: Explicitly resend PAT/SI/PMT on force-keyunit events

And don't randomly change the PCR stream, which would cause a new PMT
version to be generated instead and could confuse players.
This commit is contained in:
Sebastian Dröge 2018-03-21 13:42:30 +02:00
parent 3f0463c43e
commit 93e56ed473
3 changed files with 50 additions and 4 deletions

View file

@ -1378,16 +1378,16 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
GST_TIME_ARGS (running_time), count); GST_TIME_ARGS (running_time), count);
gst_pad_push_event (mux->srcpad, event); gst_pad_push_event (mux->srcpad, event);
/* output PAT */ /* output PAT, SI tables */
mux->tsmux->last_pat_ts = -1; tsmux_resend_pat (mux->tsmux);
tsmux_resend_si (mux->tsmux);
/* output PMT for each program */ /* output PMT for each program */
for (cur = mux->tsmux->programs; cur; cur = cur->next) { for (cur = mux->tsmux->programs; cur; cur = cur->next) {
TsMuxProgram *program = (TsMuxProgram *) cur->data; TsMuxProgram *program = (TsMuxProgram *) cur->data;
program->last_pmt_ts = -1; tsmux_resend_pmt (program);
} }
tsmux_program_set_pcr_stream (prog, NULL);
} }
} }

View file

@ -228,6 +228,20 @@ tsmux_get_pat_interval (TsMux * mux)
return mux->pat_interval; return mux->pat_interval;
} }
/**
* tsmux_resend_pat:
* @mux: a #TsMux
*
* Resends the PAT before the next stream packet.
*/
void
tsmux_resend_pat (TsMux * mux)
{
g_return_if_fail (mux != NULL);
mux->last_pat_ts = G_MININT64;
}
/** /**
* tsmux_set_si_interval: * tsmux_set_si_interval:
* @mux: a #TsMux * @mux: a #TsMux
@ -260,6 +274,21 @@ tsmux_get_si_interval (TsMux * mux)
return mux->si_interval; return mux->si_interval;
} }
/**
* tsmux_resend_si:
* @mux: a #TsMux
*
* Resends the SI tables before the next stream packet.
*
*/
void
tsmux_resend_si (TsMux * mux)
{
g_return_if_fail (mux != NULL);
mux->last_si_ts = G_MININT64;
}
/** /**
* tsmux_add_mpegts_si_section: * tsmux_add_mpegts_si_section:
* @mux: a #TsMux * @mux: a #TsMux
@ -427,6 +456,20 @@ tsmux_get_pmt_interval (TsMuxProgram * program)
return program->pmt_interval; return program->pmt_interval;
} }
/**
* tsmux_resend_pmt:
* @program: a #TsMuxProgram
*
* Resends the PMT before the next stream packet.
*/
void
tsmux_resend_pmt (TsMuxProgram * program)
{
g_return_if_fail (program != NULL);
program->last_pmt_ts = G_MININT64;
}
/** /**
* tsmux_program_add_stream: * tsmux_program_add_stream:
* @program: a #TsMuxProgram * @program: a #TsMuxProgram

View file

@ -189,6 +189,7 @@ void tsmux_set_write_func (TsMux *mux, TsMuxWriteFunc func, void *user_data)
void tsmux_set_alloc_func (TsMux *mux, TsMuxAllocFunc func, void *user_data); void tsmux_set_alloc_func (TsMux *mux, TsMuxAllocFunc func, void *user_data);
void tsmux_set_pat_interval (TsMux *mux, guint interval); void tsmux_set_pat_interval (TsMux *mux, guint interval);
guint tsmux_get_pat_interval (TsMux *mux); guint tsmux_get_pat_interval (TsMux *mux);
void tsmux_resend_pat (TsMux *mux);
guint16 tsmux_get_new_pid (TsMux *mux); guint16 tsmux_get_new_pid (TsMux *mux);
/* pid/program management */ /* pid/program management */
@ -196,10 +197,12 @@ TsMuxProgram * tsmux_program_new (TsMux *mux, gint prog_id);
void tsmux_program_free (TsMuxProgram *program); void tsmux_program_free (TsMuxProgram *program);
void tsmux_set_pmt_interval (TsMuxProgram *program, guint interval); void tsmux_set_pmt_interval (TsMuxProgram *program, guint interval);
guint tsmux_get_pmt_interval (TsMuxProgram *program); guint tsmux_get_pmt_interval (TsMuxProgram *program);
void tsmux_resend_pmt (TsMuxProgram *program);
/* SI table management */ /* SI table management */
void tsmux_set_si_interval (TsMux *mux, guint interval); void tsmux_set_si_interval (TsMux *mux, guint interval);
guint tsmux_get_si_interval (TsMux *mux); guint tsmux_get_si_interval (TsMux *mux);
void tsmux_resend_si (TsMux *mux);
gboolean tsmux_add_mpegts_si_section (TsMux * mux, GstMpegtsSection * section); gboolean tsmux_add_mpegts_si_section (TsMux * mux, GstMpegtsSection * section);
/* stream management */ /* stream management */