diff options
author | wm4 <wm4@nowhere> | 2013-09-10 16:38:34 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-09-10 16:38:34 +0200 |
commit | cf0e852fcdd4f6e223d76f21ce27f89681bd6e74 (patch) | |
tree | a004e0bf29f48d3486d368947e58dab450da28e7 /mpvcore/resolve_quvi.c | |
parent | c9a740fccd1128e43542beeec6f50bc59c2bddb9 (diff) | |
download | mpv-cf0e852fcdd4f6e223d76f21ce27f89681bd6e74.tar.bz2 mpv-cf0e852fcdd4f6e223d76f21ce27f89681bd6e74.tar.xz |
quvi: coerce libquvi 0.4 support into allowing format switching
libquvi 0.4 doesn't allow us listing the formats supported by a
streaming site without doing additional network accesses, so switching
formats was not supported with it. (It's different with libquvi 0.9.)
But the most important case is switching between SD and HD. Usually,
--quvi-format=default will get SD, while --quvi-format=best gives HD.
Use this, and pretend that an URL supported by libquvi 0.4 supports both
of these. "cycle quvi-format" will switch between these. If the user
specifies something else via --quvi-format, this is included in the list
of switchable formats additionally to "default" and "best".
Diffstat (limited to 'mpvcore/resolve_quvi.c')
-rw-r--r-- | mpvcore/resolve_quvi.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/mpvcore/resolve_quvi.c b/mpvcore/resolve_quvi.c index 9e98f2a992..00279c568f 100644 --- a/mpvcore/resolve_quvi.c +++ b/mpvcore/resolve_quvi.c @@ -23,6 +23,17 @@ #include "mpvcore/options.h" #include "resolve.h" +static void add_source(struct mp_resolve_result *res, const char *url, + const char *encid) +{ + struct mp_resolve_src *src = talloc_ptrtype(res, src); + *src = (struct mp_resolve_src) { + .url = talloc_strdup(src, url), + .encid = talloc_strdup(src, encid), + }; + MP_TARRAY_APPEND(res, res->srcs, res->num_srcs, src); +} + struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts) { QUVIcode rc; @@ -49,14 +60,15 @@ struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts) mp_msg(MSGT_OPEN, MSGL_INFO, "[quvi] Checking URL...\n"); + const char *req_format = opts->quvi_format ? opts->quvi_format : "best"; + // Can use quvi_query_formats() to get a list of formats like this: // "fmt05_240p|fmt18_360p|fmt34_360p|fmt35_480p|fmt43_360p|fmt44_480p" // (This example is youtube specific.) // That call requires an extra net access. quvi_next_media_url() doesn't // seem to do anything useful. So we can't really do anything useful // except pass through the user's format setting. - quvi_setopt(q, QUVIOPT_FORMAT, opts->quvi_format - ? opts->quvi_format : "best"); + quvi_setopt(q, QUVIOPT_FORMAT, req_format); quvi_media_t m; rc = quvi_parse(q, (char *)url, &m); @@ -89,5 +101,11 @@ struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts) result = NULL; } + // Useful for quvi-format cycling + add_source(result, NULL, "default"); + add_source(result, NULL, "best"); + if (strcmp(req_format, "best") != 0 && strcmp(req_format, "default") != 0) + add_source(result, NULL, req_format); + return result; } |