Browse code

lavd: add avdevice_app_to_dev_control_message API

New API allows to send messages from application to devices.

Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>

Lukasz Marek authored on 2014/01/20 00:11:09
Showing 5 changed files
... ...
@@ -36,3 +36,11 @@ const char * avdevice_license(void)
36 36
 #define LICENSE_PREFIX "libavdevice license: "
37 37
     return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
38 38
 }
39
+
40
+int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type,
41
+                                        void *data, size_t data_size)
42
+{
43
+    if (!s->oformat || !s->oformat->control_message)
44
+        return AVERROR(ENOSYS);
45
+    return s->oformat->control_message(s, type, data, data_size);
46
+}
... ...
@@ -66,4 +66,56 @@ const char *avdevice_license(void);
66 66
  */
67 67
 void avdevice_register_all(void);
68 68
 
69
+typedef struct AVDeviceRect {
70
+    int x;      /**< x coordinate of top left corner */
71
+    int y;      /**< y coordinate of top left corner */
72
+    int width;  /**< width */
73
+    int height; /**< height */
74
+} AVDeviceRect;
75
+
76
+/**
77
+ * Message types used by avdevice_app_to_dev_control_message().
78
+ */
79
+enum AVAppToDevMessageType {
80
+    /**
81
+     * Dummy message.
82
+     */
83
+    AV_APP_TO_DEV_NONE = MKBETAG('N','O','N','E'),
84
+
85
+    /**
86
+     * Window size change message.
87
+     *
88
+     * Message is sent to the device every time the application changes the size
89
+     * of the window device renders to.
90
+     * Message should also be sent right after window is created.
91
+     *
92
+     * data: AVDeviceRect: new window size.
93
+     */
94
+    AV_APP_TO_DEV_WINDOW_SIZE = MKBETAG('G','E','O','M'),
95
+
96
+    /**
97
+     * Repaint request message.
98
+     *
99
+     * Message is sent to the device when window have to be rapainted.
100
+     *
101
+     * data: AVDeviceRect: area required to be repainted.
102
+     *       NULL: whole area is required to be repainted.
103
+     */
104
+    AV_APP_TO_DEV_WINDOW_REPAINT = MKBETAG('R','E','P','A')
105
+};
106
+
107
+/**
108
+ * Send control message from application to device.
109
+ *
110
+ * @param s         device context.
111
+ * @param type      message type.
112
+ * @param data      message data. Exact type depends on message type.
113
+ * @param data_size size of message data.
114
+ * @return >= 0 on success, negative on error.
115
+ *         AVERROR(ENOSYS) when device doesn't implement handler of the message.
116
+ */
117
+int avdevice_app_to_dev_control_message(struct AVFormatContext *s,
118
+                                        enum AVAppToDevMessageType type,
119
+                                        void *data, size_t data_size);
120
+
69 121
 #endif /* AVDEVICE_AVDEVICE_H */
... ...
@@ -28,8 +28,8 @@
28 28
 #include "libavutil/version.h"
29 29
 
30 30
 #define LIBAVDEVICE_VERSION_MAJOR  55
31
-#define LIBAVDEVICE_VERSION_MINOR   5
32
-#define LIBAVDEVICE_VERSION_MICRO 102
31
+#define LIBAVDEVICE_VERSION_MINOR   6
32
+#define LIBAVDEVICE_VERSION_MICRO 100
33 33
 
34 34
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
35 35
                                                LIBAVDEVICE_VERSION_MINOR, \
... ...
@@ -453,6 +453,11 @@ typedef struct AVOutputFormat {
453 453
 
454 454
     void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
455 455
                                  int64_t *dts, int64_t *wall);
456
+    /**
457
+     * Allows sending messages from application to device.
458
+     */
459
+    int (*control_message)(struct AVFormatContext *s, int type,
460
+                           void *data, size_t data_size);
456 461
 } AVOutputFormat;
457 462
 /**
458 463
  * @}
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR 55
33
-#define LIBAVFORMAT_VERSION_MINOR 26
33
+#define LIBAVFORMAT_VERSION_MINOR 27
34 34
 #define LIBAVFORMAT_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \