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

View File

@ -201,8 +201,8 @@ rule ArchitectureSetup architecture
libraryGrist = $(architecture) ;
}
local i ;
for i in be bnetapi codec debug device game locale mail media midi
midi2 network package root screensaver textencoding tracker
for i in be bnetapi debug device game locale mail media midi midi2
network package root screensaver textencoding tracker
translation z {
local library = lib$(i).so ;
HAIKU_LIBRARY_NAME_MAP_$(architecture)_$(i)

View File

@ -436,9 +436,9 @@ rule FStandardOSHeaders
local osIncludes = add-ons add-ons/file_system add-ons/graphics
add-ons/input_server add-ons/registrar
add-ons/screen_saver
add-ons/tracker app codec device drivers game
interface kernel locale media mail midi midi2
net storage support translation ;
add-ons/tracker app device drivers game interface
kernel locale media mail midi midi2 net storage
support translation ;
return [ FDirName $(HAIKU_TOP) headers os ]
[ PublicHeaders $(osIncludes) ] ;
@ -450,9 +450,9 @@ rule FStandardHeaders architecture
local osIncludes = add-ons add-ons/file_system add-ons/graphics
add-ons/input_server add-ons/registrar
add-ons/screen_saver
add-ons/tracker app device drivers game codec
interface kernel locale media mail midi midi2
net storage support translation ;
add-ons/tracker app device drivers game interface
kernel locale media mail midi midi2 net storage
support translation ;
local headers = ;

View File

@ -73,7 +73,6 @@ rule HaikuImageGetSystemLibs
libalm.so
libbe.so libbsd.so libbnetapi.so
libbluetooth.so
libcodec.so
libdebug.so
libdebugger.so@primary
libdevice.so

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

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

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

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

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

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 */

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;

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;

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;

View File

@ -1,36 +1,28 @@
#ifndef _DECODER_PLUGIN_H
#define _DECODER_PLUGIN_H
#include <MediaTrack.h>
#include <MediaFormats.h>
#include "MediaPlugin.h"
namespace BCodecKit {
namespace BPrivate { namespace media {
namespace BPrivate {
class PluginManager;
}
class PluginManager;
class BChunkProvider {
class ChunkProvider {
public:
BChunkProvider();
virtual ~BChunkProvider();
protected:
friend class BDecoder;
virtual ~ChunkProvider() {};
virtual status_t GetNextChunk(const void** chunkBuffer,
size_t* chunkSize,
media_header* mediaHeader) = 0;
};
class BDecoder {
class Decoder {
public:
Decoder();
virtual ~Decoder();
virtual void GetCodecInfo(media_codec_info* codecInfo) = 0;
// Setup get's called with the info data from Reader::GetStreamInfo
@ -51,44 +43,38 @@ public:
size_t* chunkSize,
media_header* mediaHeader);
void SetChunkProvider(BChunkProvider* provider);
void SetChunkProvider(ChunkProvider* 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();
ChunkProvider* fChunkProvider;
// needed for plug-in reference count management
friend class PluginManager;
MediaPlugin* fMediaPlugin;
uint32 fReserved[5];
};
class BDecoderPlugin : public virtual BMediaPlugin {
class DecoderPlugin : public virtual MediaPlugin {
public:
BDecoderPlugin();
DecoderPlugin();
virtual BDecoder* NewDecoder(uint index) = 0;
virtual Decoder* NewDecoder(uint index) = 0;
virtual status_t GetSupportedFormats(media_format** formats,
size_t* count) = 0;
};
} } // namespace BPrivate::media
} // namespace BCodecKit
using namespace BPrivate::media;
#endif // _DECODER_PLUGIN_H

View File

@ -6,35 +6,30 @@
#define _ENCODER_PLUGIN_H
#include <MediaPlugin.h>
#include <MediaTrack.h>
#include <MediaFormats.h>
#include <View.h>
#include "MediaPlugin.h"
namespace BCodecKit {
namespace BPrivate { namespace media {
namespace BPrivate {
class PluginManager;
}
class PluginManager;
class BChunkWriter {
class ChunkWriter {
public:
BChunkWriter();
virtual ~BChunkWriter();
protected:
friend class BEncoder;
virtual ~ChunkWriter() {};
virtual status_t WriteChunk(const void* chunkBuffer,
size_t chunkSize,
media_encode_info* encodeInfo) = 0;
};
class BEncoder {
class Encoder {
public:
Encoder();
virtual ~Encoder();
// 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,
@ -82,21 +77,20 @@ public:
size_t chunkSize,
media_encode_info* encodeInfo);
void SetChunkWriter(BChunkWriter* writer);
void SetChunkWriter(ChunkWriter* writer);
virtual status_t Perform(perform_code code, void* data);
protected:
BEncoder();
virtual ~BEncoder();
private:
BChunkWriter* fChunkWriter;
BMediaPlugin* fMediaPlugin;
ChunkWriter* fChunkWriter;
// needed for plug-in reference count management
friend class BCodecKit::BPrivate::PluginManager;
friend class PluginManager;
MediaPlugin* fMediaPlugin;
private:
// FBC padding
uint32 fReserved[20];
virtual void _ReservedEncoder1();
virtual void _ReservedEncoder2();
@ -118,20 +112,17 @@ private:
virtual void _ReservedEncoder18();
virtual void _ReservedEncoder19();
virtual void _ReservedEncoder20();
// FBC padding
uint32 fReserved[20];
};
class BEncoderPlugin : public virtual BMediaPlugin {
class EncoderPlugin : public virtual MediaPlugin {
public:
BEncoderPlugin();
EncoderPlugin();
virtual BEncoder* NewEncoder(
virtual Encoder* NewEncoder(
const media_codec_info& codecInfo) = 0;
virtual BEncoder* NewEncoder(
virtual Encoder* NewEncoder(
const media_format& format) = 0;
virtual status_t RegisterNextEncoder(int32* cookie,
@ -141,8 +132,8 @@ public:
media_format* outputFormat) = 0;
};
} } // namespace BPrivate::media
}
using namespace BPrivate::media;
#endif // _ENCODER_PLUGIN_H

View File

@ -10,36 +10,47 @@
#define _MEDIA_EXTRACTOR_H
#include <Decoder.h>
#include <MediaStreamer.h>
#include <Reader.h>
#include "ReaderPlugin.h"
#include "DecoderPlugin.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
struct stream_info;
class ChunkCache;
struct chunk_buffer;
class BMediaExtractor {
struct stream_info {
status_t status;
void* cookie;
bool hasCookie;
const void* infoBuffer;
size_t infoBufferSize;
ChunkCache* chunkCache;
chunk_buffer* lastChunk;
media_format encodedFormat;
};
class MediaExtractor {
public:
BMediaExtractor(BDataIO* source, int32 flags);
// TODO
//BMediaExtractor(BMediaStreamer* streamer);
~BMediaExtractor();
MediaExtractor(BDataIO* source, int32 flags);
status_t InitCheck() const;
~MediaExtractor();
status_t InitCheck();
BDataIO* Source() const;
void GetFileFormatInfo(
media_file_format* fileFormat) const;
status_t GetMetaData(BMessage* _data) const;
status_t GetMetaData(BMetaData* data) const;
status_t GetStreamMetaData(int32 stream,
BMetaData* data) const;
int32 StreamCount();
int32 CountStreams() const;
const char* Copyright();
const media_format* EncodedFormat(int32 stream);
int64 CountFrames(int32 stream) const;
@ -55,13 +66,15 @@ public:
size_t* _chunkSize,
media_header* mediaHeader);
status_t CreateDecoder(int32 stream, BDecoder** _decoder,
status_t CreateDecoder(int32 stream, Decoder** _decoder,
media_codec_info* codecInfo);
// TODO: Explore if would be better to add a Start/Stop
// methods pair to MediaExtractor.
status_t GetStreamMetaData(int32 stream,
BMessage* _data) const;
void StopProcessing();
private:
void _Init(BDataIO* source, int32 flags);
@ -69,24 +82,24 @@ private:
static int32 _ExtractorEntry(void* arg);
void _ExtractorThread();
private:
status_t fInitStatus;
sem_id fExtractorWaitSem;
thread_id fExtractorThread;
BDataIO* fSource;
BReader* fReader;
Reader* fReader;
stream_info* fStreamInfo;
int32 fStreamCount;
media_file_format fFileFormat;
uint32 fReserved[5];
};
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit
using namespace BPrivate::media;
#endif // _MEDIA_EXTRACTOR_H

View File

@ -0,0 +1,33 @@
/*
* Copyright 2003, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT license.
*/
#ifndef _MEDIA_PLUGIN_H
#define _MEDIA_PLUGIN_H
#include <SupportDefs.h>
namespace BPrivate { namespace media {
class MediaPlugin {
public:
MediaPlugin();
virtual ~MediaPlugin();
private:
// needed for plug-in reference count management
friend class PluginManager;
int32 fRefCount;
};
class Decoder;
class Reader;
} } // namespace BPrivate::media
using namespace BPrivate::media;
extern "C" MediaPlugin* instantiate_plugin();
#endif // _MEDIA_PLUGIN_H

View File

@ -0,0 +1,36 @@
/*
* Copyright 2017, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MEDIA_STREAMER_H
#define _MEDIA_STREAMER_H
#include <Url.h>
#include "StreamerPlugin.h"
namespace BPrivate {
namespace media {
class MediaStreamer {
public:
MediaStreamer(BUrl url);
~MediaStreamer();
status_t CreateAdapter(BDataIO** adapter);
private:
BUrl fUrl;
Streamer* fStreamer;
};
}; // namespace media
}; // namespace BPrivate
using namespace BPrivate::media;
#endif

View File

@ -6,37 +6,34 @@
#define _MEDIA_WRITER_H
#include <Encoder.h>
#include <MetaData.h>
#include <Writer.h>
#include "EncoderPlugin.h"
#include "TList.h"
#include "WriterPlugin.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
class BMediaWriter {
class MediaWriter {
public:
BMediaWriter(BDataIO* target,
MediaWriter(BDataIO* target,
const media_file_format& fileFormat);
~BMediaWriter();
~MediaWriter();
status_t InitCheck() const;
status_t InitCheck();
BDataIO* Target() const;
void GetFileFormatInfo(media_file_format* mfi) const;
status_t CreateEncoder(BEncoder** _encoder,
status_t CreateEncoder(Encoder** _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 SetCopyright(int32 streamIndex,
const char* copyright);
status_t SetCopyright(const char* copyright);
status_t CommitHeader();
status_t Flush();
status_t Close();
@ -54,17 +51,20 @@ private:
void* cookie;
};
status_t fInitCheck;
private:
BDataIO* fTarget;
BWriter* fWriter;
List<StreamInfo> fStreamInfos;
media_file_format fFileFormat;
Writer* fWriter;
uint32 fReserved[5];
List<StreamInfo> fStreamInfos;
media_file_format fFileFormat;
};
} // namespace BCodecKit
}; // namespace media
}; // namespace BPrivate
using namespace BPrivate::media;
#endif // _MEDIA_WRITER_H

View File

@ -10,70 +10,68 @@
#include <string.h>
#include <Decoder.h>
#include <Encoder.h>
#include "DecoderPlugin.h"
#include "EncoderPlugin.h"
#include "ReaderPlugin.h"
#include "StreamerPlugin.h"
#include "WriterPlugin.h"
#include <TList.h>
#include <Locker.h>
#include <Reader.h>
#include <Streamer.h>
#include <Writer.h>
#include "TList.h"
namespace BCodecKit {
namespace BPrivate {
namespace BPrivate { namespace media {
class PluginManager {
public:
PluginManager();
~PluginManager();
BMediaPlugin* GetPlugin(const entry_ref& ref);
void PutPlugin(BMediaPlugin* plugin);
MediaPlugin* GetPlugin(const entry_ref& ref);
void PutPlugin(MediaPlugin* plugin);
// Readers and Decoders
status_t CreateReader(BReader** reader,
status_t CreateReader(Reader** reader,
int32* streamCount, media_file_format* mff,
BDataIO* source);
void DestroyReader(BReader* reader);
void DestroyReader(Reader* reader);
status_t CreateDecoder(BDecoder** decoder,
status_t CreateDecoder(Decoder** decoder,
const media_format& format);
status_t CreateDecoder(BDecoder** decoder,
status_t CreateDecoder(Decoder** decoder,
const media_codec_info& mci);
status_t GetDecoderInfo(BDecoder* decoder,
status_t GetDecoderInfo(Decoder* decoder,
media_codec_info* _info) const;
void DestroyDecoder(BDecoder* decoder);
void DestroyDecoder(Decoder* decoder);
// Writers and Encoders
status_t CreateWriter(BWriter** writer,
status_t CreateWriter(Writer** writer,
const media_file_format& mff,
BDataIO* target);
void DestroyWriter(BWriter* writer);
void DestroyWriter(Writer* writer);
status_t CreateEncoder(BEncoder** encoder,
status_t CreateEncoder(Encoder** encoder,
const media_codec_info* codecInfo,
uint32 flags);
status_t CreateEncoder(BEncoder** encoder,
status_t CreateEncoder(Encoder** encoder,
const media_format& format);
void DestroyEncoder(BEncoder* encoder);
void DestroyEncoder(Encoder* encoder);
status_t CreateStreamer(BStreamer** streamer,
BUrl url);
void DestroyStreamer(BStreamer* streamer);
status_t CreateStreamer(Streamer** streamer,
BUrl url, BDataIO** source);
void DestroyStreamer(Streamer* streamer);
private:
status_t _LoadPlugin(const entry_ref& ref,
BMediaPlugin** plugin, image_id* image);
MediaPlugin** plugin, image_id* image);
struct plugin_info {
char name[260];
int usecount;
BMediaPlugin* plugin;
MediaPlugin* plugin;
image_id image;
plugin_info& operator=(const plugin_info& other)
@ -90,11 +88,10 @@ private:
BLocker fLocker;
};
} } // namespace BPrivate::media
} } // namespace BCodecKit::BPrivate
extern BCodecKit::BPrivate::PluginManager gPluginManager;
using namespace BPrivate::media;
extern PluginManager gPluginManager;
#endif // _PLUGIN_MANAGER_H

View File

@ -1,35 +1,29 @@
#ifndef _READER_PLUGIN_H
#define _READER_PLUGIN_H
#include <MediaTrack.h>
#include <MetaData.h>
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class PluginManager;
enum {
B_MEDIA_SEEK_TO_TIME = 0x10000,
B_MEDIA_SEEK_TO_FRAME = 0x20000
};
class BReader {
class Reader {
public:
Reader();
virtual ~Reader();
virtual const char* Copyright() = 0;
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 GetMetaData(BMessage* _data);
virtual status_t AllocateCookie(int32 streamNumber,
void** cookie) = 0;
@ -49,41 +43,40 @@ public:
const void** chunkBuffer, size_t* chunkSize,
media_header* mediaHeader) = 0;
virtual status_t GetStreamMetaData(void* cookie,
BMessage* _data);
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();
public: // XXX for test programs only
void Setup(BDataIO* source);
BDataIO* fSource;
// needed for plug-in reference count management
friend class PluginManager;
MediaPlugin* fMediaPlugin;
uint32 fReserved[5];
};
class BReaderPlugin : public virtual BMediaPlugin {
class ReaderPlugin : public virtual MediaPlugin {
public:
virtual BReader* NewReader() = 0;
virtual Reader* NewReader() = 0;
};
} } // namespace BPrivate::media
} // namespace BCodecKit
using namespace BPrivate::media;
#endif // _READER_PLUGIN_H

View File

@ -0,0 +1,46 @@
#ifndef _STREAMER_PLUGIN_H
#define _STREAMER_PLUGIN_H
#include <MediaIO.h>
#include <MediaTrack.h>
#include <Url.h>
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
class PluginManager;
class Streamer {
public:
Streamer();
virtual ~Streamer();
virtual status_t Sniff(const BUrl& url, BDataIO** source) = 0;
private:
virtual void _ReservedStreamer1();
virtual void _ReservedStreamer2();
virtual void _ReservedStreamer3();
virtual void _ReservedStreamer4();
virtual void _ReservedStreamer5();
MediaPlugin* fMediaPlugin;
uint32 fReserved[5];
friend class PluginManager;
};
class StreamerPlugin : public virtual MediaPlugin {
public:
virtual Streamer* NewStreamer() = 0;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
#endif // _STREAMER_PLUGIN_H

View File

@ -1,22 +1,21 @@
#ifndef _WRITER_PLUGIN_H
#define _WRITER_PLUGIN_H
#include <MetaData.h>
#include <MediaTrack.h>
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
namespace BCodecKit {
class PluginManager;
namespace BPrivate {
class PluginManager;
}
class BWriter {
class Writer {
public:
virtual status_t SetMetaData(BMetaData* data) = 0;
Writer();
virtual ~Writer();
virtual status_t Init(const media_file_format* fileFormat) = 0;
virtual status_t SetCopyright(const char* copyright) = 0;
virtual status_t CommitHeader() = 0;
virtual status_t Flush() = 0;
virtual status_t Close() = 0;
@ -26,8 +25,8 @@ public:
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 SetCopyright(void* cookie,
const char* copyright) = 0;
virtual status_t AddTrackInfo(void* cookie, uint32 code,
const void* data, size_t size,
@ -41,43 +40,37 @@ public:
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();
public: // XXX for test programs only
void Setup(BDataIO* target);
BDataIO* fTarget;
// needed for plug-in reference count management
friend class PluginManager;
MediaPlugin* fMediaPlugin;
uint32 fReserved[5];
};
class BWriterPlugin : public virtual BMediaPlugin {
class WriterPlugin : public virtual MediaPlugin {
public:
virtual BWriter* NewWriter() = 0;
virtual Writer* NewWriter() = 0;
virtual status_t GetSupportedFileFormats(
const media_file_format** _fileFormats,
size_t* _count) = 0;
};
} } // namespace BPrivate::media
} // namespace BCodecKit
using namespace BPrivate::media;
#endif // _WRITER_PLUGIN_H

View File

@ -8,15 +8,10 @@
#include <MediaIO.h>
#include <OS.h>
#include <RWLocker.h>
#include <SupportDefs.h>
class RWLocker;
namespace BCodecKit {
class BAdapterIO;
class RelativePositionIO;
@ -100,8 +95,4 @@ private:
uint32 _reserved[5];
};
} // namespace BCodecKit
#endif // _ADAPTER_IO_H

View File

@ -10,9 +10,6 @@
#include <SupportDefs.h>
namespace BCodecKit {
enum media_io_flags {
B_MEDIA_STREAMING = 0x00000001,
@ -44,8 +41,4 @@ private:
uint32 _reserved[5];
};
} // namespace BCodecKit
#endif // _MEDIA_IO_H

View File

@ -2,8 +2,8 @@ SubDir HAIKU_TOP src add-ons media plugins ;
SubInclude HAIKU_TOP src add-ons media plugins ape_reader ;
SubInclude HAIKU_TOP src add-ons media plugins au_reader ;
SubInclude HAIKU_TOP src add-ons media plugins dvd_streamer ;
SubInclude HAIKU_TOP src add-ons media plugins ffmpeg ;
SubInclude HAIKU_TOP src add-ons media plugins dvd_streamer ;
SubInclude HAIKU_TOP src add-ons media plugins http_streamer ;
SubInclude HAIKU_TOP src add-ons media plugins raw_decoder ;
SubInclude HAIKU_TOP src add-ons media plugins rtsp_streamer ;

View File

@ -10,13 +10,6 @@
#include "MACLib.h"
B_DECLARE_CODEC_KIT_PLUGIN(
TAPEReaderPlugin,
"ape_reader",
B_CODEC_KIT_PLUGIN_VERSION
);
static const char* kCopyrightString
= "Copyright " B_UTF8_COPYRIGHT " 2005-2009 by SHINTA";
@ -280,8 +273,15 @@ TAPEReaderPlugin::~TAPEReaderPlugin()
}
BReader*
Reader*
TAPEReaderPlugin::NewReader()
{
return new TAPEReader();
}
MediaPlugin*
instantiate_plugin()
{
return new TAPEReaderPlugin();
}

View File

@ -6,9 +6,7 @@
#include "MonkeysAudioMIMEType.h"
#include "PositionBridgeIO.h"
#include "Reader.h" // Haiku private header
using namespace BCodecKit;
#include "ReaderPlugin.h" // Haiku private header
const int32 BLOCK_COUNT = 1024*4; // number of blocks, get from MACLib at once
@ -16,7 +14,7 @@ const int32 BUFFER_SIZE = 1024*4; // size of audio data passing to Media Kit
const int32 MEDIA_FILE_FORMAT_VERSION = 100; // media_file_format::version
class TAPEReader : public BReader
class TAPEReader : public Reader
{
public:
TAPEReader();
@ -45,7 +43,7 @@ public:
size_t* oChunkSize, media_header* oMediaHeader);
private:
typedef BReader SUPER;
typedef Reader SUPER;
bigtime_t CurrentTime() const;
status_t LoadAPECheck() const;
@ -64,14 +62,17 @@ private:
};
class TAPEReaderPlugin : public BReaderPlugin
class TAPEReaderPlugin : public ReaderPlugin
{
public:
TAPEReaderPlugin();
virtual ~TAPEReaderPlugin();
virtual BReader* NewReader();
virtual Reader* NewReader();
};
MediaPlugin* instantiate_plugin();
#endif // ___APEReader_H_

View File

@ -14,7 +14,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
Addon [ MultiArchDefaultGristFiles ape_reader ] :
APEReader.cpp
: [ MultiArchDefaultGristFiles libMonkeysAudio.a MAClib.a ]
be codec media [ TargetLibsupc++ ]
be media [ TargetLibsupc++ ]
;
}
}

View File

@ -15,8 +15,6 @@
#include "MediaDebug.h"
using namespace BCodecKit;
#define DVD_READ_CACHE 1
@ -194,7 +192,7 @@ DVDMediaIO::HandleDVDEvent(int event, int len)
dvdnav_highlight_event_t* highlight_event
= (dvdnav_highlight_event_t*) fBuffer;
TRACE("DVDMediaIO::HandleDVDEvent: Button: %d\n",
highlight_event->buttonN);
highlight_event->buttonN);
break;
}

View File

@ -13,10 +13,6 @@
#include <dvdnav/dvdnav.h>
using BCodecKit::BAdapterIO;
using BCodecKit::BInputAdapter;
class DVDMediaIO : public BAdapterIO
{
public:

View File

@ -28,35 +28,29 @@ DVDStreamer::~DVDStreamer()
status_t
DVDStreamer::Sniff(const BUrl& url)
DVDStreamer::Sniff(const BUrl& url, BDataIO** source)
{
BString path = url.UrlString();
BString protocol = url.Protocol();
if (protocol == "dvd") {
path = path.RemoveFirst("dvd://");
} else if (protocol == "file") {
path = path.RemoveFirst("file://");
path = path.RemoveFirst("file://");
} else
return B_UNSUPPORTED;
DVDMediaIO* adapter = new DVDMediaIO(path);
status_t ret = adapter->Open();
if (ret == B_OK) {
fAdapter = adapter;
*source = adapter;
return B_OK;
}
delete adapter;
return ret;
}
BMediaIO*
DVDStreamer::Adapter() const
{
return fAdapter;
return ret;
}
#if 0
void
DVDStreamer::MouseMoved(uint32 x, uint32 y)
{
@ -69,10 +63,18 @@ DVDStreamer::MouseDown(uint32 x, uint32 y)
{
fAdapter->MouseDown(x, y);
}
#endif
BStreamer*
Streamer*
DVDStreamerPlugin::NewStreamer()
{
return new DVDStreamer();
}
MediaPlugin*
instantiate_plugin()
{
return new DVDStreamerPlugin();
}

View File

@ -6,35 +6,27 @@
#define _DVD_STREAMER_PLUGIN_H
#include <Streamer.h>
#include "StreamerPlugin.h"
#include "DVDMediaIO.h"
using BCodecKit::BMediaIO;
using BCodecKit::BStreamer;
using BCodecKit::BStreamerPlugin;
class DVDStreamer : public BStreamer
class DVDStreamer : public Streamer
{
public:
DVDStreamer();
virtual ~DVDStreamer();
virtual status_t Sniff(const BUrl& url);
virtual BMediaIO* Adapter() const;
virtual status_t Sniff(const BUrl& url, BDataIO**);
#if 0
virtual void MouseMoved(uint32 x, uint32 y);
virtual void MouseDown(uint32 x, uint32 y);
private:
DVDMediaIO* fAdapter;
#endif
};
class DVDStreamerPlugin : public BStreamerPlugin {
class DVDStreamerPlugin : public StreamerPlugin
{
public:
virtual BStreamer* NewStreamer();
virtual Streamer* NewStreamer();
};

View File

@ -1,7 +1,7 @@
SubDir HAIKU_TOP src add-ons media plugins dvd_streamer ;
# For MediaDebug.h
UsePrivateHeaders media ;
UsePrivateHeaders media shared ;
UsePrivateHeaders [ FDirName media experimental ] ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
@ -25,7 +25,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
DVDMediaIO.cpp
:
[ BuildFeatureAttribute libdvdnav : libraries ]
be codec shared
be media shared
[ TargetLibstdc++ ] [ TargetLibsupc++ ]
;
}

View File

@ -13,11 +13,9 @@
//! libavcodec based decoder for Haiku
#include <Decoder.h>
#include <MediaFormats.h>
#include <Reader.h>
using namespace BCodecKit;
#include <MediaFormats.h>
extern "C" {
#include "avcodec.h"
@ -30,6 +28,10 @@ extern "C" {
#include "timestamp.h"
}
#include "DecoderPlugin.h"
#include "ReaderPlugin.h"
#include "CodecTable.h"
#include "gfx_util.h"
@ -44,7 +46,7 @@ extern "C" {
#endif
class AVCodecDecoder : public BDecoder {
class AVCodecDecoder : public Decoder {
public:
AVCodecDecoder();

View File

@ -39,7 +39,7 @@ static const size_t kDefaultChunkBufferSize = 2 * 1024 * 1024;
AVCodecEncoder::AVCodecEncoder(uint32 codecID, int bitRateScale)
:
BEncoder(),
Encoder(),
fBitRateScale(bitRateScale),
fCodecID((CodecID)codecID),
fCodec(NULL),

View File

@ -6,22 +6,21 @@
#define AVCODEC_ENCODER_H
#include <Encoder.h>
#include <MediaFormats.h>
using namespace BCodecKit;
extern "C" {
#include "avcodec.h"
#include "swscale.h"
#include "libavutil/fifo.h"
}
#include "EncoderPlugin.h"
typedef AVCodecID CodecID;
class AVCodecEncoder : public BEncoder {
class AVCodecEncoder : public Encoder {
public:
AVCodecEncoder(uint32 codecID,
int bitRateScale);

View File

@ -58,7 +58,7 @@ avformat_to_beos_byte_order(AVSampleFormat format)
static void
avdictionary_to_message(AVDictionary* dictionary, BMetaData* data)
avdictionary_to_message(AVDictionary* dictionary, BMessage* message)
{
if (dictionary == NULL)
return;
@ -69,45 +69,45 @@ avdictionary_to_message(AVDictionary* dictionary, BMetaData* data)
// convert entry keys into something more meaningful using the names from
// id3v2.c
if (strcmp(entry->key, "TALB") == 0 || strcmp(entry->key, "TAL") == 0)
data->SetString(kAlbum, entry->value);
message->AddString("album", entry->value);
else if (strcmp(entry->key, "TCOM") == 0)
data->SetString(kComposer, entry->value);
message->AddString("composer", entry->value);
else if (strcmp(entry->key, "TCON") == 0 || strcmp(entry->key, "TCO") == 0)
data->SetString(kGenre, entry->value);
message->AddString("genre", entry->value);
else if (strcmp(entry->key, "TCOP") == 0)
data->SetString(kCopyright, entry->value);
message->AddString("copyright", entry->value);
else if (strcmp(entry->key, "TDRL") == 0 || strcmp(entry->key, "TDRC") == 0)
data->SetString(kDate, entry->value);
message->AddString("date", entry->value);
else if (strcmp(entry->key, "TENC") == 0 || strcmp(entry->key, "TEN") == 0)
data->SetString(kEncodedBy, entry->value);
message->AddString("encoded_by", entry->value);
else if (strcmp(entry->key, "TIT2") == 0 || strcmp(entry->key, "TT2") == 0)
data->SetString(kTitle, entry->value);
message->AddString("title", entry->value);
else if (strcmp(entry->key, "TLAN") == 0)
data->SetString(kLanguage, entry->value);
message->AddString("language", entry->value);
else if (strcmp(entry->key, "TPE1") == 0 || strcmp(entry->key, "TP1") == 0)
data->SetString(kArtist, entry->value);
message->AddString("artist", entry->value);
else if (strcmp(entry->key, "TPE2") == 0 || strcmp(entry->key, "TP2") == 0)
data->SetString(kAlbumArtist, entry->value);
message->AddString("album_artist", entry->value);
else if (strcmp(entry->key, "TPE3") == 0 || strcmp(entry->key, "TP3") == 0)
data->SetString(kPerformer, entry->value);
message->AddString("performer", entry->value);
else if (strcmp(entry->key, "TPOS") == 0)
data->SetString(kDisc, entry->value);
message->AddString("disc", entry->value);
else if (strcmp(entry->key, "TPUB") == 0)
data->SetString(kPublisher, entry->value);
message->AddString("publisher", entry->value);
else if (strcmp(entry->key, "TRCK") == 0 || strcmp(entry->key, "TRK") == 0)
data->SetString(kTrack, entry->value);
message->AddString("track", entry->value);
else if (strcmp(entry->key, "TSOA") == 0)
data->SetString("album-sort", entry->value);
message->AddString("album-sort", entry->value);
else if (strcmp(entry->key, "TSOP") == 0)
data->SetString("artist-sort", entry->value);
message->AddString("artist-sort", entry->value);
else if (strcmp(entry->key, "TSOT") == 0)
data->SetString("title-sort", entry->value);
message->AddString("title-sort", entry->value);
else if (strcmp(entry->key, "TSSE") == 0)
data->SetString(kEncoder, entry->value);
message->AddString("encoder", entry->value);
else if (strcmp(entry->key, "TYER") == 0)
data->SetString(kYear, entry->value);
message->AddString("year", entry->value);
else
data->SetString(entry->key, entry->value);
message->AddString(entry->key, entry->value);
}
}
@ -900,7 +900,7 @@ public:
// This will also initialize the media_format.
virtual status_t Init(int32 streamIndex);
status_t GetMetaData(BMetaData* data);
status_t GetMetaData(BMessage* data);
// Support for AVFormatReader
status_t GetStreamInfo(int64* frameCount,
@ -1181,7 +1181,7 @@ AVFormatReader::Stream::Init(int32 virtualIndex)
status_t
AVFormatReader::Stream::GetMetaData(BMetaData* data)
AVFormatReader::Stream::GetMetaData(BMessage* data)
{
BAutolock _(&fLock);
@ -1441,6 +1441,18 @@ AVFormatReader::~AVFormatReader()
// #pragma mark -
const char*
AVFormatReader::Copyright()
{
if (fCopyright.Length() <= 0) {
BMessage message;
if (GetMetaData(&message) == B_OK)
message.FindString("copyright", &fCopyright);
}
return fCopyright.String();
}
status_t
AVFormatReader::Sniff(int32* _streamCount)
{
@ -1563,7 +1575,7 @@ AVFormatReader::GetFileFormatInfo(media_file_format* mff)
status_t
AVFormatReader::GetMetaData(BMetaData* data)
AVFormatReader::GetMetaData(BMessage* _data)
{
// The first cookie is always there!
const AVFormatContext* context = fStreams[0]->Context();
@ -1571,28 +1583,28 @@ AVFormatReader::GetMetaData(BMetaData* data)
if (context == NULL)
return B_NO_INIT;
avdictionary_to_message(context->metadata, data);
avdictionary_to_message(context->metadata, _data);
// Add chapter info
for (unsigned i = 0; i < context->nb_chapters; i++) {
AVChapter* chapter = context->chapters[i];
BMetaData chapterData;
chapterData.SetUInt64(kChapterStart, bigtime_t(1000000.0
BMessage chapterData;
chapterData.AddInt64("start", bigtime_t(1000000.0
* chapter->start * chapter->time_base.num
/ chapter->time_base.den + 0.5));
chapterData.SetUInt64(kChapterEnd, bigtime_t(1000000.0
chapterData.AddInt64("end", bigtime_t(1000000.0
* chapter->end * chapter->time_base.num
/ chapter->time_base.den + 0.5));
avdictionary_to_message(chapter->metadata, &chapterData);
data->AddMetaData(kChapter, &chapterData);
_data->AddMessage("be:chapter", &chapterData);
}
// Add program info
for (unsigned i = 0; i < context->nb_programs; i++) {
BMetaData programData;
BMessage programData;
avdictionary_to_message(context->programs[i]->metadata, &programData);
data->AddMetaData(kProgramData, &programData);
_data->AddMessage("be:program", &programData);
}
return B_OK;
@ -1691,10 +1703,10 @@ AVFormatReader::GetStreamInfo(void* _cookie, int64* frameCount,
status_t
AVFormatReader::GetStreamMetaData(void* _cookie, BMetaData* data)
AVFormatReader::GetStreamMetaData(void* _cookie, BMessage* _data)
{
Stream* cookie = reinterpret_cast<Stream*>(_cookie);
return cookie->GetMetaData(data);
return cookie->GetMetaData(_data);
}

View File

@ -6,22 +6,23 @@
#define AV_FORMAT_READER_H
#include <Reader.h>
#include <Locker.h>
#include <String.h>
using namespace BCodecKit;
#include "ReaderPlugin.h"
class AVFormatReader : public BReader {
class AVFormatReader : public Reader {
public:
AVFormatReader();
~AVFormatReader();
virtual const char* Copyright();
virtual status_t Sniff(int32* streamCount);
virtual void GetFileFormatInfo(media_file_format* mff);
virtual status_t GetMetaData(BMetaData* data);
virtual status_t GetMetaData(BMessage* _data);
virtual status_t AllocateCookie(int32 streamNumber,
void** cookie);
@ -33,7 +34,7 @@ public:
size_t* infoSize);
virtual status_t GetStreamMetaData(void* cookie,
BMetaData* data);
BMessage* _data);
virtual status_t Seek(void* cookie, uint32 flags, int64* frame,
bigtime_t* time);

View File

@ -425,7 +425,7 @@ AVFormatWriter::Init(const media_file_format* fileFormat)
status_t
AVFormatWriter::SetMetaData(BMetaData* data)
AVFormatWriter::SetCopyright(const char* copyright)
{
TRACE("AVFormatWriter::SetCopyright(%s)\n", copyright);
@ -541,9 +541,9 @@ AVFormatWriter::FreeCookie(void* _cookie)
status_t
AVFormatWriter::SetMetaData(void* cookie, BMetaData* data)
AVFormatWriter::SetCopyright(void* cookie, const char* copyright)
{
TRACE("AVFormatWriter::SetMetaData(%p)\n", cookie);
TRACE("AVFormatWriter::SetCopyright(%p, %s)\n", cookie, copyright);
return B_NOT_SUPPORTED;
}
@ -590,7 +590,7 @@ AVFormatWriter::_Write(void* cookie, uint8* buffer, int bufferSize)
AVFormatWriter* writer = reinterpret_cast<AVFormatWriter*>(cookie);
ssize_t written = writer->Target()->Write(buffer, bufferSize);
ssize_t written = writer->fTarget->Write(buffer, bufferSize);
TRACE_IO(" written: %ld\n", written);
return (int)written;
@ -606,7 +606,7 @@ AVFormatWriter::_Seek(void* cookie, off_t offset, int whence)
AVFormatWriter* writer = reinterpret_cast<AVFormatWriter*>(cookie);
BMediaIO* mediaIO = dynamic_cast<BMediaIO*>(writer->Target());
BMediaIO* mediaIO = dynamic_cast<BMediaIO*>(writer->fTarget);
if (mediaIO == NULL)
return -1;

View File

@ -6,25 +6,23 @@
#define AV_FORMAT_WRITER_H
#include <Writer.h>
#include <Locker.h>
using namespace BCodecKit;
#include "WriterPlugin.h"
extern "C" {
#include "avformat.h"
}
class AVFormatWriter : public BWriter {
class AVFormatWriter : public Writer {
public:
AVFormatWriter();
~AVFormatWriter();
virtual status_t Init(const media_file_format* fileFormat);
virtual status_t SetMetaData(BMetaData* data);
virtual status_t SetCopyright(const char* copyright);
virtual status_t CommitHeader();
virtual status_t Flush();
virtual status_t Close();
@ -34,8 +32,8 @@ public:
const media_codec_info* codecInfo);
virtual status_t FreeCookie(void* cookie);
virtual status_t SetMetaData(void* cookie,
BMetaData* data);
virtual status_t SetCopyright(void* cookie,
const char* copyright);
virtual status_t AddTrackInfo(void* cookie, uint32 code,
const void* data, size_t size,

View File

@ -4,7 +4,6 @@
* Copyright (C) 2001 Axel Dörfler
* Copyright (C) 2004 Marcus Overhagen
* Copyright (C) 2009 Stephan Aßmus <superstippi@gmx.de>
* Copyright (C) 2018 Dario Casalinuovo
*
* All rights reserved. Distributed under the terms of the MIT License.
*/
@ -41,17 +40,10 @@ extern "C" {
#define ERROR(a...) fprintf(stderr, a)
B_DECLARE_CODEC_KIT_PLUGIN(
FFmpegPlugin,
"ffmpeg",
B_CODEC_KIT_PLUGIN_VERSION
);
// #pragma mark -
BDecoder*
Decoder*
FFmpegPlugin::NewDecoder(uint index)
{
// TODO: Confirm we can check index here.
@ -61,7 +53,7 @@ FFmpegPlugin::NewDecoder(uint index)
}
BReader*
Reader*
FFmpegPlugin::NewReader()
{
return new(std::nothrow) AVFormatReader();
@ -75,7 +67,7 @@ FFmpegPlugin::GetSupportedFormats(media_format** _formats, size_t* _count)
}
BWriter*
Writer*
FFmpegPlugin::NewWriter()
{
return new(std::nothrow) AVFormatWriter();
@ -92,7 +84,7 @@ FFmpegPlugin::GetSupportedFileFormats(const media_file_format** _fileFormats,
}
BEncoder*
Encoder*
FFmpegPlugin::NewEncoder(const media_codec_info& codecInfo)
{
for (size_t i = 0; i < gEncoderCount; i++) {
@ -105,7 +97,7 @@ FFmpegPlugin::NewEncoder(const media_codec_info& codecInfo)
}
BEncoder*
Encoder*
FFmpegPlugin::NewEncoder(const media_format& format)
{
for (size_t i = 0; i < gEncoderCount; i++) {
@ -136,3 +128,14 @@ FFmpegPlugin::RegisterNextEncoder(int32* cookie, media_codec_info* _codecInfo,
return B_OK;
}
// #pragma mark -
MediaPlugin*
instantiate_plugin()
{
return new(std::nothrow) FFmpegPlugin;
}

View File

@ -12,32 +12,30 @@
#include <MediaFormats.h>
#include <Decoder.h>
#include <Encoder.h>
#include <Reader.h>
#include <Writer.h>
using namespace BCodecKit;
#include "DecoderPlugin.h"
#include "EncoderPlugin.h"
#include "ReaderPlugin.h"
#include "WriterPlugin.h"
class FFmpegPlugin : public BReaderPlugin, public BDecoderPlugin,
public BWriterPlugin, public BEncoderPlugin {
class FFmpegPlugin : public ReaderPlugin, public DecoderPlugin,
public WriterPlugin, public EncoderPlugin {
public:
virtual BReader* NewReader();
virtual Reader* NewReader();
virtual BDecoder* NewDecoder(uint index);
virtual Decoder* NewDecoder(uint index);
virtual status_t GetSupportedFormats(media_format** _formats,
size_t* _count);
virtual BWriter* NewWriter();
virtual Writer* NewWriter();
virtual status_t GetSupportedFileFormats(
const media_file_format** _fileFormats,
size_t* _count);
virtual BEncoder* NewEncoder(
virtual Encoder* NewEncoder(
const media_codec_info& codecInfo);
virtual BEncoder* NewEncoder(const media_format& format);
virtual Encoder* NewEncoder(const media_format& format);
virtual status_t RegisterNextEncoder(int32* cookie,
media_codec_info* codecInfo,

View File

@ -1,6 +1,7 @@
SubDir HAIKU_TOP src add-ons media plugins ffmpeg ;
UsePrivateHeaders shared ;
UsePrivateHeaders media shared ;
UsePrivateHeaders [ FDirName media experimental ] ;
SubDirC++Flags -D__STDC_CONSTANT_MACROS -Wdeprecated ;
@ -55,7 +56,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
be
media
codec
[ TargetLibsupc++ ]
;
}

View File

@ -10,9 +10,7 @@
#include <HttpRequest.h>
#include <UrlProtocolRoster.h>
#include "MediaDebug.h"
using namespace BCodecKit;
#include "debug.h"
// 10 seconds timeout

View File

@ -12,9 +12,6 @@
#include <UrlContext.h>
#include <UrlProtocolAsynchronousListener.h>
using BCodecKit::BAdapterIO;
using BCodecKit::BInputAdapter;
class FileListener;

View File

@ -1,19 +1,14 @@
/*
* Copyright 2016-2018, Dario Casalinuovo
* Copyright 2016, Dario Casalinuovo
* Distributed under the terms of the MIT License.
*/
#include "HTTPStreamerPlugin.h"
#include "MediaDebug.h"
#include "HTTPMediaIO.h"
B_DECLARE_CODEC_KIT_PLUGIN(
HTTPStreamerPlugin,
"http_streamer",
B_CODEC_KIT_PLUGIN_VERSION
);
#include "debug.h"
HTTPStreamer::HTTPStreamer()
@ -29,31 +24,30 @@ HTTPStreamer::~HTTPStreamer()
status_t
HTTPStreamer::Sniff(const BUrl& url)
HTTPStreamer::Sniff(const BUrl& url, BDataIO** source)
{
CALLED();
HTTPMediaIO* adapter = new HTTPMediaIO(url);
HTTPMediaIO* outSource = new HTTPMediaIO(url);
status_t ret = adapter->Open();
status_t ret = outSource->Open();
if (ret == B_OK) {
fAdapter = adapter;
*source = outSource;
return B_OK;
}
delete adapter;
delete outSource;
return ret;
}
BMediaIO*
HTTPStreamer::Adapter() const
{
return fAdapter;
}
BStreamer*
Streamer*
HTTPStreamerPlugin::NewStreamer()
{
return new HTTPStreamer();
}
MediaPlugin *instantiate_plugin()
{
return new HTTPStreamerPlugin();
}

View File

@ -6,34 +6,22 @@
#define _HTTP_STREAMER_PLUGIN_H
#include <Streamer.h>
#include "StreamerPlugin.h"
#include "HTTPMediaIO.h"
using BCodecKit::BMediaIO;
using BCodecKit::BMediaPlugin;
using BCodecKit::BStreamer;
using BCodecKit::BStreamerPlugin;
class HTTPStreamer : public BStreamer
class HTTPStreamer : public Streamer
{
public:
HTTPStreamer();
virtual ~HTTPStreamer();
virtual status_t Sniff(const BUrl& url);
virtual BMediaIO* Adapter() const;
private:
HTTPMediaIO* fAdapter;
virtual status_t Sniff(const BUrl& url, BDataIO** source);
};
class HTTPStreamerPlugin : public BStreamerPlugin
class HTTPStreamerPlugin : public StreamerPlugin
{
public:
virtual BStreamer* NewStreamer();
virtual Streamer* NewStreamer();
};
#endif // _HTTP_STREAMER_PLUGIN_H

View File

@ -1,6 +1,7 @@
SubDir HAIKU_TOP src add-ons media plugins http_streamer ;
UsePrivateHeaders media ;
UsePrivateHeaders media shared ;
UsePrivateHeaders [ FDirName media experimental ] ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
@ -8,7 +9,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
Addon [ MultiArchDefaultGristFiles http_streamer ] :
HTTPStreamerPlugin.cpp
HTTPMediaIO.cpp
: be codec media bnetapi shared
: be media bnetapi shared
[ TargetLibsupc++ ]
;
}

View File

@ -8,7 +8,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
Addon [ MultiArchDefaultGristFiles raw_decoder ] :
AudioConversion.cpp
RawDecoderPlugin.cpp
: be codec media [ TargetLibsupc++ ]
: be media [ TargetLibsupc++ ]
;
}
}

View File

@ -27,7 +27,7 @@
#include <DataIO.h>
#include <OS.h>
#include <MediaRoster.h>
#include <Reader.h>
#include <ReaderPlugin.h>
#include "RawFormats.h"
#include "RawDecoderPlugin.h"
@ -40,14 +40,6 @@
#define TRACE(a...)
#endif
B_DECLARE_CODEC_KIT_PLUGIN(
RawDecoderPlugin,
"raw_decoder",
B_CODEC_KIT_PLUGIN_VERSION
);
inline size_t
AudioBufferSize(int32 channel_count, uint32 sample_format, float frame_rate, bigtime_t buffer_duration = 50000 /* 50 ms */)
{
@ -528,7 +520,7 @@ RawDecoder::Decode(void *buffer, int64 *frameCount,
}
BDecoder *
Decoder *
RawDecoderPlugin::NewDecoder(uint index)
{
return new RawDecoder;
@ -572,3 +564,8 @@ RawDecoderPlugin::GetSupportedFormats(media_format ** formats, size_t * count)
return B_OK;
}
MediaPlugin *instantiate_plugin()
{
return new RawDecoderPlugin;
}

View File

@ -25,14 +25,9 @@
#ifndef _RAW_DECODER_PLUGIN_H
#define _RAW_DECODER_PLUGIN_H
#include <Decoder.h>
#include "DecoderPlugin.h"
using BCodecKit::BMediaPlugin;
using BCodecKit::BDecoder;
using BCodecKit::BDecoderPlugin;
class RawDecoder : public BDecoder
class RawDecoder : public Decoder
{
public:
void GetCodecInfo(media_codec_info *info);
@ -71,10 +66,10 @@ private:
};
class RawDecoderPlugin : public BDecoderPlugin
class RawDecoderPlugin : public DecoderPlugin
{
public:
BDecoder * NewDecoder(uint index);
Decoder * NewDecoder(uint index);
status_t GetSupportedFormats(media_format ** formats, size_t * count);
};

View File

@ -1,5 +1,8 @@
SubDir HAIKU_TOP src add-ons media plugins rtsp_streamer ;
UsePrivateHeaders media shared ;
UsePrivateHeaders [ FDirName media experimental ] ;
# TODO: Investigate this
SubDirC++Flags -w ;
@ -21,7 +24,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
rtsp.cpp
:
[ BuildFeatureAttribute live555 : libraries ]
be codec network shared
be media network bnetapi shared
[ TargetLibstdc++ ] [ TargetLibsupc++ ]
;
}

View File

@ -10,9 +10,6 @@
#define LIVE555_VERBOSITY 1
using namespace BCodecKit;
RTSPMediaIO::RTSPMediaIO(BUrl ourUrl)
:
BAdapterIO(

View File

@ -11,8 +11,6 @@
#include "rtsp.h"
using BCodecKit::BAdapterIO;
using BCodecKit::BInputAdapter;
class HaikuRTSPClient;

View File

@ -1,23 +1,10 @@
/*
* Copyright 2016-2019, Dario Casalinuovo
* Distributed under the terms of the MIT License.
*/
#include "RTSPStreamerPlugin.h"
#include "RTSPMediaIO.h"
B_DECLARE_CODEC_KIT_PLUGIN(
RTSPStreamerPlugin,
"rtsp_streamer",
B_CODEC_KIT_PLUGIN_VERSION
);
RTSPStreamer::RTSPStreamer()
:
BStreamer()
{
}
@ -41,8 +28,14 @@ RTSPStreamer::Sniff(const BUrl& url, BDataIO** source)
}
BStreamer*
Streamer*
RTSPStreamerPlugin::NewStreamer()
{
return new RTSPStreamer();
}
MediaPlugin *instantiate_plugin()
{
return new RTSPStreamerPlugin();
}

View File

@ -1,17 +1,9 @@
/*
* Copyright 2016-2019, Dario Casalinuovo
* Distributed under the terms of the MIT License.
*/
#ifndef _RTSP_STREAMER_PLUGIN_H
#define _RTSP_STREAMER_PLUGIN_H
#include <Streamer.h>
#include "StreamerPlugin.h"
using BCodecKit::BStreamer;
using BCodecKit::BStreamerPlugin;
class RTSPStreamer : public BStreamer
class RTSPStreamer : public Streamer
{
public:
RTSPStreamer();
@ -21,9 +13,9 @@ public:
};
class RTSPStreamerPlugin : public BStreamerPlugin {
class RTSPStreamerPlugin : public StreamerPlugin {
public:
virtual BStreamer* NewStreamer();
virtual Streamer* NewStreamer();
};
#endif // _RTSP_STREAMER_PLUGIN_H

View File

@ -12,8 +12,7 @@
#include <assert.h>
#include <stdio.h>
#include <MediaDebug.h>
#include <debug.h>
#ifdef DEBUG
#define DELAYED_MODE 1

View File

@ -106,7 +106,6 @@ DoCatalogs libbe.so
SubInclude HAIKU_TOP src kits app ;
SubInclude HAIKU_TOP src kits bluetooth ;
SubInclude HAIKU_TOP src kits codec ;
SubInclude HAIKU_TOP src kits debug ;
SubInclude HAIKU_TOP src kits debugger ;
SubInclude HAIKU_TOP src kits device ;

View File

@ -1,271 +0,0 @@
/*
* Copyright 2018, Dario Casalinuovo. All rights reserved.
* Copyright 2004-2009, The Haiku Project. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler
* Marcus Overhagen
*/
#include <CodecRoster.h>
#include <MediaFormats.h>
#include "AddOnManager.h"
#include "FormatManager.h"
#include "PluginManager.h"
namespace BCodecKit {
status_t
BCodecRoster::InstantiateReader(BReader** reader, int32* streamCount,
media_file_format* mff, BDataIO* source)
{
return gPluginManager.CreateReader(reader, streamCount, mff, source);
}
void
BCodecRoster::ReleaseReader(BReader* reader)
{
return gPluginManager.DestroyReader(reader);
}
status_t
BCodecRoster::InstantiateDecoder(BDecoder** decoder, const media_format& format)
{
return gPluginManager.CreateDecoder(decoder, format);
}
status_t
BCodecRoster::InstantiateDecoder(BDecoder** decoder, const media_codec_info& mci)
{
return gPluginManager.CreateDecoder(decoder, mci);
}
void
BCodecRoster::ReleaseDecoder(BDecoder* decoder)
{
return gPluginManager.DestroyDecoder(decoder);
}
status_t
BCodecRoster::GetDecoderInfo(BDecoder* decoder, media_codec_info* info)
{
return gPluginManager.GetDecoderInfo(decoder, info);
}
status_t
BCodecRoster::InstantiateWriter(BWriter** writer, const media_file_format& mff,
BDataIO* target)
{
return gPluginManager.CreateWriter(writer, mff, target);
}
void
BCodecRoster::ReleaseWriter(BWriter* writer)
{
return gPluginManager.DestroyWriter(writer);
}
status_t
BCodecRoster::InstantiateEncoder(BEncoder** encoder, const media_format& format)
{
return gPluginManager.CreateEncoder(encoder, format);
}
status_t
BCodecRoster::InstantiateEncoder(BEncoder** encoder,
const media_codec_info* codecInfo, uint32 flags)
{
return gPluginManager.CreateEncoder(encoder, codecInfo, flags);
}
void
BCodecRoster::ReleaseEncoder(BEncoder* encoder)
{
return gPluginManager.DestroyEncoder(encoder);
}
status_t
BCodecRoster::InstantiateStreamer(BStreamer** streamer, BUrl url)
{
return gPluginManager.CreateStreamer(streamer, url);
}
void
BCodecRoster::ReleaseStreamer(BStreamer* streamer)
{
return gPluginManager.DestroyStreamer(streamer);
}
status_t
BCodecRoster::GetNextEncoder(int32* cookie, const media_file_format* fileFormat,
const media_format* inputFormat, media_format* _outputFormat,
media_codec_info* _codecInfo)
{
// TODO: If fileFormat is provided (existing apps also pass NULL),
// we could at least check fileFormat->capabilities against
// outputFormat->type without even contacting the server.
if (cookie == NULL || inputFormat == NULL || _codecInfo == NULL)
return B_BAD_VALUE;
while (true) {
media_codec_info candidateCodecInfo;
media_format_family candidateFormatFamily;
media_format candidateInputFormat;
media_format candidateOutputFormat;
status_t ret = BCodecRoster::GetCodecInfo(&candidateCodecInfo,
&candidateFormatFamily, &candidateInputFormat,
&candidateOutputFormat, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
if (fileFormat != NULL && candidateFormatFamily != B_ANY_FORMAT_FAMILY
&& fileFormat->family != B_ANY_FORMAT_FAMILY
&& fileFormat->family != candidateFormatFamily) {
continue;
}
if (!candidateInputFormat.Matches(inputFormat))
continue;
if (_outputFormat != NULL)
*_outputFormat = candidateOutputFormat;
*_codecInfo = candidateCodecInfo;
break;
}
return B_OK;
}
status_t
BCodecRoster::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)
{
// TODO: If fileFormat is provided (existing apps also pass NULL),
// we could at least check fileFormat->capabilities against
// outputFormat->type without even contacting the server.
if (cookie == NULL || inputFormat == NULL || outputFormat == NULL
|| _codecInfo == NULL) {
return B_BAD_VALUE;
}
while (true) {
media_codec_info candidateCodecInfo;
media_format_family candidateFormatFamily;
media_format candidateInputFormat;
media_format candidateOutputFormat;
status_t ret = BCodecRoster::GetCodecInfo(&candidateCodecInfo,
&candidateFormatFamily, &candidateInputFormat,
&candidateOutputFormat, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
if (fileFormat != NULL && candidateFormatFamily != B_ANY_FORMAT_FAMILY
&& fileFormat->family != B_ANY_FORMAT_FAMILY
&& fileFormat->family != candidateFormatFamily) {
continue;
}
if (!candidateInputFormat.Matches(inputFormat)
|| !candidateOutputFormat.Matches(outputFormat)) {
continue;
}
// TODO: These formats are currently way too generic. For example,
// an encoder may want to adjust video width to a multiple of 16,
// or overwrite the intput and or output color space. To make this
// possible, we actually have to instantiate an Encoder here and
// ask it to specifiy the format.
if (_acceptedInputFormat != NULL)
*_acceptedInputFormat = candidateInputFormat;
if (_acceptedOutputFormat != NULL)
*_acceptedOutputFormat = candidateOutputFormat;
*_codecInfo = candidateCodecInfo;
break;
}
return B_OK;
}
status_t
BCodecRoster::GetNextEncoder(int32* cookie, media_codec_info* _codecInfo)
{
if (cookie == NULL || _codecInfo == NULL)
return B_BAD_VALUE;
media_format_family formatFamily;
media_format inputFormat;
media_format outputFormat;
status_t ret = BCodecRoster::GetCodecInfo(_codecInfo,
&formatFamily, &inputFormat, &outputFormat, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
return B_OK;
}
status_t
BCodecRoster::GetNextFileFormat(int32* cookie, media_file_format* mff)
{
if (cookie == NULL || mff == NULL)
return B_BAD_VALUE;
status_t ret = BPrivate::AddOnManager::GetInstance()->GetFileFormat(mff,
*cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
return B_OK;
}
status_t
BCodecRoster::GetCodecInfo(media_codec_info* codecInfo,
media_format_family* formatFamily, media_format* inputFormat,
media_format* outputFormat, int32 cookie)
{
return BPrivate::AddOnManager::GetInstance()->GetCodecInfo(codecInfo,
formatFamily, inputFormat, outputFormat, cookie);
}
} // namespace BCodecKit

View File

@ -1,77 +0,0 @@
/*
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Decoder.h>
#include <MediaFormats.h>
#include <stdio.h>
#include <string.h>
namespace BCodecKit {
BDecoder::BDecoder()
:
fChunkProvider(NULL),
fMediaPlugin(NULL)
{
}
BDecoder::~BDecoder()
{
delete fChunkProvider;
}
status_t
BDecoder::GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
media_header *mediaHeader)
{
return fChunkProvider->GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
}
void
BDecoder::SetChunkProvider(BChunkProvider *provider)
{
delete fChunkProvider;
fChunkProvider = provider;
}
status_t
BDecoder::Perform(perform_code code, void* _data)
{
return B_OK;
}
void BDecoder::_ReservedDecoder1() {}
void BDecoder::_ReservedDecoder2() {}
void BDecoder::_ReservedDecoder3() {}
void BDecoder::_ReservedDecoder4() {}
void BDecoder::_ReservedDecoder5() {}
BDecoderPlugin::BDecoderPlugin()
{
}
BChunkProvider::BChunkProvider()
{
}
BChunkProvider::~BChunkProvider()
{
}
} // namespace BCodecKit

View File

@ -1,154 +0,0 @@
/*
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Encoder.h>
#include <MediaFormats.h>
#include <stdio.h>
#include <string.h>
namespace BCodecKit {
BEncoder::BEncoder()
:
fChunkWriter(NULL),
fMediaPlugin(NULL)
{
}
BEncoder::~BEncoder()
{
delete fChunkWriter;
}
// #pragma mark - Convenience stubs
status_t
BEncoder::AddTrackInfo(uint32 code, const void* data, size_t size, uint32 flags)
{
return B_NOT_SUPPORTED;
}
BView*
BEncoder::ParameterView()
{
return NULL;
}
BParameterWeb*
BEncoder::ParameterWeb()
{
return NULL;
}
status_t
BEncoder::GetParameterValue(int32 id, void* value, size_t* size) const
{
return B_NOT_SUPPORTED;
}
status_t
BEncoder::SetParameterValue(int32 id, const void* value, size_t size)
{
return B_NOT_SUPPORTED;
}
status_t
BEncoder::GetEncodeParameters(encode_parameters* parameters) const
{
return B_NOT_SUPPORTED;
}
status_t
BEncoder::SetEncodeParameters(encode_parameters* parameters)
{
return B_NOT_SUPPORTED;
}
// #pragma mark -
status_t
BEncoder::WriteChunk(const void* chunkBuffer, size_t chunkSize,
media_encode_info* encodeInfo)
{
return fChunkWriter->WriteChunk(chunkBuffer, chunkSize, encodeInfo);
}
void
BEncoder::SetChunkWriter(BChunkWriter* writer)
{
delete fChunkWriter;
fChunkWriter = writer;
}
// #pragma mark - FBC padding
status_t
BEncoder::Perform(perform_code code, void* data)
{
return B_OK;
}
void BEncoder::_ReservedEncoder1() {}
void BEncoder::_ReservedEncoder2() {}
void BEncoder::_ReservedEncoder3() {}
void BEncoder::_ReservedEncoder4() {}
void BEncoder::_ReservedEncoder5() {}
void BEncoder::_ReservedEncoder6() {}
void BEncoder::_ReservedEncoder7() {}
void BEncoder::_ReservedEncoder8() {}
void BEncoder::_ReservedEncoder9() {}
void BEncoder::_ReservedEncoder10() {}
void BEncoder::_ReservedEncoder11() {}
void BEncoder::_ReservedEncoder12() {}
void BEncoder::_ReservedEncoder13() {}
void BEncoder::_ReservedEncoder14() {}
void BEncoder::_ReservedEncoder15() {}
void BEncoder::_ReservedEncoder16() {}
void BEncoder::_ReservedEncoder17() {}
void BEncoder::_ReservedEncoder18() {}
void BEncoder::_ReservedEncoder19() {}
void BEncoder::_ReservedEncoder20() {}
// #pragma mark - EncoderPlugin
BEncoderPlugin::BEncoderPlugin()
{
}
BChunkWriter::BChunkWriter()
{
}
BChunkWriter::~BChunkWriter()
{
}
} // namespace BCodecKit

View File

@ -1,53 +0,0 @@
SubDir HAIKU_TOP src kits codec ;
UsePrivateHeaders app codec media shared ;
if $(CHECK_MALLOC) {
SubDirC++Flags -D_NO_INLINE_ASM -fcheck-memory-usage ;
}
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
on $(architectureObject) {
# This will be removed someday
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits media ] ;
SharedLibrary [ MultiArchDefaultGristFiles libcodec.so ] :
# Adapter Kit
AdapterIO.cpp
MediaIO.cpp
# Support API
MetaData.cpp
CodecRoster.cpp
MediaExtractor.cpp
MediaStreamer.cpp
MediaWriter.cpp
# Codec Plugin API
MediaPlugin.cpp
Decoder.cpp
Encoder.cpp
Reader.cpp
Streamer.cpp
Writer.cpp
# Internal Functionality
ChunkCache.cpp
AddOnManager.cpp
PluginManager.cpp
# We need this to do not depend on libmedia
# will be removed when libmedia2 is introduced
FormatManager.cpp
MediaDefs.cpp
MediaFormats.cpp
RealtimeAlloc.cpp
:
be localestub shared
[ TargetLibsupc++ ] [ TargetLibstdc++ ]
;
}
}

View File

@ -1,30 +0,0 @@
/*
** Copyright 2004, Marcus Overhagen. All rights reserved.
** Distributed under the terms of the MIT License.
*/
#include "MediaPlugin.h"
namespace BCodecKit {
BMediaPlugin::BMediaPlugin()
:
fRefCount(0)
{
}
BMediaPlugin::~BMediaPlugin()
{
}
// FBC
void BMediaPlugin::_ReservedMediaPlugin1() {}
void BMediaPlugin::_ReservedMediaPlugin2() {}
} // namespace BCodecKit

View File

@ -1,102 +0,0 @@
/*
* Copyright 2017, Dario Casalinuovo
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "MediaStreamer.h"
#include <CodecRoster.h>
#include <stdio.h>
#include <string.h>
#include "MediaDebug.h"
#include "PluginManager.h"
namespace BCodecKit {
BMediaStreamer::BMediaStreamer(BUrl url)
:
fUrl(url),
fStreamer(NULL),
fInitCheck(B_OK),
fOpened(false)
{
// TODO: ideally we should see if the url IsValid() and
// matches our protocol.
CALLED();
}
BMediaStreamer::~BMediaStreamer()
{
CALLED();
if (fOpened)
Close();
}
status_t
BMediaStreamer::InitCheck() const
{
return fInitCheck;
}
status_t
BMediaStreamer::Open()
{
CALLED();
fOpened = true;
// NOTE: Consider splitting the streamer creation and
// sniff in PluginManager.
if (fStreamer != NULL)
BCodecRoster::ReleaseStreamer(fStreamer);
return BCodecRoster::InstantiateStreamer(&fStreamer, fUrl);
}
void
BMediaStreamer::Close()
{
if (fStreamer != NULL)
BCodecRoster::ReleaseStreamer(fStreamer);
}
bool
BMediaStreamer::IsOpened() const
{
return fOpened;
}
BMediaIO*
BMediaStreamer::Adapter() const
{
return fStreamer->Adapter();
}
void
BMediaStreamer::MouseMoved(uint32 x, uint32 y)
{
fStreamer->MouseMoved(x, y);
}
void
BMediaStreamer::MouseDown(uint32 x, uint32 y)
{
fStreamer->MouseDown(x, y);
}
} // namespace BCodecKit

View File

@ -1,236 +0,0 @@
/*
* Copyright 2018, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <MetaData.h>
#include <String.h>
#include <stdio.h>
#include <stdlib.h>
namespace BCodecKit {
const char* kCanPause = "canpause";
const char* kCanSeekBackward = "canseekbackward";
const char* kCanSeekForward = "canseekforward";
const char* kCanSeek = "canseek";
const char* kAudioBitRate = "audiobitrate";
const char* kVideoBitRate = "videobitrate";
const char* kAudioSampleRate = "audiosamplerate";
const char* kVideoFrameRate = "videoframerate";
const char* kMimeType = "mime";
const char* kAudioCodec = "audiocodec";
const char* kVideoCodec = "videocodec";
const char* kVideoHeight = "videoheight";
const char* kVideoWidth = "videowidth";
const char* kNumTracks = "numtracks";
const char* kDrmCrippled = "drmcrippled";
const char* kMediaType = "mediatype";
const char* kChannelCount = "channelcount";
const char* kAudioFormat = "audioformat";
const char* kByteOrder = "byteorder";
const char* kBufferSize = "buffersize";
const char* kChannelMask = "channelmask";
const char* kLineWidth = "linewidth";
const char* kLineCount = "linecount";
const char* kBytesPerRow = "bytesperrow";
const char* kPixelOffset = "pixeloffset";
const char* kLineOffset = "lineoffset";
const char* kColorSpace = "colorspace";
const char* kOrientation = "orientation";
const char* kVideoFrameSize = "orientation";
const char* kEncoding = "encoding";
const char* kTitle = "title";
const char* kComment = "comment";
const char* kCopyright = "copyright";
const char* kAlbum = "album";
const char* kArtist = "artist";
const char* kAuthor = "author";
const char* kComposer = "composer";
const char* kGenre = "genre";
const char* kDuration = "duration";
const char* kRating = "rating";
const char* kCDTrackNum = "cdtracknumber";
const char* kCDTrackMax = "cdtrackmax";
const char* kDate = "date";
const char* kEncodedBy = "encoded_by";
const char* kLanguage = "language";
const char* kAlbumArtist = "album_artist";
const char* kPerformer = "performer";
const char* kDisc = "disc";
const char* kPublisher = "publisher";
const char* kTrack = "track";
const char* kEncoder = "encoder";
const char* kYear = "year";
const char* kChapter = "be:chapter";
const char* kChapterStart = "be:chapter:start";
const char* kChapterEnd = "be:chapter:end";
const char* kProgramData = "be:program";
BMetaData::BMetaData()
:
fMessage(NULL)
{
fMessage = new BMessage();
}
BMetaData::BMetaData(const BMetaData& data)
:
fMessage(NULL)
{
fMessage = new BMessage(*data.fMessage);
}
BMetaData::BMetaData(const BMessage& msg)
:
fMessage(NULL)
{
fMessage = new BMessage(msg);
}
BMetaData::~BMetaData()
{
delete fMessage;
}
bool
BMetaData::SetString(const char* key, const BString& value)
{
return fMessage->SetString(key, value) == B_OK ? true : false;
}
bool
BMetaData::SetBool(const char* key, bool value)
{
return fMessage->SetBool(key, value) == B_OK ? true : false;
}
bool
BMetaData::SetUInt32(const char* key, uint32 value)
{
return fMessage->SetUInt32(key, value) == B_OK ? true : false;
}
bool
BMetaData::SetUInt64(const char* key, uint64 value)
{
return fMessage->SetUInt64(key, value) == B_OK ? true : false;
}
bool
BMetaData::SetFloat(const char* key, float value)
{
return fMessage->SetFloat(key, value) == B_OK ? true : false;
}
bool
BMetaData::GetUInt32(const char* key, uint32* value) const
{
return fMessage->FindUInt32(key, value) == B_OK ? true : false;
}
bool
BMetaData::GetFloat(const char* key, float* value) const
{
return fMessage->FindFloat(key, value) == B_OK ? true : false;
}
bool
BMetaData::GetString(const char* key, BString* value) const
{
return fMessage->FindString(key, value) == B_OK ? true : false;
}
bool
BMetaData::GetBool(const char* key, bool* value) const
{
return fMessage->FindBool(key, value) == B_OK ? true : false;
}
bool
BMetaData::AddMetaData(const char* key, BMetaData* data)
{
return fMessage->AddMessage(key, data->Message())
== B_OK ? true : false;
}
bool
BMetaData::GetMetaData(const char* key, BMetaData* data, uint32 index)
{
BMessage msg;
status_t err = fMessage->FindMessage(key, index, &msg);
if (err == B_OK) {
*data = BMetaData(msg);
return true;
}
return false;
}
bool
BMetaData::RemoveValue(const char* key)
{
return fMessage->RemoveName(key) == B_OK ? true : false;
}
void
BMetaData::MakeEmpty()
{
fMessage->MakeEmpty();
}
bool
BMetaData::IsEmpty()
{
return fMessage->IsEmpty();
}
const BMessage*
BMetaData::Message()
{
return fMessage;
}
BMetaData&
BMetaData::operator=(const BMetaData& other)
{
delete fMessage;
fMessage = new BMessage(*other.fMessage);
return *this;
}
} // namespace BCodecKit

View File

@ -1,87 +0,0 @@
/*
* Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de>.
* Distributed under the terms of the MIT License.
*
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Reader.h>
#include <stdio.h>
namespace BCodecKit {
BReader::BReader()
:
fSource(NULL),
fMediaPlugin(NULL)
{
}
BReader::~BReader()
{
}
status_t
BReader::GetMetaData(BMetaData* data)
{
return B_NOT_SUPPORTED;
}
status_t
BReader::Seek(void* cookie, uint32 flags, int64* frame, bigtime_t* time)
{
return B_NOT_SUPPORTED;
}
status_t
BReader::FindKeyFrame(void* cookie, uint32 flags, int64* frame, bigtime_t* time)
{
return B_NOT_SUPPORTED;
}
status_t
BReader::GetStreamMetaData(void* cookie, BMetaData* data)
{
return B_NOT_SUPPORTED;
}
BDataIO*
BReader::Source() const
{
return fSource;
}
void
BReader::_Setup(BDataIO *source)
{
fSource = source;
}
status_t
BReader::Perform(perform_code code, void* _data)
{
return B_OK;
}
void BReader::_ReservedReader1() {}
void BReader::_ReservedReader2() {}
void BReader::_ReservedReader3() {}
void BReader::_ReservedReader4() {}
void BReader::_ReservedReader5() {}
} // namespace BCodecKit

View File

@ -1,49 +0,0 @@
/*
* Copyright 2016, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Streamer.h>
namespace BCodecKit {
BStreamer::BStreamer()
:
fMediaPlugin(NULL)
{
}
BStreamer::~BStreamer()
{
}
void
BStreamer::MouseMoved(uint32 x, uint32 y)
{
}
void
BStreamer::MouseDown(uint32 x, uint32 y)
{
}
void BStreamer::_ReservedStreamer1() {}
void BStreamer::_ReservedStreamer2() {}
void BStreamer::_ReservedStreamer3() {}
void BStreamer::_ReservedStreamer4() {}
void BStreamer::_ReservedStreamer5() {}
BStreamerPlugin::BStreamerPlugin()
{
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Writer.h>
#include <stdio.h>
namespace BCodecKit {
BWriter::BWriter()
:
fTarget(NULL),
fMediaPlugin(NULL)
{
}
BWriter::~BWriter()
{
}
BDataIO*
BWriter::Target() const
{
return fTarget;
}
void
BWriter::_Setup(BDataIO* target)
{
fTarget = target;
}
status_t
BWriter::Perform(perform_code code, void* data)
{
return B_OK;
}
void BWriter::_ReservedWriter1() {}
void BWriter::_ReservedWriter2() {}
void BWriter::_ReservedWriter3() {}
void BWriter::_ReservedWriter4() {}
void BWriter::_ReservedWriter5() {}
}

View File

@ -29,8 +29,9 @@
#include "MetaFormat.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
// #pragma mark - ImageLoader
@ -344,7 +345,7 @@ AddOnManager::_RegisterAddOn(const entry_ref& ref)
if (status != B_OK)
return status;
BMediaPlugin* (*instantiate_plugin_func)();
MediaPlugin* (*instantiate_plugin_func)();
if (get_image_symbol(loader.Image(), "instantiate_plugin",
B_SYMBOL_TYPE_TEXT, (void**)&instantiate_plugin_func) < B_OK) {
@ -353,30 +354,30 @@ AddOnManager::_RegisterAddOn(const entry_ref& ref)
return B_BAD_TYPE;
}
BMediaPlugin* plugin = (*instantiate_plugin_func)();
MediaPlugin* plugin = (*instantiate_plugin_func)();
if (plugin == NULL) {
printf("AddOnManager::_RegisterAddOn(): instantiate_plugin in \"%s\" "
"returned NULL\n", path.Path());
return B_ERROR;
}
BReaderPlugin* reader = dynamic_cast<BReaderPlugin*>(plugin);
ReaderPlugin* reader = dynamic_cast<ReaderPlugin*>(plugin);
if (reader != NULL)
_RegisterReader(reader, ref);
BDecoderPlugin* decoder = dynamic_cast<BDecoderPlugin*>(plugin);
DecoderPlugin* decoder = dynamic_cast<DecoderPlugin*>(plugin);
if (decoder != NULL)
_RegisterDecoder(decoder, ref);
BWriterPlugin* writer = dynamic_cast<BWriterPlugin*>(plugin);
WriterPlugin* writer = dynamic_cast<WriterPlugin*>(plugin);
if (writer != NULL)
_RegisterWriter(writer, ref);
BEncoderPlugin* encoder = dynamic_cast<BEncoderPlugin*>(plugin);
EncoderPlugin* encoder = dynamic_cast<EncoderPlugin*>(plugin);
if (encoder != NULL)
_RegisterEncoder(encoder, ref);
BStreamerPlugin* streamer = dynamic_cast<BStreamerPlugin*>(plugin);
StreamerPlugin* streamer = dynamic_cast<StreamerPlugin*>(plugin);
if (streamer != NULL)
_RegisterStreamer(streamer, ref);
@ -443,7 +444,7 @@ AddOnManager::_UnregisterAddOn(const entry_ref& ref)
void
AddOnManager::_RegisterReader(BReaderPlugin* reader, const entry_ref& ref)
AddOnManager::_RegisterReader(ReaderPlugin* reader, const entry_ref& ref)
{
BAutolock locker(fLock);
@ -463,7 +464,7 @@ AddOnManager::_RegisterReader(BReaderPlugin* reader, const entry_ref& ref)
void
AddOnManager::_RegisterDecoder(BDecoderPlugin* plugin, const entry_ref& ref)
AddOnManager::_RegisterDecoder(DecoderPlugin* plugin, const entry_ref& ref)
{
BAutolock locker(fLock);
@ -493,7 +494,7 @@ AddOnManager::_RegisterDecoder(BDecoderPlugin* plugin, const entry_ref& ref)
void
AddOnManager::_RegisterWriter(BWriterPlugin* writer, const entry_ref& ref)
AddOnManager::_RegisterWriter(WriterPlugin* writer, const entry_ref& ref)
{
BAutolock locker(fLock);
@ -533,7 +534,7 @@ AddOnManager::_RegisterWriter(BWriterPlugin* writer, const entry_ref& ref)
void
AddOnManager::_RegisterEncoder(BEncoderPlugin* plugin, const entry_ref& ref)
AddOnManager::_RegisterEncoder(EncoderPlugin* plugin, const entry_ref& ref)
{
BAutolock locker(fLock);
@ -576,7 +577,7 @@ AddOnManager::_RegisterEncoder(BEncoderPlugin* plugin, const entry_ref& ref)
void
AddOnManager::_RegisterStreamer(BStreamerPlugin* streamer, const entry_ref& ref)
AddOnManager::_RegisterStreamer(StreamerPlugin* streamer, const entry_ref& ref)
{
BAutolock locker(fLock);
@ -674,5 +675,5 @@ AddOnManager::_GetReaders(const BPath& path, entry_ref* outRefs,
}
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit

View File

@ -16,19 +16,18 @@
*/
#include <Decoder.h>
#include <Entry.h>
#include <Encoder.h>
#include <Reader.h>
#include <Streamer.h>
#include <Writer.h>
#include "DataExchange.h"
#include "TList.h"
#include "DecoderPlugin.h"
#include "EncoderPlugin.h"
#include "ReaderPlugin.h"
#include "StreamerPlugin.h"
#include "WriterPlugin.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
class AddOnManager {
public:
@ -68,17 +67,17 @@ private:
status_t _RegisterAddOn(const entry_ref& ref);
status_t _UnregisterAddOn(const entry_ref& ref);
void _RegisterReader(BReaderPlugin* reader,
void _RegisterReader(ReaderPlugin* reader,
const entry_ref& ref);
void _RegisterDecoder(BDecoderPlugin* decoder,
void _RegisterDecoder(DecoderPlugin* decoder,
const entry_ref& ref);
void _RegisterWriter(BWriterPlugin* writer,
void _RegisterWriter(WriterPlugin* writer,
const entry_ref& ref);
void _RegisterEncoder(BEncoderPlugin* encoder,
void _RegisterEncoder(EncoderPlugin* encoder,
const entry_ref& ref);
void _RegisterStreamer(BStreamerPlugin* streamer,
void _RegisterStreamer(StreamerPlugin* streamer,
const entry_ref& ref);
bool _FindDecoder(const media_format& format,
@ -132,9 +131,7 @@ private:
static AddOnManager sInstance;
};
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit
#endif // _ADD_ON_MANAGER_H

View File

@ -15,10 +15,6 @@
// #pragma mark -
namespace BCodecKit {
namespace BPrivate {
ChunkCache::ChunkCache(sem_id waitSem, size_t maxBytes)
:
BLocker("media chunk cache"),
@ -74,7 +70,7 @@ ChunkCache::SpaceLeft() const
chunk_buffer*
ChunkCache::NextChunk(BReader* reader, void* cookie)
ChunkCache::NextChunk(Reader* reader, void* cookie)
{
ASSERT(IsLocked());
@ -113,7 +109,7 @@ ChunkCache::RecycleChunk(chunk_buffer* chunk)
bool
ChunkCache::ReadNextChunk(BReader* reader, void* cookie)
ChunkCache::ReadNextChunk(Reader* reader, void* cookie)
{
ASSERT(IsLocked());
@ -160,7 +156,3 @@ ChunkCache::ReadNextChunk(BReader* reader, void* cookie)
fChunkCache.push(chunk);
return chunk->status == B_OK;
}
} // namespace BPrivate
} // namespace BCodecKit

View File

@ -8,14 +8,15 @@
#include <Locker.h>
#include <MediaDefs.h>
#include <Reader.h>
#include <RealtimeAlloc.h>
#include <queue>
#include <deque>
#include "ReaderPlugin.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
// Limit to 10 entries, we might want to instead limit to a length of time
#define CACHE_MAX_ENTRIES 10
@ -41,9 +42,9 @@ public:
void MakeEmpty();
bool SpaceLeft() const;
chunk_buffer* NextChunk(BReader* reader, void* cookie);
chunk_buffer* NextChunk(Reader* reader, void* cookie);
void RecycleChunk(chunk_buffer* chunk);
bool ReadNextChunk(BReader* reader, void* cookie);
bool ReadNextChunk(Reader* reader, void* cookie);
private:
rtm_pool* fRealTimePool;
@ -54,9 +55,9 @@ private:
};
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit
//using namespace BPrivate::media;
using namespace BPrivate::media;
#endif // _CHUNK_CACHE_H

View File

@ -0,0 +1,61 @@
/*
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "DecoderPlugin.h"
#include <stdio.h>
#include <string.h>
#include <MediaFormats.h>
Decoder::Decoder()
:
fChunkProvider(NULL),
fMediaPlugin(NULL)
{
}
Decoder::~Decoder()
{
delete fChunkProvider;
}
status_t
Decoder::GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
media_header *mediaHeader)
{
return fChunkProvider->GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
}
void
Decoder::SetChunkProvider(ChunkProvider *provider)
{
delete fChunkProvider;
fChunkProvider = provider;
}
status_t
Decoder::Perform(perform_code code, void* _data)
{
return B_OK;
}
void Decoder::_ReservedDecoder1() {}
void Decoder::_ReservedDecoder2() {}
void Decoder::_ReservedDecoder3() {}
void Decoder::_ReservedDecoder4() {}
void Decoder::_ReservedDecoder5() {}
// #pragma mark -
DecoderPlugin::DecoderPlugin()
{
}

View File

@ -0,0 +1,137 @@
/*
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "EncoderPlugin.h"
#include <stdio.h>
#include <string.h>
#include <MediaFormats.h>
Encoder::Encoder()
:
fChunkWriter(NULL),
fMediaPlugin(NULL)
{
}
Encoder::~Encoder()
{
delete fChunkWriter;
}
// #pragma mark - Convenience stubs
status_t
Encoder::AddTrackInfo(uint32 code, const void* data, size_t size, uint32 flags)
{
return B_NOT_SUPPORTED;
}
BView*
Encoder::ParameterView()
{
return NULL;
}
BParameterWeb*
Encoder::ParameterWeb()
{
return NULL;
}
status_t
Encoder::GetParameterValue(int32 id, void* value, size_t* size) const
{
return B_NOT_SUPPORTED;
}
status_t
Encoder::SetParameterValue(int32 id, const void* value, size_t size)
{
return B_NOT_SUPPORTED;
}
status_t
Encoder::GetEncodeParameters(encode_parameters* parameters) const
{
return B_NOT_SUPPORTED;
}
status_t
Encoder::SetEncodeParameters(encode_parameters* parameters)
{
return B_NOT_SUPPORTED;
}
// #pragma mark -
status_t
Encoder::WriteChunk(const void* chunkBuffer, size_t chunkSize,
media_encode_info* encodeInfo)
{
return fChunkWriter->WriteChunk(chunkBuffer, chunkSize, encodeInfo);
}
void
Encoder::SetChunkWriter(ChunkWriter* writer)
{
delete fChunkWriter;
fChunkWriter = writer;
}
// #pragma mark - FBC padding
status_t
Encoder::Perform(perform_code code, void* data)
{
return B_OK;
}
void Encoder::_ReservedEncoder1() {}
void Encoder::_ReservedEncoder2() {}
void Encoder::_ReservedEncoder3() {}
void Encoder::_ReservedEncoder4() {}
void Encoder::_ReservedEncoder5() {}
void Encoder::_ReservedEncoder6() {}
void Encoder::_ReservedEncoder7() {}
void Encoder::_ReservedEncoder8() {}
void Encoder::_ReservedEncoder9() {}
void Encoder::_ReservedEncoder10() {}
void Encoder::_ReservedEncoder11() {}
void Encoder::_ReservedEncoder12() {}
void Encoder::_ReservedEncoder13() {}
void Encoder::_ReservedEncoder14() {}
void Encoder::_ReservedEncoder15() {}
void Encoder::_ReservedEncoder16() {}
void Encoder::_ReservedEncoder17() {}
void Encoder::_ReservedEncoder18() {}
void Encoder::_ReservedEncoder19() {}
void Encoder::_ReservedEncoder20() {}
// #pragma mark - EncoderPlugin
EncoderPlugin::EncoderPlugin()
{
}

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src kits media ;
UsePrivateHeaders app codec media shared ;
UsePrivateHeaders app media shared ;
UsePrivateHeaders [ FDirName media experimental ] ;
if $(CHECK_MALLOC) {
@ -25,7 +25,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
MediaAddOn.cpp
MediaDecoder.cpp
MediaDefs.cpp
MediaDefsNotify.cpp
MediaEncoder.cpp
MediaEventLooper.cpp
MediaFile.cpp
@ -47,13 +46,16 @@ for architectureObject in [ MultiArchSubDirSetup ] {
TimeSource.cpp
# Experimental Media Kit
AdapterIO.cpp
MediaClient.cpp
MediaClientDefs.cpp
MediaClientNode.cpp
MediaConnection.cpp
MediaIO.cpp
SimpleMediaClient.cpp
# Internal Functionality
AddOnManager.cpp
BufferCache.cpp
DataExchange.cpp
DefaultMediaTheme.cpp
@ -77,11 +79,24 @@ for architectureObject in [ MultiArchSubDirSetup ] {
OldMediaModule.cpp
OldSubscriber.cpp
# Codec Plugin API
ChunkCache.cpp
DecoderPlugin.cpp
EncoderPlugin.cpp
MediaExtractor.cpp
MediaPlugin.cpp
MediaStreamer.cpp
MediaWriter.cpp
PluginManager.cpp
ReaderPlugin.cpp
StreamerPlugin.cpp
WriterPlugin.cpp
# Compat Media Kit
!missing_symbols.cpp
Deprecated.cpp
:
be codec localestub shared
be localestub shared
[ TargetLibsupc++ ] [ TargetLibstdc++ ]
;
}

View File

@ -3,17 +3,12 @@
* FILE: MediaDecoder.cpp
* DESCR:
***********************************************************************/
#include <CodecRoster.h>
#include <Decoder.h>
#include <MediaDecoder.h>
#include <DecoderPlugin.h>
#include <new>
#include "PluginManager.h"
#include "MediaDebug.h"
using namespace BCodecKit;
/*************************************************************
* public BMediaDecoder
*************************************************************/
@ -46,7 +41,7 @@ BMediaDecoder::BMediaDecoder(const media_codec_info *mci)
/* virtual */
BMediaDecoder::~BMediaDecoder()
{
BCodecRoster::ReleaseDecoder(fDecoder);
gPluginManager.DestroyDecoder(fDecoder);
}
@ -62,10 +57,10 @@ BMediaDecoder::SetTo(const media_format *in_format,
const void *info,
size_t info_size)
{
BCodecRoster::ReleaseDecoder(fDecoder);
gPluginManager.DestroyDecoder(fDecoder);
fDecoder = NULL;
status_t err = BCodecRoster::InstantiateDecoder(&fDecoder, *in_format);
status_t err = gPluginManager.CreateDecoder(&fDecoder, *in_format);
if (err < B_OK)
goto fail;
@ -81,7 +76,7 @@ BMediaDecoder::SetTo(const media_format *in_format,
return B_OK;
fail:
BCodecRoster::ReleaseDecoder(fDecoder);
gPluginManager.DestroyDecoder(fDecoder);
fDecoder = NULL;
fInitStatus = B_NO_INIT;
return err;
@ -91,10 +86,10 @@ fail:
status_t
BMediaDecoder::SetTo(const media_codec_info *mci)
{
BCodecRoster::ReleaseDecoder(fDecoder);
gPluginManager.DestroyDecoder(fDecoder);
fDecoder = NULL;
status_t err = BCodecRoster::InstantiateDecoder(&fDecoder, *mci);
status_t err = gPluginManager.CreateDecoder(&fDecoder, *mci);
if (err < B_OK)
goto fail;
@ -106,7 +101,7 @@ BMediaDecoder::SetTo(const media_codec_info *mci)
return B_OK;
fail:
BCodecRoster::ReleaseDecoder(fDecoder);
gPluginManager.DestroyDecoder(fDecoder);
fDecoder = NULL;
fInitStatus = B_NO_INIT;
return err;
@ -182,7 +177,7 @@ BMediaDecoder::GetDecoderInfo(media_codec_info *out_info) const
if (!fDecoder)
return B_NO_INIT;
return BCodecRoster::GetDecoderInfo(fDecoder, out_info);
return gPluginManager.GetDecoderInfo(fDecoder, out_info);
}
@ -204,7 +199,7 @@ BMediaDecoder::BMediaDecoder & operator=(const BMediaDecoder &);
status_t
BMediaDecoder::AttachToDecoder()
{
class MediaDecoderChunkProvider : public BChunkProvider {
class MediaDecoderChunkProvider : public ChunkProvider {
private:
BMediaDecoder * fDecoder;
public:

View File

@ -13,18 +13,20 @@
#include <Application.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <CodecRoster.h>
#include <IconUtils.h>
#include <LaunchRoster.h>
#include <Locale.h>
#include <MediaNode.h>
#include <MediaRoster.h>
#include <Node.h>
#include <Notification.h>
#include <Roster.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "AddOnManager.h"
#include "DataExchange.h"
#include "MediaDebug.h"
#include "MediaMisc.h"
@ -1218,7 +1220,247 @@ operator<(const media_file_format_id& a, const media_file_format_id& b)
status_t
get_next_file_format(int32* cookie, media_file_format* mff)
{
return BCodecKit::BCodecRoster::GetNextFileFormat(cookie, mff);
if (cookie == NULL || mff == NULL)
return B_BAD_VALUE;
status_t ret = AddOnManager::GetInstance()->GetFileFormat(mff, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
return B_OK;
}
// #pragma mark -
// final & verified
const char* B_MEDIA_SERVER_SIGNATURE = "application/x-vnd.Be.media-server";
const char* B_MEDIA_ADDON_SERVER_SIGNATURE = "application/x-vnd.Be.addon-host";
const type_code B_CODEC_TYPE_INFO = 0x040807b2;
// #pragma mark -
// shutdown_media_server() and launch_media_server()
// are provided by libbe.so in BeOS R5
#define MEDIA_SERVICE_NOTIFICATION_ID "MediaServiceNotificationID"
void
notify_system(float progress, const char* message)
{
BNotification notification(B_PROGRESS_NOTIFICATION);
notification.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
notification.SetProgress(progress);
notification.SetGroup(B_TRANSLATE("Media Service"));
notification.SetContent(message);
app_info info;
be_app->GetAppInfo(&info);
BBitmap icon(BRect(0, 0, 32, 32), B_RGBA32);
BNode node(&info.ref);
BIconUtils::GetVectorIcon(&node, "BEOS:ICON", &icon);
notification.SetIcon(&icon);
notification.Send();
}
void
progress_shutdown(int stage,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie)
{
// parameter "message" is no longer used. It is kept for compatibility with
// BeOS as this is used as a shutdown_media_server callback.
TRACE("stage: %i\n", stage);
const char* string = "Unknown stage";
switch (stage) {
case 10:
string = B_TRANSLATE("Stopping media server" B_UTF8_ELLIPSIS);
break;
case 20:
string = B_TRANSLATE("Waiting for media_server to quit.");
break;
case 40:
string = B_TRANSLATE("Telling media_addon_server to quit.");
break;
case 50:
string = B_TRANSLATE("Waiting for media_addon_server to quit.");
break;
case 70:
string = B_TRANSLATE("Cleaning up.");
break;
case 100:
string = B_TRANSLATE("Done shutting down.");
break;
}
if (progress == NULL)
notify_system(stage / 100.0f, string);
else
progress(stage, string, cookie);
}
status_t
shutdown_media_server(bigtime_t timeout,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie)
{
BMessage msg(B_QUIT_REQUESTED);
status_t err = B_MEDIA_SYSTEM_FAILURE;
bool shutdown = false;
BMediaRoster* roster = BMediaRoster::Roster(&err);
if (roster == NULL || err != B_OK)
return err;
if (progress == NULL && roster->Lock()) {
MediaRosterEx(roster)->EnableLaunchNotification(true, true);
roster->Unlock();
}
if ((err = msg.AddBool("be:_user_request", true)) != B_OK)
return err;
team_id mediaServer = be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE);
team_id addOnServer = be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE);
if (mediaServer != B_ERROR) {
BMessage reply;
BMessenger messenger(B_MEDIA_SERVER_SIGNATURE, mediaServer);
progress_shutdown(10, progress, cookie);
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
reply.FindBool("_shutdown", &shutdown);
if (err == B_TIMED_OUT || shutdown == false) {
if (messenger.IsValid())
kill_team(mediaServer);
} else if (err != B_OK)
return err;
progress_shutdown(20, progress, cookie);
int32 rv;
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
return rv;
}
if (addOnServer != B_ERROR) {
shutdown = false;
BMessage reply;
BMessenger messenger(B_MEDIA_ADDON_SERVER_SIGNATURE, addOnServer);
progress_shutdown(40, progress, cookie);
// The media_server usually shutdown the media_addon_server,
// if not let's do something.
if (messenger.IsValid()) {
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
reply.FindBool("_shutdown", &shutdown);
if (err == B_TIMED_OUT || shutdown == false) {
if (messenger.IsValid())
kill_team(addOnServer);
} else if (err != B_OK)
return err;
progress_shutdown(50, progress, cookie);
int32 rv;
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
return rv;
}
}
progress_shutdown(100, progress, cookie);
return B_OK;
}
void
progress_startup(int stage,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie)
{
// parameter "message" is no longer used. It is kept for compatibility with
// BeOS as this is used as a shutdown_media_server callback.
TRACE("stage: %i\n", stage);
const char* string = "Unknown stage";
switch (stage) {
case 10:
string = B_TRANSLATE("Stopping media server" B_UTF8_ELLIPSIS);
break;
case 20:
string = B_TRANSLATE("Stopping media_addon_server.");
break;
case 50:
string = B_TRANSLATE("Starting media_services.");
break;
case 90:
string = B_TRANSLATE("Error occurred starting media services.");
break;
case 100:
string = B_TRANSLATE("Ready for use.");
break;
}
if (progress == NULL)
notify_system(stage / 100.0f, string);
else
progress(stage, string, cookie);
}
status_t
launch_media_server(bigtime_t timeout,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie, uint32 flags)
{
if (BMediaRoster::IsRunning())
return B_ALREADY_RUNNING;
status_t err = B_MEDIA_SYSTEM_FAILURE;
BMediaRoster* roster = BMediaRoster::Roster(&err);
if (roster == NULL || err != B_OK)
return err;
if (progress == NULL && roster->Lock()) {
MediaRosterEx(roster)->EnableLaunchNotification(true, true);
roster->Unlock();
}
// The media_server crashed
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
progress_startup(10, progress, cookie);
kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
}
// The media_addon_server crashed
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
progress_startup(20, progress, cookie);
kill_team(be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE));
}
progress_startup(50, progress, cookie);
err = BLaunchRoster().Start(B_MEDIA_SERVER_SIGNATURE);
if (err != B_OK)
progress_startup(90, progress, cookie);
else if (progress != NULL) {
progress_startup(100, progress, cookie);
err = B_OK;
}
return err;
}
@ -1246,3 +1488,5 @@ media_decode_info::media_decode_info()
codec_data = NULL;
codec_data_size = 0;
}

View File

@ -1,250 +0,0 @@
/*
* Copyright 2015, Dario Casalinuovo
* Copyright 2004, 2006, Jérôme Duval.
* Copyright 2003-2004, Andrew Bachmann.
* Copyright 2002-2004, 2006 Marcus Overhagen.
* Copyright 2002, Eric Jaessler.
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include <MediaDefs.h>
#include <Application.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <IconUtils.h>
#include <LaunchRoster.h>
#include <Locale.h>
#include <MediaRoster.h>
#include <Notification.h>
#include <Roster.h>
#include "MediaRosterEx.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "MediaDefs"
// final & verified
const char* B_MEDIA_SERVER_SIGNATURE = "application/x-vnd.Be.media-server";
const char* B_MEDIA_ADDON_SERVER_SIGNATURE = "application/x-vnd.Be.addon-host";
const type_code B_CODEC_TYPE_INFO = 0x040807b2;
// shutdown_media_server() and launch_media_server()
// are provided by libbe.so in BeOS R5
#define MEDIA_SERVICE_NOTIFICATION_ID "MediaServiceNotificationID"
void
notify_system(float progress, const char* message)
{
BNotification notification(B_PROGRESS_NOTIFICATION);
notification.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
notification.SetProgress(progress);
notification.SetGroup(B_TRANSLATE("Media Service"));
notification.SetContent(message);
app_info info;
be_app->GetAppInfo(&info);
BBitmap icon(BRect(0, 0, 32, 32), B_RGBA32);
BNode node(&info.ref);
BIconUtils::GetVectorIcon(&node, "BEOS:ICON", &icon);
notification.SetIcon(&icon);
notification.Send();
}
void
progress_shutdown(int stage,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie)
{
// parameter "message" is no longer used. It is kept for compatibility with
// BeOS as this is used as a shutdown_media_server callback.
TRACE("stage: %i\n", stage);
const char* string = "Unknown stage";
switch (stage) {
case 10:
string = B_TRANSLATE("Stopping media server" B_UTF8_ELLIPSIS);
break;
case 20:
string = B_TRANSLATE("Waiting for media_server to quit.");
break;
case 40:
string = B_TRANSLATE("Telling media_addon_server to quit.");
break;
case 50:
string = B_TRANSLATE("Waiting for media_addon_server to quit.");
break;
case 70:
string = B_TRANSLATE("Cleaning up.");
break;
case 100:
string = B_TRANSLATE("Done shutting down.");
break;
}
if (progress == NULL)
notify_system(stage / 100.0f, string);
else
progress(stage, string, cookie);
}
status_t
shutdown_media_server(bigtime_t timeout,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie)
{
BMessage msg(B_QUIT_REQUESTED);
status_t err = B_MEDIA_SYSTEM_FAILURE;
bool shutdown = false;
BMediaRoster* roster = BMediaRoster::Roster(&err);
if (roster == NULL || err != B_OK)
return err;
if (progress == NULL && roster->Lock()) {
MediaRosterEx(roster)->EnableLaunchNotification(true, true);
roster->Unlock();
}
if ((err = msg.AddBool("be:_user_request", true)) != B_OK)
return err;
team_id mediaServer = be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE);
team_id addOnServer = be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE);
if (mediaServer != B_ERROR) {
BMessage reply;
BMessenger messenger(B_MEDIA_SERVER_SIGNATURE, mediaServer);
progress_shutdown(10, progress, cookie);
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
reply.FindBool("_shutdown", &shutdown);
if (err == B_TIMED_OUT || shutdown == false) {
if (messenger.IsValid())
kill_team(mediaServer);
} else if (err != B_OK)
return err;
progress_shutdown(20, progress, cookie);
int32 rv;
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
return rv;
}
if (addOnServer != B_ERROR) {
shutdown = false;
BMessage reply;
BMessenger messenger(B_MEDIA_ADDON_SERVER_SIGNATURE, addOnServer);
progress_shutdown(40, progress, cookie);
// The media_server usually shutdown the media_addon_server,
// if not let's do something.
if (messenger.IsValid()) {
err = messenger.SendMessage(&msg, &reply, 2000000, 2000000);
reply.FindBool("_shutdown", &shutdown);
if (err == B_TIMED_OUT || shutdown == false) {
if (messenger.IsValid())
kill_team(addOnServer);
} else if (err != B_OK)
return err;
progress_shutdown(50, progress, cookie);
int32 rv;
if (reply.FindInt32("error", &rv) == B_OK && rv != B_OK)
return rv;
}
}
progress_shutdown(100, progress, cookie);
return B_OK;
}
void
progress_startup(int stage,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie)
{
// parameter "message" is no longer used. It is kept for compatibility with
// BeOS as this is used as a shutdown_media_server callback.
TRACE("stage: %i\n", stage);
const char* string = "Unknown stage";
switch (stage) {
case 10:
string = B_TRANSLATE("Stopping media server" B_UTF8_ELLIPSIS);
break;
case 20:
string = B_TRANSLATE("Stopping media_addon_server.");
break;
case 50:
string = B_TRANSLATE("Starting media_services.");
break;
case 90:
string = B_TRANSLATE("Error occurred starting media services.");
break;
case 100:
string = B_TRANSLATE("Ready for use.");
break;
}
if (progress == NULL)
notify_system(stage / 100.0f, string);
else
progress(stage, string, cookie);
}
status_t
launch_media_server(bigtime_t timeout,
bool (*progress)(int stage, const char* message, void* cookie),
void* cookie, uint32 flags)
{
if (BMediaRoster::IsRunning())
return B_ALREADY_RUNNING;
status_t err = B_MEDIA_SYSTEM_FAILURE;
BMediaRoster* roster = BMediaRoster::Roster(&err);
if (roster == NULL || err != B_OK)
return err;
if (progress == NULL && roster->Lock()) {
MediaRosterEx(roster)->EnableLaunchNotification(true, true);
roster->Unlock();
}
// The media_server crashed
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
progress_startup(10, progress, cookie);
kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
}
// The media_addon_server crashed
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
progress_startup(20, progress, cookie);
kill_team(be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE));
}
progress_startup(50, progress, cookie);
err = BLaunchRoster().Start(B_MEDIA_SERVER_SIGNATURE);
if (err != B_OK)
progress_startup(90, progress, cookie);
else if (progress != NULL) {
progress_startup(100, progress, cookie);
err = B_OK;
}
return err;
}

View File

@ -9,16 +9,13 @@
#include <MediaEncoder.h>
#include <CodecRoster.h>
#include <Encoder.h>
#include <EncoderPlugin.h>
#include <PluginManager.h>
#include <new>
#include "MediaDebug.h"
using namespace BCodecKit;
/*************************************************************
* public BMediaEncoder
*************************************************************/
@ -79,7 +76,7 @@ BMediaEncoder::SetTo(const media_format* outputFormat)
return fInitStatus;
media_format format = *outputFormat;
err = BCodecRoster::InstantiateEncoder(&fEncoder, format);
err = gPluginManager.CreateEncoder(&fEncoder, format);
if (fEncoder != NULL && err == B_OK) {
err = _AttachToEncoder();
if (err == B_OK)
@ -97,7 +94,7 @@ BMediaEncoder::SetTo(const media_codec_info* mci)
CALLED();
ReleaseEncoder();
status_t err = BCodecRoster::InstantiateEncoder(&fEncoder, mci, 0);
status_t err = gPluginManager.CreateEncoder(&fEncoder, mci, 0);
if (fEncoder != NULL && err == B_OK) {
err = _AttachToEncoder();
if (err == B_OK) {
@ -219,7 +216,7 @@ BMediaEncoder::ReleaseEncoder()
{
CALLED();
if (fEncoder != NULL) {
BCodecRoster::ReleaseEncoder(fEncoder);
gPluginManager.DestroyEncoder(fEncoder);
fEncoder = NULL;
}
fInitStatus = B_NO_INIT;
@ -229,7 +226,7 @@ BMediaEncoder::ReleaseEncoder()
status_t
BMediaEncoder::_AttachToEncoder()
{
class MediaEncoderChunkWriter : public BChunkWriter {
class MediaEncoderChunkWriter : public ChunkWriter {
public:
MediaEncoderChunkWriter(BMediaEncoder* encoder)
{

View File

@ -20,12 +20,6 @@
#include "PluginManager.h"
namespace BCodecKit {
using BCodecKit::BPrivate::ChunkCache;
using BCodecKit::BPrivate::chunk_buffer;
// should be 0, to disable the chunk cache set it to 1
#define DISABLE_CHUNK_CACHE 0
@ -33,21 +27,9 @@ using BCodecKit::BPrivate::chunk_buffer;
static const size_t kMaxCacheBytes = 3 * 1024 * 1024;
struct stream_info {
status_t status;
void* cookie;
bool hasCookie;
const void* infoBuffer;
size_t infoBufferSize;
ChunkCache* chunkCache;
chunk_buffer* lastChunk;
media_format encodedFormat;
};
class BMediaExtractorChunkProvider : public BChunkProvider {
class MediaExtractorChunkProvider : public ChunkProvider {
public:
BMediaExtractorChunkProvider(BMediaExtractor* extractor, int32 stream)
MediaExtractorChunkProvider(MediaExtractor* extractor, int32 stream)
:
fExtractor(extractor),
fStream(stream)
@ -62,7 +44,7 @@ public:
}
private:
BMediaExtractor* fExtractor;
MediaExtractor* fExtractor;
int32 fStream;
};
@ -70,7 +52,7 @@ private:
// #pragma mark -
BMediaExtractor::BMediaExtractor(BDataIO* source, int32 flags)
MediaExtractor::MediaExtractor(BDataIO* source, int32 flags)
:
fExtractorThread(-1),
fReader(NULL),
@ -82,7 +64,7 @@ BMediaExtractor::BMediaExtractor(BDataIO* source, int32 flags)
void
BMediaExtractor::_Init(BDataIO* source, int32 flags)
MediaExtractor::_Init(BDataIO* source, int32 flags)
{
CALLED();
@ -128,7 +110,7 @@ BMediaExtractor::_Init(BDataIO* source, int32 flags)
fStreamInfo[i].cookie = 0;
fStreamInfo[i].hasCookie = false;
fStreamInfo[i].status = B_ERROR;
ERROR("BMediaExtractor::BMediaExtractor: AllocateCookie for stream %"
ERROR("MediaExtractor::MediaExtractor: AllocateCookie for stream %"
B_PRId32 " failed\n", i);
} else
fStreamInfo[i].hasCookie = true;
@ -146,7 +128,7 @@ BMediaExtractor::_Init(BDataIO* source, int32 flags)
&fStreamInfo[i].infoBuffer, &fStreamInfo[i].infoBufferSize)
!= B_OK) {
fStreamInfo[i].status = B_ERROR;
ERROR("BMediaExtractor::BMediaExtractor: GetStreamInfo for "
ERROR("MediaExtractor::MediaExtractor: GetStreamInfo for "
"stream %" B_PRId32 " failed\n", i);
}
}
@ -160,7 +142,7 @@ BMediaExtractor::_Init(BDataIO* source, int32 flags)
}
BMediaExtractor::~BMediaExtractor()
MediaExtractor::~MediaExtractor()
{
CALLED();
@ -184,7 +166,7 @@ BMediaExtractor::~BMediaExtractor()
status_t
BMediaExtractor::InitCheck() const
MediaExtractor::InitCheck()
{
CALLED();
return fInitStatus;
@ -192,14 +174,14 @@ BMediaExtractor::InitCheck() const
BDataIO*
BMediaExtractor::Source() const
MediaExtractor::Source() const
{
return fSource;
}
void
BMediaExtractor::GetFileFormatInfo(media_file_format* fileFormat) const
MediaExtractor::GetFileFormatInfo(media_file_format* fileFormat) const
{
CALLED();
*fileFormat = fFileFormat;
@ -207,30 +189,37 @@ BMediaExtractor::GetFileFormatInfo(media_file_format* fileFormat) const
status_t
BMediaExtractor::GetMetaData(BMetaData* data) const
MediaExtractor::GetMetaData(BMessage* _data) const
{
CALLED();
return fReader->GetMetaData(data);
return fReader->GetMetaData(_data);
}
int32
BMediaExtractor::CountStreams() const
MediaExtractor::StreamCount()
{
CALLED();
return fStreamCount;
}
const char*
MediaExtractor::Copyright()
{
return fReader->Copyright();
}
const media_format*
BMediaExtractor::EncodedFormat(int32 stream)
MediaExtractor::EncodedFormat(int32 stream)
{
return &fStreamInfo[stream].encodedFormat;
}
int64
BMediaExtractor::CountFrames(int32 stream) const
MediaExtractor::CountFrames(int32 stream) const
{
CALLED();
if (fStreamInfo[stream].status != B_OK)
@ -250,7 +239,7 @@ BMediaExtractor::CountFrames(int32 stream) const
bigtime_t
BMediaExtractor::Duration(int32 stream) const
MediaExtractor::Duration(int32 stream) const
{
CALLED();
@ -271,7 +260,7 @@ BMediaExtractor::Duration(int32 stream) const
status_t
BMediaExtractor::Seek(int32 stream, uint32 seekTo, int64* _frame,
MediaExtractor::Seek(int32 stream, uint32 seekTo, int64* _frame,
bigtime_t* _time)
{
CALLED();
@ -294,7 +283,7 @@ BMediaExtractor::Seek(int32 stream, uint32 seekTo, int64* _frame,
status_t
BMediaExtractor::FindKeyFrame(int32 stream, uint32 seekTo, int64* _frame,
MediaExtractor::FindKeyFrame(int32 stream, uint32 seekTo, int64* _frame,
bigtime_t* _time) const
{
CALLED();
@ -308,7 +297,7 @@ BMediaExtractor::FindKeyFrame(int32 stream, uint32 seekTo, int64* _frame,
status_t
BMediaExtractor::GetNextChunk(int32 stream, const void** _chunkBuffer,
MediaExtractor::GetNextChunk(int32 stream, const void** _chunkBuffer,
size_t* _chunkSize, media_header* mediaHeader)
{
stream_info& info = fStreamInfo[stream];
@ -342,21 +331,21 @@ BMediaExtractor::GetNextChunk(int32 stream, const void** _chunkBuffer,
status_t
BMediaExtractor::CreateDecoder(int32 stream, BDecoder** _decoder,
MediaExtractor::CreateDecoder(int32 stream, Decoder** _decoder,
media_codec_info* codecInfo)
{
CALLED();
status_t status = fStreamInfo[stream].status;
if (status != B_OK) {
ERROR("BMediaExtractor::CreateDecoder can't create decoder for "
ERROR("MediaExtractor::CreateDecoder can't create decoder for "
"stream %" B_PRId32 ": %s\n", stream, strerror(status));
return status;
}
// TODO: Here we should work out a way so that if there is a setup
// failure we can try the next decoder
BDecoder* decoder;
Decoder* decoder;
status = gPluginManager.CreateDecoder(&decoder,
fStreamInfo[stream].encodedFormat);
if (status != B_OK) {
@ -365,18 +354,18 @@ BMediaExtractor::CreateDecoder(int32 stream, BDecoder** _decoder,
string_for_format(fStreamInfo[stream].encodedFormat, formatString,
sizeof(formatString));
ERROR("BMediaExtractor::CreateDecoder gPluginManager.CreateDecoder "
ERROR("MediaExtractor::CreateDecoder gPluginManager.CreateDecoder "
"failed for stream %" B_PRId32 ", format: %s: %s\n", stream,
formatString, strerror(status));
#endif
return status;
}
BChunkProvider* chunkProvider
= new(std::nothrow) BMediaExtractorChunkProvider(this, stream);
ChunkProvider* chunkProvider
= new(std::nothrow) MediaExtractorChunkProvider(this, stream);
if (chunkProvider == NULL) {
gPluginManager.DestroyDecoder(decoder);
ERROR("BMediaExtractor::CreateDecoder can't create chunk provider "
ERROR("MediaExtractor::CreateDecoder can't create chunk provider "
"for stream %" B_PRId32 "\n", stream);
return B_NO_MEMORY;
}
@ -387,7 +376,7 @@ BMediaExtractor::CreateDecoder(int32 stream, BDecoder** _decoder,
fStreamInfo[stream].infoBuffer, fStreamInfo[stream].infoBufferSize);
if (status != B_OK) {
gPluginManager.DestroyDecoder(decoder);
ERROR("BMediaExtractor::CreateDecoder Setup failed for stream %" B_PRId32
ERROR("MediaExtractor::CreateDecoder Setup failed for stream %" B_PRId32
": %s\n", stream, strerror(status));
return status;
}
@ -395,7 +384,7 @@ BMediaExtractor::CreateDecoder(int32 stream, BDecoder** _decoder,
status = gPluginManager.GetDecoderInfo(decoder, codecInfo);
if (status != B_OK) {
gPluginManager.DestroyDecoder(decoder);
ERROR("BMediaExtractor::CreateDecoder GetCodecInfo failed for stream %"
ERROR("MediaExtractor::CreateDecoder GetCodecInfo failed for stream %"
B_PRId32 ": %s\n", stream, strerror(status));
return status;
}
@ -406,19 +395,19 @@ BMediaExtractor::CreateDecoder(int32 stream, BDecoder** _decoder,
status_t
BMediaExtractor::GetStreamMetaData(int32 stream, BMetaData* data) const
MediaExtractor::GetStreamMetaData(int32 stream, BMessage* _data) const
{
const stream_info& info = fStreamInfo[stream];
if (info.status != B_OK)
return info.status;
return fReader->GetStreamMetaData(fStreamInfo[stream].cookie, data);
return fReader->GetStreamMetaData(fStreamInfo[stream].cookie, _data);
}
void
BMediaExtractor::StopProcessing()
MediaExtractor::StopProcessing()
{
#if !DISABLE_CHUNK_CACHE
if (fExtractorWaitSem > -1) {
@ -434,7 +423,7 @@ BMediaExtractor::StopProcessing()
void
BMediaExtractor::_RecycleLastChunk(stream_info& info)
MediaExtractor::_RecycleLastChunk(stream_info& info)
{
if (info.lastChunk != NULL) {
info.chunkCache->RecycleChunk(info.lastChunk);
@ -444,15 +433,15 @@ BMediaExtractor::_RecycleLastChunk(stream_info& info)
status_t
BMediaExtractor::_ExtractorEntry(void* extractor)
MediaExtractor::_ExtractorEntry(void* extractor)
{
static_cast<BMediaExtractor*>(extractor)->_ExtractorThread();
static_cast<MediaExtractor*>(extractor)->_ExtractorThread();
return B_OK;
}
void
BMediaExtractor::_ExtractorThread()
MediaExtractor::_ExtractorThread()
{
while (true) {
status_t status;
@ -487,6 +476,3 @@ BMediaExtractor::_ExtractorThread()
} while (streamsFilled < fStreamCount);
}
}
} // namespace BCodecKit

View File

@ -6,21 +6,20 @@
#include <MediaFile.h>
#include <File.h>
#include <MediaExtractor.h>
#include <MediaStreamer.h>
#include <MediaTrack.h>
#include <MediaWriter.h>
#include <Url.h>
#include <new>
#include <stdlib.h>
#include <string.h>
#include <File.h>
#include <MediaTrack.h>
#include <Url.h>
#include "MediaDebug.h"
using namespace BCodecKit;
#include "MediaExtractor.h"
#include "MediaStreamer.h"
#include "MediaWriter.h"
BMediaFile::BMediaFile(const entry_ref* ref)
@ -198,25 +197,14 @@ BMediaFile::GetMetaData(BMessage* _data) const
_data->MakeEmpty();
BMetaData metaData;
if (fExtractor->GetMetaData(&metaData) == B_OK) {
*_data = *metaData.Message();
return B_OK;
}
return B_ERROR;
return fExtractor->GetMetaData(_data);
}
const char*
BMediaFile::Copyright() const
{
BMetaData data;
BString copyright;
if (fExtractor->GetMetaData(&data) == B_OK)
data.GetString(kCopyright, &copyright);
return copyright.String();
return fExtractor->Copyright();
}
@ -357,9 +345,7 @@ BMediaFile::AddCopyright(const char* copyright)
if (fWriter == NULL)
return B_NO_INIT;
BMetaData* data = new BMetaData();
data->SetString(kCopyright, copyright);
return fWriter->SetMetaData(data);
return fWriter->SetCopyright(copyright);
}
@ -527,7 +513,7 @@ BMediaFile::_InitReader(BDataIO* source, const BUrl* url, int32 flags)
if (fErr != B_OK)
return;
fExtractor = new(std::nothrow) BMediaExtractor(source, flags);
fExtractor = new(std::nothrow) MediaExtractor(source, flags);
if (fExtractor == NULL)
fErr = B_NO_MEMORY;
@ -541,7 +527,7 @@ BMediaFile::_InitReader(BDataIO* source, const BUrl* url, int32 flags)
fSource = fExtractor->Source();
fExtractor->GetFileFormatInfo(&fMFI);
fTrackNum = fExtractor->CountStreams();
fTrackNum = fExtractor->StreamCount();
fTrackList = (BMediaTrack**)malloc(fTrackNum * sizeof(BMediaTrack*));
if (fTrackList == NULL) {
fErr = B_NO_MEMORY;
@ -575,7 +561,7 @@ BMediaFile::_InitWriter(BDataIO* target, const BUrl* url,
return;
}
fWriter = new(std::nothrow) BMediaWriter(target, fMFI);
fWriter = new(std::nothrow) MediaWriter(target, fMFI);
if (fWriter == NULL)
fErr = B_NO_MEMORY;
@ -598,14 +584,13 @@ BMediaFile::_InitStreamer(const BUrl& url, BDataIO** adapter)
TRACE(url.UrlString());
fStreamer = new(std::nothrow) BMediaStreamer(url);
fStreamer = new(std::nothrow) MediaStreamer(url);
if (fStreamer == NULL) {
fErr = B_NO_MEMORY;
return;
}
fErr = fStreamer->Open();
*adapter = fStreamer->Adapter();
fErr = fStreamer->CreateAdapter(adapter);
}
/*

View File

@ -7,12 +7,6 @@
* Marcus Overhagen
*/
#include <MediaFormats.h>
#include <CodecRoster.h>
#include <ObjectList.h>
#include <Message.h>
#include <Autolock.h>
#include "AddOnManager.h"
#include "DataExchange.h"
@ -20,6 +14,11 @@
#include "MetaFormat.h"
#include "MediaDebug.h"
#include <MediaFormats.h>
#include <ObjectList.h>
#include <Message.h>
#include <Autolock.h>
#include <string.h>
using namespace BPrivate::media;
@ -35,8 +34,45 @@ get_next_encoder(int32* cookie, const media_file_format* fileFormat,
const media_format* inputFormat, media_format* _outputFormat,
media_codec_info* _codecInfo)
{
return BCodecKit::BCodecRoster::GetNextEncoder(cookie, fileFormat,
inputFormat, _outputFormat, _codecInfo);
// TODO: If fileFormat is provided (existing apps also pass NULL),
// we could at least check fileFormat->capabilities against
// outputFormat->type without even contacting the server.
if (cookie == NULL || inputFormat == NULL || _codecInfo == NULL)
return B_BAD_VALUE;
while (true) {
media_codec_info candidateCodecInfo;
media_format_family candidateFormatFamily;
media_format candidateInputFormat;
media_format candidateOutputFormat;
status_t ret = AddOnManager::GetInstance()->GetCodecInfo(
&candidateCodecInfo, &candidateFormatFamily,
&candidateInputFormat, &candidateOutputFormat, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
if (fileFormat != NULL && candidateFormatFamily != B_ANY_FORMAT_FAMILY
&& fileFormat->family != B_ANY_FORMAT_FAMILY
&& fileFormat->family != candidateFormatFamily) {
continue;
}
if (!candidateInputFormat.Matches(inputFormat))
continue;
if (_outputFormat != NULL)
*_outputFormat = candidateOutputFormat;
*_codecInfo = candidateCodecInfo;
break;
}
return B_OK;
}
@ -46,16 +82,77 @@ get_next_encoder(int32* cookie, const media_file_format* fileFormat,
media_codec_info* _codecInfo, media_format* _acceptedInputFormat,
media_format* _acceptedOutputFormat)
{
return BCodecKit::BCodecRoster::GetNextEncoder(cookie, fileFormat,
inputFormat, outputFormat, _codecInfo, _acceptedInputFormat,
_acceptedOutputFormat);
// TODO: If fileFormat is provided (existing apps also pass NULL),
// we could at least check fileFormat->capabilities against
// outputFormat->type without even contacting the server.
if (cookie == NULL || inputFormat == NULL || outputFormat == NULL
|| _codecInfo == NULL) {
return B_BAD_VALUE;
}
while (true) {
media_codec_info candidateCodecInfo;
media_format_family candidateFormatFamily;
media_format candidateInputFormat;
media_format candidateOutputFormat;
status_t ret = AddOnManager::GetInstance()->GetCodecInfo(
&candidateCodecInfo, &candidateFormatFamily, &candidateInputFormat,
&candidateOutputFormat, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
if (fileFormat != NULL && candidateFormatFamily != B_ANY_FORMAT_FAMILY
&& fileFormat->family != B_ANY_FORMAT_FAMILY
&& fileFormat->family != candidateFormatFamily) {
continue;
}
if (!candidateInputFormat.Matches(inputFormat)
|| !candidateOutputFormat.Matches(outputFormat)) {
continue;
}
// TODO: These formats are currently way too generic. For example,
// an encoder may want to adjust video width to a multiple of 16,
// or overwrite the intput and or output color space. To make this
// possible, we actually have to instantiate an Encoder here and
// ask it to specifiy the format.
if (_acceptedInputFormat != NULL)
*_acceptedInputFormat = candidateInputFormat;
if (_acceptedOutputFormat != NULL)
*_acceptedOutputFormat = candidateOutputFormat;
*_codecInfo = candidateCodecInfo;
break;
}
return B_OK;
}
status_t
get_next_encoder(int32* cookie, media_codec_info* _codecInfo)
{
return BCodecKit::BCodecRoster::GetNextEncoder(cookie, _codecInfo);
if (cookie == NULL || _codecInfo == NULL)
return B_BAD_VALUE;
media_format_family formatFamily;
media_format inputFormat;
media_format outputFormat;
status_t ret = AddOnManager::GetInstance()->GetCodecInfo(_codecInfo,
&formatFamily, &inputFormat, &outputFormat, *cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
return B_OK;
}
@ -269,7 +366,7 @@ update_media_formats()
// We want the add-ons to register themselves with the format manager, so
// the list is up to date.
BCodecKit::BPrivate::AddOnManager::GetInstance()->RegisterAddOns();
AddOnManager::GetInstance()->RegisterAddOns();
BMessage reply;
FormatManager::GetInstance()->GetFormats(sLastFormatsUpdate, reply);
@ -524,8 +621,10 @@ BMediaFormats::MakeFormatFor(const media_format_description* descriptions,
int32 descriptionCount, media_format* format, uint32 flags,
void* _reserved)
{
return FormatManager::GetInstance()->MakeFormatFor(descriptions,
status_t status = FormatManager::GetInstance()->MakeFormatFor(descriptions,
descriptionCount, *format, flags, _reserved);
return status;
}
@ -539,3 +638,4 @@ BMediaFormats::MakeFormatFor(const media_format_description& description,
*_outFormat = inFormat;
return MakeFormatFor(&description, 1, _outFormat);
}

View File

@ -0,0 +1,20 @@
/*
** Copyright 2004, Marcus Overhagen. All rights reserved.
** Distributed under the terms of the MIT License.
*/
#include "MediaPlugin.h"
MediaPlugin::MediaPlugin()
:
fRefCount(0)
{
}
MediaPlugin::~MediaPlugin()
{
}

View File

@ -0,0 +1,47 @@
/*
* Copyright 2017, Dario Casalinuovo
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "MediaStreamer.h"
#include <stdio.h>
#include <string.h>
#include "MediaDebug.h"
#include "PluginManager.h"
MediaStreamer::MediaStreamer(BUrl url)
:
fStreamer(NULL)
{
CALLED();
fUrl = url;
}
MediaStreamer::~MediaStreamer()
{
CALLED();
if (fStreamer != NULL)
gPluginManager.DestroyStreamer(fStreamer);
}
status_t
MediaStreamer::CreateAdapter(BDataIO** adapter)
{
CALLED();
// NOTE: Consider splitting the streamer creation and
// sniff in PluginManager.
if (fStreamer != NULL)
gPluginManager.DestroyStreamer(fStreamer);
return gPluginManager.CreateStreamer(&fStreamer, fUrl, adapter);
}

View File

@ -12,18 +12,17 @@
#include <MediaTrack.h>
#include <CodecRoster.h>
#include <MediaExtractor.h>
#include <MediaWriter.h>
#include <Roster.h>
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace BCodecKit;
#include <Roster.h>
#include "MediaExtractor.h"
#include "MediaWriter.h"
#include "PluginManager.h"
//#define TRACE_MEDIA_TRACK
@ -59,9 +58,9 @@ enum {
// TODO: move this (after name change?) to MediaDefs.h
class RawDecoderChunkProvider : public BChunkProvider {
class RawDecoderChunkProvider : public ChunkProvider {
public:
RawDecoderChunkProvider(BDecoder* decoder,
RawDecoderChunkProvider(Decoder* decoder,
int buffer_size, int frame_size);
virtual ~RawDecoderChunkProvider();
@ -70,7 +69,7 @@ public:
media_header* mediaHeader);
private:
BDecoder* fDecoder;
Decoder* fDecoder;
void* fBuffer;
int fBufferSize;
int fFrameSize;
@ -85,9 +84,9 @@ BMediaTrack::~BMediaTrack()
{
CALLED();
BCodecRoster::ReleaseDecoder(fRawDecoder);
BCodecRoster::ReleaseDecoder(fDecoder);
BCodecRoster::ReleaseEncoder(fEncoder);
gPluginManager.DestroyDecoder(fRawDecoder);
gPluginManager.DestroyDecoder(fDecoder);
gPluginManager.DestroyEncoder(fEncoder);
}
/*************************************************************
@ -164,7 +163,7 @@ BMediaTrack::DecodedFormat(media_format* _format, uint32 flags)
if (fExtractor == NULL || fDecoder == NULL)
return B_NO_INIT;
BCodecRoster::ReleaseDecoder(fRawDecoder);
gPluginManager.DestroyDecoder(fRawDecoder);
fRawDecoder = NULL;
#ifdef TRACE_MEDIA_TRACK
@ -302,12 +301,7 @@ BMediaTrack::GetMetaData(BMessage* _data) const
_data->MakeEmpty();
BMetaData data;
if (fExtractor->GetStreamMetaData(fStream, &data) != B_OK) {
*_data = *data.Message();
return B_OK;
}
return B_ERROR;
return fExtractor->GetStreamMetaData(fStream, _data);
}
@ -632,9 +626,7 @@ BMediaTrack::AddCopyright(const char* copyright)
if (fWriter == NULL)
return B_NO_INIT;
BMetaData* data = new BMetaData();
data->SetString(kCopyright, copyright);
return fWriter->SetMetaData(data);
return fWriter->SetCopyright(fStream, copyright);
}
@ -840,7 +832,7 @@ BMediaTrack::Perform(int32 selector, void* data)
// #pragma mark - private
BMediaTrack::BMediaTrack(BCodecKit::BMediaExtractor* extractor,
BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor* extractor,
int32 stream)
{
CALLED();
@ -872,7 +864,7 @@ BMediaTrack::BMediaTrack(BCodecKit::BMediaExtractor* extractor,
}
BMediaTrack::BMediaTrack(BCodecKit::BMediaWriter* writer,
BMediaTrack::BMediaTrack(BPrivate::media::MediaWriter* writer,
int32 streamIndex, media_format* format,
const media_codec_info* codecInfo)
{
@ -951,7 +943,7 @@ BMediaTrack::SetupWorkaround()
bool
BMediaTrack::SetupFormatTranslation(const media_format &from, media_format* to)
{
BCodecRoster::ReleaseDecoder(fRawDecoder);
gPluginManager.DestroyDecoder(fRawDecoder);
fRawDecoder = NULL;
#ifdef TRACE_MEDIA_TRACK
@ -960,7 +952,7 @@ BMediaTrack::SetupFormatTranslation(const media_format &from, media_format* to)
printf("BMediaTrack::SetupFormatTranslation: from: %s\n", s);
#endif
status_t result = BCodecRoster::InstantiateDecoder(&fRawDecoder, from);
status_t result = gPluginManager.CreateDecoder(&fRawDecoder, from);
if (result != B_OK) {
ERROR("BMediaTrack::SetupFormatTranslation: CreateDecoder failed\n");
return false;
@ -972,7 +964,7 @@ BMediaTrack::SetupFormatTranslation(const media_format &from, media_format* to)
* from.u.raw_audio.channel_count;
media_format fromNotConst = from;
BChunkProvider* chunkProvider
ChunkProvider* chunkProvider
= new (std::nothrow) RawDecoderChunkProvider(fDecoder, buffer_size,
frame_size);
if (chunkProvider == NULL) {
@ -1008,7 +1000,7 @@ BMediaTrack::SetupFormatTranslation(const media_format &from, media_format* to)
return true;
error:
BCodecRoster::ReleaseDecoder(fRawDecoder);
gPluginManager.DestroyDecoder(fRawDecoder);
fRawDecoder = NULL;
return false;
}
@ -1088,7 +1080,7 @@ status_t BMediaTrack::_Reserved_BMediaTrack_46(int32 arg, ...) { return B_ERROR;
status_t BMediaTrack::_Reserved_BMediaTrack_47(int32 arg, ...) { return B_ERROR; }
RawDecoderChunkProvider::RawDecoderChunkProvider(BDecoder* decoder,
RawDecoderChunkProvider::RawDecoderChunkProvider(Decoder* decoder,
int buffer_size, int frame_size)
{
// printf("RawDecoderChunkProvider: buffer_size %d, frame_size %d\n",

View File

@ -18,12 +18,10 @@
#include "PluginManager.h"
namespace BCodecKit {
class BMediaExtractorChunkWriter : public BChunkWriter {
class MediaExtractorChunkWriter : public ChunkWriter {
public:
BMediaExtractorChunkWriter(BMediaWriter* writer, int32 streamIndex)
MediaExtractorChunkWriter(MediaWriter* writer, int32 streamIndex)
:
fWriter(writer),
fStreamIndex(streamIndex)
@ -38,7 +36,7 @@ public:
}
private:
BMediaWriter* fWriter;
MediaWriter* fWriter;
int32 fStreamIndex;
};
@ -46,7 +44,7 @@ private:
// #pragma mark -
BMediaWriter::BMediaWriter(BDataIO* target, const media_file_format& fileFormat)
MediaWriter::MediaWriter(BDataIO* target, const media_file_format& fileFormat)
:
fTarget(target),
fWriter(NULL),
@ -56,12 +54,10 @@ BMediaWriter::BMediaWriter(BDataIO* target, const media_file_format& fileFormat)
CALLED();
gPluginManager.CreateWriter(&fWriter, fFileFormat, fTarget);
fInitCheck = fWriter->Init(&fFileFormat);
}
BMediaWriter::~BMediaWriter()
MediaWriter::~MediaWriter()
{
CALLED();
@ -80,23 +76,23 @@ BMediaWriter::~BMediaWriter()
status_t
BMediaWriter::InitCheck() const
MediaWriter::InitCheck()
{
CALLED();
return fWriter != NULL ? fInitCheck : B_NO_INIT;
return fWriter != NULL ? fWriter->Init(&fFileFormat) : B_NO_INIT;
}
BDataIO*
BMediaWriter::Target() const
MediaWriter::Target() const
{
return fTarget;
}
void
BMediaWriter::GetFileFormatInfo(media_file_format* _fileFormat) const
MediaWriter::GetFileFormatInfo(media_file_format* _fileFormat) const
{
CALLED();
@ -106,7 +102,7 @@ BMediaWriter::GetFileFormatInfo(media_file_format* _fileFormat) const
status_t
BMediaWriter::CreateEncoder(BEncoder** _encoder,
MediaWriter::CreateEncoder(Encoder** _encoder,
const media_codec_info* codecInfo, media_format* format, uint32 flags)
{
CALLED();
@ -116,10 +112,10 @@ BMediaWriter::CreateEncoder(BEncoder** _encoder,
// TODO: Here we should work out a way so that if there is a setup
// failure we can try the next encoder.
BEncoder* encoder;
Encoder* encoder;
status_t ret = gPluginManager.CreateEncoder(&encoder, codecInfo, flags);
if (ret != B_OK) {
ERROR("BMediaWriter::CreateEncoder gPluginManager.CreateEncoder "
ERROR("MediaWriter::CreateEncoder gPluginManager.CreateEncoder "
"failed, codec: %s\n", codecInfo->pretty_name);
return ret;
}
@ -135,16 +131,16 @@ BMediaWriter::CreateEncoder(BEncoder** _encoder,
if (!fStreamInfos.Insert(info)) {
gPluginManager.DestroyEncoder(encoder);
ERROR("BMediaWriter::CreateEncoder can't create StreamInfo "
ERROR("MediaWriter::CreateEncoder can't create StreamInfo "
"for stream %" B_PRId32 "\n", streamIndex);
return B_NO_MEMORY;
}
BChunkWriter* chunkWriter = new(std::nothrow) BMediaExtractorChunkWriter(
ChunkWriter* chunkWriter = new(std::nothrow) MediaExtractorChunkWriter(
this, streamIndex);
if (chunkWriter == NULL) {
gPluginManager.DestroyEncoder(encoder);
ERROR("BMediaWriter::CreateEncoder can't create ChunkWriter "
ERROR("MediaWriter::CreateEncoder can't create ChunkWriter "
"for stream %" B_PRId32 "\n", streamIndex);
return B_NO_MEMORY;
}
@ -157,17 +153,17 @@ BMediaWriter::CreateEncoder(BEncoder** _encoder,
status_t
BMediaWriter::SetMetaData(BMetaData* data)
MediaWriter::SetCopyright(const char* copyright)
{
if (fWriter == NULL)
return B_NO_INIT;
return fWriter->SetMetaData(data);
return fWriter->SetCopyright(copyright);
}
status_t
BMediaWriter::SetMetaData(int32 streamIndex, BMetaData* data)
MediaWriter::SetCopyright(int32 streamIndex, const char* copyright)
{
if (fWriter == NULL)
return B_NO_INIT;
@ -176,12 +172,12 @@ BMediaWriter::SetMetaData(int32 streamIndex, BMetaData* data)
if (!fStreamInfos.Get(streamIndex, &info))
return B_BAD_INDEX;
return fWriter->SetMetaData(info->cookie, data);
return fWriter->SetCopyright(info->cookie, copyright);
}
status_t
BMediaWriter::CommitHeader()
MediaWriter::CommitHeader()
{
if (fWriter == NULL)
return B_NO_INIT;
@ -191,7 +187,7 @@ BMediaWriter::CommitHeader()
status_t
BMediaWriter::Flush()
MediaWriter::Flush()
{
if (fWriter == NULL)
return B_NO_INIT;
@ -201,7 +197,7 @@ BMediaWriter::Flush()
status_t
BMediaWriter::Close()
MediaWriter::Close()
{
if (fWriter == NULL)
return B_NO_INIT;
@ -211,7 +207,7 @@ BMediaWriter::Close()
status_t
BMediaWriter::AddTrackInfo(int32 streamIndex, uint32 code,
MediaWriter::AddTrackInfo(int32 streamIndex, uint32 code,
const void* data, size_t size, uint32 flags)
{
if (fWriter == NULL)
@ -226,7 +222,7 @@ BMediaWriter::AddTrackInfo(int32 streamIndex, uint32 code,
status_t
BMediaWriter::WriteChunk(int32 streamIndex, const void* chunkBuffer,
MediaWriter::WriteChunk(int32 streamIndex, const void* chunkBuffer,
size_t chunkSize, media_encode_info* encodeInfo)
{
if (fWriter == NULL)
@ -240,5 +236,3 @@ BMediaWriter::WriteChunk(int32 streamIndex, const void* chunkBuffer,
encodeInfo);
}
} // namespace BCodecKit

View File

@ -21,13 +21,7 @@
#include "MediaDebug.h"
// Need to stay outside namespace
BCodecKit::BPrivate::PluginManager gPluginManager;
namespace BCodecKit {
namespace BPrivate {
PluginManager gPluginManager;
#define BLOCK_SIZE 4096
#define MAX_STREAMERS 40
@ -231,7 +225,7 @@ private:
status_t
PluginManager::CreateReader(BReader** reader, int32* streamCount,
PluginManager::CreateReader(Reader** reader, int32* streamCount,
media_file_format* mff, BDataIO* source)
{
TRACE("PluginManager::CreateReader enter\n");
@ -261,13 +255,13 @@ PluginManager::CreateReader(BReader** reader, int32* streamCount,
// try each reader by calling it's Sniff function...
for (int32 i = 0; i < count; i++) {
entry_ref ref = refs[i];
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (plugin == NULL) {
printf("PluginManager::CreateReader: GetPlugin failed\n");
return B_ERROR;
}
BReaderPlugin* readerPlugin = dynamic_cast<BReaderPlugin*>(plugin);
ReaderPlugin* readerPlugin = dynamic_cast<ReaderPlugin*>(plugin);
if (readerPlugin == NULL) {
printf("PluginManager::CreateReader: dynamic_cast failed\n");
PutPlugin(plugin);
@ -282,7 +276,7 @@ PluginManager::CreateReader(BReader** reader, int32* streamCount,
}
buffered_source->Seek(0, SEEK_SET);
(*reader)->_Setup(buffered_source);
(*reader)->Setup(buffered_source);
(*reader)->fMediaPlugin = plugin;
if ((*reader)->Sniff(streamCount) == B_OK) {
@ -303,7 +297,7 @@ PluginManager::CreateReader(BReader** reader, int32* streamCount,
void
PluginManager::DestroyReader(BReader* reader)
PluginManager::DestroyReader(Reader* reader)
{
if (reader != NULL) {
TRACE("PluginManager::DestroyReader(%p (plugin: %p))\n", reader,
@ -311,7 +305,7 @@ PluginManager::DestroyReader(BReader* reader)
// NOTE: We have to put the plug-in after deleting the reader,
// since otherwise we may actually unload the code for the
// destructor...
BMediaPlugin* plugin = reader->fMediaPlugin;
MediaPlugin* plugin = reader->fMediaPlugin;
delete reader;
PutPlugin(plugin);
}
@ -319,7 +313,7 @@ PluginManager::DestroyReader(BReader* reader)
status_t
PluginManager::CreateDecoder(BDecoder** _decoder, const media_format& format)
PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format)
{
TRACE("PluginManager::CreateDecoder enter\n");
@ -333,13 +327,13 @@ PluginManager::CreateDecoder(BDecoder** _decoder, const media_format& format)
return ret;
}
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (plugin == NULL) {
printf("PluginManager::CreateDecoder: GetPlugin failed\n");
return B_ERROR;
}
BDecoderPlugin* decoderPlugin = dynamic_cast<BDecoderPlugin*>(plugin);
DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin);
if (decoderPlugin == NULL) {
printf("PluginManager::CreateDecoder: dynamic_cast failed\n");
PutPlugin(plugin);
@ -364,7 +358,7 @@ PluginManager::CreateDecoder(BDecoder** _decoder, const media_format& format)
status_t
PluginManager::CreateDecoder(BDecoder** decoder, const media_codec_info& mci)
PluginManager::CreateDecoder(Decoder** decoder, const media_codec_info& mci)
{
TRACE("PluginManager::CreateDecoder enter\n");
entry_ref ref;
@ -372,13 +366,13 @@ PluginManager::CreateDecoder(BDecoder** decoder, const media_codec_info& mci)
if (status != B_OK)
return status;
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (plugin == NULL) {
ERROR("PluginManager::CreateDecoder: GetPlugin failed\n");
return B_ERROR;
}
BDecoderPlugin* decoderPlugin = dynamic_cast<BDecoderPlugin*>(plugin);
DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin);
if (decoderPlugin == NULL) {
ERROR("PluginManager::CreateDecoder: dynamic_cast failed\n");
PutPlugin(plugin);
@ -404,7 +398,7 @@ PluginManager::CreateDecoder(BDecoder** decoder, const media_codec_info& mci)
status_t
PluginManager::GetDecoderInfo(BDecoder* decoder, media_codec_info* _info) const
PluginManager::GetDecoderInfo(Decoder* decoder, media_codec_info* _info) const
{
if (decoder == NULL)
return B_BAD_VALUE;
@ -418,7 +412,7 @@ PluginManager::GetDecoderInfo(BDecoder* decoder, media_codec_info* _info) const
void
PluginManager::DestroyDecoder(BDecoder* decoder)
PluginManager::DestroyDecoder(Decoder* decoder)
{
if (decoder != NULL) {
TRACE("PluginManager::DestroyDecoder(%p, plugin: %p)\n", decoder,
@ -426,7 +420,7 @@ PluginManager::DestroyDecoder(BDecoder* decoder)
// NOTE: We have to put the plug-in after deleting the decoder,
// since otherwise we may actually unload the code for the
// destructor...
BMediaPlugin* plugin = decoder->fMediaPlugin;
MediaPlugin* plugin = decoder->fMediaPlugin;
delete decoder;
PutPlugin(plugin);
}
@ -437,7 +431,7 @@ PluginManager::DestroyDecoder(BDecoder* decoder)
status_t
PluginManager::CreateWriter(BWriter** writer, const media_file_format& mff,
PluginManager::CreateWriter(Writer** writer, const media_file_format& mff,
BDataIO* target)
{
TRACE("PluginManager::CreateWriter enter\n");
@ -452,13 +446,13 @@ PluginManager::CreateWriter(BWriter** writer, const media_file_format& mff,
return ret;
}
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (plugin == NULL) {
printf("PluginManager::CreateWriter: GetPlugin failed\n");
return B_ERROR;
}
BWriterPlugin* writerPlugin = dynamic_cast<BWriterPlugin*>(plugin);
WriterPlugin* writerPlugin = dynamic_cast<WriterPlugin*>(plugin);
if (writerPlugin == NULL) {
printf("PluginManager::CreateWriter: dynamic_cast failed\n");
PutPlugin(plugin);
@ -472,7 +466,7 @@ PluginManager::CreateWriter(BWriter** writer, const media_file_format& mff,
return B_ERROR;
}
(*writer)->_Setup(target);
(*writer)->Setup(target);
(*writer)->fMediaPlugin = plugin;
TRACE("PluginManager::CreateWriter leave\n");
@ -481,7 +475,7 @@ PluginManager::CreateWriter(BWriter** writer, const media_file_format& mff,
void
PluginManager::DestroyWriter(BWriter* writer)
PluginManager::DestroyWriter(Writer* writer)
{
if (writer != NULL) {
TRACE("PluginManager::DestroyWriter(%p (plugin: %p))\n", writer,
@ -489,7 +483,7 @@ PluginManager::DestroyWriter(BWriter* writer)
// NOTE: We have to put the plug-in after deleting the writer,
// since otherwise we may actually unload the code for the
// destructor...
BMediaPlugin* plugin = writer->fMediaPlugin;
MediaPlugin* plugin = writer->fMediaPlugin;
delete writer;
PutPlugin(plugin);
}
@ -497,7 +491,7 @@ PluginManager::DestroyWriter(BWriter* writer)
status_t
PluginManager::CreateEncoder(BEncoder** _encoder,
PluginManager::CreateEncoder(Encoder** _encoder,
const media_codec_info* codecInfo, uint32 flags)
{
TRACE("PluginManager::CreateEncoder enter\n");
@ -512,13 +506,13 @@ PluginManager::CreateEncoder(BEncoder** _encoder,
return ret;
}
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (!plugin) {
printf("PluginManager::CreateEncoder: GetPlugin failed\n");
return B_ERROR;
}
BEncoderPlugin* encoderPlugin = dynamic_cast<BEncoderPlugin*>(plugin);
EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin);
if (encoderPlugin == NULL) {
printf("PluginManager::CreateEncoder: dynamic_cast failed\n");
PutPlugin(plugin);
@ -541,7 +535,7 @@ PluginManager::CreateEncoder(BEncoder** _encoder,
status_t
PluginManager::CreateEncoder(BEncoder** encoder, const media_format& format)
PluginManager::CreateEncoder(Encoder** encoder, const media_format& format)
{
TRACE("PluginManager::CreateEncoder enter nr2\n");
@ -556,13 +550,13 @@ PluginManager::CreateEncoder(BEncoder** encoder, const media_format& format)
return ret;
}
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (plugin == NULL) {
ERROR("PluginManager::CreateEncoder: GetPlugin failed\n");
return B_ERROR;
}
BEncoderPlugin* encoderPlugin = dynamic_cast<BEncoderPlugin*>(plugin);
EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin);
if (encoderPlugin == NULL) {
ERROR("PluginManager::CreateEncoder: dynamic_cast failed\n");
PutPlugin(plugin);
@ -586,7 +580,7 @@ PluginManager::CreateEncoder(BEncoder** encoder, const media_format& format)
void
PluginManager::DestroyEncoder(BEncoder* encoder)
PluginManager::DestroyEncoder(Encoder* encoder)
{
if (encoder != NULL) {
TRACE("PluginManager::DestroyEncoder(%p, plugin: %p)\n", encoder,
@ -594,7 +588,7 @@ PluginManager::DestroyEncoder(BEncoder* encoder)
// NOTE: We have to put the plug-in after deleting the encoder,
// since otherwise we may actually unload the code for the
// destructor...
BMediaPlugin* plugin = encoder->fMediaPlugin;
MediaPlugin* plugin = encoder->fMediaPlugin;
delete encoder;
PutPlugin(plugin);
}
@ -602,7 +596,7 @@ PluginManager::DestroyEncoder(BEncoder* encoder)
status_t
PluginManager::CreateStreamer(BStreamer** streamer, BUrl url)
PluginManager::CreateStreamer(Streamer** streamer, BUrl url, BDataIO** source)
{
BAutolock _(fLocker);
@ -622,13 +616,13 @@ PluginManager::CreateStreamer(BStreamer** streamer, BUrl url)
// try each reader by calling it's Sniff function...
for (int32 i = 0; i < count; i++) {
entry_ref ref = refs[i];
BMediaPlugin* plugin = GetPlugin(ref);
MediaPlugin* plugin = GetPlugin(ref);
if (plugin == NULL) {
printf("PluginManager::CreateStreamer: GetPlugin failed\n");
return B_ERROR;
}
BStreamerPlugin* streamerPlugin = dynamic_cast<BStreamerPlugin*>(plugin);
StreamerPlugin* streamerPlugin = dynamic_cast<StreamerPlugin*>(plugin);
if (streamerPlugin == NULL) {
printf("PluginManager::CreateStreamer: dynamic_cast failed\n");
PutPlugin(plugin);
@ -645,8 +639,10 @@ PluginManager::CreateStreamer(BStreamer** streamer, BUrl url)
(*streamer)->fMediaPlugin = plugin;
plugin->fRefCount++;
if ((*streamer)->Sniff(url) == B_OK) {
BDataIO* streamSource = NULL;
if ((*streamer)->Sniff(url, &streamSource) == B_OK) {
TRACE("PluginManager::CreateStreamer: Sniff success\n");
*source = streamSource;
return B_OK;
}
@ -660,7 +656,7 @@ PluginManager::CreateStreamer(BStreamer** streamer, BUrl url)
void
PluginManager::DestroyStreamer(BStreamer* streamer)
PluginManager::DestroyStreamer(Streamer* streamer)
{
BAutolock _(fLocker);
@ -671,7 +667,7 @@ PluginManager::DestroyStreamer(BStreamer* streamer)
// NOTE: We have to put the plug-in after deleting the streamer,
// since otherwise we may actually unload the code for the
// destructor...
BMediaPlugin* plugin = streamer->fMediaPlugin;
MediaPlugin* plugin = streamer->fMediaPlugin;
delete streamer;
// Delete the plugin only when every reference is released
@ -710,13 +706,13 @@ PluginManager::~PluginManager()
}
BMediaPlugin*
MediaPlugin*
PluginManager::GetPlugin(const entry_ref& ref)
{
TRACE("PluginManager::GetPlugin(%s)\n", ref.name);
fLocker.Lock();
BMediaPlugin* plugin;
MediaPlugin* plugin;
plugin_info* pinfo;
plugin_info info;
@ -751,7 +747,7 @@ PluginManager::GetPlugin(const entry_ref& ref)
void
PluginManager::PutPlugin(BMediaPlugin* plugin)
PluginManager::PutPlugin(MediaPlugin* plugin)
{
TRACE("PluginManager::PutPlugin()\n");
fLocker.Lock();
@ -780,7 +776,7 @@ PluginManager::PutPlugin(BMediaPlugin* plugin)
status_t
PluginManager::_LoadPlugin(const entry_ref& ref, BMediaPlugin** plugin,
PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin,
image_id* image)
{
BPath p(&ref);
@ -794,7 +790,7 @@ PluginManager::_LoadPlugin(const entry_ref& ref, BMediaPlugin** plugin,
return B_ERROR;
}
BMediaPlugin* (*instantiate_plugin_func)();
MediaPlugin* (*instantiate_plugin_func)();
if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT,
(void**)&instantiate_plugin_func) < B_OK) {
@ -804,7 +800,7 @@ PluginManager::_LoadPlugin(const entry_ref& ref, BMediaPlugin** plugin,
return B_ERROR;
}
BMediaPlugin *pl;
MediaPlugin *pl;
pl = (*instantiate_plugin_func)();
if (pl == NULL) {
@ -818,7 +814,3 @@ PluginManager::_LoadPlugin(const entry_ref& ref, BMediaPlugin** plugin,
*image = id;
return B_OK;
}
} // namespace BPrivate
} // namespace BCodecKit

View File

@ -0,0 +1,81 @@
/*
* Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de>.
* Distributed under the terms of the MIT License.
*
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "ReaderPlugin.h"
#include <stdio.h>
Reader::Reader()
:
fSource(NULL),
fMediaPlugin(NULL)
{
}
Reader::~Reader()
{
}
status_t
Reader::GetMetaData(BMessage* _data)
{
return B_NOT_SUPPORTED;
}
status_t
Reader::Seek(void* cookie, uint32 flags, int64* frame, bigtime_t* time)
{
return B_NOT_SUPPORTED;
}
status_t
Reader::FindKeyFrame(void* cookie, uint32 flags, int64* frame, bigtime_t* time)
{
return B_NOT_SUPPORTED;
}
status_t
Reader::GetStreamMetaData(void* cookie, BMessage* _data)
{
return B_NOT_SUPPORTED;
}
BDataIO*
Reader::Source() const
{
return fSource;
}
void
Reader::Setup(BDataIO *source)
{
fSource = source;
}
status_t
Reader::Perform(perform_code code, void* _data)
{
return B_OK;
}
void Reader::_ReservedReader1() {}
void Reader::_ReservedReader2() {}
void Reader::_ReservedReader3() {}
void Reader::_ReservedReader4() {}
void Reader::_ReservedReader5() {}

View File

@ -0,0 +1,25 @@
/*
* Copyright 2016, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "StreamerPlugin.h"
Streamer::Streamer()
:
fMediaPlugin(NULL)
{
}
Streamer::~Streamer()
{
}
void Streamer::_ReservedStreamer1() {}
void Streamer::_ReservedStreamer2() {}
void Streamer::_ReservedStreamer3() {}
void Streamer::_ReservedStreamer4() {}
void Streamer::_ReservedStreamer5() {}

View File

@ -0,0 +1,50 @@
/*
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
* Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "WriterPlugin.h"
#include <stdio.h>
Writer::Writer()
:
fTarget(NULL),
fMediaPlugin(NULL)
{
}
Writer::~Writer()
{
}
BDataIO*
Writer::Target() const
{
return fTarget;
}
void
Writer::Setup(BDataIO* target)
{
fTarget = target;
}
status_t
Writer::Perform(perform_code code, void* data)
{
return B_OK;
}
void Writer::_ReservedWriter1() {}
void Writer::_ReservedWriter2() {}
void Writer::_ReservedWriter3() {}
void Writer::_ReservedWriter4() {}
void Writer::_ReservedWriter5() {}

View File

@ -4,20 +4,15 @@
*
*/
#include <AdapterIO.h>
#include "AdapterIO.h"
#include <MediaIO.h>
#include <RWLocker.h>
#include <string.h>
#include "MediaDebug.h"
namespace BCodecKit {
#define TIMEOUT_QUANTA 100000
@ -465,6 +460,3 @@ void BAdapterIO::_ReservedAdapterIO5() {}
void BInputAdapter::_ReservedInputAdapter1() {}
void BInputAdapter::_ReservedInputAdapter2() {}
} // namespace BCodecKit

View File

@ -337,9 +337,6 @@ BMediaClient::Start()
remoteNode, fNode->TimeSource()->Now());
}
if (err != B_OK)
return err;
return BMediaRoster::CurrentRoster()->StartNode(
fNode->Node(), fNode->TimeSource()->Now());
}

View File

@ -4,13 +4,9 @@
*
*/
#include <MediaIO.h>
namespace BCodecKit {
BMediaIO::BMediaIO()
{
}
@ -33,6 +29,3 @@ void BMediaIO::_ReservedMediaIO2() {}
void BMediaIO::_ReservedMediaIO3() {}
void BMediaIO::_ReservedMediaIO4() {}
void BMediaIO::_ReservedMediaIO5() {}
} // namespace BCodecKit

View File

@ -12,6 +12,7 @@ class BufferManager;
class NotificationManager;
class MediaFilesManager;
class AddOnManager;
class FormatManager;
extern AppManager* gAppManager;
extern NodeManager* gNodeManager;
@ -19,5 +20,6 @@ extern BufferManager* gBufferManager;
extern NotificationManager* gNotificationManager;
extern MediaFilesManager* gMediaFilesManager;
extern AddOnManager* gAddOnManager;
extern FormatManager* gFormatManager;
#endif // MEDIA_SERVER_H