summaryrefslogtreecommitdiffstats
path: root/stream/stream.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2016-08-07 18:10:05 +0200
committerwm4 <wm4@nowhere>2016-08-07 19:33:20 +0200
commit7ca4a453e03d76621c7740b71ba17157c7756737 (patch)
treead29dc38fdd7719dfd536efca12e924afdc650b1 /stream/stream.c
parent52a0cbe4568afd11ad2e24596f81712ff508112d (diff)
downloadmpv-7ca4a453e03d76621c7740b71ba17157c7756737.tar.bz2
mpv-7ca4a453e03d76621c7740b71ba17157c7756737.tar.xz
client API: add stream_cb API for user-defined stream implementations
Based on #2630. Some heavy changes by committer. Signed-off-by: wm4 <wm4@nowhere>
Diffstat (limited to 'stream/stream.c')
-rw-r--r--stream/stream.c19
1 files changed, 19 insertions, 0 deletions
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;
+}