summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorPavel Koshevoy <pkoshevoy@gmail.com>2012-02-10 18:19:08 -0700
committerMichael Niedermayer <michaelni@gmx.at>2012-02-11 23:57:35 +0100
commit277e52845ef8ffa55985512415b8849f35409958 (patch)
tree7a86a50fc3eeef83ff930bc6aac1758ad1175d9c /libavformat
parent69494fd5c50742cb7d9ad9ca45b154ab9c33fa19 (diff)
Modified to generate PAT/PMT for video keyframes
This is so that TS fragments produced by http://code.google.com/p/httpsegmenter/ would be compatible with JW Player. A new member variable prev_payload_key was added to MpegTSWriteStream to help detect transition from non-key to key frame, so that PAT/PMT would not be produced for every keyframe in intra-only videos. Signed-off-by: Pavel Koshevoy <pkoshevoy@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mpegtsenc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a8c5c5cd47..4b303def4b 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -211,6 +211,7 @@ typedef struct MpegTSWriteStream {
int cc;
int payload_size;
int first_pts_check; ///< first pts check needed
+ int prev_payload_key;
int64_t payload_pts;
int64_t payload_dts;
int payload_flags;
@@ -589,7 +590,7 @@ static int mpegts_write_header(AVFormatContext *s)
ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
} else {
- /* Arbitrary values, PAT/PMT could be written on key frames */
+ /* Arbitrary values, PAT/PMT will also be written on video key frames */
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
if (pcr_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -650,7 +651,7 @@ static int mpegts_write_header(AVFormatContext *s)
}
/* send SDT, PAT and PMT tables regulary */
-static void retransmit_si_info(AVFormatContext *s)
+static void retransmit_si_info(AVFormatContext *s, int force_pat)
{
MpegTSWrite *ts = s->priv_data;
int i;
@@ -659,7 +660,7 @@ static void retransmit_si_info(AVFormatContext *s)
ts->sdt_packet_count = 0;
mpegts_write_sdt(s);
}
- if (++ts->pat_packet_count == ts->pat_packet_period) {
+ if (++ts->pat_packet_count == ts->pat_packet_period || force_pat) {
ts->pat_packet_count = 0;
mpegts_write_pat(s);
for(i = 0; i < ts->nb_services; i++) {
@@ -788,10 +789,12 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
int afc_len, stuffing_len;
int64_t pcr = -1; /* avoid warning */
int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
+ int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
is_start = 1;
while (payload_size > 0) {
- retransmit_si_info(s);
+ retransmit_si_info(s, force_pat);
+ force_pat = 0;
write_pcr = 0;
if (ts_st->pid == ts_st->service->pcr_pid) {
@@ -961,6 +964,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
avio_write(s->pb, buf, TS_PACKET_SIZE);
}
avio_flush(s->pb);
+ ts_st->prev_payload_key = key;
}
static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)