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
13extern "C" {
14	#include "avformat.h"
15}
16
17
18class AVFormatWriter : public Writer {
19public:
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
46private:
47	static	int					_Write(void* cookie, uint8* buffer,
48									int bufferSize);
49	static	off_t				_Seek(void* cookie, off_t offset, int whence);
50
51private:
52			class StreamCookie;
53
54			AVFormatContext*	fFormatContext;
55			bool				fCodecOpened;
56			int					fHeaderError;
57
58			AVIOContext*		fIOContext;
59
60			StreamCookie**		fStreams;
61			BLocker				fStreamLock;
62};
63
64
65#endif // AV_FORMAT_WRITER_H
66