diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2019-07-30 21:18:59 +0200 |
---|---|---|
committer | Mathieu Duponchelle <mathieu@centricular.com> | 2019-07-31 15:54:13 +0200 |
commit | 73f92371b8e55ff4920d213f6268874bdf503972 (patch) | |
tree | 57f32ff1958eb935dcd4b4710b241aaf00abd093 /gst/mpegtsmux/tsmux | |
parent | dae6e7964c05e0a101726a1be7fc1a7e49a48127 (diff) | |
download | gstreamer-plugins-bad-73f92371b8e55ff4920d213f6268874bdf503972.tar.gz |
basetsmux: expose pcr-interval property
Instead of using a static hardcoded PCR interval, allow the user
to configure it.
Also revert back the default to a 40 ms interval, that was changed
in recent patches for no good reason.
Diffstat (limited to 'gst/mpegtsmux/tsmux')
-rw-r--r-- | gst/mpegtsmux/tsmux/tsmux.c | 25 | ||||
-rw-r--r-- | gst/mpegtsmux/tsmux/tsmux.h | 4 | ||||
-rw-r--r-- | gst/mpegtsmux/tsmux/tsmuxcommon.h | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/gst/mpegtsmux/tsmux/tsmux.c b/gst/mpegtsmux/tsmux/tsmux.c index 16b556f7c..63c61904e 100644 --- a/gst/mpegtsmux/tsmux/tsmux.c +++ b/gst/mpegtsmux/tsmux/tsmux.c @@ -106,9 +106,6 @@ * 1/8 second atm */ #define TSMUX_PCR_OFFSET (TSMUX_CLOCK_FREQ / 8) -/* Times per second to write PCR */ -#define TSMUX_DEFAULT_PCR_FREQ (50) - /* Base for all written PCR and DTS/PTS, * so we have some slack to go backwards */ #define CLOCK_BASE (TSMUX_CLOCK_FREQ * 10 * 360) @@ -149,6 +146,8 @@ tsmux_new (void) mux->si_changed = TRUE; mux->si_interval = TSMUX_DEFAULT_SI_INTERVAL; + mux->pcr_interval = TSMUX_DEFAULT_PCR_INTERVAL; + mux->next_si_pcr = -1; mux->si_sections = g_hash_table_new_full (g_direct_hash, g_direct_equal, @@ -237,6 +236,21 @@ tsmux_set_pat_interval (TsMux * mux, guint freq) } /** + * tsmux_set_pcr_interval: + * @mux: a #TsMux + * @freq: a new PCR interval + * + * Set the interval (in cycles of the 90kHz clock) for writing the PCR. + */ +void +tsmux_set_pcr_interval (TsMux * mux, guint freq) +{ + g_return_if_fail (mux != NULL); + + mux->pcr_interval = freq; +} + +/** * tsmux_get_pat_interval: * @mux: a #TsMux * @@ -1086,10 +1100,9 @@ write_new_pcr (TsMux * mux, TsMuxStream * stream, gint64 cur_pcr) stream->pi.pcr = cur_pcr; if (stream->next_pcr == -1) - stream->next_pcr = - cur_pcr + TSMUX_SYS_CLOCK_FREQ / TSMUX_DEFAULT_PCR_FREQ; + stream->next_pcr = cur_pcr + mux->pcr_interval * 300; else - stream->next_pcr += TSMUX_SYS_CLOCK_FREQ / TSMUX_DEFAULT_PCR_FREQ; + stream->next_pcr += mux->pcr_interval * 300; } else { cur_pcr = -1; } diff --git a/gst/mpegtsmux/tsmux/tsmux.h b/gst/mpegtsmux/tsmux/tsmux.h index 59d69fece..a9819149e 100644 --- a/gst/mpegtsmux/tsmux/tsmux.h +++ b/gst/mpegtsmux/tsmux/tsmux.h @@ -164,6 +164,9 @@ struct TsMux { /* Next PAT position, 27 MHz */ gint64 next_pat_pcr; + /* interval between PCR in MPEG PTS clock time */ + guint pcr_interval; + /* trigger writing Service Information Tables */ gboolean si_changed; /* interval between SIT in MPEG PTS clock time */ @@ -224,6 +227,7 @@ TsMuxStream * tsmux_find_stream (TsMux *mux, guint16 pid); void tsmux_program_add_stream (TsMuxProgram *program, TsMuxStream *stream); void tsmux_program_set_pcr_stream (TsMuxProgram *program, TsMuxStream *stream); +void tsmux_set_pcr_interval (TsMux * mux, guint freq); /* writing stuff */ gboolean tsmux_write_stream_packet (TsMux *mux, TsMuxStream *stream); diff --git a/gst/mpegtsmux/tsmux/tsmuxcommon.h b/gst/mpegtsmux/tsmux/tsmuxcommon.h index 32203e6c1..7bfc15c17 100644 --- a/gst/mpegtsmux/tsmux/tsmuxcommon.h +++ b/gst/mpegtsmux/tsmux/tsmuxcommon.h @@ -121,6 +121,8 @@ G_BEGIN_DECLS #define TSMUX_DEFAULT_PMT_INTERVAL (TSMUX_CLOCK_FREQ / 10) /* SI interval (1/10th sec) */ #define TSMUX_DEFAULT_SI_INTERVAL (TSMUX_CLOCK_FREQ / 10) +/* PCR interval (1/25th sec) */ +#define TSMUX_DEFAULT_PCR_INTERVAL (TSMUX_CLOCK_FREQ / 25) /* Bitrate (bits per second) */ #define TSMUX_DEFAULT_BITRATE 0 |