xref: /haiku/headers/os/media/MediaDecoder.h (revision 5d9e40fe9252c8f9c5e5e41594545bfa4419fcc7)
1 #ifndef MEDIADECODER_H
2 #define MEDIADECODER_H
3 
4 #include <MediaDefs.h>
5 #include <MediaFormats.h>
6 
7 namespace BPrivate {
8 	class Decoder;
9 }
10 namespace BPrivate {
11 	namespace media {
12 		class Decoder;
13 		class DecoderPlugin;
14 	}
15 }
16 
17 class BMediaDecoder {
18 	public:
19 		BMediaDecoder();
20 		BMediaDecoder(const media_format *in_format,
21 		              const void *info = NULL, size_t info_size = 0);
22 		BMediaDecoder(const media_codec_info *mci);
23 		virtual ~BMediaDecoder();
24 		status_t InitCheck() const;
25 
26 		status_t SetTo(const media_format *in_format,
27 		               const void *info = NULL, size_t info_size = 0);
28 		status_t SetTo(const media_codec_info *mci);
29 		status_t SetInputFormat(const media_format *in_format,
30 		                        const void *in_info = NULL, size_t in_size = 0);
31 		status_t SetOutputFormat(media_format *output_format);
32 			// Set output format to closest acceptable format, returns the
33 			// format used.
34 		status_t Decode(void *out_buffer, int64 *out_frameCount,
35 		                media_header *out_mh, media_decode_info *info);
36 		status_t GetDecoderInfo(media_codec_info *out_info) const;
37 
38 	protected:
39 		virtual status_t GetNextChunk(const void **chunkData, size_t *chunkLen,
40 		                              media_header *mh) = 0;
41 
42 	private:
43 
44 		//	unimplemented
45 		BMediaDecoder(const BMediaDecoder &);
46 		BMediaDecoder & operator=(const BMediaDecoder &);
47 
48 		status_t AttachToDecoder();
49 
50 		BPrivate::media::Decoder	*fDecoder;
51 		int32				fDecoderID;
52 		BPrivate::media::DecoderPlugin	*fDecoderPlugin;
53 		int32				fDecoderPluginID;
54 		status_t			fInitStatus;
55 
56 		bool				fNeedsInit;
57 		media_format *		fInitFormat;
58 		char *				fInitInfo;
59 		size_t				fInitInfoSize;
60 
61 		/* fbc data and virtuals */
62 
63 		uint32 _reserved_BMediaDecoder_[26];
64 
65 		virtual	status_t _Reserved_BMediaDecoder_0(int32 arg, ...);
66 		virtual	status_t _Reserved_BMediaDecoder_1(int32 arg, ...);
67 		virtual	status_t _Reserved_BMediaDecoder_2(int32 arg, ...);
68 		virtual	status_t _Reserved_BMediaDecoder_3(int32 arg, ...);
69 		virtual	status_t _Reserved_BMediaDecoder_4(int32 arg, ...);
70 		virtual	status_t _Reserved_BMediaDecoder_5(int32 arg, ...);
71 		virtual	status_t _Reserved_BMediaDecoder_6(int32 arg, ...);
72 		virtual	status_t _Reserved_BMediaDecoder_7(int32 arg, ...);
73 		virtual	status_t _Reserved_BMediaDecoder_8(int32 arg, ...);
74 		virtual	status_t _Reserved_BMediaDecoder_9(int32 arg, ...);
75 		virtual	status_t _Reserved_BMediaDecoder_10(int32 arg, ...);
76 		virtual	status_t _Reserved_BMediaDecoder_11(int32 arg, ...);
77 		virtual	status_t _Reserved_BMediaDecoder_12(int32 arg, ...);
78 		virtual	status_t _Reserved_BMediaDecoder_13(int32 arg, ...);
79 		virtual	status_t _Reserved_BMediaDecoder_14(int32 arg, ...);
80 		virtual	status_t _Reserved_BMediaDecoder_15(int32 arg, ...);
81 };
82 
83 class BMediaBufferDecoder : public BMediaDecoder {
84 	public:
85 		BMediaBufferDecoder();
86 		BMediaBufferDecoder(const media_format *in_format,
87 		                    const void *info = NULL, size_t info_size = 0);
88 		BMediaBufferDecoder(const media_codec_info *mci);
89 		status_t DecodeBuffer(const void *input_buffer, size_t input_size,
90 		                      void *out_buffer, int64 *out_frameCount,
91 		                      media_header *out_mh,
92 		                      media_decode_info *info = NULL);
93 	protected:
94 		virtual status_t GetNextChunk(const void **chunkData, size_t *chunkLen,
95 		                              media_header *mh);
96 		const void *buffer;
97 		int32 buffer_size;
98 };
99 
100 #endif
101 
102