Browse code

lavf: add AVFormatContext/AVStream fields for signaling to the user when events happen.

The only flags, for now, indicate if metadata was updated and are set after each call to
av_read_frame(). This comes with the caveat that, on stream start, it might not be set properly
as packets might be buffered in AVFormatContext.packet_buffer before being given to the user
in av_read_frame().

Signed-off-by: Anton Khirnov <anton@khirnov.net>

Andrew Stone authored on 2014/08/09 02:09:23
Showing 3 changed files
... ...
@@ -13,6 +13,10 @@ libavutil:     2014-08-09
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2014-xx-xx - xxxxxxx - lavf 56.01.0 - avformat.h
17
+  Add AVFormatContext.event_flags and AVStream.event_flags for signaling to
18
+  the user when events happen in the file/stream.
19
+
16 20
 2014-04-xx - xxxxxxx - lavr 2.1.0 - avresample.h
17 21
   Add avresample_convert_frame() and avresample_config().
18 22
 
... ...
@@ -296,6 +296,11 @@ struct AVFormatContext;
296 296
  *    -  sorting  -- a modified version of a tag that should be used for
297 297
  *       sorting will have '-sort' appended. E.g. artist="The Beatles",
298 298
  *       artist-sort="Beatles, The".
299
+ * - Some protocols and demuxers support metadata updates. After a successful
300
+ *   call to av_read_packet(), AVFormatContext.event_flags or AVStream.event_flags
301
+ *   will be updated to indicate if metadata changed. In order to detect metadata
302
+ *   changes on a stream, you need to loop through all streams in the AVFormatContext
303
+ *   and check their individual event_flags.
299 304
  *
300 305
  * -  Demuxers attempt to export metadata in a generic format, however tags
301 306
  *    with no generic equivalents are left as they are stored in the container.
... ...
@@ -798,6 +803,14 @@ typedef struct AVStream {
798 798
      */
799 799
     int            nb_side_data;
800 800
 
801
+    /**
802
+     * Flags for the user to detect events happening on the stream. Flags must
803
+     * be cleared by the user once the event has been handled.
804
+     * A combination of AVSTREAM_EVENT_FLAG_*.
805
+     */
806
+    int event_flags;
807
+#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata.
808
+
801 809
     /*****************************************************************
802 810
      * All fields below this line are not part of the public API. They
803 811
      * may not be used outside of libavformat and can be changed and
... ...
@@ -1170,6 +1183,15 @@ typedef struct AVFormatContext {
1170 1170
      * @see AVCodecContext.strict_std_compliance
1171 1171
      */
1172 1172
     int strict_std_compliance;
1173
+
1174
+    /**
1175
+     * Flags for the user to detect events happening on the file. Flags must
1176
+     * be cleared by the user once the event has been handled.
1177
+     * A combination of AVFMT_EVENT_FLAG_*.
1178
+     */
1179
+    int event_flags;
1180
+#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata.
1181
+
1173 1182
     /*****************************************************************
1174 1183
      * All fields below this line are not part of the public API. They
1175 1184
      * may not be used outside of libavformat and can be changed and
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR 56
33
-#define LIBAVFORMAT_VERSION_MINOR  0
33
+#define LIBAVFORMAT_VERSION_MINOR  1
34 34
 #define LIBAVFORMAT_VERSION_MICRO  0
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \