From 7ca4a453e03d76621c7740b71ba17157c7756737 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Sun, 7 Aug 2016 18:10:05 +0200 Subject: client API: add stream_cb API for user-defined stream implementations Based on #2630. Some heavy changes by committer. Signed-off-by: wm4 --- stream/stream.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'stream/stream.c') diff --git a/stream/stream.c b/stream/stream.c index 846765f326..4b55b1134a 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -75,6 +75,7 @@ extern const stream_info_t stream_info_bdnav; extern const stream_info_t stream_info_rar; extern const stream_info_t stream_info_edl; extern const stream_info_t stream_info_libarchive; +extern const stream_info_t stream_info_cb; static const stream_info_t *const stream_list[] = { #if HAVE_CDDA @@ -115,6 +116,7 @@ static const stream_info_t *const stream_list[] = { &stream_info_edl, &stream_info_rar, &stream_info_file, + &stream_info_cb, NULL }; @@ -243,6 +245,9 @@ static stream_t *new_stream(void) static const char *match_proto(const char *url, const char *proto) { + if (strcmp(proto, "*") == 0) + return url; + int l = strlen(proto); if (l > 0) { if (strncasecmp(url, proto, l) == 0 && strncmp("://", url + l, 3) == 0) @@ -1111,3 +1116,17 @@ void stream_print_proto_list(struct mp_log *log) talloc_free(list); mp_info(log, "\nTotal: %d protocols\n", count); } + +bool stream_has_proto(const char *proto) +{ + for (int i = 0; stream_list[i]; i++) { + const stream_info_t *stream_info = stream_list[i]; + + for (int j = 0; stream_info->protocols && stream_info->protocols[j]; j++) { + if (strcmp(stream_info->protocols[j], proto) == 0) + return true; + } + } + + return false; +} -- cgit v1.2.3