Commit 35c57312 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

demux: force demux based on (some) Content-Type values

The initial set of recognized content types is based on existing
forced psz_demux values. It is likely better not to add entries unless
detection of the file format is known to be difficult/impossible.
parent d314a0b6
......@@ -32,10 +32,46 @@
#include <vlc_meta.h>
#include <vlc_url.h>
#include <vlc_modules.h>
#include <vlc_strings.h>
static bool SkipID3Tag( demux_t * );
static bool SkipAPETag( demux_t *p_demux );
struct demux_type
{
char type[20];
char demux[8];
};
static int typecmp( const void *k, const void *t )
{
const char *key = k;
const struct demux_type *type = t;
return vlc_ascii_strcasecmp( key, type->type );
}
static const char *demux_FromContentType(const char *mime)
{
static const struct demux_type types[] =
{ /* Must be sorted in ascending ASCII order */
{ "audio/aac", "m4a" },
{ "audio/aacp", "m4a" },
{ "audio/mpeg", "mp3" },
{ "application/rss+xml", "podcast" },
{ "video/MP2T", "ts" },
{ "video/dv", "rawdv" },
{ "video/mpeg", "ps" },
{ "video/nsa", "nsv" },
{ "video/nsv", "nsv" },
};
const struct demux_type *type;
type = bsearch( mime, types, sizeof (types) / sizeof (types[0]),
sizeof (types[0]), typecmp );
return (type != NULL) ? type->demux : "any";
}
#undef demux_New
/*****************************************************************************
* demux_New:
......@@ -50,6 +86,16 @@ demux_t *demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
if( unlikely(p_demux == NULL) )
return NULL;
if( s != NULL && (!strcasecmp( psz_demux, "any" ) || !psz_demux[0]) )
{ /* Look up demux by Content-Type for hard to detect formats */
char *type = stream_ContentType( s );
if( type != NULL )
{
psz_demux = demux_FromContentType( type );
free( type );
}
}
p_demux->p_input = p_parent_input;
p_demux->psz_access = strdup( psz_access );
p_demux->psz_demux = strdup( psz_demux );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment