diff --git a/headers/os/codec/MediaPlugin.h b/headers/os/codec/MediaPlugin.h index d3809b40a7..3af688c405 100644 --- a/headers/os/codec/MediaPlugin.h +++ b/headers/os/codec/MediaPlugin.h @@ -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 diff --git a/src/add-ons/media/plugins/ape_reader/APEReader.cpp b/src/add-ons/media/plugins/ape_reader/APEReader.cpp index 5f0c40304d..96475f6a17 100644 --- a/src/add-ons/media/plugins/ape_reader/APEReader.cpp +++ b/src/add-ons/media/plugins/ape_reader/APEReader.cpp @@ -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(); -} diff --git a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp index 17ae4c48f4..c83182c7a7 100644 --- a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp +++ b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp @@ -4,6 +4,7 @@ * Copyright (C) 2001 Axel Dörfler * Copyright (C) 2004 Marcus Overhagen * Copyright (C) 2009 Stephan Aßmus + * 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; -} - diff --git a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp index d81966ebb4..911bfb680e 100644 --- a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp +++ b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp @@ -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(); -} diff --git a/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp b/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp index b1dd0470aa..4f5dcd84db 100644 --- a/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp +++ b/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp @@ -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; -}