1 /* 2 * Copyright 2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _MEDIA_ENCODER_H 6 #define _MEDIA_ENCODER_H 7 8 9 #include <MediaFormats.h> 10 11 namespace BPrivate { 12 namespace media { 13 class Encoder; 14 class EncoderPlugin; 15 } 16 } 17 18 using namespace BPrivate::media; 19 20 21 class BMediaEncoder { 22 public: 23 BMediaEncoder(); 24 BMediaEncoder( 25 const media_format* outputFormat); 26 BMediaEncoder(const media_codec_info* info); 27 virtual ~BMediaEncoder(); 28 29 status_t InitCheck() const; 30 31 status_t SetTo(const media_format* outputFormat); 32 status_t SetTo(const media_codec_info* info); 33 status_t SetFormat(media_format* inputFormat, 34 media_format* outputFormat, 35 media_file_format* fileFormat = NULL); 36 37 status_t Encode(const void* buffer, int64 frameCount, 38 media_encode_info* info); 39 40 status_t GetEncodeParameters( 41 encode_parameters* parameters) const; 42 status_t SetEncodeParameters( 43 encode_parameters* parameters); 44 45 protected: 46 virtual status_t WriteChunk(const void* buffer, size_t size, 47 media_encode_info* info) = 0; 48 49 virtual status_t AddTrackInfo(uint32 code, const char* data, 50 size_t size); 51 52 // TODO: Needs Perform() method for FBC! 53 54 private: 55 // FBC padding and forbidden methods 56 virtual status_t _Reserved_BMediaEncoder_0(int32 arg, ...); 57 virtual status_t _Reserved_BMediaEncoder_1(int32 arg, ...); 58 virtual status_t _Reserved_BMediaEncoder_2(int32 arg, ...); 59 virtual status_t _Reserved_BMediaEncoder_3(int32 arg, ...); 60 virtual status_t _Reserved_BMediaEncoder_4(int32 arg, ...); 61 virtual status_t _Reserved_BMediaEncoder_5(int32 arg, ...); 62 virtual status_t _Reserved_BMediaEncoder_6(int32 arg, ...); 63 virtual status_t _Reserved_BMediaEncoder_7(int32 arg, ...); 64 virtual status_t _Reserved_BMediaEncoder_8(int32 arg, ...); 65 virtual status_t _Reserved_BMediaEncoder_9(int32 arg, ...); 66 virtual status_t _Reserved_BMediaEncoder_10(int32 arg, ...); 67 virtual status_t _Reserved_BMediaEncoder_11(int32 arg, ...); 68 virtual status_t _Reserved_BMediaEncoder_12(int32 arg, ...); 69 virtual status_t _Reserved_BMediaEncoder_13(int32 arg, ...); 70 virtual status_t _Reserved_BMediaEncoder_14(int32 arg, ...); 71 virtual status_t _Reserved_BMediaEncoder_15(int32 arg, ...); 72 73 BMediaEncoder(const BMediaEncoder& other); 74 BMediaEncoder& operator=(const BMediaEncoder& other); 75 76 private: 77 status_t _AttachToEncoder(); 78 79 static status_t write_chunk(void* classPtr, 80 const void* buffer, size_t size, 81 media_encode_info* info); 82 83 void Init(); 84 void ReleaseEncoder(); 85 86 uint32 _reserved_was_fEncoderMgr; 87 Encoder* fEncoder; 88 89 int32 fEncoderID; 90 bool fFormatValid; 91 bool fEncoderStarted; 92 status_t fInitStatus; 93 94 uint32 _reserved_BMediaEncoder_[32]; 95 }; 96 97 98 class BMediaBufferEncoder : public BMediaEncoder { 99 public: 100 BMediaBufferEncoder(); 101 BMediaBufferEncoder( 102 const media_format* outputFormat); 103 BMediaBufferEncoder( 104 const media_codec_info* info); 105 106 status_t EncodeToBuffer(void* outputBuffer, 107 size_t* _size, const void* inputBuffer, 108 int64 frameCount, media_encode_info* info); 109 110 protected: 111 virtual status_t WriteChunk(const void* buffer, size_t size, 112 media_encode_info* info); 113 114 protected: 115 void* fBuffer; 116 int32 fBufferSize; 117 }; 118 119 #endif // _MEDIA_ENCODER_H 120 121