2009-07-30 20:05:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Haiku Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT license.
|
|
|
|
*/
|
2009-07-29 16:25:30 +00:00
|
|
|
#ifndef _ENCODER_PLUGIN_H
|
|
|
|
#define _ENCODER_PLUGIN_H
|
|
|
|
|
2009-07-30 20:05:11 +00:00
|
|
|
|
2009-07-29 16:25:30 +00:00
|
|
|
#include <MediaTrack.h>
|
|
|
|
#include <MediaFormats.h>
|
|
|
|
#include "MediaPlugin.h"
|
|
|
|
|
2009-07-30 20:05:11 +00:00
|
|
|
|
2009-07-29 16:25:30 +00:00
|
|
|
class AddOnManager;
|
|
|
|
|
|
|
|
namespace BPrivate { namespace media {
|
|
|
|
|
|
|
|
class PluginManager;
|
|
|
|
|
|
|
|
class ChunkWriter {
|
|
|
|
public:
|
|
|
|
virtual ~ChunkWriter() {};
|
|
|
|
virtual status_t WriteChunk(const void* chunkBuffer,
|
2009-07-31 10:46:58 +00:00
|
|
|
size_t chunkSize,
|
|
|
|
media_encode_info* encodeInfo) = 0;
|
2009-07-29 16:25:30 +00:00
|
|
|
};
|
|
|
|
|
2009-07-30 20:05:11 +00:00
|
|
|
|
2009-07-29 16:25:30 +00:00
|
|
|
class Encoder {
|
|
|
|
public:
|
|
|
|
Encoder();
|
|
|
|
virtual ~Encoder();
|
|
|
|
|
2009-07-31 10:46:58 +00:00
|
|
|
// Some codecs may only support certain input color spaces, or output
|
|
|
|
// color spaces, or multiple of 16 width/height... This method is needed
|
|
|
|
// for get_next_encoder() functionality. If _acceptedInputFormat is NULL,
|
|
|
|
// you simply return a status indicating if proposed format is acceptable.
|
|
|
|
// If it contains wildcards for fields that you have restrictions on,
|
|
|
|
// return an error. In that case, the user should be using the form of
|
|
|
|
// get_next_encoder() that allows to specify the accepted format. If
|
|
|
|
// _acceptedInputFormat is not NULL, copy the proposedFormat into
|
|
|
|
// _acceptedInputFormat and specialize any wildcards. You must (!) also
|
|
|
|
// change non-wildcard fields, like the video width if you want to round to
|
|
|
|
// the nearest multiple of 16 for example. Only if the format is completely
|
|
|
|
// unacceptable, return an error.
|
|
|
|
virtual status_t AcceptedFormat(
|
|
|
|
const media_format* proposedInputFormat,
|
|
|
|
media_format* _acceptedInputFormat = NULL)
|
|
|
|
= 0;
|
|
|
|
|
|
|
|
// The passed media_format may not contain wildcards and must be the same
|
|
|
|
// format that was passed to get_next_encoder() (or it must be the format
|
|
|
|
// returned in _acceptedInputFormat).
|
|
|
|
virtual status_t SetUp(const media_format* inputFormat) = 0;
|
2009-07-29 16:25:30 +00:00
|
|
|
|
|
|
|
virtual status_t AddTrackInfo(uint32 code, const void* data,
|
2009-07-31 10:46:58 +00:00
|
|
|
size_t size, uint32 flags = 0);
|
2009-07-29 16:25:30 +00:00
|
|
|
|
|
|
|
virtual status_t GetEncodeParameters(
|
2009-07-31 10:46:58 +00:00
|
|
|
encode_parameters* parameters) const;
|
2009-07-29 16:25:30 +00:00
|
|
|
virtual status_t SetEncodeParameters(
|
2009-07-31 10:46:58 +00:00
|
|
|
encode_parameters* parameters) const;
|
|
|
|
|
2009-07-29 16:25:30 +00:00
|
|
|
virtual status_t Encode(const void* buffer, int64 frameCount,
|
|
|
|
media_encode_info* info) = 0;
|
2009-07-31 10:46:58 +00:00
|
|
|
|
2009-07-29 16:25:30 +00:00
|
|
|
status_t WriteChunk(const void* chunkBuffer,
|
2009-07-31 10:46:58 +00:00
|
|
|
size_t chunkSize,
|
|
|
|
media_encode_info* encodeInfo);
|
2009-07-29 16:25:30 +00:00
|
|
|
|
|
|
|
void SetChunkWriter(ChunkWriter* writer);
|
|
|
|
|
|
|
|
virtual status_t Perform(perform_code code, void* data);
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void _ReservedEncoder1();
|
|
|
|
virtual void _ReservedEncoder2();
|
|
|
|
virtual void _ReservedEncoder3();
|
|
|
|
virtual void _ReservedEncoder4();
|
|
|
|
virtual void _ReservedEncoder5();
|
|
|
|
|
|
|
|
ChunkWriter* fChunkWriter;
|
|
|
|
|
|
|
|
// needed for plug-in reference count management
|
|
|
|
friend class PluginManager;
|
|
|
|
MediaPlugin* fMediaPlugin;
|
|
|
|
|
|
|
|
uint32 fReserved[5];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class EncoderPlugin : public virtual MediaPlugin {
|
|
|
|
public:
|
|
|
|
EncoderPlugin();
|
|
|
|
|
2009-07-30 20:05:11 +00:00
|
|
|
virtual Encoder* NewEncoder(
|
|
|
|
const media_codec_info& codecInfo) = 0;
|
|
|
|
|
2009-07-31 00:46:36 +00:00
|
|
|
virtual status_t RegisterNextEncoder(int32* cookie,
|
|
|
|
media_codec_info* codecInfo,
|
|
|
|
media_format_family* formatFamily,
|
|
|
|
media_format* inputFormat,
|
|
|
|
media_format* outputFormat) = 0;
|
2009-07-29 16:25:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace BPrivate::media
|
|
|
|
|
|
|
|
using namespace BPrivate::media;
|
|
|
|
|
|
|
|
#endif // _ENCODER_PLUGIN_H
|