xref: /haiku/headers/private/media/DecoderPlugin.h (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
1 #ifndef _DECODER_PLUGIN_H
2 #define _DECODER_PLUGIN_H
3 
4 #include <MediaTrack.h>
5 #include <MediaFormats.h>
6 #include "MediaPlugin.h"
7 
8 class AddOnManager;
9 
10 namespace BPrivate { namespace media {
11 
12 class PluginManager;
13 
14 class ChunkProvider {
15 public:
16 	virtual						~ChunkProvider() {};
17 	virtual	status_t			GetNextChunk(const void** chunkBuffer,
18 									size_t* chunkSize,
19 									media_header* mediaHeader) = 0;
20 };
21 
22 class Decoder {
23 public:
24 								Decoder();
25 	virtual						~Decoder();
26 
27 	virtual	void				GetCodecInfo(media_codec_info* codecInfo) = 0;
28 
29 	// Setup get's called with the info data from Reader::GetStreamInfo
30 	virtual	status_t			Setup(media_format* ioEncodedFormat,
31 									const void* infoBuffer,
32 									size_t infoSize) = 0;
33 
34 	virtual	status_t			NegotiateOutputFormat(
35 									media_format* ioDecodedFormat) = 0;
36 
37 	virtual	status_t			Seek(uint32 seekTo, int64 seekFrame,
38 									int64* frame, bigtime_t seekTime,
39 									bigtime_t* time) = 0;
40 
41 	virtual status_t			Decode(void* buffer, int64* frameCount,
42 									media_header* mediaHeader,
43 									media_decode_info* info = 0) = 0;
44 
45 			status_t			GetNextChunk(const void** chunkBuffer,
46 									size_t* chunkSize,
47 									media_header* mediaHeader);
48 
49 			void				SetChunkProvider(ChunkProvider* provider);
50 
51 	virtual status_t			Perform(perform_code code, void* data);
52 
53 private:
54 	virtual void				_ReservedDecoder1();
55 	virtual void				_ReservedDecoder2();
56 	virtual void				_ReservedDecoder3();
57 	virtual void				_ReservedDecoder4();
58 	virtual void				_ReservedDecoder5();
59 
60 			ChunkProvider*		fChunkProvider;
61 
62 	// needed for plug-in reference count management
63 	friend class PluginManager;
64 			MediaPlugin*		fMediaPlugin;
65 
66 			uint32				fReserved[5];
67 };
68 
69 
70 class DecoderPlugin : public virtual MediaPlugin {
71 public:
72 								DecoderPlugin();
73 
74 	virtual	Decoder*			NewDecoder(uint index) = 0;
75 	virtual	status_t			GetSupportedFormats(media_format** formats,
76 									size_t* count) = 0;
77 };
78 
79 } } // namespace BPrivate::media
80 
81 using namespace BPrivate::media;
82 
83 #endif // _DECODER_PLUGIN_H
84