summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-29 20:57:31 +0100
committerwm4 <wm4@nowhere>2016-02-29 20:57:56 +0100
commitd7de123110411ae02df5bb61dd960441d9a8ab90 (patch)
treee3536233405b551acb24272ebd81be94092c0aec
parent0a1e926670a5563df788f9c732a93e3230d86182 (diff)
downloadmpv-d7de123110411ae02df5bb61dd960441d9a8ab90.tar.bz2
mpv-d7de123110411ae02df5bb61dd960441d9a8ab90.tar.xz
command: export list of all decoders
Was only available via --vd=help and --ad=help (i.e. not at all via client API). Not bothering with separating audio and video codecs, since this list isn't all that useful anyway in general. If someone complains, a type field could be added.
-rw-r--r--DOCS/man/input.rst32
-rw-r--r--player/command.c32
2 files changed, 64 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 9918f7384f..726354eafa 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1988,6 +1988,38 @@ Property list
In some cases, the protocol will not actually be supported (consider
``https`` if ffmpeg is not compiled with TLS support).
+``decoder-list``
+ List of decoders supported. This lists decoders which can be passed to
+ ``--vd`` and ``--ad``.
+
+ ``family``
+ Decoder driver. Usually ``lavc`` for libavcodec.
+
+ ``codec``
+ Canonical codec name, which identifies the format the decoder can
+ handle.
+
+ ``decoder``
+ The name of the decoder itself. Often, this is the same as ``codec``.
+ Sometimes it can be different. It is used to distinguish multiple
+ decoders for the same codec.
+
+ ``description``
+ Human readable description of the decoder and codec.
+
+ When querying the property with the client API using ``MPV_FORMAT_NODE``,
+ or with Lua ``mp.get_property_native``, this will return a mpv_node with
+ the following contents:
+
+ ::
+
+ MPV_FORMAT_NODE_ARRAY
+ MPV_FORMAT_NODE_MAP (for each decoder entry)
+ "family" MPV_FORMAT_STRING
+ "codec" MPV_FORMAT_STRING
+ "decoder" MPV_FORMAT_STRING
+ "description" MPV_FORMAT_STRING
+
``mpv-version``
Return the mpv version/copyright string. Depending on how the binary was
built, it might contain either a release version, or just a git hash.
diff --git a/player/command.c b/player/command.c
index 421f001573..f4a78e11fb 100644
--- a/player/command.c
+++ b/player/command.c
@@ -32,6 +32,7 @@
#include "config.h"
#include "mpv_talloc.h"
#include "client.h"
+#include "common/codecs.h"
#include "common/msg.h"
#include "common/msg_control.h"
#include "command.h"
@@ -3290,6 +3291,36 @@ static int mp_property_protocols(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int get_decoder_entry(int item, int action, void *arg, void *ctx)
+{
+ struct mp_decoder_list *codecs = ctx;
+ struct mp_decoder_entry *c = &codecs->entries[item];
+
+ struct m_sub_property props[] = {
+ {"family", SUB_PROP_STR(c->family)},
+ {"codec", SUB_PROP_STR(c->codec)},
+ {"decoder", SUB_PROP_STR(c->decoder)},
+ {"description", SUB_PROP_STR(c->desc)},
+ {0}
+ };
+
+ return m_property_read_sub(props, action, arg);
+}
+
+static int mp_property_decoders(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ struct mp_decoder_list *codecs = talloc_zero(NULL, struct mp_decoder_list);
+ struct mp_decoder_list *v = talloc_steal(codecs, video_decoder_list());
+ struct mp_decoder_list *a = talloc_steal(codecs, audio_decoder_list());
+ mp_append_decoders(codecs, v);
+ mp_append_decoders(codecs, a);
+ int r = m_property_read_list(action, arg, codecs->num_entries,
+ get_decoder_entry, codecs);
+ talloc_free(codecs);
+ return r;
+}
+
static int mp_property_version(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3707,6 +3738,7 @@ static const struct m_property mp_properties[] = {
{"working-directory", mp_property_cwd},
{"protocol-list", mp_property_protocols},
+ {"decoder-list", mp_property_decoders},
{"mpv-version", mp_property_version},
{"mpv-configuration", mp_property_configuration},