aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-17 03:18:44 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-17 03:18:44 +0100
commit38a08e0aea0255e8a960bd5d6b21104c889f27f2 (patch)
treed03453f7a0ce15802b7a333a9956e2d28cabf1b5
parentb02b78341799f8c2b013b7168f8687d835e47a1c (diff)
parent81c3f81d6f11bf1dad9c6f3de5938e665447b991 (diff)
downloadffmpeg-38a08e0aea0255e8a960bd5d6b21104c889f27f2.tar.gz
Merge remote-tracking branch 'lukaszmluki/master'
* lukaszmluki/master: lavd: add list devices API lavd/opengl_enc_shaders: fix gray* shader Conflicts: doc/APIchanges Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--doc/APIchanges3
-rw-r--r--libavdevice/avdevice.c41
-rw-r--r--libavdevice/avdevice.h39
-rw-r--r--libavdevice/opengl_enc_shaders.h2
-rw-r--r--libavdevice/version.h4
-rw-r--r--libavformat/avformat.h12
6 files changed, 98 insertions, 3 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 836b670f2f..047b9bdc37 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2014-02-xx - xxxxxxx - lavd 55.10.100 - avdevice.h
+ Add avdevice_list_devices() and avdevice_free_list_devices()
+
2014-02-16 - db3c970 - lavf 55.33.100 - avio.h
Add avio_find_protocol_name() to find out the name of the protocol that would
be selected for a given URL.
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 51617fb921..9e2b7d52da 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -52,3 +52,44 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA
return AVERROR(ENOSYS);
return s->control_message_cb(s, type, data, data_size);
}
+
+int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
+{
+ av_assert0(s);
+ av_assert0(device_list);
+ av_assert0(s->oformat || s->iformat);
+ if ((s->oformat && !s->oformat->get_device_list) ||
+ (s->iformat && !s->iformat->get_device_list)) {
+ *device_list = NULL;
+ return AVERROR(ENOSYS);
+ }
+ *device_list = av_mallocz(sizeof(AVDeviceInfoList));
+ if (!(*device_list))
+ return AVERROR(ENOMEM);
+ if (s->oformat)
+ return s->oformat->get_device_list(s, *device_list);
+ return s->iformat->get_device_list(s, *device_list);
+}
+
+void avdevice_free_list_devices(AVDeviceInfoList **device_list)
+{
+ AVDeviceInfoList *list;
+ AVDeviceInfo *dev;
+ int i;
+
+ av_assert0(device_list);
+ list = *device_list;
+ if (!list)
+ return;
+
+ for (i = 0; i < list->nb_devices; i++) {
+ dev = list->devices[i];
+ if (dev) {
+ av_free(dev->device_name);
+ av_free(dev->device_description);
+ av_free(dev);
+ }
+ }
+ av_free(list->devices);
+ av_freep(device_list);
+}
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 3306020628..28344ca161 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -191,4 +191,43 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
enum AVDevToAppMessageType type,
void *data, size_t data_size);
+/**
+ * Structure describes basic parameters of the device.
+ */
+typedef struct AVDeviceInfo {
+ char *device_name; /**< device name, format depends on device */
+ char *device_description; /**< human friendly name */
+} AVDeviceInfo;
+
+/**
+ * List of devices.
+ */
+typedef struct AVDeviceInfoList {
+ AVDeviceInfo **devices; /**< list of autodetected devices */
+ int nb_devices; /**< number of autodetected devices */
+ int default_device; /**< index of default device or -1 if no default */
+} AVDeviceInfoList;
+
+/**
+ * List devices.
+ *
+ * Returns available device names and their parameters.
+ *
+ * @note: Some devices may accept system-dependent device names that cannot be
+ * autodetected. The list returned by this function cannot be assumed to
+ * be always completed.
+ *
+ * @param s device context.
+ * @param[out] device_list list of autodetected devices.
+ * @return count of autodetected devices, negative on error.
+ */
+int avdevice_list_devices(struct AVFormatContext *s, AVDeviceInfoList **device_list);
+
+/**
+ * Convinient function to free result of avdevice_list_devices().
+ *
+ * @param devices device list to be freed.
+ */
+void avdevice_free_list_devices(AVDeviceInfoList **device_list);
+
#endif /* AVDEVICE_AVDEVICE_H */
diff --git a/libavdevice/opengl_enc_shaders.h b/libavdevice/opengl_enc_shaders.h
index 6378dfb8cc..ed8b3d3041 100644
--- a/libavdevice/opengl_enc_shaders.h
+++ b/libavdevice/opengl_enc_shaders.h
@@ -181,7 +181,7 @@ static const char * const FF_OPENGL_FRAGMENT_SHADER_GRAY =
"varying vec2 texture_coordinate;"
"void main()"
"{"
- "float c = texture2D(u_texture0, texture_coordinate);"
+ "float c = texture2D(u_texture0, texture_coordinate).r;"
"gl_FragColor = vec4(c, c, c, 1.0);"
"}";
diff --git a/libavdevice/version.h b/libavdevice/version.h
index 55d7e93b3b..85b3b37662 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -28,8 +28,8 @@
#include "libavutil/version.h"
#define LIBAVDEVICE_VERSION_MAJOR 55
-#define LIBAVDEVICE_VERSION_MINOR 9
-#define LIBAVDEVICE_VERSION_MICRO 101
+#define LIBAVDEVICE_VERSION_MINOR 10
+#define LIBAVDEVICE_VERSION_MICRO 100
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
LIBAVDEVICE_VERSION_MINOR, \
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 2667b37b5c..c990ad60e9 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -261,6 +261,7 @@
struct AVFormatContext;
+struct AVDeviceInfoList;
/**
* @defgroup metadata_api Public Metadata API
@@ -523,6 +524,11 @@ typedef struct AVOutputFormat {
*/
int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
AVFrame **frame, unsigned flags);
+ /**
+ * Returns device list with it properties.
+ * @see avdevice_list_devices() for more details.
+ */
+ int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
} AVOutputFormat;
/**
* @}
@@ -651,6 +657,12 @@ typedef struct AVInputFormat {
* Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
*/
int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
+
+ /**
+ * Returns device list with it properties.
+ * @see avdevice_list_devices() for more details.
+ */
+ int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
} AVInputFormat;
/**
* @}