xref: /haiku/headers/private/media/PluginManager.h (revision 218a8c03cbadd95d8888b218930f514fa0b4fac4)
1*218a8c03SAugustin Cavalier /*
2*218a8c03SAugustin Cavalier  * Copyright 2015, Dario Casalinuovo. All rights reserved.
3*218a8c03SAugustin Cavalier  * Copyright 2012, Fredrik Modéen. All rights reserved.
4*218a8c03SAugustin Cavalier  * Copyright 2004-2007, Marcus Overhagen. All rights reserved.
5*218a8c03SAugustin Cavalier  * Distributed under the terms of the MIT License.
6*218a8c03SAugustin Cavalier  */
7*218a8c03SAugustin Cavalier #ifndef _PLUGIN_MANAGER_H
8*218a8c03SAugustin Cavalier #define _PLUGIN_MANAGER_H
9*218a8c03SAugustin Cavalier 
10*218a8c03SAugustin Cavalier 
11*218a8c03SAugustin Cavalier #include <string.h>
12*218a8c03SAugustin Cavalier 
13*218a8c03SAugustin Cavalier 
14*218a8c03SAugustin Cavalier #include "DecoderPlugin.h"
15*218a8c03SAugustin Cavalier #include "EncoderPlugin.h"
16*218a8c03SAugustin Cavalier #include "ReaderPlugin.h"
17*218a8c03SAugustin Cavalier #include "StreamerPlugin.h"
18*218a8c03SAugustin Cavalier #include "WriterPlugin.h"
19*218a8c03SAugustin Cavalier 
20*218a8c03SAugustin Cavalier #include <TList.h>
21*218a8c03SAugustin Cavalier #include <Locker.h>
22*218a8c03SAugustin Cavalier 
23*218a8c03SAugustin Cavalier 
24*218a8c03SAugustin Cavalier namespace BPrivate { namespace media {
25*218a8c03SAugustin Cavalier 
26*218a8c03SAugustin Cavalier class PluginManager {
27*218a8c03SAugustin Cavalier public:
28*218a8c03SAugustin Cavalier 								PluginManager();
29*218a8c03SAugustin Cavalier 								~PluginManager();
30*218a8c03SAugustin Cavalier 
31*218a8c03SAugustin Cavalier 			MediaPlugin*		GetPlugin(const entry_ref& ref);
32*218a8c03SAugustin Cavalier 			void				PutPlugin(MediaPlugin* plugin);
33*218a8c03SAugustin Cavalier 
34*218a8c03SAugustin Cavalier 	// Readers and Decoders
35*218a8c03SAugustin Cavalier 			status_t			CreateReader(Reader** reader,
36*218a8c03SAugustin Cavalier 									int32* streamCount, media_file_format* mff,
37*218a8c03SAugustin Cavalier 									BDataIO* source);
38*218a8c03SAugustin Cavalier 			void				DestroyReader(Reader* reader);
39*218a8c03SAugustin Cavalier 
40*218a8c03SAugustin Cavalier 			status_t			CreateDecoder(Decoder** decoder,
41*218a8c03SAugustin Cavalier 									const media_format& format);
42*218a8c03SAugustin Cavalier 			status_t			CreateDecoder(Decoder** decoder,
43*218a8c03SAugustin Cavalier 									const media_codec_info& mci);
44*218a8c03SAugustin Cavalier 			status_t			GetDecoderInfo(Decoder* decoder,
45*218a8c03SAugustin Cavalier 									media_codec_info* _info) const;
46*218a8c03SAugustin Cavalier 			void				DestroyDecoder(Decoder* decoder);
47*218a8c03SAugustin Cavalier 
48*218a8c03SAugustin Cavalier 	// Writers and Encoders
49*218a8c03SAugustin Cavalier 			status_t			CreateWriter(Writer** writer,
50*218a8c03SAugustin Cavalier 									const media_file_format& mff,
51*218a8c03SAugustin Cavalier 									BDataIO* target);
52*218a8c03SAugustin Cavalier 			void				DestroyWriter(Writer* writer);
53*218a8c03SAugustin Cavalier 
54*218a8c03SAugustin Cavalier 			status_t			CreateEncoder(Encoder** encoder,
55*218a8c03SAugustin Cavalier 									const media_codec_info* codecInfo,
56*218a8c03SAugustin Cavalier 									uint32 flags);
57*218a8c03SAugustin Cavalier 
58*218a8c03SAugustin Cavalier 			status_t			CreateEncoder(Encoder** encoder,
59*218a8c03SAugustin Cavalier 									const media_format& format);
60*218a8c03SAugustin Cavalier 
61*218a8c03SAugustin Cavalier 			void				DestroyEncoder(Encoder* encoder);
62*218a8c03SAugustin Cavalier 
63*218a8c03SAugustin Cavalier 			status_t			CreateStreamer(Streamer** streamer,
64*218a8c03SAugustin Cavalier 									BUrl url, BDataIO** source);
65*218a8c03SAugustin Cavalier 			void				DestroyStreamer(Streamer* streamer);
66*218a8c03SAugustin Cavalier 
67*218a8c03SAugustin Cavalier private:
68*218a8c03SAugustin Cavalier 			status_t			_LoadPlugin(const entry_ref& ref,
69*218a8c03SAugustin Cavalier 									MediaPlugin** plugin, image_id* image);
70*218a8c03SAugustin Cavalier 
71*218a8c03SAugustin Cavalier 			struct plugin_info {
72*218a8c03SAugustin Cavalier 				char			name[260];
73*218a8c03SAugustin Cavalier 				int				usecount;
74*218a8c03SAugustin Cavalier 				MediaPlugin*	plugin;
75*218a8c03SAugustin Cavalier 				image_id		image;
76*218a8c03SAugustin Cavalier 
77*218a8c03SAugustin Cavalier 				plugin_info& operator=(const plugin_info& other)
78*218a8c03SAugustin Cavalier 				{
79*218a8c03SAugustin Cavalier 					strcpy(name, other.name);
80*218a8c03SAugustin Cavalier 					usecount = other.usecount;
81*218a8c03SAugustin Cavalier 					plugin = other.plugin;
82*218a8c03SAugustin Cavalier 					image = other.image;
83*218a8c03SAugustin Cavalier 					return *this;
84*218a8c03SAugustin Cavalier 				}
85*218a8c03SAugustin Cavalier 			};
86*218a8c03SAugustin Cavalier 
87*218a8c03SAugustin Cavalier 			List<plugin_info>	fPluginList;
88*218a8c03SAugustin Cavalier 			BLocker				fLocker;
89*218a8c03SAugustin Cavalier };
90*218a8c03SAugustin Cavalier 
91*218a8c03SAugustin Cavalier } } // namespace BPrivate::media
92*218a8c03SAugustin Cavalier 
93*218a8c03SAugustin Cavalier using namespace BPrivate::media;
94*218a8c03SAugustin Cavalier 
95*218a8c03SAugustin Cavalier extern PluginManager gPluginManager;
96*218a8c03SAugustin Cavalier 
97*218a8c03SAugustin Cavalier #endif // _PLUGIN_MANAGER_H
98