xref: /haiku/headers/private/media/PluginManager.h (revision a1163de83ea633463a79de234b8742ee106531b2)
1 #ifndef _PLUGIN_MANAGER_H
2 #define _PLUGIN_MANAGER_H
3 
4 
5 #include <string.h>
6 
7 
8 #include "ReaderPlugin.h"
9 #include "DecoderPlugin.h"
10 #include <TList.h>
11 #include <Locker.h>
12 
13 
14 namespace BPrivate { namespace media {
15 
16 class PluginManager
17 {
18 public:
19 					PluginManager();
20 					~PluginManager();
21 
22 	MediaPlugin *	GetPlugin(const entry_ref &ref);
23 	void			PutPlugin(MediaPlugin *plugin);
24 
25 
26 	status_t		CreateReader(Reader **reader, int32 *streamCount, media_file_format *mff, BDataIO *source);
27 	void			DestroyReader(Reader *reader);
28 
29 	status_t		CreateDecoder(Decoder **decoder, const media_format &format);
30 	status_t		CreateDecoder(Decoder **decoder, const media_codec_info &mci);
31 	status_t		GetDecoderInfo(Decoder *decoder, media_codec_info *out_info) const;
32 	void			DestroyDecoder(Decoder *decoder);
33 
34 private:
35 	status_t		LoadPlugin(const entry_ref &ref, MediaPlugin **plugin, image_id *image);
36 
37 	struct plugin_info
38 	{
39 		char		name[260];
40 		int			usecount;
41 		MediaPlugin *plugin;
42 		image_id	image;
43 
44 		plugin_info& operator=(const plugin_info& other)
45 		{
46 			strcpy(name, other.name);
47 			usecount = other.usecount;
48 			plugin = other.plugin;
49 			image = other.image;
50 			return *this;
51 		}
52 	};
53 
54 	List<plugin_info> *fPluginList;
55 	BLocker 		*fLocker;
56 };
57 
58 } } // namespace BPrivate::media
59 
60 using namespace BPrivate::media;
61 
62 extern PluginManager _plugin_manager;
63 
64 #endif
65