xref: /haiku/src/add-ons/media/plugins/ffmpeg/AVFormatReader.h (revision 827faf77a469d9bbefec9a0618bd22daa38aec6c)
1 /*
2  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3  * All rights reserved. Distributed under the terms of the GNU L-GPL license.
4  */
5 #ifndef AV_FORMAT_READER_H
6 #define AV_FORMAT_READER_H
7 
8 
9 #include "ReaderPlugin.h"
10 
11 extern "C" {
12 	#include "avformat.h"
13 }
14 
15 
16 class AVFormatReader : public Reader {
17 public:
18 								AVFormatReader();
19 								~AVFormatReader();
20 
21 	virtual	const char*			Copyright();
22 
23 	virtual	status_t			Sniff(int32* streamCount);
24 
25 	virtual	void				GetFileFormatInfo(media_file_format* mff);
26 
27 	virtual	status_t			AllocateCookie(int32 streamNumber,
28 									void** cookie);
29 	virtual	status_t			FreeCookie(void* cookie);
30 
31 	virtual	status_t			GetStreamInfo(void* cookie, int64* frameCount,
32 									bigtime_t* duration, media_format* format,
33 									const void** infoBuffer,
34 									size_t* infoSize);
35 
36 	virtual	status_t			Seek(void* cookie, uint32 flags, int64* frame,
37 									bigtime_t* time);
38 	virtual	status_t			FindKeyFrame(void* cookie, uint32 flags,
39 									int64* frame, bigtime_t* time);
40 
41 	virtual	status_t			GetNextChunk(void* cookie,
42 									const void** chunkBuffer, size_t* chunkSize,
43 									media_header* mediaHeader);
44 
45 private:
46 	static	int				_ReadPacket(void* cookie,
47 									uint8* buffer, int bufferSize);
48 
49 	static	off_t				_Seek(void* cookie,
50 									off_t offset, int whence);
51 
52 			AVFormatContext*	fContext;
53 			AVFormatParameters	fFormatParameters;
54 			ByteIOContext		fIOContext;
55 			uint8*				fIOBuffer;
56 
57 	struct StreamCookie {
58 		AVStream*			stream;
59 		AVCodecContext*		codecContext;
60 		AVCodec*			codec;
61 		media_format		format;
62 		// TODO: Maybe we don't need the codec after all, maybe we do
63 		// for getting stream information...
64 		// TODO: Some form of packet queue
65 	};
66 
67 };
68 
69 
70 #endif // AV_FORMAT_READER_H
71