From patchwork Tue Nov 12 21:29:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 16230 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2D06344A5E4 for ; Tue, 12 Nov 2019 23:29:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 16D7268AA1F; Tue, 12 Nov 2019 23:29:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F19668A9A2 for ; Tue, 12 Nov 2019 23:29:25 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6FD3BE3E43; Tue, 12 Nov 2019 22:29:25 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4HXpu8KmqB_R; Tue, 12 Nov 2019 22:29:23 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9BAA7E3E2F; Tue, 12 Nov 2019 22:29:22 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Nov 2019 22:29:02 +0100 Message-Id: <20191112212906.18539-6-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191112212906.18539-1-cus@passwd.hu> References: <20191112212906.18539-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 06/10] avformat/mpegtsenc: use standard pids for m2ts X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/muxers.texi | 6 ++++-- libavformat/mpegtsenc.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index c36ae60f19..b2fae01995 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1583,11 +1583,13 @@ Advanced Codec Digital HDTV service. @item mpegts_pmt_start_pid @var{integer} Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0010}, -maximum is @code{0x1ffe}. +maximum is @code{0x1ffe}. This option has no effect in m2ts mode where the PMT +PID is fixed @code{0x0100}. @item mpegts_start_pid @var{integer} Set the first PID for elementary streams. Default is @code{0x0100}, minimum is -@code{0x0010}, maximum is @code{0x1ffe}. +@code{0x0010}, maximum is @code{0x1ffe}. This option has no effect in m2ts mode +where the elementary PIDs are fixed. @item mpegts_m2ts_mode @var{boolean} Enable m2ts mode if set to @code{1}. Default value is @code{-1} which diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 726e4786ad..be41311bf7 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -94,6 +94,10 @@ typedef struct MpegTSWrite { int pmt_start_pid; int start_pid; int m2ts_mode; + int m2ts_video_pid; + int m2ts_audio_pid; + int m2ts_subtitle_pid; + int m2ts_other_pid; int pcr_period_ms; #define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01 @@ -858,6 +862,14 @@ static int mpegts_init(AVFormatContext *s) } } + ts->m2ts_video_pid = 0x1011; + ts->m2ts_audio_pid = 0x1100; + ts->m2ts_subtitle_pid = 0x1200; + ts->m2ts_other_pid = 0x1300; // should not be needed + + if (ts->m2ts_mode) + ts->pmt_start_pid = 0x0100; + if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = 0; @@ -921,7 +933,24 @@ static int mpegts_init(AVFormatContext *s) /* MPEG pid values < 16 are reserved. Applications which set st->id in * this range are assigned a calculated pid. */ if (st->id < FIRST_OTHER_PID) { - ts_st->pid = ts->start_pid + i; + if (ts->m2ts_mode) { + switch (st->codecpar->codec_type) { + case AVMEDIA_TYPE_VIDEO: + ts_st->pid = ts->m2ts_video_pid++; + break; + case AVMEDIA_TYPE_AUDIO: + ts_st->pid = ts->m2ts_audio_pid++; + break; + case AVMEDIA_TYPE_SUBTITLE: + ts_st->pid = ts->m2ts_subtitle_pid++; + break; + default: + ts_st->pid = ts->m2ts_other_pid++; + break; + } + } else { + ts_st->pid = ts->start_pid + i; + } } else { ts_st->pid = st->id; }