diff mbox series

[FFmpeg-devel,2/4] avformat/mpegtsenc: only allow one program in m2ts mode

Message ID 20200410194453.11257-2-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avformat/mpegtsenc: use standard pids for m2ts | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint April 10, 2020, 7:44 p.m. UTC
The standard does not allow more.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/mpegtsenc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 5e71a0b6f8..97d2dda22d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -869,8 +869,13 @@  static int mpegts_init(AVFormatContext *s)
     ts->m2ts_pgssub_pid  = M2TS_PGSSUB_START_PID;
     ts->m2ts_textsub_pid = M2TS_TEXTSUB_START_PID;
 
-    if (ts->m2ts_mode)
+    if (ts->m2ts_mode) {
         ts->pmt_start_pid = M2TS_PMT_PID;
+        if (s->nb_programs > 1) {
+            av_log(s, AV_LOG_ERROR, "Only one program is allowed in m2ts mode!\n");
+            return AVERROR(EINVAL);
+        }
+    }
 
     if (s->max_delay < 0) /* Not set by the caller */
         s->max_delay = 0;