xref: /haiku/src/kits/media/AddOnManager.h (revision 91c0454716f24a7454b20f7a54cfe32e288e3710)
1 /*
2  * Copyright 2004-2009, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT license.
4  *
5  * Authors:
6  *		Marcus Overhagen
7  *		Axel Dörfler
8  *		Stephan Aßmus <superstippi@gmx.de>
9  */
10 #ifndef _ADD_ON_MANAGER_H
11 #define _ADD_ON_MANAGER_H
12 
13 
14 /*!	Manager for codec add-ons (reader, writer, encoder, decoder)
15 	BMediaAddOn are handled in the NodeManager
16 */
17 
18 
19 #include "DataExchange.h"
20 #include "TList.h"
21 
22 #include "DecoderPlugin.h"
23 #include "EncoderPlugin.h"
24 #include "ReaderPlugin.h"
25 #include "WriterPlugin.h"
26 
27 
28 class AddOnManager {
29 public:
30 								AddOnManager();
31 								~AddOnManager();
32 
33 			static AddOnManager* GetInstance();
34 
35 			status_t			GetDecoderForFormat(entry_ref* _ref,
36 									const media_format& format);
37 
38 			status_t			GetReaders(entry_ref* _ref,
39 									int32* _count, int32 maxCount);
40 
41 			status_t			GetEncoder(entry_ref* _ref, int32 id);
42 
43 			status_t			GetWriter(entry_ref* _ref,
44 									uint32 internalID);
45 
46 			status_t			GetFileFormat(media_file_format* _fileFormat,
47 									int32 cookie);
48 			status_t			GetCodecInfo(media_codec_info* _codecInfo,
49 									media_format_family* _formatFamily,
50 									media_format* _inputFormat,
51 									media_format* _outputFormat, int32 cookie);
52 
53 			void				RegisterAddOns();
54 
55 private:
56 
57 			status_t			_RegisterAddOn(const entry_ref& ref);
58 			status_t			_UnregisterAddOn(const entry_ref& ref);
59 
60 			void				_RegisterReader(ReaderPlugin* reader,
61 									const entry_ref& ref);
62 			void				_RegisterDecoder(DecoderPlugin* decoder,
63 									const entry_ref& ref);
64 
65 			void				_RegisterWriter(WriterPlugin* writer,
66 									const entry_ref& ref);
67 			void				_RegisterEncoder(EncoderPlugin* encoder,
68 									const entry_ref& ref);
69 
70 			bool				_FindDecoder(const media_format& format,
71 									const BPath& path,
72 									entry_ref* _decoderRef);
73 			void				_GetReaders(const BPath& path,
74 									entry_ref* outRefs, int32* outCount,
75 									int32 maxCount);
76 
77 private:
78 			struct reader_info {
79 				entry_ref			ref;
80 			};
81 			struct writer_info {
82 				entry_ref			ref;
83 				uint32				internalID;
84 			};
85 			struct decoder_info {
86 				entry_ref			ref;
87 				List<media_format>	formats;
88 			};
89 			struct encoder_info {
90 				entry_ref			ref;
91 				uint32				internalID;
92 				media_codec_info	codecInfo;
93 				media_format_family	formatFamily;
94 				media_format		intputFormat;
95 				media_format		outputFormat;
96 			};
97 
98 			BLocker				fLock;
99 			List<reader_info>	fReaderList;
100 			List<writer_info>	fWriterList;
101 			List<decoder_info>	fDecoderList;
102 			List<encoder_info>	fEncoderList;
103 
104 			List<media_file_format> fWriterFileFormats;
105 
106 			uint32				fNextWriterFormatFamilyID;
107 			uint32				fNextEncoderCodecInfoID;
108 
109 			static AddOnManager	sInstance;
110 };
111 
112 #endif // _ADD_ON_MANAGER_H
113