xref: /haiku/headers/private/media/MediaExtractor.h (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
1 #ifndef _MEDIA_EXTRACTOR_H
2 #define _MEDIA_EXTRACTOR_H
3 
4 #include "ReaderPlugin.h"
5 #include "DecoderPlugin.h"
6 
7 namespace BPrivate {
8 namespace media {
9 
10 class ChunkCache;
11 
12 struct stream_info
13 {
14 	status_t		status;
15 	void *			cookie;
16 	bool			hasCookie;
17 	const void *	infoBuffer;
18 	size_t			infoBufferSize;
19 	ChunkCache *	chunkCache;
20 	media_format	encodedFormat;
21 };
22 
23 class MediaExtractor
24 {
25 public:
26 					MediaExtractor(BDataIO * source, int32 flags);
27 					~MediaExtractor();
28 
29 	status_t		InitCheck();
30 
31 	void			GetFileFormatInfo(media_file_format *mfi) const;
32 
33 	int32			StreamCount();
34 
35 	const char*		Copyright();
36 
37 	const media_format * EncodedFormat(int32 stream);
38 	int64			CountFrames(int32 stream) const;
39 	bigtime_t		Duration(int32 stream) const;
40 
41 	status_t		Seek(int32 stream, uint32 seekTo,
42 						 int64 *frame, bigtime_t *time);
43 	status_t		FindKeyFrame(int32 stream, uint32 seekTo,
44 						 int64 *frame, bigtime_t *time) const;
45 
46 	status_t		GetNextChunk(int32 stream,
47 								 const void **chunkBuffer, size_t *chunkSize,
48 								 media_header *mediaHeader);
49 
50 	status_t		CreateDecoder(int32 stream, Decoder **decoder,
51 								  media_codec_info *mci);
52 
53 private:
54 	static int32	extractor_thread(void *arg);
55 	void			ExtractorThread();
56 
57 private:
58 	status_t		fErr;
59 
60 	sem_id			fExtractorWaitSem;
61 	thread_id		fExtractorThread;
62 	volatile bool	fTerminateExtractor;
63 
64 	BDataIO			*fSource;
65 	Reader			*fReader;
66 
67 	stream_info *	fStreamInfo;
68 	int32			fStreamCount;
69 
70 	media_file_format fMff;
71 };
72 
73 }; // namespace media
74 }; // namespace BPrivate
75 
76 using namespace BPrivate::media;
77 
78 #endif
79