xref: /haiku/headers/private/media/MediaWriter.h (revision 97dfeb96704e5dbc5bec32ad7b21379d0125e031)
1 /*
2  * Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef _MEDIA_WRITER_H
6 #define _MEDIA_WRITER_H
7 
8 
9 #include <Url.h>
10 
11 #include "EncoderPlugin.h"
12 #include "StreamerPlugin.h"
13 #include "TList.h"
14 #include "WriterPlugin.h"
15 
16 
17 namespace BPrivate {
18 namespace media {
19 
20 
21 class MediaWriter {
22 public:
23 								MediaWriter(BDataIO* target,
24 									const media_file_format& fileFormat);
25 								MediaWriter(BUrl* url,
26 									const media_file_format& fileFormat);
27 								~MediaWriter();
28 
29 			status_t			InitCheck();
30 
31 			BDataIO*			Target() const;
32 
33 			void				GetFileFormatInfo(media_file_format* mfi) const;
34 
35 			status_t			CreateEncoder(Encoder** _encoder,
36 									const media_codec_info* codecInfo,
37 									media_format* format, uint32 flags = 0);
38 
39 			status_t			SetCopyright(int32 streamIndex,
40 									const char* copyright);
41 			status_t			SetCopyright(const char* copyright);
42 			status_t			CommitHeader();
43 			status_t			Flush();
44 			status_t			Close();
45 
46 			status_t			AddTrackInfo(int32 streamIndex, uint32 code,
47 									const void* data, size_t size,
48 									uint32 flags = 0);
49 
50 			status_t			WriteChunk(int32 streamIndex,
51 									const void* chunkBuffer, size_t chunkSize,
52 									media_encode_info* encodeInfo);
53 
54 private:
55 			struct StreamInfo {
56 				void*			cookie;
57 			};
58 
59 private:
60 			BDataIO*			fTarget;
61 			Writer*				fWriter;
62 			Streamer*			fStreamer;
63 
64 			List<StreamInfo>	fStreamInfos;
65 
66 			media_file_format	fFileFormat;
67 };
68 
69 
70 }; // namespace media
71 }; // namespace BPrivate
72 
73 using namespace BPrivate::media;
74 
75 
76 #endif // _MEDIA_WRITER_H
77