Sorry, I haven't really managed to make my mail client work properly with this 
mailing list. Here's the patch, I hope it ends up in the correct thread. :(

Regards,
John Högberg
From 97447c2e66296b37df89a44ba5d30b4204d23418 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <[email protected]>
Date: Mon, 18 May 2015 11:16:51 +0200
Subject: [PATCH] lavf: add a mechanism for raising events through omission

av_reset_event_flags() is the new canonical way of clearing the event flags of a
stream, and is intended to support the new base_event_flags feature on AVStream,
which lets formats choose which events they want to trigger through raising and
which events they want to trigger through omission.
---
 libavformat/avformat.h | 18 +++++++++++++++++-
 libavformat/utils.c    | 13 +++++++++++++
 libavformat/version.h  |  2 +-
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index aa11cff..df18709 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -809,7 +809,9 @@ typedef struct AVStream {
 
     /**
      * Flags for the user to detect events happening on the stream. Flags must
-     * be cleared by the user once the event has been handled.
+     * be cleared by the user through av_reset_event_flags() once the event has
+     * been handled.
+     *
      * A combination of AVSTREAM_EVENT_FLAG_*.
      */
     int event_flags;
@@ -824,6 +826,13 @@ typedef struct AVStream {
      */
 
     /**
+     * The base event flags that event_flags should be set to on each reset, in
+     * order to support events that may be raised through omission like
+     * "NO_CARRIER" on some formats. Used internally by av_reset_event_flags()
+     */
+    int base_event_flags;
+
+    /**
      * Stream information used internally by av_find_stream_info()
      */
 #define MAX_STD_TIMEBASES (60*12+5)
@@ -1563,6 +1572,13 @@ int av_read_play(AVFormatContext *s);
 int av_read_pause(AVFormatContext *s);
 
 /**
+ * Reset the event flags on the given file and all its substreams.
+ *
+ * @param s media file handle
+ */
+void av_reset_event_flags(AVFormatContext *s);
+
+/**
  * Close an opened input AVFormatContext. Free it and all its contents
  * and set *s to NULL.
  */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 18cd0d7..f91b056 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2430,6 +2430,19 @@ int av_read_pause(AVFormatContext *s)
     return AVERROR(ENOSYS);
 }
 
+void av_reset_event_flags(AVFormatContext *s)
+{
+    int i;
+
+    s->event_flags = 0;
+
+    for (i = 0; i < s->nb_streams; i++) {
+        AVStream *st = s->streams[i];
+
+        st->event_flags = st->base_event_flags;
+    }
+}
+
 void avformat_free_context(AVFormatContext *s)
 {
     int i, j;
diff --git a/libavformat/version.h b/libavformat/version.h
index 495302a..714ec72 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR 18
+#define LIBAVFORMAT_VERSION_MINOR 19
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.1.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to