xref: /haiku/src/add-ons/media/plugins/ffmpeg/DemuxerTable.cpp (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
1 /*
2  * Copyright 2009 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 
8 extern "C" {
9 	#include "avformat.h"
10 }
11 
12 
13 // NOTE: AVFormatReader will refuse any streams which do not match to any
14 // of these formats from the table. It could very well be that it could play
15 // these streams, but testing has to be done first.
16 
17 
18 static const DemuxerFormat gDemuxerTable[] = {
19 //	{
20 //		// Tested with a limited number of streams. Some videos show bad
21 //		// artifacts on keyframes with our own ASF Reader, while they play
22 //		// fine with this Reader. But seeking seems to be a problem.
23 //		"asf", "ASF Movie", "video/x-asf",
24 //		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
25 //	},
26 //	{
27 //		// Tested with a limited amount of streams and works ok, keep using
28 //		// the avi_reader implementation by Marcus Overhagen.
29 //		"avi", "AVI (Audio Video Interleaved)", "video/x-msvideo",
30 //		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
31 //	},
32 	{
33 		"dv", "DV Movie", "video/dv",
34 		B_WAV_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
35 	},
36 	{
37 		"flac", "FLAC", "audio/x-flac",
38 		B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
39 	},
40 	{
41 		"flv", "Flash Video", "video/x-flv",
42 		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
43 	},
44 //	{
45 //		TODO: untested!
46 //		"mov", "MOV (Quicktime Movie)", "video/x-mov",
47 //		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
48 //	},
49 //	{
50 // 		// TODO: Broken because of buggy FindKeyFrame() or Seek() support.
51 //		"mp3", "MPEG (Motion Picture Experts Group)", "audio/mpg",
52 //		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
53 //	},
54 	{
55 		// NOTE: Tested with a couple of files and only audio works ok.
56 		// On some files, the duration and time_base is detected incorrectly
57 		// by libavformat and those streams don't play at all.
58 		"mpg", "MPEG (Motion Picture Experts Group)", "video/mpeg",
59 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
60 	},
61 	{
62 		// NOTE: keep this before "mpeg" so it detects "mpegts" first.
63 		"mpegts", "MPEG (Motion Picture Experts Group)", "video/mpeg",
64 		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
65 	},
66 	{
67 		// TODO: Also covers "mpegvideo", plus see above.
68 		"mpeg", "MPEG (Motion Picture Experts Group)", "video/mpeg",
69 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
70 	},
71 	{
72 		// TODO: untested!
73 		"nsv", "NSV (NullSoft Video File)", "video/nsv",
74 		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
75 	},
76 	{
77 		// TODO: untested!
78 		"rm", "RM (RealVideo Clip)", "video/vnd.rn-realvideo",
79 		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
80 	},
81 	{
82 		// TODO: untested!
83 		"vob", "VOB Movie", "video/x-vob",
84 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
85 	},
86 	{
87 		"ac3", "AC3", "audio/ac3",
88 		B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
89 	},
90 };
91 
92 
93 const DemuxerFormat*
94 demuxer_format_for(AVInputFormat* format)
95 {
96 	int32 demuxerFormatCount = sizeof(gDemuxerTable) / sizeof(DemuxerFormat);
97 	for (int32 i = 0; i < demuxerFormatCount; i++) {
98 		const DemuxerFormat* demuxerFormat = &gDemuxerTable[i];
99 		if (strstr(format->name, demuxerFormat->demuxer_name) != NULL)
100 			return demuxerFormat;
101 	}
102 	return NULL;
103 }
104 
105