From patchwork Fri May 18 18:15:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 9016 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp5610837jad; Fri, 18 May 2018 11:21:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqXAnFsjqsxI2b3T9CKAcpDh9MC5SPKlni/mvv7/UsBsApx6tncJtygPjN0jXdnAXAuonct X-Received: by 2002:adf:e582:: with SMTP id l2-v6mr2663923wrm.229.1526667682930; Fri, 18 May 2018 11:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526667682; cv=none; d=google.com; s=arc-20160816; b=TmRuuJ3fI388RE6V96ztfwb+0G2P9zzjWAdYXLQibFy1lJOmqORRGm70oOImyYvhQG 6gE7RgLE5xFwzZJkEorgE96zA0Tg96mjJO/4agbkfT81h2UzMKEa6NkP9Wbwbez/u5TU foCxwIiywzHpc6yu52tmxcY2rK5erA/EyAd0eFb14I7F88XD5Rnqui4hazqjtjTAcLt/ undNcHSsrt91a73UsP1qHDQkrnJWAB2+/OMPCzFft6kWeDxwxzbT5EFdWmA9B1x6IpRC uSwTfl9oHvfLZ1PZ8OVVWwZ7LJi1mW4QnYEq8gbM2FnulI+2TrFyTj60/6PpDICyFioa SMJA== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=YpOATE2H0KKA7DlujS99RknvQPb/ER/23XZNMlPOFY4=; b=JYbuLYk4v8mIekfk2jbeoTZZTGZUIFYc89b3EEl5BOLllL27pbFbQbzCYjB4PCe/Vl VixjN3OZQKcbyuq0j/uZpVbSH11oycDTv9Uuz9CGIEdDcczwrF49sCIpfY+sXK3F2MQG SC/HXFNMuB9Sqz/phAv3WcwV5R/nngt0ZiZHJzYUGHg5KL9BS3pSEN86ETeo4w751ZFx +UquFmzJWYyuTzaCJXtec4bXvvUHeVP9acKartgH6WXCKLMzFaL0YCfi9NkfRzYH+U/9 FVTK99ilAkZD00sehWYa4RE/osR5V5UGobvsMNYJEpfCZWJ87tEtNVEt9hhHSkqJvTIK GlNg== 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=NXpsf6E+; 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 y27-v6si6879032wrd.376.2018.05.18.11.21.22; Fri, 18 May 2018 11:21:22 -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=NXpsf6E+; 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 A5E2C68A3E6; Fri, 18 May 2018 21:20:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 145B9689EB5 for ; Fri, 18 May 2018 21:20:35 +0300 (EEST) Received: by mail-pl0-f68.google.com with SMTP id v24-v6so5040923plo.3 for ; Fri, 18 May 2018 11:21:14 -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; bh=FEabPSc+5WUYe4eIPcJNIo4lyM7AYuHKI07/Bc16u+Y=; b=NXpsf6E+uXe6UkFsdvjBFIz60eyZ4KC3x015RwpVzfuun9XcYYFfKn3526z560Xw/L 4LSiCne4VIBzsaLvhaRbvJvW7SbwHxr2hNApNHg0rR3DxnV+ZsDn1ANyzek3fSKnW5OL AqT/D/N3LEMDMnk+DZHX2fVfn4gSKw6DcBPKb0ouAvj9riVQ5md+oAmUW/4zNo3Q+gIl FQNx05a2EU9vxTDotnLrKTsKXGRiYyUiyZ2LDofrdQyW7PApjCAjDwPQa8+cGOn8Wm3O Z6MqchU+RsnSa5S/eYqIvRWzlnu4nFSvNeSlpa4Rwo2A3RuGUmViUS2esXnGWZJEXxAm 0DPA== 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; bh=FEabPSc+5WUYe4eIPcJNIo4lyM7AYuHKI07/Bc16u+Y=; b=FABWQZ08jZ7U7FQuUTOGu2BXiIdBwxl+SUJylN1BaahKGYaMGGKuyzdibGcfdHbnLq rPvdh0XQmJKwd29L0X5Wrn2tKvWyCako18F8bWLa3IEidnYiB5rxFAVNA3zRCU365Y59 OuhPAEe2Bn8utI6CTn7b+lPTgVAS/fLOMtS11xrsHXeuxUKOKf4d+3fLerzl/tgFcpwj 59Qh9/b12BP4UBVKtefHZbb0w7nnK4N9zXxOK9INeJCTQnhg393mNz10tTsdsWnKkRrl 2VhUpjVfet8IQGerrSxJ3V/UoIMr22bqOXCq+8vaWA1nUlgX45tJOnqaTD8MVzBnVRt/ NLTg== X-Gm-Message-State: ALKqPwe+5h4K9Q5hiKgYHIdnoM5tBEWkwrhzmnLL540AEN79o3Rvxxl1 tjj7ie1cOnBp5IY4oDtDESJX9pST X-Received: by 2002:a17:902:1004:: with SMTP id b4-v6mr10363707pla.82.1526667310908; Fri, 18 May 2018 11:15:10 -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 185-v6sm13638991pfu.13.2018.05.18.11.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 May 2018 11:15:10 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 May 2018 11:15:04 -0700 Message-Id: <20180518181506.88903-1-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH v4 1/3] avformat: add fields to AVProgram/AVStream for PMT change tracking 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: Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta These fields will allow the mpegts demuxer to expose details about the PMT/program which created the AVProgram and its AVStreams. In mpegts, a PMT which advertises streams has a version number which can be incremented at any time. When the version changes, the pids which correspond to each of it's streams can also change. Since ffmpeg creates a new AVStream per pid by default, an API user needs the ability to (a) detect when the PMT changed, and (b) tell which AVStream were added to replace earlier streams. This has been a long-standing issue with ffmpeg's handling of mpegts streams with PMT changes, and I found two related patches in the wild that attempt to solve the same problem. The first is in MythTV's ffmpeg fork, where they added a void (*streams_changed)(void*); to AVFormatContext and call it from their fork of the mpegts demuxer whenever the PMT changes. The second was proposed by XBMC in https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html, where they created a new AVMEDIA_TYPE_DATA stream with id=0 and attempted to send packets to it whenever the PMT changed. Signed-off-by: Aman Gupta --- doc/APIchanges | 4 ++++ libavformat/avformat.h | 8 ++++++++ libavformat/utils.c | 1 + libavformat/version.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index befa58c84a..a592073ca5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-05-xx - xxxxxxxxxx - lavf 58.15.100 - avformat.h + 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 6dce88fad5..ade918f99c 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; @@ -1260,6 +1267,7 @@ typedef struct AVProgram { int program_num; int pmt_pid; int pcr_pid; + int pmt_version; /***************************************************************** * All fields below this line are not part of the public API. They diff --git a/libavformat/utils.c b/libavformat/utils.c index 636fae3779..a4aa4e10b1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4569,6 +4569,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) return NULL; dynarray_add(&ac->programs, &ac->nb_programs, program); program->discard = AVDISCARD_NONE; + program->pmt_version = -1; } program->id = id; program->pts_wrap_reference = AV_NOPTS_VALUE; diff --git a/libavformat/version.h b/libavformat/version.h index e9b94cc216..c8e89cdce1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 14 +#define LIBAVFORMAT_VERSION_MINOR 15 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \