1 #ifndef MEDIAENCODER_H 2 #define MEDIAENCODER_H 3 4 #include <MediaDefs.h> 5 #include <MediaFormats.h> 6 7 namespace BPrivate { 8 class Encoder; 9 class _AddonManager; 10 } 11 12 class BMediaEncoder { 13 public: 14 BMediaEncoder(); 15 BMediaEncoder(const media_format *output_format); 16 BMediaEncoder(const media_codec_info *mci); 17 virtual ~BMediaEncoder(); 18 status_t InitCheck() const; 19 20 status_t SetTo(const media_format *output_format); 21 status_t SetTo(const media_codec_info *mci); 22 status_t SetFormat(media_format *input_format, 23 media_format *output_format, 24 media_file_format *mfi = NULL); 25 status_t Encode(const void *buffer, int64 frame_count, 26 media_encode_info *info); 27 status_t GetEncodeParameters(encode_parameters *parameters) const; 28 status_t SetEncodeParameters(encode_parameters *parameters); 29 protected: 30 virtual status_t WriteChunk(const void *chunk_data, size_t chunk_len, 31 media_encode_info *info) = 0; 32 virtual status_t AddTrackInfo(uint32 code, const char *data, size_t size); 33 34 private: 35 // unimplemented 36 BMediaEncoder(const BMediaEncoder &); 37 BMediaEncoder & operator=(const BMediaEncoder &); 38 39 static status_t write_chunk(void *classptr, const void *chunk_data, 40 size_t chunk_len, media_encode_info *info); 41 void Init(); 42 void ReleaseEncoder(); 43 44 BPrivate::_AddonManager *fEncoderMgr; 45 BPrivate::Encoder *fEncoder; 46 int32 fEncoderID; 47 bool fFormatValid; 48 bool fEncoderStarted; 49 status_t fInitStatus; 50 51 /* fbc data and virtuals */ 52 53 uint32 _reserved_BMediaEncoder_[32]; 54 55 virtual status_t _Reserved_BMediaEncoder_0(int32 arg, ...); 56 virtual status_t _Reserved_BMediaEncoder_1(int32 arg, ...); 57 virtual status_t _Reserved_BMediaEncoder_2(int32 arg, ...); 58 virtual status_t _Reserved_BMediaEncoder_3(int32 arg, ...); 59 virtual status_t _Reserved_BMediaEncoder_4(int32 arg, ...); 60 virtual status_t _Reserved_BMediaEncoder_5(int32 arg, ...); 61 virtual status_t _Reserved_BMediaEncoder_6(int32 arg, ...); 62 virtual status_t _Reserved_BMediaEncoder_7(int32 arg, ...); 63 virtual status_t _Reserved_BMediaEncoder_8(int32 arg, ...); 64 virtual status_t _Reserved_BMediaEncoder_9(int32 arg, ...); 65 virtual status_t _Reserved_BMediaEncoder_10(int32 arg, ...); 66 virtual status_t _Reserved_BMediaEncoder_11(int32 arg, ...); 67 virtual status_t _Reserved_BMediaEncoder_12(int32 arg, ...); 68 virtual status_t _Reserved_BMediaEncoder_13(int32 arg, ...); 69 virtual status_t _Reserved_BMediaEncoder_14(int32 arg, ...); 70 virtual status_t _Reserved_BMediaEncoder_15(int32 arg, ...); 71 }; 72 73 class BMediaBufferEncoder: public BMediaEncoder { 74 public: 75 BMediaBufferEncoder(); 76 BMediaBufferEncoder(const media_format *output_format); 77 BMediaBufferEncoder(const media_codec_info *mci); 78 status_t EncodeToBuffer(void *output_buffer, size_t *output_size, 79 const void *input_buffer, int64 frame_count, 80 media_encode_info *info); 81 protected: 82 virtual status_t WriteChunk(const void *chunk_data, size_t chunk_len, 83 media_encode_info *info); 84 85 void *fBuffer; 86 int32 fBufferSize; 87 }; 88 89 90 #endif 91 92