xref: /haiku/src/kits/media/AddOnManager.h (revision d0ac609964842f8cdb6d54b3c539c6c15293e172)
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 namespace BPrivate {
29 namespace media {
30 
31 class AddOnManager {
32 public:
33 								AddOnManager();
34 								~AddOnManager();
35 
36 			static AddOnManager* GetInstance();
37 
38 			status_t			GetDecoderForFormat(entry_ref* _ref,
39 									const media_format& format);
40 
41 			status_t			GetReaders(entry_ref* _ref,
42 									int32* _count, int32 maxCount);
43 
44 			status_t			GetEncoder(entry_ref* _ref, int32 id);
45 
46 			status_t			GetWriter(entry_ref* _ref,
47 									uint32 internalID);
48 
49 			status_t			GetFileFormat(media_file_format* _fileFormat,
50 									int32 cookie);
51 			status_t			GetCodecInfo(media_codec_info* _codecInfo,
52 									media_format_family* _formatFamily,
53 									media_format* _inputFormat,
54 									media_format* _outputFormat, int32 cookie);
55 
56 			void				RegisterAddOns();
57 
58 private:
59 
60 			status_t			_RegisterAddOn(const entry_ref& ref);
61 			status_t			_UnregisterAddOn(const entry_ref& ref);
62 
63 			void				_RegisterReader(ReaderPlugin* reader,
64 									const entry_ref& ref);
65 			void				_RegisterDecoder(DecoderPlugin* decoder,
66 									const entry_ref& ref);
67 
68 			void				_RegisterWriter(WriterPlugin* writer,
69 									const entry_ref& ref);
70 			void				_RegisterEncoder(EncoderPlugin* encoder,
71 									const entry_ref& ref);
72 
73 			bool				_FindDecoder(const media_format& format,
74 									const BPath& path,
75 									entry_ref* _decoderRef);
76 			void				_GetReaders(const BPath& path,
77 									entry_ref* outRefs, int32* outCount,
78 									int32 maxCount);
79 
80 private:
81 			struct reader_info {
82 				entry_ref			ref;
83 			};
84 			struct writer_info {
85 				entry_ref			ref;
86 				uint32				internalID;
87 			};
88 			struct decoder_info {
89 				entry_ref			ref;
90 				List<media_format>	formats;
91 			};
92 			struct encoder_info {
93 				entry_ref			ref;
94 				uint32				internalID;
95 				media_codec_info	codecInfo;
96 				media_format_family	formatFamily;
97 				media_format		intputFormat;
98 				media_format		outputFormat;
99 			};
100 
101 			BLocker				fLock;
102 			List<reader_info>	fReaderList;
103 			List<writer_info>	fWriterList;
104 			List<decoder_info>	fDecoderList;
105 			List<encoder_info>	fEncoderList;
106 
107 			List<media_file_format> fWriterFileFormats;
108 
109 			uint32				fNextWriterFormatFamilyID;
110 			uint32				fNextEncoderCodecInfoID;
111 
112 			static AddOnManager	sInstance;
113 };
114 
115 } // namespace media
116 } // namespace BPrivate
117 
118 #endif // _ADD_ON_MANAGER_H
119