Codec Kit: Introduce declarative macro with version and name
* Namespaces protect symbols, I didn't consider that when adding the BCodecKit namespace, so, the AddOnManager complained that instantiate_plugin() was missing. A macro is introduced that allow plugins to specify it's className, version and name, this ease the declaration of the plugin symbols, otherwise the function should have been declared inside the BCodecKit namespace which we would like to avoid. * The code is also more future proof, since in future the AddOn manager can begin to check for plugin versions.
This commit is contained in:
parent
cf6760f20c
commit
a57cf128a6
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* 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
|
||||
@ -39,6 +40,29 @@ private:
|
||||
|
||||
|
||||
extern "C" BMediaPlugin* instantiate_plugin();
|
||||
extern "C" uint32 get_plugin_version();
|
||||
extern "C" const char* get_plugin_name();
|
||||
|
||||
|
||||
#define B_CODEC_KIT_PLUGIN_VERSION 1
|
||||
|
||||
#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
|
||||
|
@ -10,6 +10,13 @@
|
||||
#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";
|
||||
|
||||
@ -278,10 +285,3 @@ TAPEReaderPlugin::NewReader()
|
||||
{
|
||||
return new TAPEReader();
|
||||
}
|
||||
|
||||
|
||||
BMediaPlugin*
|
||||
instantiate_plugin()
|
||||
{
|
||||
return new TAPEReaderPlugin();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
* 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.
|
||||
*/
|
||||
@ -40,6 +41,13 @@ extern "C" {
|
||||
#define ERROR(a...) fprintf(stderr, a)
|
||||
|
||||
|
||||
B_DECLARE_CODEC_KIT_PLUGIN(
|
||||
FFmpegPlugin,
|
||||
"ffmpeg",
|
||||
B_CODEC_KIT_PLUGIN_VERSION
|
||||
);
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
@ -128,14 +136,3 @@ FFmpegPlugin::RegisterNextEncoder(int32* cookie, media_codec_info* _codecInfo,
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
BMediaPlugin*
|
||||
instantiate_plugin()
|
||||
{
|
||||
return new(std::nothrow) FFmpegPlugin;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016, Dario Casalinuovo
|
||||
* Copyright 2016-2018, Dario Casalinuovo
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -11,6 +11,13 @@
|
||||
#include "MediaDebug.h"
|
||||
|
||||
|
||||
B_DECLARE_CODEC_KIT_PLUGIN(
|
||||
HTTPStreamerPlugin,
|
||||
"http_streamer",
|
||||
B_CODEC_KIT_PLUGIN_VERSION
|
||||
);
|
||||
|
||||
|
||||
HTTPStreamer::HTTPStreamer()
|
||||
{
|
||||
CALLED();
|
||||
@ -45,9 +52,3 @@ HTTPStreamerPlugin::NewStreamer()
|
||||
{
|
||||
return new HTTPStreamer();
|
||||
}
|
||||
|
||||
|
||||
BMediaPlugin *instantiate_plugin()
|
||||
{
|
||||
return new HTTPStreamerPlugin();
|
||||
}
|
||||
|
@ -40,6 +40,14 @@
|
||||
#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 */)
|
||||
{
|
||||
@ -564,8 +572,3 @@ RawDecoderPlugin::GetSupportedFormats(media_format ** formats, size_t * count)
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
BMediaPlugin *instantiate_plugin()
|
||||
{
|
||||
return new RawDecoderPlugin;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user