diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/input/input_http.c | 18 | ||||
-rw-r--r-- | src/xine-engine/load_plugins.c | 63 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 21 |
3 files changed, 78 insertions, 24 deletions
diff --git a/src/input/input_http.c b/src/input/input_http.c index 2ba92808f..7276ea44a 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -81,6 +81,8 @@ typedef struct { char preview[MAX_PREVIEW_SIZE]; off_t preview_size; + char *mime_type; + char *proto; char *user; char *password; @@ -590,17 +592,20 @@ static const char* http_plugin_get_mrl (input_plugin_t *this_gen) { } static int http_plugin_get_optional_data (input_plugin_t *this_gen, - void *data, int data_type) { + void *const data, int data_type) { + void **const ptr = (void **const) data; http_input_plugin_t *this = (http_input_plugin_t *) this_gen; switch (data_type) { case INPUT_OPTIONAL_DATA_PREVIEW: - memcpy (data, this->preview, this->preview_size); return this->preview_size; - break; + case INPUT_OPTIONAL_DATA_MIME_TYPE: + *ptr = this->mime_type; + case INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE: + return *this->mime_type ? INPUT_OPTIONAL_SUCCESS : INPUT_OPTIONAL_UNSUPPORTED; } return INPUT_OPTIONAL_UNSUPPORTED; @@ -655,7 +660,9 @@ static int http_plugin_open (input_plugin_t *this_gen ) { int mpegurl_redirect = 0; char auth[BUFSIZE]; char proxyauth[BUFSIZE]; - + char mime_type[256]; + + mime_type[0] = 0; use_proxy = this_class->proxyhost && strlen(this_class->proxyhost); if (use_proxy) { @@ -930,6 +937,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { const char *type = this->buf + sizeof (TAG_CONTENT_TYPE) - 1; while (isspace (*type)) ++type; + sprintf (mime_type, "%.255s", type); if (!strncasecmp (type, "video/nsv", 9)) { lprintf("shoutcast nsv detected\n"); this->is_nsv = 1; @@ -1005,6 +1013,8 @@ static int http_plugin_open (input_plugin_t *this_gen ) { lprintf("preview_size=%"PRId64"\n", this->preview_size); this->curpos = 0; + if (*mime_type) + this->mime_type = strdup (mime_type); return 1; } diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 254977ef7..2ff9f494f 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -1346,6 +1346,26 @@ void _x_free_input_plugin (xine_stream_t *stream, input_plugin_t *input) { } } +static int probe_mime_type (xine_t *self, plugin_node_t *node, const char *mime_type) +{ + /* catalog->lock is expected to be locked */ + if (node->plugin_class || _load_plugin_class(self, node, NULL)) + { + const unsigned int mime_type_len = strlen (mime_type); + demux_class_t *cls = (demux_class_t *)node->plugin_class; + const char *mime = cls->mimetypes; + while (mime) + { + while (*mime == ';' || isspace (*mime)) + ++mime; + if (!strncasecmp (mime, mime_type, mime_type_len) && + (!mime[mime_type_len] || mime[mime_type_len] == ':' || mime[mime_type_len] == ';')) + return 1; + mime = strchr (mime, ';'); + } + } + return 0; +} static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int method2, input_plugin_t *input) { @@ -1368,8 +1388,6 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth while (methods[i] != -1 && !plugin) { int list_id, list_size; - stream->content_detection_method = methods[i]; - pthread_mutex_lock (&catalog->lock); list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]); @@ -1381,6 +1399,25 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: probing demux '%s'\n", node->info->id); if (node->plugin_class || _load_plugin_class(stream->xine, node, NULL)) { + const char *mime_type; + + /* If detecting by MRL, try the MIME type first (but not text/plain)... */ + stream->content_detection_method = METHOD_EXPLICIT; + if (methods[i] == METHOD_BY_MRL && + stream->input_plugin->get_optional_data && + stream->input_plugin->get_optional_data (stream->input_plugin, NULL, INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED && + stream->input_plugin->get_optional_data (stream->input_plugin, &mime_type, INPUT_OPTIONAL_DATA_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED && + mime_type && strcasecmp (mime_type, "text/plain") && + probe_mime_type (stream->xine, node, mime_type) && + (plugin = ((demux_class_t *)node->plugin_class)->open_plugin (node->plugin_class, stream, input))) + { + inc_node_ref(node); + plugin->node = node; + break; + } + + /* ... then try the extension */ + stream->content_detection_method = methods[i]; if ( stream->content_detection_method == METHOD_BY_MRL && ! _x_demux_check_extension(input->get_mrl(input), ((demux_class_t *)node->plugin_class)->extensions) @@ -2664,7 +2701,6 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { plugin_node_t *node; char *id = NULL; int list_id, list_size; - const size_t mime_type_len = strlen (mime_type); pthread_mutex_lock (&catalog->lock); @@ -2673,23 +2709,10 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { for (list_id = 0; (list_id < list_size) && !id; list_id++) { node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id); - if (node->plugin_class || _load_plugin_class(self, node, NULL)) { - - demux_class_t *cls = (demux_class_t *)node->plugin_class; - const char *mime = cls->mimetypes; - while (mime) - { - while (*mime == ';' || isspace (*mime)) - ++mime; - if (!strncmp (mime, mime_type, mime_type_len) && - (!mime[mime_type_len] || mime[mime_type_len] == ':' || mime[mime_type_len] == ';')) - { - free (id); - id = strdup(node->info->id); - break; - } - mime = strchr (mime, ';'); - } + if (probe_mime_type (self, node, mime_type)) + { + free (id); + id = strdup(node->info->id); } } diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 39bef61d8..1e7c5c2c7 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -1228,6 +1228,27 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { /* enable buffered input plugin (request optimizer) */ stream->input_plugin = _x_cache_plugin_get_instance(stream); + /* Let the plugin request a specific demuxer (if the user hasn't). + * This overrides find-by-content & find-by-extension. + */ + if (!stream->demux_plugin) + { + char *default_demux = NULL; + stream->input_plugin->get_optional_data (stream->input_plugin, &default_demux, INPUT_OPTIONAL_DATA_DEMUXER); + if (default_demux) + { + stream->demux_plugin = _x_find_demux_plugin_by_name (stream, default_demux, stream->input_plugin); + if (stream->demux_plugin) + { + lprintf ("demux and input plugin found\n"); + _x_meta_info_set_utf8 (stream, XINE_META_INFO_SYSTEMLAYER, + stream->demux_plugin->demux_class->identifier); + } + else + xine_log (stream->xine, XINE_LOG_MSG, _("xine: couldn't load plugin-specified demux %s for >%s<\n"), default_demux, mrl); + } + } + if (!stream->demux_plugin) { /* |