Browse code

avformat/mpegtsenc: support storing PAT/PMT per frame

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2015/07/16 08:54:56
Showing 2 changed files
... ...
@@ -810,6 +810,8 @@ Option mpegts_flags may take a set of such flags:
810 810
 Reemit PAT/PMT before writing the next packet.
811 811
 @item latm
812 812
 Use LATM packetization for AAC.
813
+@item pat_pmt_at_frames
814
+Reemit PAT and PMT at each video frame.
813 815
 @end table
814 816
 
815 817
 @subsection Example
... ...
@@ -98,6 +98,7 @@ typedef struct MpegTSWrite {
98 98
     int pcr_period;
99 99
 #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
100 100
 #define MPEGTS_FLAG_AAC_LATM        0x02
101
+#define MPEGTS_FLAG_PAT_PMT_AT_FRAMES           0x04
101 102
     int flags;
102 103
     int copyts;
103 104
     int tables_version;
... ...
@@ -971,6 +972,11 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
971 971
     int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
972 972
     int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
973 973
 
974
+    av_assert0(ts_st->payload != buf || st->codec->codec_type != AVMEDIA_TYPE_VIDEO);
975
+    if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
976
+        force_pat = 1;
977
+    }
978
+
974 979
     is_start = 1;
975 980
     while (payload_size > 0) {
976 981
         retransmit_si_info(s, force_pat);
... ...
@@ -1505,6 +1511,9 @@ static const AVOption options[] = {
1505 1505
     { "latm", "Use LATM packetization for AAC",
1506 1506
       0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_AAC_LATM }, 0, INT_MAX,
1507 1507
       AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
1508
+    { "pat_pmt_at_frames", "Reemit PAT and PMT at each video frame",
1509
+      0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_PAT_PMT_AT_FRAMES}, 0, INT_MAX,
1510
+      AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
1508 1511
     // backward compatibility
1509 1512
     { "resend_headers", "Reemit PAT/PMT before writing the next packet",
1510 1513
       offsetof(MpegTSWrite, reemit_pat_pmt), AV_OPT_TYPE_INT,