summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki@gmail.com>2014-01-19 16:12:07 +0100
committerLukasz Marek <lukasz.m.luki@gmail.com>2014-01-27 15:18:17 +0100
commit102bd641687a6ec4704ce2b3f259e895b68d8e4b (patch)
treed6ba6f1c686036af9c9077543624b5adebd72a18
parent7151411b9cf74ce43ab56f0ff8577b8031b997d9 (diff)
lavd: add avdevice_dev_to_app_control_message API
New API allows to send messages from devices to application. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
-rw-r--r--libavdevice/avdevice.c8
-rw-r--r--libavdevice/avdevice.h68
-rw-r--r--libavdevice/version.h2
-rw-r--r--libavformat/avformat.h24
-rw-r--r--libavformat/utils.c2
-rw-r--r--libavformat/version.h2
6 files changed, 104 insertions, 2 deletions
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index c232bbdc8f..51617fb921 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -44,3 +44,11 @@ int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToD
return AVERROR(ENOSYS);
return s->oformat->control_message(s, type, data, data_size);
}
+
+int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToAppMessageType type,
+ void *data, size_t data_size)
+{
+ if (!s->control_message_cb)
+ return AVERROR(ENOSYS);
+ return s->control_message_cb(s, type, data, data_size);
+}
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 1bc91e4d0f..a6408ea4db 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -105,6 +105,60 @@ enum AVAppToDevMessageType {
};
/**
+ * Message types used by avdevice_dev_to_app_control_message().
+ */
+enum AVDevToAppMessageType {
+ /**
+ * Dummy message.
+ */
+ AV_DEV_TO_APP_NONE = MKBETAG('N','O','N','E'),
+
+ /**
+ * Create window buffer message.
+ *
+ * Device requests to create a window buffer. Exact meaning is device-
+ * and application-dependent. Message is sent before rendering first
+ * frame and all one-shot initializations should be done here.
+ *
+ * data: NULL.
+ */
+ AV_DEV_TO_APP_CREATE_WINDOW_BUFFER = MKBETAG('B','C','R','E'),
+
+ /**
+ * Prepare window buffer message.
+ *
+ * Device requests to prepare a window buffer for rendering.
+ * Exact meaning is device- and application-dependent.
+ * Message is sent before rendering of each frame.
+ *
+ * data: NULL.
+ */
+ AV_DEV_TO_APP_PREPARE_WINDOW_BUFFER = MKBETAG('B','P','R','E'),
+
+ /**
+ * Display window buffer message.
+ *
+ * Device requests to display a window buffer.
+ * Message is sent when new frame is ready to be displyed.
+ * Usually buffers need to be swapped in handler of this message.
+ *
+ * data: NULL.
+ */
+ AV_DEV_TO_APP_DISPLAY_WINDOW_BUFFER = MKBETAG('B','D','I','S'),
+
+ /**
+ * Destroy window buffer message.
+ *
+ * Device requests to destroy a window buffer.
+ * Message is sent when device is about to be destroyed and window
+ * buffer is not required anymore.
+ *
+ * data: NULL.
+ */
+ AV_DEV_TO_APP_DESTROY_WINDOW_BUFFER = MKBETAG('B','D','E','S')
+};
+
+/**
* Send control message from application to device.
*
* @param s device context.
@@ -118,4 +172,18 @@ int avdevice_app_to_dev_control_message(struct AVFormatContext *s,
enum AVAppToDevMessageType type,
void *data, size_t data_size);
+/**
+ * Send control message from device to application.
+ *
+ * @param s device context.
+ * @param type message type.
+ * @param data message data. Can be NULL.
+ * @param data_size size of message data.
+ * @return >= 0 on success, negative on error.
+ * AVERROR(ENOSYS) when application doesn't implement handler of the message.
+ */
+int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
+ enum AVDevToAppMessageType type,
+ void *data, size_t data_size);
+
#endif /* AVDEVICE_AVDEVICE_H */
diff --git a/libavdevice/version.h b/libavdevice/version.h
index bfd4a7089d..a62177518f 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -28,7 +28,7 @@
#include "libavutil/version.h"
#define LIBAVDEVICE_VERSION_MAJOR 55
-#define LIBAVDEVICE_VERSION_MINOR 6
+#define LIBAVDEVICE_VERSION_MINOR 7
#define LIBAVDEVICE_VERSION_MICRO 100
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 09eea74ad9..002b015255 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -953,6 +953,13 @@ typedef struct AVChapter {
/**
+ * Callback used by devices to communicate with application.
+ */
+typedef int (*av_format_control_message)(struct AVFormatContext *s, int type,
+ void *data, size_t data_size);
+
+
+/**
* The duration of a video can be estimated through various ways, and this enum can be used
* to know how the duration was estimated.
*/
@@ -1360,6 +1367,19 @@ typedef struct AVFormatContext {
* Muxing: Set by user via av_format_set_metadata_header_padding.
*/
int metadata_header_padding;
+
+ /**
+ * User data.
+ * This is a place for some private data of the user.
+ * Mostly usable with control_message_cb or any future callbacks in device's context.
+ */
+ void *opaque;
+
+ /**
+ * Callback used by devices to communicate with application.
+ */
+ av_format_control_message control_message_cb;
+
} AVFormatContext;
int av_format_get_probe_score(const AVFormatContext *s);
@@ -1371,6 +1391,10 @@ AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s);
void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c);
int av_format_get_metadata_header_padding(const AVFormatContext *s);
void av_format_set_metadata_header_padding(AVFormatContext *s, int c);
+void * av_format_get_opaque(const AVFormatContext *s);
+void av_format_set_opaque(AVFormatContext *s, void *opaque);
+av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s);
+void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback);
/**
* Returns the method used to set ctx->duration.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d425b5bc61..ac9236b18f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -107,6 +107,8 @@ 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, int, metadata_header_padding)
+MAKE_ACCESSORS(AVFormatContext, format, void *, opaque)
+MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb)
static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
{
diff --git a/libavformat/version.h b/libavformat/version.h
index 51f6d598d9..92f81a93b1 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 27
+#define LIBAVFORMAT_VERSION_MINOR 28
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \