From patchwork Thu Oct 3 12:43:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Delannoy X-Patchwork-Id: 15493 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 017F5448F87 for ; Thu, 3 Oct 2019 17:00:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D02D96809A9; Thu, 3 Oct 2019 17:00:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3F35680922 for ; Thu, 3 Oct 2019 17:00:08 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id b24so2385620wmj.5 for ; Thu, 03 Oct 2019 07:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xpU3mgvZ2aCYpxlA1f9fI+mQXhtBQjVlaFyjgyumb00=; b=pI+LLFjrHk6wRcv2mPwJCf098QqQaoWNaGoSOA43eobLcIRAXYiayb2b4YxZfufRBA kK5s/iw885u6bHbvzI1e8pdNsvlNPGS05+RZerlKmdbg++ooV4mVGM9NJ7tvfIMUcMFf X2Wc4GYSiKr6rMw9of3BpOw4F6+Plf/ovRtNed2+PjvGgiK8LUD9UjjRD2ZrjsQC6yIm o6EDXXUuidCZ11Aiw/lF0dd3xvW7aK4bEkUxOQRJV/OPRMrVPeKGrDPwMYcdEa3rWBVD EmY8ptjG2swyFtPseyAGPrgEqtmq9shcyWZTQpcB9Z8gmwxwDAEAztNs0A5/7Zaals2F zn6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xpU3mgvZ2aCYpxlA1f9fI+mQXhtBQjVlaFyjgyumb00=; b=KAUh4lam1DjhNtubf5BGSW3KsLO37cgtcBYSbOKI/sxQ8IjnqEO1EmBQQujtLNyKgv 9YP0QJ6ocDZXNBjlrXCXAT3NPd5wvb8f7QItnrsOfHNz03tuJ6M0ituU2PJPFQrSkdqf aKpmdOtf71tCv1MJ6qkh7F5Sihz6RxhR6UFpYvlkvV8rlxkKk88aXqGU3agmCKRlbAY9 Rg3f8cvXWvkLRS+NbxWK+AibAlr7wSIL6DdqJ4uz4504Z8JgIfId5BpmksP6+KI0dr6o h7pOP/2ctjSrW4s415SOPjeJPFUm27OofNxj4myins1IFK6ev1OiAmsi6EgShbX48Erx KJ2Q== X-Gm-Message-State: APjAAAV+mH3s3ULf3I4rv3q6pShw11G9EOn/2ZMUEkxo2ulHl9Fw9ETX F5LXMOi8iaec6LUsn8G5SdkVkbRk X-Google-Smtp-Source: APXvYqxt9mpE2L+zzkSGdf/fzjt1YI5IG/dUYzmI/smeJQtZfH3+1zgf40QlGI6LmzdI8SW7ZukOJg== X-Received: by 2002:a7b:cb0e:: with SMTP id u14mr7675908wmj.115.1570111207542; Thu, 03 Oct 2019 07:00:07 -0700 (PDT) Received: from tvty-lt-28.localdomain (host.251.54.23.62.rev.coltfrance.com. [62.23.54.251]) by smtp.gmail.com with ESMTPSA id b62sm3918854wmc.13.2019.10.03.07.00.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Oct 2019 07:00:06 -0700 (PDT) Received: by tvty-lt-28.localdomain (Postfix, from userid 1001) id 69247B60019; Thu, 3 Oct 2019 14:43:57 +0200 (CEST) From: Anthony Delannoy To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Oct 2019 14:43:52 +0200 Message-Id: <20191003124352.31565-3-anthony.2lannoy@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003124352.31565-1-anthony.2lannoy@gmail.com> References: <20191003124352.31565-1-anthony.2lannoy@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/mpegts: add support for non-standard NIT pid 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: Anthony Delannoy Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/mpegts.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 5a3e71d9ab..02da272325 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -169,6 +169,7 @@ struct MpegTSContext { MpegTSFilter *pids[NB_PID_MAX]; int current_pid; + int nit_pid; AVStream *epg_stream, *nit_stream; }; @@ -2432,15 +2433,6 @@ static void nit_cb(MpegTSFilter *filter, const uint8_t *section, int section_len const uint8_t *p, *p_end; SectionHeader h1, *h = &h1; - if (!ts->nit_stream) { - ts->nit_stream = avformat_new_stream(ts->stream, NULL); - if (!ts->nit_stream) - return; - ts->nit_stream->id = NIT_PID; - ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA; - ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT; - } - if (ts->nit_stream->discard == AVDISCARD_ALL) return; @@ -2508,7 +2500,25 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (sid == 0x0000) { /* NIT info */ - // XXX for now we only use default NIT_PID + if (!ts->nit_stream) { + ts->nit_pid = pmt_pid; + + if (ts->nit_pid != NIT_PID) + av_log(ts->stream, AV_LOG_WARNING, + "Using non-standard PID %i for NIT table.\n", pmt_pid); + + if (ts->pids[ts->nit_pid]) + mpegts_close_filter(ts, ts->pids[ts->nit_pid]); + + mpegts_open_section_filter(ts, ts->nit_pid, nit_cb, ts, 1); + + ts->nit_stream = avformat_new_stream(ts->stream, NULL); + if (!ts->nit_stream) + return; + ts->nit_stream->id = ts->nit_pid; + ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA; + ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT; + } } else { MpegTSFilter *fil = ts->pids[pmt_pid]; program = av_new_program(ts->stream, sid); @@ -3084,7 +3094,6 @@ static int mpegts_read_header(AVFormatContext *s) mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1); - mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1); handle_packets(ts, probesize / ts->raw_packet_size); /* if could not find service, enable auto_guess */ @@ -3343,7 +3352,6 @@ MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s) mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1); - mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1); return ts; }