From ac79eb733741d8d22bbd550be39fe63c28a575f9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 27 Jun 2013 18:20:59 +0200 Subject: core: rename mplayer.h and quvi.c mplayer.h used to be used for much more stuff, but all what is left are quvi related definitions. Rename quvi.c as well to make its purpose clearer. --- Makefile | 2 +- core/command.c | 2 +- core/mplayer.c | 2 +- core/mplayer.h | 36 --------------------- core/quvi.c | 93 ----------------------------------------------------- core/resolve.h | 32 ++++++++++++++++++ core/resolve_quvi.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ sub/sub.c | 1 - 8 files changed, 128 insertions(+), 133 deletions(-) delete mode 100644 core/mplayer.h delete mode 100644 core/quvi.c create mode 100644 core/resolve.h create mode 100644 core/resolve_quvi.c diff --git a/Makefile b/Makefile index 14a1e54fee..151ddf9226 100644 --- a/Makefile +++ b/Makefile @@ -107,7 +107,7 @@ SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c \ SOURCES-$(JACK) += audio/out/ao_jack.c SOURCES-$(JOYSTICK) += core/input/joystick.c -SOURCES-$(LIBQUVI) += core/quvi.c +SOURCES-$(LIBQUVI) += core/resolve_quvi.c SOURCES-$(LIRC) += core/input/lirc.c SOURCES-$(OPENAL) += audio/out/ao_openal.c SOURCES-$(OSS) += audio/out/ao_oss.c diff --git a/core/command.c b/core/command.c index c39bb3c16d..11ee73ec57 100644 --- a/core/command.c +++ b/core/command.c @@ -31,7 +31,7 @@ #include "stream/stream.h" #include "demux/demux.h" #include "demux/stheader.h" -#include "mplayer.h" +#include "resolve.h" #include "playlist.h" #include "playlist_parser.h" #include "sub/sub.h" diff --git a/core/mplayer.c b/core/mplayer.c index 3cdd83021d..fa0723f022 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -68,7 +68,7 @@ #include "core/m_option.h" #include "core/m_config.h" -#include "core/mplayer.h" +#include "core/resolve.h" #include "core/m_property.h" #include "sub/find_subfiles.h" diff --git a/core/mplayer.h b/core/mplayer.h deleted file mode 100644 index 825458b6f5..0000000000 --- a/core/mplayer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_MPLAYER_H -#define MPLAYER_MPLAYER_H - -#include - -#include "core/mp_msg.h" - -struct MPContext; -struct MPOpts; - -struct mp_resolve_result { - char *url; - char *title; -}; - -struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts); - -#endif /* MPLAYER_MPLAYER_H */ diff --git a/core/quvi.c b/core/quvi.c deleted file mode 100644 index e300e2dd03..0000000000 --- a/core/quvi.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mpv; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include - -#include "talloc.h" -#include "core/mp_msg.h" -#include "core/options.h" -#include "mplayer.h" - -struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts) -{ - QUVIcode rc; - bool mp_url = false; - - quvi_t q; - rc = quvi_init(&q); - if (rc != QUVI_OK) - return NULL; - - if (!strncmp(url, "mp_", 3)) { - url += 3; - mp_url = true; - } - - // Don't try to use quvi on an URL that's not directly supported, since - // quvi will do a network access anyway in order to check for HTTP - // redirections etc. - // The documentation says this will fail on "shortened" URLs. - if (quvi_supported(q, (char *)url) != QUVI_OK) { - quvi_close(&q); - return NULL; - } - - mp_msg(MSGT_OPEN, MSGL_INFO, "[quvi] Checking URL...\n"); - - // 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_media_t m; - rc = quvi_parse(q, (char *)url, &m); - if (rc != QUVI_OK) { - mp_msg(MSGT_OPEN, MSGL_ERR, "[quvi] %s\n", quvi_strerror(q, rc)); - quvi_close(&q); - return NULL; - } - - struct mp_resolve_result *result - = talloc_zero(NULL, struct mp_resolve_result); - - char *val; - - if (quvi_getprop(m, QUVIPROP_MEDIAURL, &val) == QUVI_OK) { - if (mp_url) - result->url = talloc_asprintf(result, "mp_%s", val); - else - result->url = talloc_strdup(result, val); - } - - if (quvi_getprop(m, QUVIPROP_PAGETITLE, &val) == QUVI_OK) - result->title = talloc_strdup(result, val); - - quvi_parse_close(&m); - quvi_close(&q); - - if (!result->url) { - talloc_free(result); - result = NULL; - } - - return result; -} diff --git a/core/resolve.h b/core/resolve.h new file mode 100644 index 0000000000..d991bf1a39 --- /dev/null +++ b/core/resolve.h @@ -0,0 +1,32 @@ +/* + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MP_RESOLVE_H +#define MP_RESOLVE_H + +struct MPContext; +struct MPOpts; + +struct mp_resolve_result { + char *url; + char *title; +}; + +struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts); + +#endif diff --git a/core/resolve_quvi.c b/core/resolve_quvi.c new file mode 100644 index 0000000000..5870335811 --- /dev/null +++ b/core/resolve_quvi.c @@ -0,0 +1,93 @@ +/* + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mpv is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mpv; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "talloc.h" +#include "core/mp_msg.h" +#include "core/options.h" +#include "resolve.h" + +struct mp_resolve_result *mp_resolve_quvi(const char *url, struct MPOpts *opts) +{ + QUVIcode rc; + bool mp_url = false; + + quvi_t q; + rc = quvi_init(&q); + if (rc != QUVI_OK) + return NULL; + + if (!strncmp(url, "mp_", 3)) { + url += 3; + mp_url = true; + } + + // Don't try to use quvi on an URL that's not directly supported, since + // quvi will do a network access anyway in order to check for HTTP + // redirections etc. + // The documentation says this will fail on "shortened" URLs. + if (quvi_supported(q, (char *)url) != QUVI_OK) { + quvi_close(&q); + return NULL; + } + + mp_msg(MSGT_OPEN, MSGL_INFO, "[quvi] Checking URL...\n"); + + // 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_media_t m; + rc = quvi_parse(q, (char *)url, &m); + if (rc != QUVI_OK) { + mp_msg(MSGT_OPEN, MSGL_ERR, "[quvi] %s\n", quvi_strerror(q, rc)); + quvi_close(&q); + return NULL; + } + + struct mp_resolve_result *result + = talloc_zero(NULL, struct mp_resolve_result); + + char *val; + + if (quvi_getprop(m, QUVIPROP_MEDIAURL, &val) == QUVI_OK) { + if (mp_url) + result->url = talloc_asprintf(result, "mp_%s", val); + else + result->url = talloc_strdup(result, val); + } + + if (quvi_getprop(m, QUVIPROP_PAGETITLE, &val) == QUVI_OK) + result->title = talloc_strdup(result, val); + + quvi_parse_close(&m); + quvi_close(&q); + + if (!result->url) { + talloc_free(result); + result = NULL; + } + + return result; +} diff --git a/sub/sub.c b/sub/sub.c index 7eb32d5885..35d9f29326 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -31,7 +31,6 @@ #include "talloc.h" #include "core/options.h" -#include "core/mplayer.h" #include "core/mp_msg.h" #include "sub.h" #include "dec_sub.h" -- cgit v1.2.3