From patchwork Fri May 18 00:54:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 9007 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp4714339jad; Thu, 17 May 2018 17:54:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpF8wZu2xztsuoyZByuRH3o03mN0kf5EKdRpszYrIth5/ybcqC63PNjk+LZ1TaFwRtOyzHq X-Received: by 2002:a1c:5894:: with SMTP id m142-v6mr3005582wmb.10.1526604864810; Thu, 17 May 2018 17:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526604864; cv=none; d=google.com; s=arc-20160816; b=w599al34vR0SIIa/NUuaWJU7VjxHnGiD2LOUndLRaQ9xS1dIZrS86jo2nNLEAH3utb QLPSyVpKBi2xfeVjjGbG2b4lBdJGU54/zL5+1PUWIeKyx/dYIX33aXLo4mcvwcc+lbyo bL/bSBh3Hvt9NXN0xuPYjBV1e09giZ0yZ2VrxazE50oDvD5QSwPwMs+LklAHhvT/q5e4 WYAJwGjTJovudP5gF5aooOA5MzQn+/kCRRopgsRSKUW1mtDA6iyUKjN/VFiGln9R5TVL ix9tKu7d3bhypLW1NftVODn3mFjRXrboNFFgJhIAn34pqVAtKU8SI0uy7At7iy1YWm9v kpwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=ReluK1rTg0BYBFpH0VoAzDXes4Qk2ANbl6GyNuIpz5E=; b=LHqslugUR60myx9FqJ9k4h632xmIWZAcTxC9w8csryYxduWVYAwlVhlqzr0mf2ZStl cg27ftbh1ma55sJX+vWBe9E8LVjUi5p+jkGc55kavpAUXvBaAnWkHVRE0ZA7F5WseTkn JlSmCpuU4uuPJOgUrLQ1offMVWoGFDYGHaDHtXxM55ecMrsaKxTEF0ZziRz5moAz0X2p Bfnl0zLnlH0YUCiqUZpzRcwv5wTVbdbVnqjbUJxu+Z394V5IymNYYKGJLep1tWREPTiG t97TUmjViqGK5m04G1x2w7nqvZWScw9apPTFzan6YjjOKIZ305lc08dJvgLDPhnHWAVD LDNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=AGmao4ej; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r19-v6si5566388wrb.278.2018.05.17.17.54.23; Thu, 17 May 2018 17:54:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=AGmao4ej; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9162F68A54F; Fri, 18 May 2018 03:53:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4B9268A4D5 for ; Fri, 18 May 2018 03:53:36 +0300 (EEST) Received: by mail-pg0-f67.google.com with SMTP id 63-v6so395532pgg.3 for ; Thu, 17 May 2018 17:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5/xNfHKeAdd6EVwUQaN4kmKLIhjxbeYnSc4z2WZvT5E=; b=AGmao4ejirdUHnGkJSHboSkEX1lDl9Y30QmM/fzuxB1UTIym8FPgGlbdPQfP4VzcO+ cKDcPCKrf6S+7urevzm6mlE+CsGmADdW7ch0YzNDEAnvoid9LgMpGLDJq0cI+HvxZITG NFEkE26My6y5VooEV8KphLdhyRCWtkS5F0zNj+ug9PPctQqbimlgB/bDU1/76Fre77Hk QwCsGXWMc0EK37Sz7pnQmYveAWQoe9ta+XhShFEuoloWtv7Hj8bjsE6r4vPXi8TqKlxO zFNncrPB1Hkd0XHbldS8D69i0zoVywWHZpmXAHCRVqa6LiC8rjdpSet4l05PPyzgLXWJ cf8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5/xNfHKeAdd6EVwUQaN4kmKLIhjxbeYnSc4z2WZvT5E=; b=OYu04bGe7j+ZCNlwr2ajc1HP/pydfHvTvPrELkcfBXOnjnRpEPOnLICe0ZRU1YvDsb 51K5+L1xvntU0rWyDxsQa44DuHQyXqEhYNXrwN7Z4xopqOdm5wkjPMok4arcCDR5rf6Z 3gMgWIv4HRQPo1uLrPeoMXcgfkWc/ph0xPNy7VdvZlETxUxoEok1UWO2sw21bp+zKD2F n9V1QDjjdC3MB416fueqKZsJYtu5CdxEd0ytrd19O5BMCSvNq6aDCDQbbNTfCj5pHfvI vGw0QfpPpqiyurXbx6shiSvSvIeId+vTj+5jSz/m1bNCmTEvyf7oybawwfRAywbbH9Hh 6Wsg== X-Gm-Message-State: ALKqPweG+NdiW/+VNWgLKrguNvH2J8MDjNEHM1edHtk4YWK4JXtP1mCA 61J6vO7uIOnf69n60qTuzG4vDtGS X-Received: by 2002:a63:7c43:: with SMTP id l3-v6mr5851319pgn.0.1526604853829; Thu, 17 May 2018 17:54:13 -0700 (PDT) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id g11-v6sm7832177pgq.62.2018.05.17.17.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 May 2018 17:54:13 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 May 2018 17:54:08 -0700 Message-Id: <20180518005408.23746-1-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180517224926.4106-3-ffmpeg@tmm1.net> References: <20180517224926.4106-3-ffmpeg@tmm1.net> Subject: [FFmpeg-devel] [PATCH v3] avformat: keep track of PMT details in AVStream 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: michael@niedermayer.cc, cus@passwd.hu, Aman Gupta , jeebjp@gmail.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta With these fields, the user has enough information to make the same decisions externally that the demuxer does internally when merge_pmt_versions=1. An API user would monitor the AVProgram they're interested in to see if (flags&AV_PROGRAM_CHANGED), and would then iterate over the program's streams to find ones where the version matched. If new versions of any streams exist, then the user would first try to replace existing streams where stream_identifier was the same. If stream_identifier is unknown, then the user would compare pmt_stream_idx instead to replace the stream that was previously at the same position within the PMT. Signed-off-by: Aman Gupta --- doc/APIchanges | 1 + libavformat/avformat.h | 7 +++++++ libavformat/mpegts.c | 11 ++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index bca2e7485e..0bc056482e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -19,6 +19,7 @@ API changes, most recent first: Remove unused AV_PROGRAM_RUNNING Add AV_PROGRAM_CHANGED Add pmt_version field to AVProgram + Add program_num, pmt_version, pmt_stream_idx to AVStream 2018-05-xx - xxxxxxxxxx - lavf 58.14.100 - avformat.h Add AV_DISPOSITION_STILL_IMAGE diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 91285f34f8..3f7060b98a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1103,6 +1103,13 @@ typedef struct AVStream { */ int stream_identifier; + /** + * Details of the MPEG-TS program which created this stream. + */ + int program_num; + int pmt_version; + int pmt_stream_idx; + int64_t interleaver_chunk_size; int64_t interleaver_chunk_duration; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 287d7954a9..776c435ece 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2162,7 +2162,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len set_pmt_found(ts, h->id); - for (;;) { + for (i = 0; ; i++) { st = 0; pes = NULL; stream_type = get8(&p, p_end); @@ -2193,6 +2193,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (!pes->st) goto out; pes->st->id = pes->pid; + pes->st->program_num = h->id; + pes->st->pmt_version = h->version; + pes->st->pmt_stream_idx = i; } st = pes->st; } else if (is_pes_stream(stream_type, prog_reg_desc)) { @@ -2211,6 +2214,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (!st) goto out; st->id = pes->pid; + st->program_num = h->id; + st->pmt_version = h->version; + st->pmt_stream_idx = i; } } else { int idx = ff_find_stream_index(ts->stream, pid); @@ -2225,6 +2231,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (!st) goto out; st->id = pid; + st->program_num = h->id; + st->pmt_version = h->version; + st->pmt_stream_idx = i; st->codecpar->codec_type = AVMEDIA_TYPE_DATA; if (stream_type == 0x86 && prog_reg_desc == AV_RL32("CUEI")) { mpegts_find_stream_type(st, stream_type, SCTE_types);