aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mpegtsenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-26 20:34:29 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-03-26 20:52:52 +0200
commit7e496e154583b5fe11ccf04b833c418b22f05ca4 (patch)
tree51ff1dc2484ab90ede1d715d30e935ce22b1af7d /libavformat/mpegtsenc.c
parent60497cb984221268ef95d2b63476f4f3379fb7e2 (diff)
parent72ccfb3cb7a85d35cfe2c99ab53e981974e599cd (diff)
downloadffmpeg-7e496e154583b5fe11ccf04b833c418b22f05ca4.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: build: ppc: drop stray leftover backslash build: Only clean the architecture subdirectory we build for. build: drop some unnecessary dependencies from the H.264 parser build: prettyprinting cosmetics libavutil: Remove pointless rational test program. libavutil: Remove broken and pointless lzo test program. lavf doxy: expand AVStream.codec doxy. lavf doxy: improve AVStream.time_base doxy. lavf doxy: add some basic documentation about reading from the demuxer. lavf doxy: document passing options to demuxers. lavf doxy: clarify that an AVPacket contains encoded data. mpegtsenc: allow user triggered PES packet flushing APIchanges: mark the place where 0.7 was cut. APIchanges: mark the place where 0.8 was cut. APIchanges: fill in missing dates and hashes. smacker: convert palette and header reading to bytestream2. alac: convert extradata reading to bytestream2. Conflicts: doc/APIchanges libavcodec/smacker.c libavcodec/x86/Makefile libavfilter/Makefile libavutil/Makefile Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mpegtsenc.c')
-rw-r--r--libavformat/mpegtsenc.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index c3b3d5d69f..0618beb182 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -974,7 +974,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
ts_st->prev_payload_key = key;
}
-static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
+static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
int size = pkt->size;
@@ -1091,27 +1091,48 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
}
-static int mpegts_write_end(AVFormatContext *s)
+static void mpegts_write_flush(AVFormatContext *s)
{
- MpegTSWrite *ts = s->priv_data;
- MpegTSWriteStream *ts_st;
- MpegTSService *service;
- AVStream *st;
int i;
/* flush current packets */
for(i = 0; i < s->nb_streams; i++) {
- st = s->streams[i];
- ts_st = st->priv_data;
+ AVStream *st = s->streams[i];
+ MpegTSWriteStream *ts_st = st->priv_data;
if (ts_st->payload_size > 0) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
+ ts_st->payload_size = 0;
}
+ }
+ avio_flush(s->pb);
+}
+
+static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ if (!pkt) {
+ mpegts_write_flush(s);
+ return 1;
+ } else {
+ return mpegts_write_packet_internal(s, pkt);
+ }
+}
+
+static int mpegts_write_end(AVFormatContext *s)
+{
+ MpegTSWrite *ts = s->priv_data;
+ MpegTSService *service;
+ int i;
+
+ mpegts_write_flush(s);
+
+ for(i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ MpegTSWriteStream *ts_st = st->priv_data;
av_freep(&ts_st->payload);
av_freep(&ts_st->adts);
}
- avio_flush(s->pb);
for(i = 0; i < ts->nb_services; i++) {
service = ts->services[i];
@@ -1135,5 +1156,6 @@ AVOutputFormat ff_mpegts_muxer = {
.write_header = mpegts_write_header,
.write_packet = mpegts_write_packet,
.write_trailer = mpegts_write_end,
+ .flags = AVFMT_ALLOW_FLUSH,
.priv_class = &mpegts_muxer_class,
};