Revert the Codec Kit.

All of Barrett's individual reverts have been squashed into this
one commit, save a few actual bugfixes.

Change-Id: Ib0a7d0a841d3ac40b1fca7372c58b7f9229bd1f0
This commit is contained in:
Augustin Cavalier
2019-05-17 14:43:32 -04:00
parent 086528f66a
commit 218a8c03cb
96 changed files with 1545 additions and 2678 deletions
-107
View File
@@ -1,107 +0,0 @@
/*
* Copyright 2016 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ADAPTER_IO_H
#define _ADAPTER_IO_H
#include <MediaIO.h>
#include <OS.h>
#include <SupportDefs.h>
class RWLocker;
namespace BCodecKit {
class BAdapterIO;
class RelativePositionIO;
class BInputAdapter {
public:
virtual ssize_t Write(const void* buffer, size_t size);
private:
friend class BAdapterIO;
BInputAdapter(BAdapterIO* io);
virtual ~BInputAdapter();
BAdapterIO* fIO;
virtual void _ReservedInputAdapter1();
virtual void _ReservedInputAdapter2();
uint32 _reserved[2];
};
class BAdapterIO : public BMediaIO {
public:
BAdapterIO(
int32 flags,
bigtime_t timeout);
virtual ~BAdapterIO();
virtual void GetFlags(int32* flags) const;
virtual ssize_t ReadAt(off_t position, void* buffer,
size_t size);
virtual ssize_t WriteAt(off_t position,
const void* buffer, size_t size);
virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
virtual status_t GetSize(off_t* size) const;
virtual status_t Open();
virtual bool IsRunning() const;
void SeekCompleted();
status_t SetBuffer(BPositionIO* buffer);
BInputAdapter* BuildInputAdapter();
protected:
friend class BInputAdapter;
virtual status_t SeekRequested(off_t position);
ssize_t BackWrite(const void* buffer, size_t size);
private:
status_t _EvaluateWait(off_t pos, off_t size);
int32 fFlags;
RelativePositionIO* fBuffer;
off_t fTotalSize;
bool fOpened;
sem_id fSeekSem;
BInputAdapter* fInputAdapter;
BAdapterIO(const BAdapterIO&);
BAdapterIO& operator=(const BAdapterIO&);
virtual void _ReservedAdapterIO1();
virtual void _ReservedAdapterIO2();
virtual void _ReservedAdapterIO3();
virtual void _ReservedAdapterIO4();
virtual void _ReservedAdapterIO5();
uint32 _reserved[5];
};
} // namespace BCodecKit
#endif // _ADAPTER_IO_H
-140
View File
@@ -1,140 +0,0 @@
/*
* Copyright 2018, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CODEC_ROSTER_H
#define _CODEC_ROSTER_H
#include <Decoder.h>
#include <Encoder.h>
#include <MediaDefs.h>
#include <Reader.h>
#include <Streamer.h>
#include <Writer.h>
namespace BCodecKit {
class BCodecRoster {
public:
static status_t InstantiateReader(BReader** reader,
int32* streamCount, media_file_format* mff,
BDataIO* source);
static void ReleaseReader(BReader* reader);
static status_t InstantiateDecoder(BDecoder** decoder,
const media_format& format);
static status_t InstantiateDecoder(BDecoder** decoder,
const media_codec_info& mci);
static void ReleaseDecoder(BDecoder* decoder);
static status_t InstantiateWriter(BWriter** writer,
const media_file_format& mff,
BDataIO* target);
static void ReleaseWriter(BWriter* writer);
static status_t InstantiateEncoder(BEncoder** encoder,
const media_format& format);
static status_t InstantiateEncoder(BEncoder** encoder,
const media_codec_info* codecInfo,
uint32 flags);
static void ReleaseEncoder(BEncoder* encoder);
static status_t InstantiateStreamer(BStreamer** streamer,
BUrl url);
static void ReleaseStreamer(BStreamer* streamer);
static status_t GetDecoderInfo(BDecoder* decoder,
media_codec_info* info);
// The following API is from MediaFormats. The idea is to put
// there only the APIs really used in the BeOS/Haiku ecosystem
// so that we can discard unuseful code, thus reducing complexity.
// To choose the API I did a search among the Haiku codebase and
// programs for which we have the source available.
// TODO: media_format_family: really?
static status_t GetCodecInfo(media_codec_info* _codecInfo,
media_format_family* _formatFamily,
media_format* _inputFormat,
media_format* _outputFormat, int32 cookie);
//! Use this function to iterate through available file format writers.
static status_t GetNextFileFormat(int32* cookie, media_file_format* mff);
/*! \brief Use this to iterate through the available encoders for a given file
format.
\param cookie A pointer to a preallocated cookie, which you need
to initialize to \c 0 before calling this function
the first time.
\param fileFormat A pointer to a valid media_file_format structure
as can be obtained through get_next_file_format().
\param inputFormat This is the type of data given to the encoder.
\param _outputFormat This is the type of data the encoder will output.
\param _codecInfo Pointer to a preallocated media_codec_info structure,
information about the encoder is placed there.
\return
- \c B_OK: Everything went fine.
- \c B_BAD_INDEX: There are no more encoders.
*/
static status_t GetNextEncoder(int32* cookie, const media_file_format* fileFormat,
const media_format* inputFormat, media_format* _outputFormat,
media_codec_info* _codecInfo);
/*! \brief Use this to iterate through the available encoders with
restrictions to the input and output media_format while the
encoders can specialize wildcards in the media_formats.
\param cookie A pointer to a preallocated cookie, which you need
to initialize to \c 0 before calling this function
the first time.
\param fileFormat A pointer to a valid media_file_format structure
as can be obtained through get_next_file_format().
You can pass \c NULL if you don't care.
\param inputFormat This is the type of data given to the encoder,
wildcards are accepted.
\param outputFormat This is the type of data you want the encoder to
output. Wildcards are accepted.
\param _codecInfo Pointer to a preallocated media_codec_info structure,
information about the encoder is placed there.
\param _acceptedInputFormat This is the type of data that the encoder will
accept as input. Wildcards in \a inFormat will be
specialized here.
\param _acceptedOutputFormat This is the type of data that the encoder will
output. Wildcards in \a _outFormat will be specialized
here.
\return
- \c B_OK: Everything went fine.
- \c B_BAD_INDEX: There are no more encoders.
*/
static status_t GetNextEncoder(int32* cookie, const media_file_format* fileFormat,
const media_format* inputFormat, const media_format* outputFormat,
media_codec_info* _codecInfo, media_format* _acceptedInputFormat,
media_format* _acceptedOutputFormat);
/*! \brief Iterate over the all the available encoders without media_format
restrictions.
\param cookie A pointer to a preallocated cookie, which you need
to initialize to \c 0 before calling this function
the first time.
\param _codecInfo Pointer to a preallocated media_codec_info structure,
information about the encoder is placed there.
\return
- \c B_OK: Everything went fine.
- \c B_BAD_INDEX: There are no more encoders.
*/
static status_t GetNextEncoder(int32* cookie, media_codec_info* _codecInfo);
};
} // namespace BCodecKit
#endif // _CODEC_ROSTER_H
-94
View File
@@ -1,94 +0,0 @@
#ifndef _DECODER_PLUGIN_H
#define _DECODER_PLUGIN_H
#include <MediaTrack.h>
#include <MediaFormats.h>
#include "MediaPlugin.h"
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class BChunkProvider {
public:
BChunkProvider();
virtual ~BChunkProvider();
protected:
friend class BDecoder;
virtual status_t GetNextChunk(const void** chunkBuffer,
size_t* chunkSize,
media_header* mediaHeader) = 0;
};
class BDecoder {
public:
virtual void GetCodecInfo(media_codec_info* codecInfo) = 0;
// Setup get's called with the info data from Reader::GetStreamInfo
virtual status_t Setup(media_format* ioEncodedFormat,
const void* infoBuffer,
size_t infoSize) = 0;
virtual status_t NegotiateOutputFormat(
media_format* ioDecodedFormat) = 0;
virtual status_t SeekedTo(int64 frame, bigtime_t time) = 0;
virtual status_t Decode(void* buffer, int64* frameCount,
media_header* mediaHeader,
media_decode_info* info = 0) = 0;
status_t GetNextChunk(const void** chunkBuffer,
size_t* chunkSize,
media_header* mediaHeader);
void SetChunkProvider(BChunkProvider* provider);
virtual status_t Perform(perform_code code, void* data);
protected:
BDecoder();
virtual ~BDecoder();
private:
BChunkProvider* fChunkProvider;
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedDecoder1();
virtual void _ReservedDecoder2();
virtual void _ReservedDecoder3();
virtual void _ReservedDecoder4();
virtual void _ReservedDecoder5();
uint32 fReserved[5];
};
class BDecoderPlugin : public virtual BMediaPlugin {
public:
BDecoderPlugin();
virtual BDecoder* NewDecoder(uint index) = 0;
virtual status_t GetSupportedFormats(media_format** formats,
size_t* count) = 0;
};
} // namespace BCodecKit
#endif // _DECODER_PLUGIN_H
-148
View File
@@ -1,148 +0,0 @@
/*
* Copyright 2009-2015, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*/
#ifndef _ENCODER_PLUGIN_H
#define _ENCODER_PLUGIN_H
#include <MediaPlugin.h>
#include <MediaTrack.h>
#include <MediaFormats.h>
#include <View.h>
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class BChunkWriter {
public:
BChunkWriter();
virtual ~BChunkWriter();
protected:
friend class BEncoder;
virtual status_t WriteChunk(const void* chunkBuffer,
size_t chunkSize,
media_encode_info* encodeInfo) = 0;
};
class BEncoder {
public:
// 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;
virtual status_t AddTrackInfo(uint32 code, const void* data,
size_t size, uint32 flags = 0);
// Ownership of the BView and BParameterWeb remain with the Encoder.
// A window embedding the view must remove it before it is destroyed.
virtual BView* ParameterView();
virtual BParameterWeb* ParameterWeb();
virtual status_t GetParameterValue(int32 id, void* value,
size_t* size) const;
virtual status_t SetParameterValue(int32 id, const void* value,
size_t size);
virtual status_t GetEncodeParameters(
encode_parameters* parameters) const;
virtual status_t SetEncodeParameters(
encode_parameters* parameters);
virtual status_t Encode(const void* buffer, int64 frameCount,
media_encode_info* info) = 0;
status_t WriteChunk(const void* chunkBuffer,
size_t chunkSize,
media_encode_info* encodeInfo);
void SetChunkWriter(BChunkWriter* writer);
virtual status_t Perform(perform_code code, void* data);
protected:
BEncoder();
virtual ~BEncoder();
private:
BChunkWriter* fChunkWriter;
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedEncoder1();
virtual void _ReservedEncoder2();
virtual void _ReservedEncoder3();
virtual void _ReservedEncoder4();
virtual void _ReservedEncoder5();
virtual void _ReservedEncoder6();
virtual void _ReservedEncoder7();
virtual void _ReservedEncoder8();
virtual void _ReservedEncoder9();
virtual void _ReservedEncoder10();
virtual void _ReservedEncoder11();
virtual void _ReservedEncoder12();
virtual void _ReservedEncoder13();
virtual void _ReservedEncoder14();
virtual void _ReservedEncoder15();
virtual void _ReservedEncoder16();
virtual void _ReservedEncoder17();
virtual void _ReservedEncoder18();
virtual void _ReservedEncoder19();
virtual void _ReservedEncoder20();
// FBC padding
uint32 fReserved[20];
};
class BEncoderPlugin : public virtual BMediaPlugin {
public:
BEncoderPlugin();
virtual BEncoder* NewEncoder(
const media_codec_info& codecInfo) = 0;
virtual BEncoder* NewEncoder(
const media_format& format) = 0;
virtual status_t RegisterNextEncoder(int32* cookie,
media_codec_info* codecInfo,
media_format_family* formatFamily,
media_format* inputFormat,
media_format* outputFormat) = 0;
};
}
#endif // _ENCODER_PLUGIN_H
-92
View File
@@ -1,92 +0,0 @@
/*
* Copyright 2009-2010, Stephan Aßmus <[email protected]>. All rights reserved.
* Copyright 2009, Axel Dörfler, [email protected].
* Copyright 2008, Maurice Kalinowski. All rights reserved.
* Copyright 2004-2007, Marcus Overhagen. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
#ifndef _MEDIA_EXTRACTOR_H
#define _MEDIA_EXTRACTOR_H
#include <Decoder.h>
#include <MediaStreamer.h>
#include <Reader.h>
namespace BCodecKit {
struct stream_info;
class BMediaExtractor {
public:
BMediaExtractor(BDataIO* source, int32 flags);
// TODO
//BMediaExtractor(BMediaStreamer* streamer);
~BMediaExtractor();
status_t InitCheck() const;
BDataIO* Source() const;
void GetFileFormatInfo(
media_file_format* fileFormat) const;
status_t GetMetaData(BMetaData* data) const;
status_t GetStreamMetaData(int32 stream,
BMetaData* data) const;
int32 CountStreams() const;
const media_format* EncodedFormat(int32 stream);
int64 CountFrames(int32 stream) const;
bigtime_t Duration(int32 stream) const;
status_t Seek(int32 stream, uint32 seekTo,
int64* _frame, bigtime_t* _time);
status_t FindKeyFrame(int32 stream, uint32 seekTo,
int64* _frame, bigtime_t* _time) const;
status_t GetNextChunk(int32 stream,
const void** _chunkBuffer,
size_t* _chunkSize,
media_header* mediaHeader);
status_t CreateDecoder(int32 stream, BDecoder** _decoder,
media_codec_info* codecInfo);
// TODO: Explore if would be better to add a Start/Stop
// methods pair to MediaExtractor.
void StopProcessing();
private:
void _Init(BDataIO* source, int32 flags);
void _RecycleLastChunk(stream_info& info);
static int32 _ExtractorEntry(void* arg);
void _ExtractorThread();
status_t fInitStatus;
sem_id fExtractorWaitSem;
thread_id fExtractorThread;
BDataIO* fSource;
BReader* fReader;
stream_info* fStreamInfo;
int32 fStreamCount;
media_file_format fFileFormat;
uint32 fReserved[5];
};
} // namespace BCodecKit
#endif // _MEDIA_EXTRACTOR_H
-51
View File
@@ -1,51 +0,0 @@
/*
* Copyright 2016 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MEDIA_IO_H
#define _MEDIA_IO_H
#include <DataIO.h>
#include <SupportDefs.h>
namespace BCodecKit {
enum media_io_flags {
B_MEDIA_STREAMING = 0x00000001,
B_MEDIA_MUTABLE_SIZE = 0x00000002,
B_MEDIA_SEEK_FORWARD = 0x00000004,
B_MEDIA_SEEK_BACKWARD = 0x00000008,
B_MEDIA_SEEKABLE = B_MEDIA_SEEK_BACKWARD | B_MEDIA_SEEK_FORWARD
};
class BMediaIO : public BPositionIO {
public:
BMediaIO();
virtual ~BMediaIO();
virtual void GetFlags(int32* flags) const = 0;
private:
BMediaIO(const BMediaIO&);
BMediaIO& operator=(const BMediaIO&);
virtual void _ReservedMediaIO1();
virtual void _ReservedMediaIO2();
virtual void _ReservedMediaIO3();
virtual void _ReservedMediaIO4();
virtual void _ReservedMediaIO5();
uint32 _reserved[5];
};
} // namespace BCodecKit
#endif // _MEDIA_IO_H
-71
View File
@@ -1,71 +0,0 @@
/*
* Copyright 2003, Marcus Overhagen. All rights reserved.
* Copyright 2018, Dario Casalinuovo. All rights reserverd.
* Distributed under the terms of the MIT license.
*/
#ifndef _MEDIA_PLUGIN_H
#define _MEDIA_PLUGIN_H
#include <SupportDefs.h>
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
// TODO: Shouldn't this be a BReferenceable?
// TODO: This will replace BMediaAddOn in media2,
// see if we need some more accessor method and
// add the needed padding.
class BMediaPlugin {
public:
BMediaPlugin();
virtual ~BMediaPlugin();
private:
int32 fRefCount;
// needed for plug-in reference count management
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedMediaPlugin1();
virtual void _ReservedMediaPlugin2();
uint32 fReserved[5];
};
extern "C" BMediaPlugin* instantiate_plugin();
extern "C" uint32 get_plugin_version();
extern "C" const char* get_plugin_name();
#define B_CODEC_KIT_PLUGIN_VERSION 100
#define B_DECLARE_CODEC_KIT_PLUGIN(className, name, version) \
extern "C" { \
BCodecKit::BMediaPlugin* instantiate_plugin() \
{ \
return new(std::nothrow) className(); \
} \
\
uint32 get_plugin_version() \
{ \
return version; \
} \
\
const char* get_plugin_name() \
{ \
return name; \
} \
}
} // namespace BCodecKit
#endif // _MEDIA_PLUGIN_H
-61
View File
@@ -1,61 +0,0 @@
/*
* Copyright 2017, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MEDIA_STREAMER_H
#define _MEDIA_STREAMER_H
#include <MediaIO.h>
#include <Streamer.h>
#include <Url.h>
namespace BCodecKit {
class BMediaStreamer {
public:
BMediaStreamer(BUrl url);
~BMediaStreamer();
status_t InitCheck() const;
// TODO: So, it seems since this API was not public,
// the memory ownership is leaved to class users.
// See if this fits our plans, and eventually, move
// this memory management from BMediaFile to BMediaExtractor,
// BMediaWriter and BMediaStreamer.
BMediaIO* Adapter() const;
// TODO: Don't we need an open in the extractor and writer?
status_t Open();
void Close();
bool IsOpened() const;
//uint32 Capabilities() const;
//status_t GetMetaData(BMetaData* data) const;
//status_t SetHandler(BHandler* handler);
//BHandler* Handler() const;
void MouseMoved(uint32 x, uint32 y);
void MouseDown(uint32 x, uint32 y);
private:
BUrl fUrl;
BStreamer* fStreamer;
status_t fInitCheck;
bool fOpened;
// No virtual padding needed. Looks like a design decision.
// Let's respect that, for now.
// Same apply to MediaWriter and MediaExtractor.
uint32 fReserved[5];
};
} // namespace BCodecKit
#endif
-70
View File
@@ -1,70 +0,0 @@
/*
* Copyright 2009-2010, Stephan Aßmus <[email protected]>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _MEDIA_WRITER_H
#define _MEDIA_WRITER_H
#include <Encoder.h>
#include <MetaData.h>
#include <Writer.h>
#include "TList.h"
namespace BCodecKit {
class BMediaWriter {
public:
BMediaWriter(BDataIO* target,
const media_file_format& fileFormat);
~BMediaWriter();
status_t InitCheck() const;
BDataIO* Target() const;
void GetFileFormatInfo(media_file_format* mfi) const;
status_t CreateEncoder(BEncoder** _encoder,
const media_codec_info* codecInfo,
media_format* format, uint32 flags = 0);
// TODO: Why pointers? Just copy it
status_t SetMetaData(BMetaData* data);
status_t SetMetaData(int32 streamIndex,
BMetaData* data);
status_t CommitHeader();
status_t Flush();
status_t Close();
status_t AddTrackInfo(int32 streamIndex, uint32 code,
const void* data, size_t size,
uint32 flags = 0);
status_t WriteChunk(int32 streamIndex,
const void* chunkBuffer, size_t chunkSize,
media_encode_info* encodeInfo);
private:
struct StreamInfo {
void* cookie;
};
status_t fInitCheck;
BDataIO* fTarget;
BWriter* fWriter;
List<StreamInfo> fStreamInfos;
media_file_format fFileFormat;
uint32 fReserved[5];
};
} // namespace BCodecKit
#endif // _MEDIA_WRITER_H
-162
View File
@@ -1,162 +0,0 @@
/*
* Copyright 2018, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _META_DATA_H
#define _META_DATA_H
#include <Message.h>
namespace BCodecKit {
// Playback capabilities
extern const char* kCanPause; // bool
extern const char* kCanSeekBackward; // bool
extern const char* kCanSeekForward; // bool
extern const char* kCanSeek; // bool
// Bitrates
extern const char* kAudioBitRate; // uint32 (bps)
extern const char* kVideoBitRate; // uint32 (bps)
extern const char* kAudioSampleRate; // float (hz)
extern const char* kVideoFrameRate; // float (hz)
// RFC2046 and RFC4281
extern const char* kMimeType; // BString
extern const char* kAudioCodec; // BString
extern const char* kVideoCodec; // BString
extern const char* kVideoHeight; // uint32
extern const char* kVideoWidth; // uint32
extern const char* kNumTracks; // uint32
extern const char* kDrmCrippled; // bool
// Stuff needed to fully describe the BMediaFormat
// TODO: Shouldn't we just use MIME types for it?
extern const char* kMediaType; // media_type
// Audio stuff
extern const char* kChannelCount; // uint32
extern const char* kAudioFormat; // uint32
extern const char* kByteOrder; // uint32
extern const char* kBufferSize; // size_t
// Multiaudio
extern const char* kChannelMask; // size_t
// This is also BMediaFormat stuff, but mostly video
// NOTE: video width/height are defined as per RFC mentioned above
extern const char* kBytesPerRow; // uint32
extern const char* kPixelOffset; // uint32
extern const char* kLineOffset; // uint32
extern const char* kColorSpace; // color_space
extern const char* kOrientation; // uint32
extern const char* kVideoFrameSize; // uint32
extern const char* kEncoding; // uint32
// General use attributes
extern const char* kTitle; // BString
extern const char* kComment; // BString
extern const char* kCopyright; // BString
extern const char* kAlbum; // BString
extern const char* kArtist; // BString
extern const char* kAlbumArtist; // BString
extern const char* kAuthor; // BString
extern const char* kPerformer; // BString
extern const char* kComposer; // BString
extern const char* kGenre; // BString
extern const char* kYear; // BString
extern const char* kEncodedBy; // BString
extern const char* kLanguage; // BString
extern const char* kDisc; // BString
extern const char* kPublisher; // BString
extern const char* kEncoder; // BString
extern const char* kTrack;
extern const char* kDate; // BString
extern const char* kDuration; // uint32 (ms)
extern const char* kRating; // BString
// TODO: BBitmap? uint8 array? url?
//extern const char* kAlbumArt
extern const char* kCDTrackNum; // uint32
extern const char* kCDTrackMax; // uint32
extern const char* kChapter; // BMetaData
extern const char* kChapterStart; // uint64
extern const char* kChapterEnd; // uint64
// Others
extern const char* kProgramData; // BMetaData
// TODO: Fully honour this:
// https://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata
/**
* @brief BMetaData stores the media metadata.
*
* The metadata model is sparse and each key can occur at most once,
* except for BMetaData itself.
* The key is a const char and the value is the actual metadata.
* The client of this class is required to know in advance the type
* of a particular metadata key.
*/
class BMetaData {
public:
BMetaData();
BMetaData(const BMessage& msg);
virtual ~BMetaData();
// Woah. It seems we need BValue there.
bool SetString(const char* key, const BString& value);
bool SetBool(const char* key, bool value);
bool SetUInt32(const char* key, uint32 value);
bool SetUInt64(const char* key, uint64 value);
bool SetFloat(const char* key, float value);
bool GetString(const char* key, BString* value) const;
bool GetBool(const char* key, bool* value) const;
bool GetUInt32(const char* key, uint32* value) const;
bool GetUInt64(const char* key, uint64* value) const;
bool GetFloat(const char* key, float* value) const;
bool HasString(const char* key) const;
bool HasBool(const char* key) const;
bool HasUInt32(const char* key) const;
bool HasUInt64(const char* key) const;
bool HasFloat(const char* key) const;
// We allow embedding BMetaData into BMetaData. The BMetaData field
// is the only one allowed to have more occurrences for a single key
// so an index attribute is given for retrieving it.
bool AddMetaData(const char* key, BMetaData* data);
bool GetMetaData(const char* key, BMetaData* data,
uint32 index = 0);
bool HasMetaData(const char* key, uint32 index = 0);
bool RemoveMetaData(const char* key, uint32 index = 0);
bool RemoveValue(const char* key);
// Clean up all keys
void MakeEmpty();
bool IsEmpty();
// Retain ownership of the object, be careful with that
// that's why we need to introduce smart pointers!
const BMessage* Message();
BMetaData& operator=(const BMetaData& other);
BMetaData(const BMetaData&);
private:
// TODO: padding
BMessage* fMessage;
};
} // namespace BCodecKit
#endif // _META_DATA_H
-34
View File
@@ -1,34 +0,0 @@
#ifndef _RAW_FORMATS_H
#define _RAW_FORMATS_H
#include <MediaDefs.h>
// The raw audio format types defined here are only to be used by
// the media kit codec API, they are not supported for application
// use. Only the raw decoder does understand them, they are created
// by the file readers, like WAV or AIFF reader
// these values match those from media_raw_audio_format
// (type & B_AUDIO_FORMAT_SIZE_MASK) == sample size
enum {
B_AUDIO_FORMAT_UINT8 = 0x0011,
B_AUDIO_FORMAT_INT8 = 0x0001,
B_AUDIO_FORMAT_INT16 = 0x0002,
B_AUDIO_FORMAT_INT24 = 0x1003,
B_AUDIO_FORMAT_INT32 = 0x0004,
B_AUDIO_FORMAT_FLOAT32 = 0x0024,
B_AUDIO_FORMAT_FLOAT64 = 0x1008,
B_AUDIO_FORMAT_MASK = 0xffff,
B_AUDIO_FORMAT_SIZE_MASK = 0xf,
B_AUDIO_FORMAT_CHANNEL_ORDER_WAVE = 0x100000,
B_AUDIO_FORMAT_CHANNEL_ORDER_AIFF = 0x200000,
};
// FYI: A few channel orders for 6 channel audio...
// DTS channel order : C, FL, FR, SL, SR, LFE
// AAC channel order : C, FL, FR, SL, SR, LFE
// AC3 channel order : FL, C, FR, SL, SR, LFE
// wav channel order : FL, FR, C, LFE, SL, SR
// aiff channel order : FL, SL, C, FR, SR, LFE
#endif // _RAW_FORMATS_H
-89
View File
@@ -1,89 +0,0 @@
#ifndef _READER_PLUGIN_H
#define _READER_PLUGIN_H
#include <MediaTrack.h>
#include <MetaData.h>
#include "MediaPlugin.h"
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
enum {
B_MEDIA_SEEK_TO_TIME = 0x10000,
B_MEDIA_SEEK_TO_FRAME = 0x20000
};
class BReader {
public:
virtual status_t Sniff(int32* streamCount) = 0;
virtual void GetFileFormatInfo(media_file_format* mff) = 0;
virtual status_t GetMetaData(BMetaData* data);
virtual status_t GetStreamMetaData(void* cookie,
BMetaData* data);
virtual status_t AllocateCookie(int32 streamNumber,
void** cookie) = 0;
virtual status_t FreeCookie(void* cookie) = 0;
virtual status_t GetStreamInfo(void* cookie, int64* frameCount,
bigtime_t *duration, media_format* format,
const void** infoBuffer,
size_t* infoSize) = 0;
virtual status_t Seek(void* cookie, uint32 flags, int64* frame,
bigtime_t* time);
virtual status_t FindKeyFrame(void* cookie, uint32 flags,
int64* frame, bigtime_t* time);
virtual status_t GetNextChunk(void* cookie,
const void** chunkBuffer, size_t* chunkSize,
media_header* mediaHeader) = 0;
BDataIO* Source() const;
virtual status_t Perform(perform_code code, void* data);
protected:
BReader();
virtual ~BReader();
private:
void _Setup(BDataIO* source);
BDataIO* fSource;
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedReader1();
virtual void _ReservedReader2();
virtual void _ReservedReader3();
virtual void _ReservedReader4();
virtual void _ReservedReader5();
uint32 fReserved[5];
};
class BReaderPlugin : public virtual BMediaPlugin {
public:
virtual BReader* NewReader() = 0;
};
} // namespace BCodecKit
#endif // _READER_PLUGIN_H
-60
View File
@@ -1,60 +0,0 @@
/*
* Copyright 2017, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STREAMER_PLUGIN_H
#define _STREAMER_PLUGIN_H
#include <MediaIO.h>
#include <MediaPlugin.h>
#include <Url.h>
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class BStreamer {
public:
virtual status_t Sniff(const BUrl& url) = 0;
virtual BMediaIO* Adapter() const = 0;
// Base impl does nothing
virtual void MouseMoved(uint32 x, uint32 y);
virtual void MouseDown(uint32 x, uint32 y);
protected:
BStreamer();
virtual ~BStreamer();
private:
BMediaPlugin* fMediaPlugin;
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedStreamer1();
virtual void _ReservedStreamer2();
virtual void _ReservedStreamer3();
virtual void _ReservedStreamer4();
virtual void _ReservedStreamer5();
uint32 fReserved[5];
};
class BStreamerPlugin : public virtual BMediaPlugin {
public:
BStreamerPlugin();
virtual BStreamer* NewStreamer() = 0;
};
} // namespace BCodecKit
#endif // _STREAMER_PLUGIN_H
-83
View File
@@ -1,83 +0,0 @@
#ifndef _WRITER_PLUGIN_H
#define _WRITER_PLUGIN_H
#include <MetaData.h>
#include <MediaTrack.h>
#include "MediaPlugin.h"
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class BWriter {
public:
virtual status_t SetMetaData(BMetaData* data) = 0;
virtual status_t CommitHeader() = 0;
virtual status_t Flush() = 0;
virtual status_t Close() = 0;
virtual status_t AllocateCookie(void** cookie,
media_format* format,
const media_codec_info* codecInfo) = 0;
virtual status_t FreeCookie(void* cookie) = 0;
virtual status_t SetMetaData(void* cookie,
BMetaData* data) = 0;
virtual status_t AddTrackInfo(void* cookie, uint32 code,
const void* data, size_t size,
uint32 flags = 0) = 0;
virtual status_t WriteChunk(void* cookie,
const void* chunkBuffer, size_t chunkSize,
media_encode_info* encodeInfo) = 0;
BDataIO* Target() const;
virtual status_t Perform(perform_code code, void* data);
protected:
BWriter();
virtual ~BWriter();
virtual status_t Init(const media_file_format* fileFormat) = 0;
private:
void _Setup(BDataIO* target);
BDataIO* fTarget;
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class BCodecKit::BPrivate::PluginManager;
friend class BMediaWriter;
virtual void _ReservedWriter1();
virtual void _ReservedWriter2();
virtual void _ReservedWriter3();
virtual void _ReservedWriter4();
virtual void _ReservedWriter5();
uint32 fReserved[5];
};
class BWriterPlugin : public virtual BMediaPlugin {
public:
virtual BWriter* NewWriter() = 0;
virtual status_t GetSupportedFileFormats(
const media_file_format** _fileFormats,
size_t* _count) = 0;
};
} // namespace BCodecKit
#endif // _WRITER_PLUGIN_H
+11 -7
View File
@@ -1,14 +1,18 @@
#ifndef MEDIADECODER_H
#define MEDIADECODER_H
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace BCodecKit {
class BDecoder;
namespace BPrivate {
class Decoder;
}
namespace BPrivate {
namespace media {
class Decoder;
class DecoderPlugin;
}
}
class BMediaDecoder {
public:
@@ -43,8 +47,8 @@ class BMediaDecoder {
status_t AttachToDecoder();
BCodecKit::BDecoder* fDecoder;
status_t fInitStatus;
BPrivate::media::Decoder *fDecoder;
status_t fInitStatus;
/* fbc data and virtuals */
+8 -4
View File
@@ -8,11 +8,15 @@
#include <MediaFormats.h>
namespace BCodecKit {
class BEncoder;
namespace BPrivate {
namespace media {
class Encoder;
class EncoderPlugin;
}
}
using namespace BPrivate::media;
class BMediaEncoder {
public:
@@ -80,7 +84,7 @@ private:
void ReleaseEncoder();
uint32 _reserved_was_fEncoderMgr;
BCodecKit::BEncoder* fEncoder;
Encoder* fEncoder;
int32 fEncoderID;
bool fFormatValid;
+8 -9
View File
@@ -13,13 +13,12 @@
#include <StorageDefs.h>
namespace BCodecKit {
class BMediaExtractor;
class BMediaStreamer;
class BMediaWriter;
}
namespace BPrivate {
namespace media {
class MediaExtractor;
class MediaStreamer;
class MediaWriter;
}
class _AddonManager;
}
@@ -163,18 +162,18 @@ private:
status_t ControlFile(int32 selector, void* ioData,
size_t size);
BCodecKit::BMediaExtractor* fExtractor;
BPrivate::media::MediaExtractor* fExtractor;
int32 _reserved_BMediaFile_was_fExtractorID;
int32 fTrackNum;
status_t fErr;
BPrivate::_AddonManager* fEncoderMgr;
BPrivate::_AddonManager* fWriterMgr;
BCodecKit::BMediaWriter* fWriter;
BPrivate::media::MediaWriter* fWriter;
int32 fWriterID;
media_file_format fMFI;
BCodecKit::BMediaStreamer* fStreamer;
BPrivate::media::MediaStreamer* fStreamer;
bool fFileClosed;
bool fDeleteSource;
+13 -13
View File
@@ -9,12 +9,12 @@
#include <MediaFormats.h>
namespace BCodecKit {
class BDecoder;
class BEncoder;
class BMediaExtractor;
class BMediaWriter;
}
namespace BPrivate { namespace media {
class Decoder;
class Encoder;
class MediaExtractor;
class MediaWriter;
} }
class BMessage;
class BView;
@@ -219,12 +219,12 @@ private:
// For read-only access to a BMediaTrack
BMediaTrack(
BCodecKit::BMediaExtractor* extractor,
BPrivate::media::MediaExtractor* extractor,
int32 streamIndex);
// For write-only access to a BMediaTrack
BMediaTrack(
BCodecKit::BMediaWriter* writer,
BPrivate::media::MediaWriter* writer,
int32 streamIndex, media_format* format,
const media_codec_info* codecInfo);
@@ -235,9 +235,9 @@ private:
private:
status_t fInitStatus;
BCodecKit::BDecoder* fDecoder;
BCodecKit::BDecoder* fRawDecoder;
BCodecKit::BMediaExtractor* fExtractor;
BPrivate::media::Decoder* fDecoder;
BPrivate::media::Decoder* fRawDecoder;
BPrivate::media::MediaExtractor* fExtractor;
int32 fStream;
int64 fCurrentFrame;
@@ -245,9 +245,9 @@ private:
media_codec_info fCodecInfo;
BCodecKit::BEncoder* fEncoder;
BPrivate::media::Encoder* fEncoder;
int32 fEncoderID;
BCodecKit::BMediaWriter* fWriter;
BPrivate::media::MediaWriter* fWriter;
media_format fFormat;
uint32 fWorkaroundFlags;