xref: /haiku/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.h (revision 23d878482ed22e55dad6d1fca1df7bea42eb157c)
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 									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 	static	off_t				_Seek(void* cookie, off_t offset, int whence);
50 
51 private:
52 			class StreamCookie;
53 
54 			AVFormatContext*	fContext;
55 			bool				fHeaderWritten;
56 
57 			AVIOContext*		fIOContext;
58 
59 			StreamCookie**		fStreams;
60 			BLocker				fStreamLock;
61 };
62 
63 
64 #endif // AV_FORMAT_WRITER_H
65