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