From 26ae81de1da642b94ead7f13ad400cbe1c7b218f Mon Sep 17 00:00:00 2001 From: casey langen Date: Wed, 2 Jan 2019 21:47:44 -0800 Subject: [PATCH] Initial boilerplate. --- CMakeLists.txt | 1 + src/plugins/gmedecoder/CMakeLists.txt | 7 ++ src/plugins/gmedecoder/GmeDecoder.cpp | 65 ++++++++++++++++ src/plugins/gmedecoder/GmeDecoder.h | 55 +++++++++++++ src/plugins/gmedecoder/plugin.cpp | 108 ++++++++++++++++++++++++++ 5 files changed, 236 insertions(+) create mode 100644 src/plugins/gmedecoder/CMakeLists.txt create mode 100644 src/plugins/gmedecoder/GmeDecoder.cpp create mode 100644 src/plugins/gmedecoder/GmeDecoder.h create mode 100644 src/plugins/gmedecoder/plugin.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 824868570..b90bc6885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,7 @@ add_subdirectory(src/plugins/server) add_subdirectory(src/plugins/httpdatastream) add_subdirectory(src/plugins/stockencoders) add_subdirectory(src/plugins/supereqdsp) +add_subdirectory(src/plugins/gmedecoder) if (${FFMPEG_DECODER} MATCHES "false") message(STATUS "[ffmpeg] decoder enabled = false") diff --git a/src/plugins/gmedecoder/CMakeLists.txt b/src/plugins/gmedecoder/CMakeLists.txt new file mode 100644 index 000000000..887989f5e --- /dev/null +++ b/src/plugins/gmedecoder/CMakeLists.txt @@ -0,0 +1,7 @@ +set (gmedecoder_SOURCES + plugin.cpp + GmeDecoder.cpp +) + +add_library(gmedecoder SHARED ${gmedecoder_SOURCES}) +target_link_libraries(gmedecoder ${musikcube_LINK_LIBS}) diff --git a/src/plugins/gmedecoder/GmeDecoder.cpp b/src/plugins/gmedecoder/GmeDecoder.cpp new file mode 100644 index 000000000..5580a312f --- /dev/null +++ b/src/plugins/gmedecoder/GmeDecoder.cpp @@ -0,0 +1,65 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2004-2019 musikcube team +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// + +#include "GmeDecoder.h" + +GmeDecoder::GmeDecoder() { +} + +GmeDecoder::~GmeDecoder() { +} + +bool GmeDecoder::Open(musik::core::sdk::IDataStream *stream){ + return false; +} + +void GmeDecoder::Release() { + delete this; +} + +double GmeDecoder::SetPosition(double seconds) { + return -1; +} + +double GmeDecoder::GetDuration() { + return 0; +} + +bool GmeDecoder::GetBuffer(IBuffer *buffer) { + return false; +} + +bool GmeDecoder::Exhausted() { + return false; +} diff --git a/src/plugins/gmedecoder/GmeDecoder.h b/src/plugins/gmedecoder/GmeDecoder.h new file mode 100644 index 000000000..3ac92334d --- /dev/null +++ b/src/plugins/gmedecoder/GmeDecoder.h @@ -0,0 +1,55 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2004-2019 musikcube team +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include + +using namespace musik::core::sdk; + +class GmeDecoder: public musik::core::sdk::IDecoder { + public: + GmeDecoder(); + ~GmeDecoder(); + + virtual void Release() override; + virtual double SetPosition(double seconds) override; + virtual bool GetBuffer(IBuffer *buffer) override; + virtual double GetDuration() override; + virtual bool Open(musik::core::sdk::IDataStream *stream) override; + virtual bool Exhausted() override; +}; diff --git a/src/plugins/gmedecoder/plugin.cpp b/src/plugins/gmedecoder/plugin.cpp new file mode 100644 index 000000000..367f37526 --- /dev/null +++ b/src/plugins/gmedecoder/plugin.cpp @@ -0,0 +1,108 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2004-2019 musikcube team +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include "GmeDecoder.h" + +#ifdef WIN32 + #define DLLEXPORT __declspec(dllexport) +#else + #define DLLEXPORT +#endif + +#ifdef WIN32 + BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + return true; + } +#endif + +static const std::set FORMATS = { + "vgm", "gym", "spc", "sap", "nsfe", + "nsf", "ay", "gbs", "hes", "kss" +}; + +static inline bool supported(const std::string& s) { + for (auto& ext : FORMATS) { + if (s.rfind(ext) == s.size() - ext.size()) { + return true; + } + } + return false; +} + +class GmePlugin : public musik::core::sdk::IPlugin { + public: + virtual void Release() { delete this; }; + virtual const char* Name() { return "GME IDecoder"; } + virtual const char* Version() { return "0.1.0"; } + virtual const char* Author() { return "clangen"; } + virtual const char* Guid() { return "2c4eee19-6585-4984-a631-b52ff7d6d564"; } + virtual bool Configurable() { return false; } + virtual void Configure() { } + virtual void Reload() { } + virtual int SdkVersion() { return musik::core::sdk::SdkVersion; } +}; + +class GmeDecoderFactory : public musik::core::sdk::IDecoderFactory { + public: + GmeDecoderFactory() { + } + + ~GmeDecoderFactory() { + } + + virtual musik::core::sdk::IDecoder* CreateDecoder() override { + return new GmeDecoder(); + } + + virtual void Release() override { + delete this; + } + + virtual bool CanHandle(const char* type) const override { + return supported(std::string(type)); + } +}; + +extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() { + return new GmePlugin(); +} + +extern "C" DLLEXPORT musik::core::sdk::IDecoderFactory* GetDecoderFactory() { + return new GmeDecoderFactory(); +}