1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 01:22:30 +00:00

command: add protocol-list property

Fixes #1972.
This commit is contained in:
wm4 2015-05-23 15:26:55 +02:00
parent a3f8d45fb6
commit 8054c034b8
5 changed files with 45 additions and 6 deletions

View File

@ -20,6 +20,7 @@ Interface changes
:: ::
--- mpv 0.10.0 will be released --- --- mpv 0.10.0 will be released ---
- add protocol-list property
- deprecate audio-samplerate and audio-channels properties - deprecate audio-samplerate and audio-channels properties
(audio-params sub-properties are the replacement) (audio-params sub-properties are the replacement)
- add audio-params and audio-out-params properties - add audio-params and audio-out-params properties

View File

@ -1778,6 +1778,12 @@ Property list
Return the working directory of the mpv process. Can be useful for JSON IPC Return the working directory of the mpv process. Can be useful for JSON IPC
users, because the command line player usually works with relative paths. users, because the command line player usually works with relative paths.
``protocol-list``
List of protocol prefixes potentially recognized by the player. They are
returned without trailing ``://`` suffix (which is still always required).
In some cases, the protocol will not actually be supported (consider
``https`` if ffmpeg is not compiled with TLS support).
``mpv-version`` ``mpv-version``
Return the mpv version/copyright string. Depending on how the binary was 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. built, it might contain either a release version, or just a git hash.

View File

@ -3063,6 +3063,20 @@ static int mp_property_cwd(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED; return M_PROPERTY_NOT_IMPLEMENTED;
} }
static int mp_property_protocols(void *ctx, struct m_property *prop,
int action, void *arg)
{
switch (action) {
case M_PROPERTY_GET:
*(char ***)arg = stream_get_proto_list();
return M_PROPERTY_OK;
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_version(void *ctx, struct m_property *prop, static int mp_property_version(void *ctx, struct m_property *prop,
int action, void *arg) int action, void *arg)
{ {
@ -3465,6 +3479,8 @@ static const struct m_property mp_properties[] = {
{"working-directory", mp_property_cwd}, {"working-directory", mp_property_cwd},
{"protocol-list", mp_property_protocols},
{"mpv-version", mp_property_version}, {"mpv-version", mp_property_version},
{"mpv-configuration", mp_property_configuration}, {"mpv-configuration", mp_property_configuration},

View File

@ -1024,11 +1024,10 @@ int mp_cancel_get_fd(struct mp_cancel *c)
return c->wakeup_pipe[0]; return c->wakeup_pipe[0];
} }
void stream_print_proto_list(struct mp_log *log) char **stream_get_proto_list(void)
{ {
int count = 0; char **list = NULL;
int num = 0;
mp_info(log, "Protocols:\n\n");
for (int i = 0; stream_list[i]; i++) { for (int i = 0; stream_list[i]; i++) {
const stream_info_t *stream_info = stream_list[i]; const stream_info_t *stream_info = stream_list[i];
@ -1039,9 +1038,25 @@ void stream_print_proto_list(struct mp_log *log)
if (*stream_info->protocols[j] == '\0') if (*stream_info->protocols[j] == '\0')
continue; continue;
mp_info(log, " %s://\n", stream_info->protocols[j]); MP_TARRAY_APPEND(NULL, list, num,
count++; talloc_strdup(NULL, stream_info->protocols[j]));
} }
} }
MP_TARRAY_APPEND(NULL, list, num, NULL);
return list;
}
void stream_print_proto_list(struct mp_log *log)
{
int count = 0;
mp_info(log, "Protocols:\n\n");
char **list = stream_get_proto_list();
for (int i = 0; list[i]; i++) {
mp_info(log, " %s://\n", list[i]);
count++;
talloc_free(list[i]);
}
talloc_free(list);
mp_info(log, "\nTotal: %d protocols\n", count); mp_info(log, "\nTotal: %d protocols\n", count);
} }

View File

@ -289,5 +289,6 @@ void mp_setup_av_network_options(struct AVDictionary **dict,
struct MPOpts *opts); struct MPOpts *opts);
void stream_print_proto_list(struct mp_log *log); void stream_print_proto_list(struct mp_log *log);
char **stream_get_proto_list(void);
#endif /* MPLAYER_STREAM_H */ #endif /* MPLAYER_STREAM_H */