Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Lukasz Marek authored on 2014/12/22 04:12:47... | ... |
@@ -15,6 +15,10 @@ libavutil: 2014-08-09 |
15 | 15 |
|
16 | 16 |
API changes, most recent first: |
17 | 17 |
|
18 |
+2015-01-11 - xxxxxxx - lavd 56.4.100 - avdevice.h |
|
19 |
+ Add avdevice_list_input_sources(). |
|
20 |
+ Add avdevice_list_output_sinks(). |
|
21 |
+ |
|
18 | 22 |
201x-xx-xx - xxxxxxx - lavc 56.10.0 - vdpau.h |
19 | 23 |
Add av_vdpau_get_surface_parameters(). |
20 | 24 |
|
... | ... |
@@ -21,6 +21,7 @@ |
21 | 21 |
#include "libavutil/pixfmt.h" |
22 | 22 |
#include "libavcodec/avcodec.h" |
23 | 23 |
#include "avdevice.h" |
24 |
+#include "internal.h" |
|
24 | 25 |
#include "config.h" |
25 | 26 |
|
26 | 27 |
#include "libavutil/ffversion.h" |
... | ... |
@@ -208,6 +209,44 @@ int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) |
208 | 208 |
return ret; |
209 | 209 |
} |
210 | 210 |
|
211 |
+static int list_devices_for_context(AVFormatContext *s, AVDictionary *options, |
|
212 |
+ AVDeviceInfoList **device_list) |
|
213 |
+{ |
|
214 |
+ AVDictionary *tmp = NULL; |
|
215 |
+ int ret; |
|
216 |
+ |
|
217 |
+ av_dict_copy(&tmp, options, 0); |
|
218 |
+ if ((ret = av_opt_set_dict2(s, &tmp, AV_OPT_SEARCH_CHILDREN)) < 0) |
|
219 |
+ goto fail; |
|
220 |
+ ret = avdevice_list_devices(s, device_list); |
|
221 |
+ fail: |
|
222 |
+ av_dict_free(&tmp); |
|
223 |
+ avformat_free_context(s); |
|
224 |
+ return ret; |
|
225 |
+} |
|
226 |
+ |
|
227 |
+int avdevice_list_input_sources(AVInputFormat *device, const char *device_name, |
|
228 |
+ AVDictionary *device_options, AVDeviceInfoList **device_list) |
|
229 |
+{ |
|
230 |
+ AVFormatContext *s = NULL; |
|
231 |
+ int ret; |
|
232 |
+ |
|
233 |
+ if ((ret = ff_alloc_input_device_context(&s, device, device_name)) < 0) |
|
234 |
+ return ret; |
|
235 |
+ return list_devices_for_context(s, device_options, device_list); |
|
236 |
+} |
|
237 |
+ |
|
238 |
+int avdevice_list_output_sinks(AVOutputFormat *device, const char *device_name, |
|
239 |
+ AVDictionary *device_options, AVDeviceInfoList **device_list) |
|
240 |
+{ |
|
241 |
+ AVFormatContext *s = NULL; |
|
242 |
+ int ret; |
|
243 |
+ |
|
244 |
+ if ((ret = avformat_alloc_output_context2(&s, device, device_name, NULL)) < 0) |
|
245 |
+ return ret; |
|
246 |
+ return list_devices_for_context(s, device_options, device_list); |
|
247 |
+} |
|
248 |
+ |
|
211 | 249 |
void avdevice_free_list_devices(AVDeviceInfoList **device_list) |
212 | 250 |
{ |
213 | 251 |
AVDeviceInfoList *list; |
... | ... |
@@ -484,4 +484,26 @@ int avdevice_list_devices(struct AVFormatContext *s, AVDeviceInfoList **device_l |
484 | 484 |
*/ |
485 | 485 |
void avdevice_free_list_devices(AVDeviceInfoList **device_list); |
486 | 486 |
|
487 |
+/** |
|
488 |
+ * List devices. |
|
489 |
+ * |
|
490 |
+ * Returns available device names and their parameters. |
|
491 |
+ * These are convinient wrappers for avdevice_list_devices(). |
|
492 |
+ * Device context is allocated and deallocated internally. |
|
493 |
+ * |
|
494 |
+ * @param device device format. May be NULL if device name is set. |
|
495 |
+ * @param device_name device name. May be NULL if device format is set. |
|
496 |
+ * @param device_options An AVDictionary filled with device-private options. May be NULL. |
|
497 |
+ * The same options must be passed later to avformat_write_header() for output |
|
498 |
+ * devices or avformat_open_input() for input devices, or at any other place |
|
499 |
+ * that affects device-private options. |
|
500 |
+ * @param[out] device_list list of autodetected devices |
|
501 |
+ * @return count of autodetected devices, negative on error. |
|
502 |
+ * @note device argument takes precedence over device_name when both are set. |
|
503 |
+ */ |
|
504 |
+int avdevice_list_input_sources(struct AVInputFormat *device, const char *device_name, |
|
505 |
+ AVDictionary *device_options, AVDeviceInfoList **device_list); |
|
506 |
+int avdevice_list_output_sinks(struct AVOutputFormat *device, const char *device_name, |
|
507 |
+ AVDictionary *device_options, AVDeviceInfoList **device_list); |
|
508 |
+ |
|
487 | 509 |
#endif /* AVDEVICE_AVDEVICE_H */ |
488 | 510 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,27 @@ |
0 |
+/* |
|
1 |
+ * This file is part of FFmpeg. |
|
2 |
+ * |
|
3 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
5 |
+ * License as published by the Free Software Foundation; either |
|
6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 |
+ * Lesser General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
14 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#ifndef AVDEVICE_INTERNAL_H |
|
19 |
+#define AVDEVICE_INTERNAL_H |
|
20 |
+ |
|
21 |
+#include "libavformat/avformat.h" |
|
22 |
+ |
|
23 |
+int ff_alloc_input_device_context(struct AVFormatContext **avctx, struct AVInputFormat *iformat, |
|
24 |
+ const char *format); |
|
25 |
+ |
|
26 |
+#endif |
0 | 27 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,59 @@ |
0 |
+/* |
|
1 |
+ * This file is part of FFmpeg. |
|
2 |
+ * |
|
3 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
5 |
+ * License as published by the Free Software Foundation; either |
|
6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 |
+ * Lesser General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
14 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#include "internal.h" |
|
19 |
+#include "libavutil/opt.h" |
|
20 |
+#include "libavformat/avformat.h" |
|
21 |
+ |
|
22 |
+int ff_alloc_input_device_context(AVFormatContext **avctx, AVInputFormat *iformat, const char *format) |
|
23 |
+{ |
|
24 |
+ AVFormatContext *s; |
|
25 |
+ int ret = 0; |
|
26 |
+ |
|
27 |
+ *avctx = NULL; |
|
28 |
+ if (!iformat && !format) |
|
29 |
+ return AVERROR(EINVAL); |
|
30 |
+ if (!(s = avformat_alloc_context())) |
|
31 |
+ return AVERROR(ENOMEM); |
|
32 |
+ |
|
33 |
+ if (!iformat) |
|
34 |
+ iformat = av_find_input_format(format); |
|
35 |
+ if (!iformat || !iformat->priv_class || !AV_IS_INPUT_DEVICE(iformat->priv_class->category)) { |
|
36 |
+ ret = AVERROR(EINVAL); |
|
37 |
+ goto error; |
|
38 |
+ } |
|
39 |
+ s->iformat = iformat; |
|
40 |
+ if (s->iformat->priv_data_size > 0) { |
|
41 |
+ s->priv_data = av_mallocz(s->iformat->priv_data_size); |
|
42 |
+ if (!s->priv_data) { |
|
43 |
+ ret = AVERROR(ENOMEM); |
|
44 |
+ goto error; |
|
45 |
+ } |
|
46 |
+ if (s->iformat->priv_class) { |
|
47 |
+ *(const AVClass**)s->priv_data= s->iformat->priv_class; |
|
48 |
+ av_opt_set_defaults(s->priv_data); |
|
49 |
+ } |
|
50 |
+ } else |
|
51 |
+ s->priv_data = NULL; |
|
52 |
+ |
|
53 |
+ *avctx = s; |
|
54 |
+ return 0; |
|
55 |
+ error: |
|
56 |
+ avformat_free_context(s); |
|
57 |
+ return ret; |
|
58 |
+} |
... | ... |
@@ -28,7 +28,7 @@ |
28 | 28 |
#include "libavutil/version.h" |
29 | 29 |
|
30 | 30 |
#define LIBAVDEVICE_VERSION_MAJOR 56 |
31 |
-#define LIBAVDEVICE_VERSION_MINOR 3 |
|
31 |
+#define LIBAVDEVICE_VERSION_MINOR 4 |
|
32 | 32 |
#define LIBAVDEVICE_VERSION_MICRO 100 |
33 | 33 |
|
34 | 34 |
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ |