xref: /haiku/src/add-ons/media/plugins/ffmpeg/DemuxerTable.cpp (revision 1345706a9ff6ad0dc041339a02d4259998b0765d)
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 //		// Tested and appears to work ok with the one clip I have...
46 //		"matroska", "Matroska Movie", "video/x-matroska",
47 //		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
48 //	},
49 //	{
50 //		// Plays the limited amount of files I could test with.
51 //		"mov", "Quicktime Movie", "video/x-mov",
52 //		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
53 //	},
54 //	{
55 //		// Plays the limited amount of files I could test with.
56 //		"mp4", "MPEG-4 Movie", "video/x-mp4",
57 //		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
58 //	},
59 //	{
60 // 		// TODO: Broken because of buggy FindKeyFrame() or Seek() support.
61 //		"mp3", "MPEG (Motion Picture Experts Group)", "audio/mpg",
62 //		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
63 //	},
64 	{
65 		// NOTE: Tested with a couple of files and only audio works ok.
66 		// On some files, the duration and time_base is detected incorrectly
67 		// by libavformat and those streams don't play at all.
68 		"mpg", "MPEG (Motion Picture Experts Group)", "video/mpeg",
69 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
70 	},
71 	{
72 		// NOTE: keep this before "mpeg" so it detects "mpegts" first.
73 		"mpegts", "MPEG (Motion Picture Experts Group)", "video/mpeg",
74 		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
75 	},
76 	{
77 		// TODO: Also covers "mpegvideo", plus see mpegts.
78 		"mpeg", "MPEG (Motion Picture Experts Group)", "video/mpeg",
79 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
80 	},
81 	{
82 		// TODO: untested!
83 		"nsv", "NSV (NullSoft Video File)", "video/nsv",
84 		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
85 	},
86 	{
87 		// TODO: untested!
88 		"rm", "RM (RealVideo Clip)", "video/vnd.rn-realvideo",
89 		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
90 	},
91 	{
92 		// TODO: untested!
93 		"vob", "VOB Movie", "video/x-vob",
94 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
95 	},
96 	{
97 		"ac3", "AC3", "audio/ac3",
98 		B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
99 	},
100 };
101 
102 
103 const DemuxerFormat*
104 demuxer_format_for(AVInputFormat* format)
105 {
106 	int32 demuxerFormatCount = sizeof(gDemuxerTable) / sizeof(DemuxerFormat);
107 	for (int32 i = 0; i < demuxerFormatCount; i++) {
108 		const DemuxerFormat* demuxerFormat = &gDemuxerTable[i];
109 		if (strstr(format->name, demuxerFormat->demuxer_name) != NULL)
110 			return demuxerFormat;
111 	}
112 	return NULL;
113 }
114 
115