xref: /haiku/src/add-ons/media/plugins/ffmpeg/DemuxerTable.cpp (revision 2c69b5b6c0e7b481a0c43366a1942a6055cbb864)
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 //		// TODO: untested!
21 //		"asf", "ASF Movie", "video/x-asf",
22 //		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
23 //	},
24 //	{
25 //		// Tested with a limited amount of streams and works ok, keep using
26 //		// the avi_reader implementation by Marcus Overhagen.
27 //		"avi", "AVI (Audio Video Interleaved)", "video/x-msvideo",
28 //		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
29 //	},
30 	{
31 		"dv", "DV Movie", "video/dv",
32 		B_WAV_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
33 	},
34 	{
35 		"flac", "FLAC", "audio/x-flac",
36 		B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
37 	},
38 	{
39 		"flv", "Flash Video", "video/x-flv",
40 		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
41 	},
42 //	{
43 //		TODO: untested!
44 //		"mov", "MOV (Quicktime Movie)", "video/x-mov",
45 //		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
46 //	},
47 //	{
48 // 		// TODO: Broken because of buggy FindKeyFrame() or Seek() support.
49 //		"mp3", "MPEG (Motion Picture Experts Group)", "audio/mpg",
50 //		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
51 //	},
52 	{
53 		// NOTE: Tested with a couple of files and only audio works ok.
54 		// On some files, the duration and time_base is detected incorrectly
55 		// by libavformat and those streams don't play at all.
56 		"mpg", "MPEG (Motion Picture Experts Group)", "video/mpeg",
57 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
58 	},
59 	{
60 		// NOTE: keep this before "mpeg" so it detects "mpegts" first.
61 		"mpegts", "MPEG (Motion Picture Experts Group)", "video/mpeg",
62 		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
63 	},
64 	{
65 		// TODO: Also covers "mpegvideo", plus see above.
66 		"mpeg", "MPEG (Motion Picture Experts Group)", "video/mpeg",
67 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
68 	},
69 	{
70 		// TODO: untested!
71 		"nsv", "NSV (NullSoft Video File)", "video/nsv",
72 		B_QUICKTIME_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
73 	},
74 	{
75 		// TODO: untested!
76 		"rm", "RM (RealVideo Clip)", "video/vnd.rn-realvideo",
77 		B_WAV_FORMAT_FAMILY, B_AVI_FORMAT_FAMILY
78 	},
79 	{
80 		// TODO: untested!
81 		"vob", "VOB Movie", "video/x-vob",
82 		B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
83 	},
84 };
85 
86 
87 const DemuxerFormat*
88 demuxer_format_for(AVInputFormat* format)
89 {
90 	int32 demuxerFormatCount = sizeof(gDemuxerTable) / sizeof(DemuxerFormat);
91 	for (int32 i = 0; i < demuxerFormatCount; i++) {
92 		const DemuxerFormat* demuxerFormat = &gDemuxerTable[i];
93 		if (strstr(format->name, demuxerFormat->demuxer_name) != NULL)
94 			return demuxerFormat;
95 	}
96 	return NULL;
97 }
98 
99