xref: /haiku/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.h (revision b55a57da7173b9af0432bd3e148d03f06161d036)
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_WRITER_H
6 #define AV_FORMAT_WRITER_H
7 
8 
9 #include <Locker.h>
10 
11 #include "WriterPlugin.h"
12 
13 extern "C" {
14 	#include "avformat.h"
15 }
16 
17 
18 class AVFormatWriter : public Writer {
19 public:
20 								AVFormatWriter();
21 								~AVFormatWriter();
22 
23 	virtual	status_t			Init(const media_file_format* fileFormat);
24 
25 	virtual	status_t			SetCopyright(const char* copyright);
26 	virtual	status_t			CommitHeader();
27 	virtual	status_t			Flush();
28 	virtual	status_t			Close();
29 
30 	virtual	status_t			AllocateCookie(void** cookie,
31 									const media_format* format,
32 									const media_codec_info* codecInfo);
33 	virtual	status_t			FreeCookie(void* cookie);
34 
35 	virtual	status_t			SetCopyright(void* cookie,
36 									const char* copyright);
37 
38 	virtual	status_t			AddTrackInfo(void* cookie, uint32 code,
39 									const void* data, size_t size,
40 									uint32 flags = 0);
41 
42 	virtual	status_t			WriteChunk(void* cookie,
43 									const void* chunkBuffer, size_t chunkSize,
44 									media_encode_info* encodeInfo);
45 
46 private:
47 	static	int					_Write(void* cookie, uint8* buffer,
48 									int bufferSize);
49 
50 	static	off_t				_Seek(void* cookie, off_t offset, int whence);
51 
52 private:
53 	class StreamCookie;
54 
55 			AVFormatContext*	fContext;
56 			bool				fHeaderWritten;
57 
58 			ByteIOContext		fIOContext;
59 			uint8*				fIOBuffer;
60 
61 			StreamCookie**		fStreams;
62 			BLocker				fStreamLock;
63 };
64 
65 
66 #endif // AV_FORMAT_WRITER_H
67