From e6d5b31ba14be2e11bb615dde6a30764f1b1a942 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Tue, 24 Jul 2012 10:34:10 +0300 Subject: [PATCH] Remove 'query formats' feature Querying the available formats for a media URL will no longer be supported by the library the way it was implemented in 0.4 . The new design of the media script support that allows returning all available media stream URLs for different available formats with just one call, obsoletes the "traditional query formats" implementation found in 0.4 . This patch removes the planned support for the quvi_query_formats_* function set. It also also obsoletes the support for the "query_formats" function in the media scripts. --- src/Makefile.am | 1 - src/_quvi_query_formats_s.h | 32 ------------ src/api/Makefile.am | 4 -- src/api/doxy/glossary_termino.dp | 2 - src/api/doxy/groups.dp | 1 - src/api/doxy/main.dp | 1 - src/api/doxy/parse_media.dp | 1 - src/api/doxy/query_formats.dp | 63 ----------------------- src/api/query_formats_free.c | 49 ------------------ src/api/query_formats_get.c | 46 ----------------- src/api/query_formats_new.c | 79 ---------------------------- src/lua/Makefile.am | 1 - src/lua/def.h | 1 - src/lua/exec.h | 1 - src/lua/exec_media_script_query_formats.c | 85 ------------------------------- src/misc/match_media_script.c | 11 ---- src/misc/match_media_script.h | 1 - src/misc/scan_scripts.c | 1 - src/quvi-1.0/quvi/qdef.h | 1 - src/quvi-1.0/quvi/qfunc.h | 7 --- src/quvi-1.0/quvi/qoption.h | 3 -- 21 files changed, 391 deletions(-) delete mode 100644 src/_quvi_query_formats_s.h delete mode 100644 src/api/doxy/query_formats.dp delete mode 100644 src/api/query_formats_free.c delete mode 100644 src/api/query_formats_get.c delete mode 100644 src/api/query_formats_new.c delete mode 100644 src/lua/exec_media_script_query_formats.c diff --git a/src/Makefile.am b/src/Makefile.am index 8ffc438..c82f993 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,6 @@ SUBDIRS=quvi-1.0 api misc lua curl net hdr=\ - _quvi_query_formats_s.h\ _quvi_net_resolve_s.h\ _quvi_playlist_s.h\ _quvi_net_opt_s.h\ diff --git a/src/_quvi_query_formats_s.h b/src/_quvi_query_formats_s.h deleted file mode 100644 index aa280f1..0000000 --- a/src/_quvi_query_formats_s.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libquvi - * Copyright (C) 2012 Toni Gundogdu - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef _quvi_query_formats_s_h -#define _quvi_query_formats_s_h - -struct _quvi_query_formats_s -{ - GString *formats; -}; - -typedef struct _quvi_query_formats_s *_quvi_query_formats_t; - -#endif /* _quvi_query_formats_s_h */ - -/* vim: set ts=2 sw=2 tw=72 expandtab: */ diff --git a/src/api/Makefile.am b/src/api/Makefile.am index 83c67be..ec97f0c 100644 --- a/src/api/Makefile.am +++ b/src/api/Makefile.am @@ -11,14 +11,10 @@ EXTRA_DIST=\ doxy/parse_media.dp\ doxy/parse_playlist.dp\ doxy/proxy_support.dp\ - doxy/query_formats.dp\ doxy/scan_media.dp\ doxy/scripts.dp src=\ - query_formats_free.c\ - query_formats_new.c\ - query_formats_get.c\ playlist_next_media_url.c\ playlist_free.c\ playlist_new.c\ diff --git a/src/api/doxy/glossary_termino.dp b/src/api/doxy/glossary_termino.dp index 24e51a5..d0032ef 100644 --- a/src/api/doxy/glossary_termino.dp +++ b/src/api/doxy/glossary_termino.dp @@ -12,8 +12,6 @@ on the website and the properties available to the @ref m_script. Format strings are generated by the to_fmt_s function found in the many of the @ref m_script files. -@sa @ref query_formats - @section ms_url Media stream URL An URL to the media stream. diff --git a/src/api/doxy/groups.dp b/src/api/doxy/groups.dp index 5d4a5c6..e29eedb 100644 --- a/src/api/doxy/groups.dp +++ b/src/api/doxy/groups.dp @@ -1,5 +1,4 @@ /** -@defgroup queryformats Query available media formats @defgroup convenience Convenience functions @defgroup playlistprop Playlist property @defgroup mediaprop Media property diff --git a/src/api/doxy/main.dp b/src/api/doxy/main.dp index 9b8bb0b..ac8a515 100644 --- a/src/api/doxy/main.dp +++ b/src/api/doxy/main.dp @@ -26,7 +26,6 @@ stream URLs. @section p_advanced Programming: Advanced topics @li @subpage scan_media @li @subpage chk_support -@li @subpage query_formats @li @subpage scripts @li @subpage proxy_support diff --git a/src/api/doxy/parse_media.dp b/src/api/doxy/parse_media.dp index a933ecb..1000ded 100644 --- a/src/api/doxy/parse_media.dp +++ b/src/api/doxy/parse_media.dp @@ -15,7 +15,6 @@ quvi_media_free(m); /* Release when done using it. */ m = NULL; @endcode -@sa @ref query_formats @sa QuviMediaProperty The available @ref m_script collection determines which diff --git a/src/api/doxy/query_formats.dp b/src/api/doxy/query_formats.dp deleted file mode 100644 index 69bfb9f..0000000 --- a/src/api/doxy/query_formats.dp +++ /dev/null @@ -1,63 +0,0 @@ -/** @page query_formats Querying available media formats - -@section default Default behaviour - -By default, the library will return a @ref ms_url to the "default" -media format -- whatever the media script determines it to be. - -@section multi Multiple formats - -Some of the websites provide >1 formats for the media. The number, -and the quality of these media formats may vary greatly, depending on -the website. Therefore, the application should first query the available -formats to a @ref m_url , and then have either the user of the application -or the application itself to choose which one to access. - -The example below shows how to query the formats. For added readability, -it uses the GLib string utility functions (the 'g_str' prefix). - -@code -quvi_query_formats_t qqf = quvi_query_formats_new(q, URL); -abort_if_error(); -{ - gchar *fmts; - gchar **r; - gint i; - - fmts = quvi_query_formats_get(qqf); - r = g_strsplit(fmts, ",", 0); - - for (i=0; r[i] != NULL; ++i) - { - quvi_media_t m; - gchar *url; - - /* Set the format string the application should access. */ - quvi_set(q, QUVI_OPTION_REQUEST_FORMAT, r[i]); - - /* Return the media properties for the media URL. */ - m = quvi_media_new(q, URL); - abort_if_error(); - - /* Access the media stream URL for this format. */ - quvi_media_get(m, QUVI_MEDIA_PROPERTY_STREAM_URL, &url); - stream_from(url); - - quvi_media_free(m); - m = NULL; - } - - g_strfreev(r); - r = NULL; -} -quvi_query_formats_free(qqf); /* Release when done using it. */ -qqf = NULL; -@endcode - -@note @ref quvi_query_formats_get returns always at least "default" - -@sa @ref m_format - -The available @ref m_script collection determines which -websites are supported by the library. -*/ diff --git a/src/api/query_formats_free.c b/src/api/query_formats_free.c deleted file mode 100644 index c85e999..0000000 --- a/src/api/query_formats_free.c +++ /dev/null @@ -1,49 +0,0 @@ -/* libquvi - * Copyright (C) 2012 Toni Gundogdu - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -/** @file query_formats_free.c */ - -#include "config.h" - -#include - -#include "quvi.h" -/* -- */ -#include "_quvi_s.h" -#include "_quvi_query_formats_s.h" - -/** @brief Free all of memory used by a query formats handle -@note If handle is NULL the function simply returns -@ingroup queryformats -*/ -void quvi_query_formats_free(quvi_query_formats_t handle) -{ - _quvi_query_formats_t qqf = (_quvi_query_formats_t) handle; - - if (handle == NULL) - return; - - g_string_free(qqf->formats, TRUE); - qqf->formats = NULL; - - g_free(qqf); - qqf = NULL; -} - -/* vim: set ts=2 sw=2 tw=72 expandtab: */ diff --git a/src/api/query_formats_get.c b/src/api/query_formats_get.c deleted file mode 100644 index 5c1026d..0000000 --- a/src/api/query_formats_get.c +++ /dev/null @@ -1,46 +0,0 @@ -/* libquvi - * Copyright (C) 2012 Toni Gundogdu - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -/** @file query_formats_get.c */ - -#include "config.h" - -#include - -#include "quvi.h" -/* -- */ -#include "_quvi_s.h" -#include "_quvi_query_formats_s.h" - -/** @return Comma-separated string containing the format strings -@note Do not attempt to free the returned string -@sa @ref query_formats -@ingroup queryformats -*/ -const char *quvi_query_formats_get(quvi_query_formats_t handle) -{ - _quvi_query_formats_t qf = (_quvi_query_formats_t) handle; - - /* If G_DISABLE_CHECKS is defined then the check is not performed. */ - g_return_val_if_fail(handle != NULL, NULL); - - return (qf->formats->str); -} - -/* vim: set ts=2 sw=2 tw=72 expandtab: */ diff --git a/src/api/query_formats_new.c b/src/api/query_formats_new.c deleted file mode 100644 index f660f78..0000000 --- a/src/api/query_formats_new.c +++ /dev/null @@ -1,79 +0,0 @@ -/* libquvi - * Copyright (C) 2012 Toni Gundogdu - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -/** @file query_formats_new.c */ - -#include "config.h" - -#include - -#include "quvi.h" -/* -- */ -#include "_quvi_s.h" -#include "_quvi_media_s.h" -#include "_quvi_query_formats_s.h" -/* -- */ -#include "misc/match_media_script.h" - -static gpointer _query_formats_new(gchar *fmts) -{ - _quvi_query_formats_t qqf = g_new0(struct _quvi_query_formats_s, 1); - qqf->formats = g_string_new(fmts); - return (qqf); -} - -/** @brief Query available media formats to an URL -@return New handle, @ref quvi_query_formats_free it when done using it -@note Use @ref quvi_ok for checking if an error occurred -@sa @ref query_formats -@ingroup queryformats -*/ -quvi_query_formats_t quvi_query_formats_new(quvi_t handle, const char *url) -{ - _quvi_query_formats_t qqf; - _quvi_media_t m; - gchar *fmts; - _quvi_t q; - - /* If G_DISABLE_CHECKS is defined then the check is not performed. */ - g_return_val_if_fail(handle != NULL, NULL); - g_return_val_if_fail(url != NULL, NULL); - - q = (_quvi_t) handle; - fmts = NULL; - m = NULL; - - q->status.rc = m_match_media_script(q, &m, url, - QM_MATCH_MS_QUERY_FORMATS, - &fmts /* Must be g_free'd */); - quvi_media_free((quvi_media_t) m); - m = NULL; - - qqf = NULL; - - if (quvi_ok(q) == QUVI_TRUE) - qqf = _query_formats_new(fmts); - - g_free(fmts); - fmts = NULL; - - return (qqf); -} - -/* vim: set ts=2 sw=2 tw=72 expandtab: */ diff --git a/src/lua/Makefile.am b/src/lua/Makefile.am index 96715a8..37c96a5 100644 --- a/src/lua/Makefile.am +++ b/src/lua/Makefile.am @@ -4,7 +4,6 @@ src=\ util/exec_util_convert_entities.c\ util/exec_util_to_file_ext.c\ chk_accepts.c\ - exec_media_script_query_formats.c\ exec_playlist_script_ident.c\ exec_playlist_script_parse.c\ exec_media_script_ident.c\ diff --git a/src/lua/def.h b/src/lua/def.h index 48a9116..c8a5134 100644 --- a/src/lua/def.h +++ b/src/lua/def.h @@ -28,7 +28,6 @@ /* Media script */ -#define MS_AVAIL_FORMATS "avail_formats" /* Available formats to URL */ #define MS_START_TIME_MS "start_time_ms" /* Start streaming at */ #define MS_DURATION_MS "duration_ms" /* Media duration in ms */ #define MS_CATEGORIES "categories" /* Protocol categories */ diff --git a/src/lua/exec.h b/src/lua/exec.h index ca6d7fb..4261b7a 100644 --- a/src/lua/exec.h +++ b/src/lua/exec.h @@ -20,7 +20,6 @@ #ifndef l_exec_h #define l_exec_h -QuviError l_exec_media_script_query_formats(gpointer, GSList*, gchar**); QuviError l_exec_media_script_ident(gpointer, GSList*); QuviError l_exec_media_script_parse(gpointer, GSList*); diff --git a/src/lua/exec_media_script_query_formats.c b/src/lua/exec_media_script_query_formats.c deleted file mode 100644 index a159c6c..0000000 --- a/src/lua/exec_media_script_query_formats.c +++ /dev/null @@ -1,85 +0,0 @@ -/* libquvi - * Copyright (C) 2012 Toni Gundogdu - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "config.h" - -#include -#include - -#include "quvi.h" -/* -- */ -#include "_quvi_s.h" -#include "_quvi_media_s.h" -#include "_quvi_script_s.h" -/* -- */ -#include "lua/def.h" -#include "lua/getfield.h" -#include "lua/setfield.h" - -static const gchar script_func[] = "query_formats"; - -QuviError -l_exec_media_script_query_formats(gpointer p, GSList *sl, gchar **fmts) -{ - _quvi_script_t qs; - _quvi_media_t m; - lua_State *l; - - m = (_quvi_media_t) p; - l = m->handle.quvi->handle.lua; - - qs = (_quvi_script_t) sl->data; - lua_getglobal(l, script_func); - - if (!lua_isfunction(l, -1)) - luaL_error(l, "%s: `%s' function not found", qs->fpath->str, script_func); - - lua_newtable(l); - l_set_reg_userdata(l, USERDATA_QUVI_T, (gpointer) m->handle.quvi); - l_setfield_b(l, GS_VERBOSE, m->handle.quvi->opt.scripts.verbose); - l_setfield_s(l, MS_INPUT_URL, m->url.input->str); - l_setfield_s(l, MS_GOTO_URL, MS_EMPTY); - - if (lua_pcall(l, 1, 1, 0)) - { - g_string_assign(m->handle.quvi->status.errmsg, lua_tostring(l, -1)); - return (QUVI_ERROR_SCRIPT); - } - - if (!lua_istable(l, -1)) - { - luaL_error(l, "%s: expected `%s' function return a table", - qs->fpath->str, script_func); - } - - g_string_assign(m->url.redirect_to, - l_getfield_s(l, MS_GOTO_URL, - qs->fpath->str, script_func)); - - if (m->url.redirect_to->len ==0) /* No new location ("goto_url"). */ - { - *fmts = g_strdup(l_getfield_s(l, MS_AVAIL_FORMATS, - qs->fpath->str, script_func)); - } - lua_pop(l, 1); - - return (QUVI_OK); -} - -/* vim: set ts=2 sw=2 tw=72 expandtab: */ diff --git a/src/misc/match_media_script.c b/src/misc/match_media_script.c index 65376c3..264c311 100644 --- a/src/misc/match_media_script.c +++ b/src/misc/match_media_script.c @@ -94,17 +94,6 @@ QuviError m_match_media_script(_quvi_t q, _quvi_media_t *m, } break; - case QM_MATCH_MS_QUERY_FORMATS: - g_return_val_if_fail(result != NULL, QUVI_ERROR_INVALID_ARG); - rc = l_exec_media_script_query_formats(*m, s, result); - if (rc == QUVI_OK) - { - /* Check if goto_url was set. */ - if (_chk_goto_url(*m) == TRUE) - return (m_match_media_script(q, m, url, mode, result)); - } - break; - case QM_MATCH_MS_SUPPORTED_OFFLINE: case QM_MATCH_MS_SUPPORTED_ONLINE: break; diff --git a/src/misc/match_media_script.h b/src/misc/match_media_script.h index 7abc535..0d900b5 100644 --- a/src/misc/match_media_script.h +++ b/src/misc/match_media_script.h @@ -24,7 +24,6 @@ typedef enum { QM_MATCH_MS_SUPPORTED_OFFLINE, QM_MATCH_MS_SUPPORTED_ONLINE, - QM_MATCH_MS_QUERY_FORMATS, QM_MATCH_MS_PARSE } QuviMatchMediaScriptMode; diff --git a/src/misc/scan_scripts.c b/src/misc/scan_scripts.c index d1ee989..cb0d566 100644 --- a/src/misc/scan_scripts.c +++ b/src/misc/scan_scripts.c @@ -162,7 +162,6 @@ static gpointer _new_media_script(_quvi_t q, const gchar *path, gboolean OK = (_chk(c->str, "^\\-\\-\\s+libquvi\\-scripts") == TRUE && _chk(c->str, "^function ident") == TRUE - && _chk(c->str, "^function query_formats") == TRUE && _chk(c->str, "^function parse") == TRUE); if (OK == TRUE) diff --git a/src/quvi-1.0/quvi/qdef.h b/src/quvi-1.0/quvi/qdef.h index 14913e9..1e819c0 100644 --- a/src/quvi-1.0/quvi/qdef.h +++ b/src/quvi-1.0/quvi/qdef.h @@ -24,7 +24,6 @@ typedef int (*quvi_callback_status)(long,void*); /**< Status callback type */ -typedef void *quvi_query_formats_t; /**< Query formats type */ typedef void *quvi_playlist_t; /**< Playlist script type */ typedef void *quvi_resolve_t; /**< Resolve type */ typedef void *quvi_media_t; /**< Media type */ diff --git a/src/quvi-1.0/quvi/qfunc.h b/src/quvi-1.0/quvi/qfunc.h index b2daa31..03aa135 100644 --- a/src/quvi-1.0/quvi/qfunc.h +++ b/src/quvi-1.0/quvi/qfunc.h @@ -52,13 +52,6 @@ extern "C" { const char *quvi_errmsg(quvi_t); QuviBoolean quvi_ok(quvi_t); - /* Query formats */ - - quvi_query_formats_t quvi_query_formats_new(quvi_t, const char*); - void quvi_query_formats_free(quvi_query_formats_t); - - const char *quvi_query_formats_get(quvi_query_formats_t); - /* Playlist */ quvi_playlist_t quvi_playlist_new(quvi_t, const char*); diff --git a/src/quvi-1.0/quvi/qoption.h b/src/quvi-1.0/quvi/qoption.h index a9f656c..a027f85 100644 --- a/src/quvi-1.0/quvi/qoption.h +++ b/src/quvi-1.0/quvi/qoption.h @@ -55,7 +55,6 @@ typedef enum * Default: "default", can be "best" which causes the media script to * try to pick the best available format for the media. * @note - * - This option should be set only after @ref query_formats * - Available formats may vary greatly depending on the website * - The value may be a comma-separated list of format strings * @section comma_sep_list Comma-separated list of format strings @@ -68,8 +67,6 @@ typedef enum * script deems this to be), unless 'foo' is matched * @li "foo,bar" - Choose whatever script deems to be the default, * unless either 'foo' or 'bar' is matched first - * - * @sa @ref query_formats */ QUVI_OPTION_REQUEST_FORMAT, /** Autodetect and set the proxy for new connections. -- 2.11.4.GIT