xref: /haiku/headers/os/media/MediaDecoder.h (revision b4057dc9eb7e9ba1a1a29dbf3d234d2a86498994)
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 		static status_t next_chunk(void *classptr, void **chunkData, size_t *chunkLen, media_header *mh);
49 		void	ReleaseDecoder();
50 
51 		BPrivate::media::Decoder	*fDecoder;
52 		int32				fDecoderID;
53 		BPrivate::media::DecoderPlugin	*fDecoderPlugin;
54 		int32				fDecoderPluginID;
55 		status_t			fInitStatus;
56 
57 
58 		/* fbc data and virtuals */
59 
60 		uint32 _reserved_BMediaDecoder_[30];
61 
62 		virtual	status_t _Reserved_BMediaDecoder_0(int32 arg, ...);
63 		virtual	status_t _Reserved_BMediaDecoder_1(int32 arg, ...);
64 		virtual	status_t _Reserved_BMediaDecoder_2(int32 arg, ...);
65 		virtual	status_t _Reserved_BMediaDecoder_3(int32 arg, ...);
66 		virtual	status_t _Reserved_BMediaDecoder_4(int32 arg, ...);
67 		virtual	status_t _Reserved_BMediaDecoder_5(int32 arg, ...);
68 		virtual	status_t _Reserved_BMediaDecoder_6(int32 arg, ...);
69 		virtual	status_t _Reserved_BMediaDecoder_7(int32 arg, ...);
70 		virtual	status_t _Reserved_BMediaDecoder_8(int32 arg, ...);
71 		virtual	status_t _Reserved_BMediaDecoder_9(int32 arg, ...);
72 		virtual	status_t _Reserved_BMediaDecoder_10(int32 arg, ...);
73 		virtual	status_t _Reserved_BMediaDecoder_11(int32 arg, ...);
74 		virtual	status_t _Reserved_BMediaDecoder_12(int32 arg, ...);
75 		virtual	status_t _Reserved_BMediaDecoder_13(int32 arg, ...);
76 		virtual	status_t _Reserved_BMediaDecoder_14(int32 arg, ...);
77 		virtual	status_t _Reserved_BMediaDecoder_15(int32 arg, ...);
78 };
79 
80 class BMediaBufferDecoder : public BMediaDecoder {
81 	public:
82 		BMediaBufferDecoder();
83 		BMediaBufferDecoder(const media_format *in_format,
84 		                    const void *info = NULL, size_t info_size = 0);
85 		BMediaBufferDecoder(const media_codec_info *mci);
86 		status_t DecodeBuffer(const void *input_buffer, size_t input_size,
87 		                      void *out_buffer, int64 *out_frameCount,
88 		                      media_header *out_mh,
89 		                      media_decode_info *info = NULL);
90 	protected:
91 		virtual status_t GetNextChunk(const void **chunkData, size_t *chunkLen,
92 		                              media_header *mh);
93 		const void *buffer;
94 		int32 buffer_size;
95 };
96 
97 #endif
98 
99