]> git.sesse.net Git - ffmpeg/commitdiff
avformat: add fields to AVProgram/AVStream for PMT change tracking
authorAman Gupta <aman@tmm1.net>
Thu, 17 May 2018 22:30:21 +0000 (15:30 -0700)
committerAman Gupta <aman@tmm1.net>
Sat, 19 May 2018 02:00:29 +0000 (19:00 -0700)
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 <aman@tmm1.net>
doc/APIchanges
libavformat/avformat.h
libavformat/utils.c
libavformat/version.h

index befa58c84a1b2f3761f6be48f8256c93b7a02ca3..a592073ca5126f5b95959c803734abfcf7c11f92 100644 (file)
@@ -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
 
index 6dce88fad54e4ac67a31221e77b43e04be02a123..ade918f99ce326d494cf29318dea0f6a98581cc6 100644 (file)
@@ -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
index 636fae37798405e8e38b7221fef88b404c2a57a7..a4aa4e10b1b805c3d935ee9c055691ef73366d8b 100644 (file)
@@ -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;
index e9b94cc216dfcf05ec1f9071eddc93a78ae261eb..c8e89cdce1dbd8ced0391413f5a14b1417057925 100644 (file)
@@ -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, \