[haiku-commits] haiku: hrev52613 - headers/os/codec src/add-ons/media/plugins/http_streamer src/add-ons/media/plugins/ffmpeg src/add-ons/media/plugins/raw_decoder src/add-ons/media/plugins/ape_reader

  • From: Barrett17 <b.vitruvio@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 1 Dec 2018 05:22:30 -0500 (EST)

hrev52613 adds 1 changeset to branch 'master'
old head: cf6760f20ccec7f99cc6c25c80b922819e1928cf
new head: a57cf128a651f0596e5a704dd2504171b1ab38f9
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=a57cf128a651+%5Ecf6760f20cce

----------------------------------------------------------------------------

a57cf128a651: 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.

                                        [ Barrett17 <b.vitruvio@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev52613
Commit:      a57cf128a651f0596e5a704dd2504171b1ab38f9
URL:         https://git.haiku-os.org/haiku/commit/?id=a57cf128a651
Author:      Barrett17 <b.vitruvio@xxxxxxxxx>
Date:        Sat Dec  1 10:11:46 2018 UTC

----------------------------------------------------------------------------

5 files changed, 55 insertions(+), 30 deletions(-)
headers/os/codec/MediaPlugin.h                   | 24 ++++++++++++++++++++
.../media/plugins/ape_reader/APEReader.cpp       | 14 ++++++------
.../media/plugins/ffmpeg/FFmpegPlugin.cpp        | 19 +++++++---------
.../plugins/http_streamer/HTTPStreamerPlugin.cpp | 15 ++++++------
.../plugins/raw_decoder/RawDecoderPlugin.cpp     | 13 +++++++----

----------------------------------------------------------------------------

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 <superstippi@xxxxxx>
+ * 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;
-}


Other related posts:

  • » [haiku-commits] haiku: hrev52613 - headers/os/codec src/add-ons/media/plugins/http_streamer src/add-ons/media/plugins/ffmpeg src/add-ons/media/plugins/raw_decoder src/add-ons/media/plugins/ape_reader - Barrett17