avformat/mpegtsenc: only allow one program in m2ts mode
authorMarton Balint <cus@passwd.hu>
Tue, 10 Dec 2019 22:24:27 +0000 (23:24 +0100)
committerMarton Balint <cus@passwd.hu>
Tue, 21 Apr 2020 19:28:29 +0000 (21:28 +0200)
The standard does not allow more.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/mpegtsenc.c

index bee996a..c3b9dd5 100644 (file)
@@ -869,8 +869,13 @@ static int mpegts_init(AVFormatContext *s)
     ts->m2ts_pgssub_pid  = M2TS_PGSSUB_START_PID;
     ts->m2ts_textsub_pid = M2TS_TEXTSUB_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;