Codec Kit: Introduce BCodecKit namespace

This commit is contained in:
Barrett17
2018-11-27 11:38:04 +01:00
parent 247414814e
commit d33bd9ec7b
39 changed files with 258 additions and 136 deletions
+7
View File
@@ -12,6 +12,9 @@
#include <SupportDefs.h>
namespace BCodecKit {
class BAdapterIO;
class RelativePositionIO;
@@ -95,4 +98,8 @@ private:
uint32 _reserved[5];
};
} // namespace BCodecKit
#endif // _ADAPTER_IO_H
+4 -5
View File
@@ -5,6 +5,7 @@
#ifndef _CODEC_ROSTER_H
#define _CODEC_ROSTER_H
#include <Decoder.h>
#include <Encoder.h>
#include <MediaDefs.h>
@@ -13,8 +14,7 @@
#include <Writer.h>
namespace BPrivate {
namespace media {
namespace BCodecKit {
class BCodecRoster {
@@ -118,9 +118,8 @@ public:
static status_t GetNextEncoder(int32* cookie, media_codec_info* _codecInfo);
};
} // namespace media
} // namespace BPrivate
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _CODEC_ROSTER_H
+8 -5
View File
@@ -8,9 +8,12 @@
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class PluginManager;
class BChunkProvider {
public:
@@ -63,7 +66,7 @@ private:
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class PluginManager;
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedDecoder1();
virtual void _ReservedDecoder2();
@@ -84,8 +87,8 @@ public:
size_t* count) = 0;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _DECODER_PLUGIN_H
+8 -6
View File
@@ -6,16 +6,18 @@
#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 {
public:
@@ -94,7 +96,7 @@ private:
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class PluginManager;
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedEncoder1();
virtual void _ReservedEncoder2();
@@ -139,8 +141,8 @@ public:
media_format* outputFormat) = 0;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
}
#endif // _ENCODER_PLUGIN_H
+3 -7
View File
@@ -14,12 +14,9 @@
#include <Reader.h>
namespace BPrivate {
namespace media {
namespace BCodecKit {
class ChunkCache;
struct chunk_buffer;
struct stream_info;
@@ -85,9 +82,8 @@ private:
uint32 fReserved[5];
};
} // namespace media
} // namespace BPrivate
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _MEDIA_EXTRACTOR_H
+7
View File
@@ -10,6 +10,9 @@
#include <SupportDefs.h>
namespace BCodecKit {
enum media_io_flags {
B_MEDIA_STREAMING = 0x00000001,
@@ -41,4 +44,8 @@ private:
uint32 _reserved[5];
};
} // namespace BCodecKit
#endif // _MEDIA_IO_H
+12 -8
View File
@@ -5,9 +5,15 @@
#ifndef _MEDIA_PLUGIN_H
#define _MEDIA_PLUGIN_H
#include <SupportDefs.h>
namespace BPrivate { namespace media {
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
// TODO: Shouldn't this be a BReferenceable?
@@ -23,7 +29,7 @@ private:
int32 fRefCount;
// needed for plug-in reference count management
friend class PluginManager;
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedMediaPlugin1();
virtual void _ReservedMediaPlugin2();
@@ -31,13 +37,11 @@ private:
uint32 fReserved[5];
};
class BDecoder;
class BReader;
} } // namespace BPrivate::media
using namespace BPrivate::media;
extern "C" BMediaPlugin* instantiate_plugin();
} // namespace BCodecKit
#endif // _MEDIA_PLUGIN_H
+3 -7
View File
@@ -6,13 +6,11 @@
#define _MEDIA_STREAMER_H
#include <Streamer.h>
#include <Url.h>
#include "Streamer.h"
namespace BPrivate {
namespace media {
namespace BCodecKit {
class BMediaStreamer {
@@ -33,9 +31,7 @@ private:
};
}; // namespace media
}; // namespace BPrivate
} // namespace BCodecKit
using namespace BPrivate::media;
#endif
+3 -6
View File
@@ -5,6 +5,7 @@
#ifndef _MEDIA_WRITER_H
#define _MEDIA_WRITER_H
#include <Encoder.h>
#include <MetaData.h>
#include <Writer.h>
@@ -12,8 +13,7 @@
#include "TList.h"
namespace BPrivate {
namespace media {
namespace BCodecKit {
class BMediaWriter {
@@ -63,10 +63,7 @@ private:
};
}; // namespace media
}; // namespace BPrivate
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _MEDIA_WRITER_H
+3 -6
View File
@@ -2,7 +2,6 @@
* Copyright 2018, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _META_DATA_H
#define _META_DATA_H
@@ -10,8 +9,7 @@
#include <Message.h>
namespace BPrivate {
namespace media {
namespace BCodecKit {
// Playback capabilities
@@ -114,9 +112,8 @@ private:
BMetaData(const BMetaData&);
};
} // namespace media
} // namespace BPrivate
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _META_DATA_H
+8 -6
View File
@@ -8,9 +8,12 @@
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class PluginManager;
enum {
B_MEDIA_SEEK_TO_TIME = 0x10000,
@@ -62,8 +65,7 @@ private:
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class PluginManager;
friend class MediaExtractor;
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedReader1();
virtual void _ReservedReader2();
@@ -80,8 +82,8 @@ public:
virtual BReader* NewReader() = 0;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _READER_PLUGIN_H
+6 -6
View File
@@ -12,9 +12,11 @@
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
namespace BCodecKit {
class PluginManager;
namespace BPrivate {
class PluginManager;
}
class BStreamer {
@@ -28,8 +30,7 @@ protected:
private:
BMediaPlugin* fMediaPlugin;
friend class PluginManager;
friend class MediaStreamer;
friend class BCodecKit::BPrivate::PluginManager;
virtual void _ReservedStreamer1();
virtual void _ReservedStreamer2();
@@ -48,9 +49,8 @@ public:
virtual BStreamer* NewStreamer() = 0;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _STREAMER_PLUGIN_H
+9 -6
View File
@@ -6,9 +6,13 @@
#include "MediaPlugin.h"
namespace BPrivate { namespace media {
class PluginManager;
namespace BCodecKit {
namespace BPrivate {
class PluginManager;
}
class BWriter {
public:
@@ -51,7 +55,7 @@ private:
BMediaPlugin* fMediaPlugin;
// needed for plug-in reference count management
friend class PluginManager;
friend class BCodecKit::BPrivate::PluginManager;
friend class BMediaWriter;
virtual void _ReservedWriter1();
@@ -70,11 +74,10 @@ public:
virtual status_t GetSupportedFileFormats(
const media_file_format** _fileFormats,
size_t* _count) = 0;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
} // namespace BCodecKit
#endif // _WRITER_PLUGIN_H
+5 -9
View File
@@ -4,15 +4,11 @@
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace BPrivate {
namespace BCodecKit {
class BDecoder;
}
namespace BPrivate {
namespace media {
class BDecoder;
class BDecoderPlugin;
}
}
class BMediaDecoder {
public:
@@ -47,8 +43,8 @@ class BMediaDecoder {
status_t AttachToDecoder();
BPrivate::media::BDecoder* fDecoder;
status_t fInitStatus;
BCodecKit::BDecoder* fDecoder;
status_t fInitStatus;
/* fbc data and virtuals */
+5 -2
View File
@@ -26,8 +26,9 @@
#include "TList.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
class AddOnManager {
public:
@@ -131,7 +132,9 @@ private:
static AddOnManager sInstance;
};
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit
#endif // _ADD_ON_MANAGER_H
+8 -4
View File
@@ -20,7 +20,10 @@
#include "TList.h"
namespace BPrivate { namespace media {
namespace BCodecKit {
namespace BPrivate {
class PluginManager {
public:
@@ -87,10 +90,11 @@ private:
BLocker fLocker;
};
} } // namespace BPrivate::media
using namespace BPrivate::media;
} } // namespace BCodecKit::BPrivate
extern BCodecKit::BPrivate::PluginManager gPluginManager;
extern PluginManager gPluginManager;
#endif // _PLUGIN_MANAGER_H
@@ -17,6 +17,7 @@
#include <MediaFormats.h>
#include <Reader.h>
using namespace BCodecKit;
extern "C" {
#include "avcodec.h"
@@ -9,6 +9,7 @@
#include <Encoder.h>
#include <MediaFormats.h>
using namespace BCodecKit;
extern "C" {
#include "avcodec.h"
@@ -10,6 +10,8 @@
#include <Locker.h>
#include <String.h>
using namespace BCodecKit;
class AVFormatReader : public BReader {
public:
@@ -9,6 +9,8 @@
#include <Writer.h>
#include <Locker.h>
using namespace BCodecKit;
extern "C" {
#include "avformat.h"
@@ -17,6 +17,8 @@
#include <Reader.h>
#include <Writer.h>
using namespace BCodecKit;
class FFmpegPlugin : public BReaderPlugin, public BDecoderPlugin,
public BWriterPlugin, public BEncoderPlugin {
+7 -1
View File
@@ -5,7 +5,7 @@
*/
#include "AdapterIO.h"
#include <AdapterIO.h>
#include <MediaIO.h>
@@ -14,6 +14,9 @@
#include "MediaDebug.h"
namespace BCodecKit {
#define TIMEOUT_QUANTA 100000
@@ -461,3 +464,6 @@ void BAdapterIO::_ReservedAdapterIO5() {}
void BInputAdapter::_ReservedInputAdapter1() {}
void BInputAdapter::_ReservedInputAdapter2() {}
} // namespace BCodecKit
+2 -3
View File
@@ -29,9 +29,8 @@
#include "MetaFormat.h"
namespace BCodecKit {
namespace BPrivate {
namespace media {
// #pragma mark - ImageLoader
@@ -675,5 +674,5 @@ AddOnManager::_GetReaders(const BPath& path, entry_ref* outRefs,
}
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit
+8
View File
@@ -15,6 +15,10 @@
// #pragma mark -
namespace BCodecKit {
namespace BPrivate {
ChunkCache::ChunkCache(sem_id waitSem, size_t maxBytes)
:
BLocker("media chunk cache"),
@@ -156,3 +160,7 @@ ChunkCache::ReadNextChunk(BReader* reader, void* cookie)
fChunkCache.push(chunk);
return chunk->status == B_OK;
}
} // namespace BPrivate
} // namespace BCodecKit
+3 -3
View File
@@ -14,8 +14,8 @@
#include <deque>
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
@@ -54,9 +54,9 @@ private:
};
} // namespace media
} // namespace BPrivate
} // namespace BCodecKit
using namespace BPrivate::media;
//using namespace BPrivate::media;
#endif // _CHUNK_CACHE_H
+6
View File
@@ -10,6 +10,9 @@
#include "PluginManager.h"
namespace BCodecKit {
status_t
BCodecRoster::InstantiateReader(BReader** reader, int32* streamCount,
media_file_format* mff, BDataIO* source)
@@ -131,3 +134,6 @@ BCodecRoster::GetNextEncoder(int32* cookie, media_codec_info* _codecInfo)
{
return get_next_encoder(cookie, _codecInfo);
}
} // namespace BCodecKit
+6
View File
@@ -12,6 +12,9 @@
#include <string.h>
namespace BCodecKit {
BDecoder::BDecoder()
:
fChunkProvider(NULL),
@@ -69,3 +72,6 @@ BChunkProvider::BChunkProvider()
BChunkProvider::~BChunkProvider()
{
}
} // namespace BCodecKit
+6
View File
@@ -13,6 +13,9 @@
#include <string.h>
namespace BCodecKit {
BEncoder::BEncoder()
:
fChunkWriter(NULL),
@@ -146,3 +149,6 @@ BChunkWriter::BChunkWriter()
BChunkWriter::~BChunkWriter()
{
}
} // namespace BCodecKit
+10 -1
View File
@@ -20,6 +20,12 @@
#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
@@ -27,7 +33,7 @@
static const size_t kMaxCacheBytes = 3 * 1024 * 1024;
struct BPrivate::media::stream_info {
struct stream_info {
status_t status;
void* cookie;
bool hasCookie;
@@ -481,3 +487,6 @@ BMediaExtractor::_ExtractorThread()
} while (streamsFilled < fStreamCount);
}
}
} // namespace BCodecKit
+6
View File
@@ -8,6 +8,9 @@
#include <MediaIO.h>
namespace BCodecKit {
BMediaIO::BMediaIO()
{
}
@@ -30,3 +33,6 @@ void BMediaIO::_ReservedMediaIO2() {}
void BMediaIO::_ReservedMediaIO3() {}
void BMediaIO::_ReservedMediaIO4() {}
void BMediaIO::_ReservedMediaIO5() {}
} // namespace BCodecKit
+6
View File
@@ -7,6 +7,9 @@
#include "MediaPlugin.h"
namespace BCodecKit {
BMediaPlugin::BMediaPlugin()
:
fRefCount(0)
@@ -22,3 +25,6 @@ BMediaPlugin::~BMediaPlugin()
// FBC
void BMediaPlugin::_ReservedMediaPlugin1() {}
void BMediaPlugin::_ReservedMediaPlugin2() {}
} // namespace BCodecKit
+6
View File
@@ -14,6 +14,9 @@
#include "PluginManager.h"
namespace BCodecKit {
BMediaStreamer::BMediaStreamer(BUrl url)
:
fStreamer(NULL)
@@ -45,3 +48,6 @@ BMediaStreamer::CreateAdapter(BDataIO** adapter)
return gPluginManager.CreateStreamer(&fStreamer, fUrl, adapter);
}
} // namespace BCodecKit
+6
View File
@@ -18,6 +18,9 @@
#include "PluginManager.h"
namespace BCodecKit {
class BMediaExtractorChunkWriter : public BChunkWriter {
public:
BMediaExtractorChunkWriter(BMediaWriter* writer, int32 streamIndex)
@@ -234,3 +237,6 @@ BMediaWriter::WriteChunk(int32 streamIndex, const void* chunkBuffer,
return fWriter->WriteChunk(info->cookie, chunkBuffer, chunkSize,
encodeInfo);
}
} // namespace BCodecKit
+46 -43
View File
@@ -10,56 +10,56 @@
#include <stdio.h>
#include <stdlib.h>
#define P BPrivate::media
const char* P::kCanPause = "canpause";
const char* P::kCanSeekBackward = "canseekbackward";
const char* P::kCanSeekForward = "canseekforward";
const char* P::kCanSeek = "canseek";
namespace BCodecKit {
const char* P::kAudioBitRate = "audiobitrate";
const char* P::kVideoBitRate = "videobitrate";
const char* P::kAudioSampleRate = "audiosamplerate";
const char* P::kVideoFrameRate = "videoframerate";
const char* P::kMimeType = "mime";
const char* P::kAudioCodec = "audiocodec";
const char* P::kVideoCodec = "videocodec";
const char* P::kVideoHeight = "videoheight";
const char* P::kVideoWidth = "videowidth";
const char* P::kNumTracks = "numtracks";
const char* P::kDrmCrippled = "drmcrippled";
const char* kCanPause = "canpause";
const char* kCanSeekBackward = "canseekbackward";
const char* kCanSeekForward = "canseekforward";
const char* kCanSeek = "canseek";
const char* P::kTitle = "title";
const char* P::kComment = "comment";
const char* P::kCopyright = "copyright";
const char* P::kAlbum = "album";
const char* P::kArtist = "artist";
const char* P::kAuthor = "author";
const char* P::kComposer = "composer";
const char* P::kGenre = "genre";
const char* P::kDuration = "duration";
const char* P::kRating = "rating";
const char* P::kCDTrackNum = "cdtracknumber";
const char* P::kCDTrackMax = "cdtrackmax";
const char* P::kDate = "date";
const char* P::kEncodedBy = "encoded_by";
const char* P::kLanguage = "language";
const char* P::kAlbumArtist = "album_artist";
const char* P::kPerformer = "performer";
const char* P::kDisc = "disc";
const char* P::kPublisher = "publisher";
const char* P::kTrack = "track";
const char* P::kEncoder = "encoder";
const char* P::kYear = "year";
const char* kAudioBitRate = "audiobitrate";
const char* kVideoBitRate = "videobitrate";
const char* kAudioSampleRate = "audiosamplerate";
const char* kVideoFrameRate = "videoframerate";
const char* P::kChapter = "be:chapter";
const char* P::kChapterStart = "be:chapter:start";
const char* P::kChapterEnd = "be:chapter:end";
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* P::kProgramData = "be:program";
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";
#undef P
const char* kChapter = "be:chapter";
const char* kChapterStart = "be:chapter:start";
const char* kChapterEnd = "be:chapter:end";
const char* kProgramData = "be:program";
BMetaData::BMetaData()
@@ -189,3 +189,6 @@ BMetaData::operator=(const BMetaData& other)
fMessage = new BMessage(*other.fMessage);
return *this;
}
} // namespace BCodecKit
+8
View File
@@ -21,6 +21,10 @@
#include "MediaDebug.h"
namespace BCodecKit {
namespace BPrivate {
PluginManager gPluginManager;
#define BLOCK_SIZE 4096
@@ -814,3 +818,7 @@ PluginManager::_LoadPlugin(const entry_ref& ref, BMediaPlugin** plugin,
*image = id;
return B_OK;
}
} // namespace BPrivate
} // namespace BCodecKit
+6
View File
@@ -12,6 +12,9 @@
#include <stdio.h>
namespace BCodecKit {
BReader::BReader()
:
fSource(NULL),
@@ -79,3 +82,6 @@ void BReader::_ReservedReader2() {}
void BReader::_ReservedReader3() {}
void BReader::_ReservedReader4() {}
void BReader::_ReservedReader5() {}
} // namespace BCodecKit
+6
View File
@@ -7,6 +7,9 @@
#include <Streamer.h>
namespace BCodecKit {
BStreamer::BStreamer()
:
fMediaPlugin(NULL)
@@ -29,3 +32,6 @@ void BStreamer::_ReservedStreamer5() {}
BStreamerPlugin::BStreamerPlugin()
{
}
}
+6
View File
@@ -10,6 +10,9 @@
#include <stdio.h>
namespace BCodecKit {
BWriter::BWriter()
:
fTarget(NULL),
@@ -49,3 +52,6 @@ void BWriter::_ReservedWriter2() {}
void BWriter::_ReservedWriter3() {}
void BWriter::_ReservedWriter4() {}
void BWriter::_ReservedWriter5() {}
}
+7 -2
View File
@@ -3,12 +3,17 @@
* FILE: MediaDecoder.cpp
* DESCR:
***********************************************************************/
#include <MediaDecoder.h>
#include <CodecRoster.h>
#include <Decoder.h>
#include <MediaDecoder.h>
#include <new>
#include "PluginManager.h"
#include "MediaDebug.h"
using namespace BCodecKit;
/*************************************************************
* public BMediaDecoder
*************************************************************/