avformat/mpegtsenc: Add sdt_period, similar to pat_period

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2015-07-18 23:25:07 +02:00
parent 34da54fd1a
commit b5e716ae13
2 changed files with 17 additions and 1 deletions

View File

@ -761,6 +761,8 @@ Override the default PCR retransmission time (default 20ms), ignored
if variable muxrate is selected.
@item pat_period @var{number}
Maximal time in seconds between PAT/PMT tables.
@item sdt_period @var{number}
Maximal time in seconds between SDT tables.
@item -pes_payload_size @var{number}
Set minimum PES packet payload in bytes.
@item -mpegts_flags @var{flags}

View File

@ -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 },
};