2009-08-28 16:42:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _MEDIA_ENCODER_H
|
|
|
|
#define _MEDIA_ENCODER_H
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#include <MediaFormats.h>
|
|
|
|
|
2019-05-17 21:43:32 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
namespace media {
|
|
|
|
class Encoder;
|
|
|
|
class EncoderPlugin;
|
|
|
|
}
|
2018-11-27 13:35:01 +03:00
|
|
|
}
|
2015-12-02 17:24:17 +03:00
|
|
|
|
2019-05-17 21:43:32 +03:00
|
|
|
using namespace BPrivate::media;
|
|
|
|
|
2009-08-28 16:42:36 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BMediaEncoder {
|
2009-08-28 16:42:36 +04:00
|
|
|
public:
|
|
|
|
BMediaEncoder();
|
|
|
|
BMediaEncoder(
|
|
|
|
const media_format* outputFormat);
|
|
|
|
BMediaEncoder(const media_codec_info* info);
|
|
|
|
virtual ~BMediaEncoder();
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
|
|
|
|
status_t SetTo(const media_format* outputFormat);
|
|
|
|
status_t SetTo(const media_codec_info* info);
|
|
|
|
status_t SetFormat(media_format* inputFormat,
|
|
|
|
media_format* outputFormat,
|
|
|
|
media_file_format* fileFormat = NULL);
|
|
|
|
|
|
|
|
status_t Encode(const void* buffer, int64 frameCount,
|
|
|
|
media_encode_info* info);
|
|
|
|
|
|
|
|
status_t GetEncodeParameters(
|
|
|
|
encode_parameters* parameters) const;
|
|
|
|
status_t SetEncodeParameters(
|
|
|
|
encode_parameters* parameters);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual status_t WriteChunk(const void* buffer, size_t size,
|
|
|
|
media_encode_info* info) = 0;
|
|
|
|
|
|
|
|
virtual status_t AddTrackInfo(uint32 code, const char* data,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
// TODO: Needs Perform() method for FBC!
|
|
|
|
|
|
|
|
private:
|
|
|
|
// FBC padding and forbidden methods
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_0(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_1(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_2(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_3(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_4(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_5(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_6(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_7(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_8(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_9(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_10(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_11(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_12(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_13(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_14(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaEncoder_15(int32 arg, ...);
|
|
|
|
|
|
|
|
BMediaEncoder(const BMediaEncoder& other);
|
|
|
|
BMediaEncoder& operator=(const BMediaEncoder& other);
|
|
|
|
|
|
|
|
private:
|
2015-12-02 17:24:17 +03:00
|
|
|
status_t _AttachToEncoder();
|
|
|
|
|
2009-08-28 16:42:36 +04:00
|
|
|
static status_t write_chunk(void* classPtr,
|
|
|
|
const void* buffer, size_t size,
|
|
|
|
media_encode_info* info);
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
void ReleaseEncoder();
|
|
|
|
|
|
|
|
uint32 _reserved_was_fEncoderMgr;
|
2019-05-17 21:43:32 +03:00
|
|
|
Encoder* fEncoder;
|
2009-08-28 16:42:36 +04:00
|
|
|
|
|
|
|
int32 fEncoderID;
|
|
|
|
bool fFormatValid;
|
|
|
|
bool fEncoderStarted;
|
|
|
|
status_t fInitStatus;
|
|
|
|
|
|
|
|
uint32 _reserved_BMediaEncoder_[32];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2009-08-28 16:42:36 +04:00
|
|
|
|
2015-12-02 17:24:17 +03:00
|
|
|
class BMediaBufferEncoder : public BMediaEncoder {
|
2009-08-28 16:42:36 +04:00
|
|
|
public:
|
|
|
|
BMediaBufferEncoder();
|
|
|
|
BMediaBufferEncoder(
|
|
|
|
const media_format* outputFormat);
|
|
|
|
BMediaBufferEncoder(
|
|
|
|
const media_codec_info* info);
|
|
|
|
|
|
|
|
status_t EncodeToBuffer(void* outputBuffer,
|
|
|
|
size_t* _size, const void* inputBuffer,
|
|
|
|
int64 frameCount, media_encode_info* info);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-28 16:42:36 +04:00
|
|
|
protected:
|
|
|
|
virtual status_t WriteChunk(const void* buffer, size_t size,
|
|
|
|
media_encode_info* info);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void* fBuffer;
|
|
|
|
int32 fBufferSize;
|
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-28 16:42:36 +04:00
|
|
|
#endif // _MEDIA_ENCODER_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|