]> git.sesse.net Git - ffmpeg/blob - libavdevice/avdevice.h
Merge commit 'a46dc49744bdc4f2e31725b63ac8e41f701e4fa1'
[ffmpeg] / libavdevice / avdevice.h
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #ifndef AVDEVICE_AVDEVICE_H
20 #define AVDEVICE_AVDEVICE_H
21
22 #include "version.h"
23
24 /**
25  * @file
26  * @ingroup lavd
27  * Main libavdevice API header
28  */
29
30 /**
31  * @defgroup lavd Special devices muxing/demuxing library
32  * @{
33  * Libavdevice is a complementary library to @ref libavf "libavformat". It
34  * provides various "special" platform-specific muxers and demuxers, e.g. for
35  * grabbing devices, audio capture and playback etc. As a consequence, the
36  * (de)muxers in libavdevice are of the AVFMT_NOFILE type (they use their own
37  * I/O functions). The filename passed to avformat_open_input() often does not
38  * refer to an actually existing file, but has some special device-specific
39  * meaning - e.g. for x11grab it is the display name.
40  *
41  * To use libavdevice, simply call avdevice_register_all() to register all
42  * compiled muxers and demuxers. They all use standard libavformat API.
43  * @}
44  */
45
46 #include "libavformat/avformat.h"
47
48 /**
49  * Return the LIBAVDEVICE_VERSION_INT constant.
50  */
51 unsigned avdevice_version(void);
52
53 /**
54  * Return the libavdevice build-time configuration.
55  */
56 const char *avdevice_configuration(void);
57
58 /**
59  * Return the libavdevice license.
60  */
61 const char *avdevice_license(void);
62
63 /**
64  * Initialize libavdevice and register all the input and output devices.
65  * @warning This function is not thread safe.
66  */
67 void avdevice_register_all(void);
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  * Message types used by avdevice_dev_to_app_control_message().
109  */
110 enum AVDevToAppMessageType {
111     /**
112      * Dummy message.
113      */
114     AV_DEV_TO_APP_NONE = MKBETAG('N','O','N','E'),
115
116     /**
117      * Create window buffer message.
118      *
119      * Device requests to create a window buffer. Exact meaning is device-
120      * and application-dependent. Message is sent before rendering first
121      * frame and all one-shot initializations should be done here.
122      *
123      * data: NULL.
124      */
125     AV_DEV_TO_APP_CREATE_WINDOW_BUFFER = MKBETAG('B','C','R','E'),
126
127     /**
128      * Prepare window buffer message.
129      *
130      * Device requests to prepare a window buffer for rendering.
131      * Exact meaning is device- and application-dependent.
132      * Message is sent before rendering of each frame.
133      *
134      * data: NULL.
135      */
136     AV_DEV_TO_APP_PREPARE_WINDOW_BUFFER = MKBETAG('B','P','R','E'),
137
138     /**
139      * Display window buffer message.
140      *
141      * Device requests to display a window buffer.
142      * Message is sent when new frame is ready to be displyed.
143      * Usually buffers need to be swapped in handler of this message.
144      *
145      * data: NULL.
146      */
147     AV_DEV_TO_APP_DISPLAY_WINDOW_BUFFER = MKBETAG('B','D','I','S'),
148
149     /**
150      * Destroy window buffer message.
151      *
152      * Device requests to destroy a window buffer.
153      * Message is sent when device is about to be destroyed and window
154      * buffer is not required anymore.
155      *
156      * data: NULL.
157      */
158     AV_DEV_TO_APP_DESTROY_WINDOW_BUFFER = MKBETAG('B','D','E','S')
159 };
160
161 /**
162  * Send control message from application to device.
163  *
164  * @param s         device context.
165  * @param type      message type.
166  * @param data      message data. Exact type depends on message type.
167  * @param data_size size of message data.
168  * @return >= 0 on success, negative on error.
169  *         AVERROR(ENOSYS) when device doesn't implement handler of the message.
170  */
171 int avdevice_app_to_dev_control_message(struct AVFormatContext *s,
172                                         enum AVAppToDevMessageType type,
173                                         void *data, size_t data_size);
174
175 /**
176  * Send control message from device to application.
177  *
178  * @param s         device context.
179  * @param type      message type.
180  * @param data      message data. Can be NULL.
181  * @param data_size size of message data.
182  * @return >= 0 on success, negative on error.
183  *         AVERROR(ENOSYS) when application doesn't implement handler of the message.
184  */
185 int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
186                                         enum AVDevToAppMessageType type,
187                                         void *data, size_t data_size);
188
189 #endif /* AVDEVICE_AVDEVICE_H */