summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-10 01:28:20 +0100
committerwm4 <wm4@nowhere>2012-12-11 00:37:54 +0100
commit180944fe282fb57be4d8f986f7fcb0a209f943d5 (patch)
tree0a25fd0b88429c57f54019deb2d9801bf51c0224 /demux
parent222a5cf7c0a4de094f368f7154122a72312dbf39 (diff)
downloadmpv-180944fe282fb57be4d8f986f7fcb0a209f943d5.tar.bz2
mpv-180944fe282fb57be4d8f986f7fcb0a209f943d5.tar.xz
stream_lavf/demux_lavf: export/use HTTP MIME type
This is a fix for web radio streams that send raw AAC [1]. libavformat's AAC demuxer probe is picky enough to request hundreds of KBs data, which makes for a slow startup. To speed up stream startup, try use the HTTP MIME type to identify the format. The webstream in question sends an AAC specific MIME type, for which demux_lavf will force the AAC demuxer, without probing anything. ffmpeg/ffplay do the same thing. Note that as of ffmpeg commit 76d851b, av_probe_input_buffer() does the mapping from MIME type to demuxer. The actual mapping is not publicly accessible, and can only be used by calling that function. This will hopefully be rectified, and ideally ffmpeg would provide a function like find_demuxer_from_mime_type(). [1] http://lr2mp0.latvijasradio.lv:8000
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_lavf.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 7fa849f3a1..b3ae1d6315 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -83,8 +83,23 @@ typedef struct lavf_priv {
bool use_dts;
bool seek_by_bytes;
int bitrate;
+ char *mime_type;
} lavf_priv_t;
+static const char *map_demuxer_mime_type[][2] = {
+ {"audio/aacp", "aac"},
+ {0}
+};
+
+static const char *find_demuxer_from_mime_type(char *mime_type)
+{
+ for (int n = 0; map_demuxer_mime_type[n][0]; n++) {
+ if (strcasecmp(map_demuxer_mime_type[n][0], mime_type) == 0)
+ return map_demuxer_mime_type[n][1];
+ }
+ return NULL;
+}
+
static int mp_read(void *opaque, uint8_t *buf, int size)
{
struct demuxer *demuxer = opaque;
@@ -207,6 +222,8 @@ static int lavf_check_file(demuxer_t *demuxer)
format = demuxer->stream->lavf_type;
if (!format)
format = avdevice_format;
+ if (!format && demuxer->stream->mime_type)
+ format = (char *)find_demuxer_from_mime_type(demuxer->stream->mime_type);
if (format) {
if (strcmp(format, "help") == 0) {
list_formats();