1/*
2 * Copyright 2009-2010 Stephan A��mus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
5
6#include "DemuxerTable.h"
7
8extern "C" {
9	#include "avformat.h"
10}
11
12
13// NOTE: AVFormatReader uses this table only for better pretty names and
14// the MIME type info, the latter which is unavailable from AVInputFormat.
15
16
17static const DemuxerFormat gDemuxerTable[] = {
18	{
19		// Tested with a limited number of streams. Some videos show bad
20		// artifacts on keyframes with our own ASF Reader, while they play
21		// fine with this Reader. But seeking seems to be a problem.
22		"asf", "ASF Movie", "video/x-asf",
23		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
24	},
25	{
26		// Tested with many streams and works very well, with many older
27		// files, the native AVI reader does not work.
28		"avi", "AVI (Audio Video Interleaved)", "video/x-msvideo",
29		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
30	},
31	{
32		"dv", "DV Movie", "video/dv",
33		B_WAV_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
34	},
35	{
36		"flac", "Free Lossless Audio", "audio/x-flac",
37		B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
38	},
39	{
40		"flv", "Flash video", "video/x-flv",
41		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
42	},
43	{
44		"swf", "Shockwave video", "application/x-shockwave-flash",
45		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
46	},
47	{
48		// Tested and appears to work ok with regards to video,
49		// audio seems a problem.
50		"matroska", "Matroska movie", "video/x-matroska",
51		B_MISC_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
52	},
53	{
54		// Plays the limited amount of files I could test with.
55		"mov", "Quicktime Movie", "video/x-mov",
56		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
57	},
58	{
59		// Plays all files I could test with perfectly.
60		"mp4", "MPEG-4 movie", "video/x-mp4",
61		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
62	},
63	{
64 		// Works very well with all files I tested.
65		"mp3", "MPEG-3", "audio/mpg",
66		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
67	},
68	{
69		// NOTE: Tested with a couple of files and only audio works ok.
70		// On some files, the duration and time_base is detected incorrectly
71		// by libavformat and those streams don't play at all.
72		"mpg", "MPEG", "video/mpeg",
73		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
74	},
75	{
76		// NOTE: keep this before "mpeg" so it detects "mpegts" first.
77		"mpegts", "MPEG TS", "video/mpeg",
78		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
79	},
80	{
81		// TODO: Also covers "mpegvideo", plus see mpegts.
82		"mpeg", "MPEG", "video/mpeg",
83		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
84	},
85	{
86		// TODO: untested!
87		"nsv", "NSV (NullSoft video file)", "video/nsv",
88		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
89	},
90	{
91		// Works fine, expect for seeking in clips generated by
92		// native software when the video and audio stream are
93		// not interleaved.
94		"ogg", "Ogg", "video/ogg",
95		B_MISC_FORMAT_FAMILY, B_MISC_FORMAT_FAMILY
96	},
97	{
98		// TODO: untested!
99		"rm", "RM (RealVideo clip)", "video/vnd.rn-realvideo",
100		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
101	},
102	{
103		"vob", "VOB movie", "video/x-vob",
104		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
105	},
106	{
107		"ac3", "AC3", "audio/ac3",
108		B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
109	},
110};
111
112
113const DemuxerFormat*
114demuxer_format_for(AVInputFormat* format)
115{
116	int32 demuxerFormatCount = sizeof(gDemuxerTable) / sizeof(DemuxerFormat);
117	for (int32 i = 0; i < demuxerFormatCount; i++) {
118		const DemuxerFormat* demuxerFormat = &gDemuxerTable[i];
119		if (strstr(format->name, demuxerFormat->demuxer_name) != NULL)
120			return demuxerFormat;
121	}
122	return NULL;
123}
124
125