From 8054c034b883b23e68fd8c9ca64749e9776f9fcf Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 23 May 2015 15:26:55 +0200 Subject: command: add protocol-list property Fixes #1972. --- stream/stream.c | 27 +++++++++++++++++++++------ stream/stream.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index cfdf67be14..d6521586b5 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -1024,11 +1024,10 @@ int mp_cancel_get_fd(struct mp_cancel *c) return c->wakeup_pipe[0]; } -void stream_print_proto_list(struct mp_log *log) +char **stream_get_proto_list(void) { - int count = 0; - - mp_info(log, "Protocols:\n\n"); + char **list = NULL; + int num = 0; for (int i = 0; stream_list[i]; 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') continue; - mp_info(log, " %s://\n", stream_info->protocols[j]); - count++; + MP_TARRAY_APPEND(NULL, list, num, + 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); } diff --git a/stream/stream.h b/stream/stream.h index 7b4751450c..cda5c7434e 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -289,5 +289,6 @@ void mp_setup_av_network_options(struct AVDictionary **dict, struct MPOpts *opts); void stream_print_proto_list(struct mp_log *log); +char **stream_get_proto_list(void); #endif /* MPLAYER_STREAM_H */ -- cgit v1.2.3