From dd7b5d84dddb0454525832384f6d81ebbe98edf8 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 14 Feb 2003 00:35:29 +0000 Subject: introduce a new mrl key, example "stream.ext#lastdemuxprobe:demux_id" - xine will try to open stream.ext using all demuxers _except_ demux_id. - then it will be finally probed by content for demux_id. why? this is the mechanism to catch buggy content probing demuxers. it's is not intended for end users, but rather to make possible some kind of script testing of xine-lib and QA before releases. CVS patchset: 4149 CVS date: 2003/02/14 00:35:29 --- src/xine-engine/load_plugins.c | 70 ++++++++++++++++++++++++++++++++++++++++- src/xine-engine/xine.c | 45 ++++++++++++++++++++++++-- src/xine-engine/xine_internal.h | 3 +- 3 files changed, 113 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index d89548894..f1e8af1ab 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: load_plugins.c,v 1.139 2003/01/29 02:33:36 miguelfreitas Exp $ + * $Id: load_plugins.c,v 1.140 2003/02/14 00:35:29 miguelfreitas Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -1098,6 +1098,74 @@ demux_plugin_t *find_demux_plugin_by_name(xine_stream_t *stream, const char *nam return NULL; } +/* + * this is a special test mode for content detection: all demuxers are probed + * by content and extension except last_demux_name which is tested after + * every other demuxer. + * + * this way we can make sure no demuxer will interfere on probing of a + * known stream. + */ + +demux_plugin_t *find_demux_plugin_last_probe(xine_stream_t *stream, const char *last_demux_name, input_plugin_t *input) { + + int i; + int methods[3]; + xine_t *xine = stream->xine; + plugin_catalog_t *catalog = xine->plugin_catalog; + plugin_node_t *last_demux = NULL; + demux_plugin_t *plugin; + + methods[0] = METHOD_BY_CONTENT; + methods[1] = METHOD_BY_EXTENSION; + methods[2] = -1; + + i = 0; + while (methods[i] != -1) { + + plugin_node_t *node; + + stream->content_detection_method = methods[i]; + + pthread_mutex_lock (&catalog->lock); + + node = xine_list_first_content (catalog->demux); + + while (node) { + +#ifdef LOG + printf ("load_plugins: probing demux '%s'\n", node->info->id); +#endif + if (strcasecmp(node->info->id, last_demux_name) == 0) { + last_demux = node; + } else { + printf("load_plugin: probing '%s' (method %d)...\n", node->info->id, stream->content_detection_method ); + if ((plugin = ((demux_class_t *)node->plugin_class)->open_plugin(node->plugin_class, stream, input))) { + printf ("load_plugins: using demuxer '%s' (instead of '%s')\n", node->info->id, last_demux_name); + pthread_mutex_unlock (&catalog->lock); + return plugin; + } + } + + node = xine_list_next_content (stream->xine->plugin_catalog->demux); + } + + pthread_mutex_unlock (&catalog->lock); + + i++; + } + + stream->content_detection_method = METHOD_BY_CONTENT; + + if ((plugin = ((demux_class_t *)last_demux->plugin_class)->open_plugin(last_demux->plugin_class, stream, input))) { + printf ("load_plugins: using demuxer '%s'\n", last_demux_name); + return plugin; + } + + return NULL; +} + + const char *const *xine_get_autoplay_input_plugin_ids(xine_t *this) { plugin_catalog_t *catalog; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 7028f8fa0..8ff6006f0 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.229 2003/02/13 16:24:28 mroi Exp $ + * $Id: xine.c,v 1.230 2003/02/14 00:35:30 miguelfreitas Exp $ * * top-level xine functions * @@ -58,9 +58,9 @@ #include "xineutils.h" #include "compat.h" - +/* #define LOG - +*/ void xine_handle_stream_end (xine_stream_t *stream, int non_user) { @@ -567,6 +567,45 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { } continue; } + if (strncasecmp(stream_setup, "lastdemuxprobe", 14) == 0) { + if (*(stream_setup += 14) == ':') { + /* all demuxers will be probed before the specified one */ + char *tmp = ++stream_setup; + char *demux_name; + stream_setup = strchr(stream_setup, ';'); + if (stream_setup) { + demux_name = (char *)malloc(stream_setup - tmp + 1); + memcpy(demux_name, tmp, stream_setup - tmp); + demux_name[stream_setup - tmp] = '\0'; + } else { + demux_name = (char *)malloc(strlen(tmp)); + memcpy(demux_name, tmp, strlen(tmp)); + demux_name[strlen(tmp)] = '\0'; + } + mrl_unescape(demux_name); + if (!(stream->demux_plugin = find_demux_plugin_last_probe(stream, demux_name, stream->input_plugin))) { + xine_log(stream->xine, XINE_LOG_MSG, + _("xine: last_probed demuxer %s failed to start\n"), demux_name); + stream->err = XINE_ERROR_NO_DEMUX_PLUGIN; + stream->status = XINE_STATUS_STOP; + free(demux_name); + return 0; + } +#ifdef LOG + printf ("xine: demux and input plugin found\n"); +#endif + + stream->meta_info[XINE_META_INFO_SYSTEMLAYER] + = strdup (stream->demux_plugin->demux_class->get_identifier(stream->demux_plugin->demux_class)); + free(demux_name); + } else { + printf("xine: error while parsing mrl\n"); + stream->err = XINE_ERROR_MALFORMED_MRL; + stream->status = XINE_STATUS_STOP; + return 0; + } + continue; + } if (strncasecmp(stream_setup, "novideo", 7) == 0) { stream_setup += 7; if (*stream_setup == ';' || *stream_setup == '\0') { diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 2ca6a26b9..b4c786c1c 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_internal.h,v 1.126 2003/01/13 16:26:48 mroi Exp $ + * $Id: xine_internal.h,v 1.127 2003/02/14 00:35:30 miguelfreitas Exp $ * */ @@ -264,6 +264,7 @@ void xine_handle_stream_end (xine_stream_t *stream, int non_user); input_plugin_t *find_input_plugin (xine_stream_t *stream, const char *mrl); demux_plugin_t *find_demux_plugin (xine_stream_t *stream, input_plugin_t *input); demux_plugin_t *find_demux_plugin_by_name (xine_stream_t *stream, const char *name, input_plugin_t *input); +demux_plugin_t *find_demux_plugin_last_probe(xine_stream_t *stream, const char *last_demux_name, input_plugin_t *input); /* create decoder fifos and threads */ -- cgit v1.2.3