[FFmpeg-devel] [PATCH 1/3] lavf: add video device callbacks
Lukasz Marek
lukasz.m.luki at gmail.com
Mon Jan 13 01:41:46 CET 2014
Adds 2 callbacks to AVFormatContext
- window_size_cb
allows device to read user provided window dimensions
- window_swap_buffers_cb
allows device to swap buffers of user provided window
Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
---
libavformat/avformat.h | 33 +++++++++++++++++++++++++++++++++
libavformat/utils.c | 3 +++
libavformat/version.h | 2 +-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6d719d7..6fb9fdd 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -948,6 +948,17 @@ typedef struct AVChapter {
/**
+ * Callback used by video output devices to get user provided window dimensions.
+ */
+typedef int (*av_format_device_window_size_callback)(struct AVFormatContext *, int *, int *);
+
+/**
+ * Callback used by video output devices to swap buffers of user provided window.
+ */
+typedef int (*av_format_device_window_swap_buffers_callback)(struct AVFormatContext *);
+
+
+/**
* The duration of a video can be estimated through various ways, and this enum can be used
* to know how the duration was estimated.
*/
@@ -1348,6 +1359,22 @@ typedef struct AVFormatContext {
* Demuxing: Set by user via av_format_set_subtitle_codec (NO direct access).
*/
AVCodec *subtitle_codec;
+
+ /**
+ * User data.
+ */
+ void *user_data;
+
+ /**
+ * Callback dedicated for video devices to get dimensions of user provided rendering window.
+ */
+ av_format_device_window_size_callback window_size_cb;
+
+ /**
+ * Callback dedicated for video devices to swap buffers of user provided window.
+ */
+ av_format_device_window_swap_buffers_callback window_swap_buffers_cb;
+
} AVFormatContext;
int av_format_get_probe_score(const AVFormatContext *s);
@@ -1357,6 +1384,12 @@ AVCodec * av_format_get_audio_codec(const AVFormatContext *s);
void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c);
AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s);
void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c);
+void * av_format_get_user_data(const AVFormatContext *s);
+void av_format_set_user_data(AVFormatContext *s, void *user_data);
+av_format_device_window_size_callback av_format_get_window_size_cb(const AVFormatContext *s);
+void av_format_set_window_size_cb(AVFormatContext *s, av_format_device_window_size_callback callback);
+av_format_device_window_swap_buffers_callback av_format_get_window_swap_buffers_cb(const AVFormatContext *s);
+void av_format_set_window_swap_buffers_cb(AVFormatContext *s, av_format_device_window_swap_buffers_callback callback);
/**
* Returns the method used to set ctx->duration.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index fc1ab6d..50aaa80 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -103,6 +103,9 @@ MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
+MAKE_ACCESSORS(AVFormatContext, format, void *, user_data)
+MAKE_ACCESSORS(AVFormatContext, format, av_format_device_window_size_callback, window_size_cb)
+MAKE_ACCESSORS(AVFormatContext, format, av_format_device_window_swap_buffers_callback, window_swap_buffers_cb)
static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
{
diff --git a/libavformat/version.h b/libavformat/version.h
index 3ccbf4c..f48e86e 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 23
-#define LIBAVFORMAT_VERSION_MICRO 103
+#define LIBAVFORMAT_VERSION_MICRO 104
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
--
1.8.3.2
More information about the ffmpeg-devel
mailing list