aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-18 23:25:07 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-18 23:26:05 +0200
commitb5e716ae1322eb018c95988617a0f216e6bc2b30 (patch)
tree95e55e611d6a5391e3018410fe7ed911fecbd0df /libavformat
parent34da54fd1aebca62c615701fe66e4aa9c1b1b5a5 (diff)
downloadffmpeg-b5e716ae1322eb018c95988617a0f216e6bc2b30.tar.gz
avformat/mpegtsenc: Add sdt_period, similar to pat_period
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mpegtsenc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index cec77a55f0..45bab1ce01 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -103,7 +103,9 @@ typedef struct MpegTSWrite {
int copyts;
int tables_version;
float pat_period;
+ float sdt_period;
int64_t last_pat_ts;
+ int64_t last_sdt_ts;
int omit_video_pes_length;
} MpegTSWrite;
@@ -787,10 +789,14 @@ static int mpegts_write_header(AVFormatContext *s)
}
ts->last_pat_ts = AV_NOPTS_VALUE;
+ ts->last_sdt_ts = AV_NOPTS_VALUE;
// The user specified a period, use only it
if (ts->pat_period < INT_MAX/2) {
ts->pat_packet_period = INT_MAX;
}
+ if (ts->sdt_period < INT_MAX/2) {
+ ts->sdt_packet_period = INT_MAX;
+ }
// output a PCR as soon as possible
service->pcr_packet_count = service->pcr_packet_period;
@@ -847,8 +853,13 @@ static void retransmit_si_info(AVFormatContext *s, int force_pat, int64_t dts)
MpegTSWrite *ts = s->priv_data;
int i;
- if (++ts->sdt_packet_count == ts->sdt_packet_period) {
+ if (++ts->sdt_packet_count == ts->sdt_packet_period ||
+ (dts != AV_NOPTS_VALUE && ts->last_sdt_ts == AV_NOPTS_VALUE) ||
+ (dts != AV_NOPTS_VALUE && dts - ts->last_sdt_ts >= ts->sdt_period*90000.0)
+ ) {
ts->sdt_packet_count = 0;
+ if (dts != AV_NOPTS_VALUE)
+ ts->last_sdt_ts = FFMAX(dts, ts->last_sdt_ts);
mpegts_write_sdt(s);
}
if (++ts->pat_packet_count == ts->pat_packet_period ||
@@ -1546,6 +1557,9 @@ static const AVOption options[] = {
{ "pat_period", "PAT/PMT retransmission time limit in seconds",
offsetof(MpegTSWrite, pat_period), AV_OPT_TYPE_FLOAT,
{ .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+ { "sdt_period", "SDT retransmission time limit in seconds",
+ offsetof(MpegTSWrite, sdt_period), AV_OPT_TYPE_FLOAT,
+ { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
};