diff --git a/AudioFilter/CMakeLists.txt b/AudioFilter/CMakeLists.txt index 0044e42d69a1bcfa05eb0287134fd220b4741bff..c2bd485c96c05a6c2415ca973e6c98cdca538f2b 100644 --- a/AudioFilter/CMakeLists.txt +++ b/AudioFilter/CMakeLists.txt @@ -37,15 +37,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") -set(plugin_SRC filterMediaHandler.cpp - filterAudioSubscriber.cpp +set(plugin_SRC FilterMediaHandler.cpp + FilterAudioSubscriber.cpp main.cpp ../lib/frameFilter.cpp ../lib/frameUtils.cpp ) -set(plugin_HDR filterMediaHandler.h - filterAudioSubscriber.h +set(plugin_HDR FilterMediaHandler.h + FilterAudioSubscriber.h ../lib/frameUtils.h ../lib/audioFormat.h ../lib/frameFilter.h diff --git a/AudioFilter/filterAudioSubscriber.cpp b/AudioFilter/FilterAudioSubscriber.cpp similarity index 99% rename from AudioFilter/filterAudioSubscriber.cpp rename to AudioFilter/FilterAudioSubscriber.cpp index 13e7fee69c8d147887e194652c721841cf9a8c97..0ff8a27138b5f0fd7074687fd31b2ec666c07c34 100644 --- a/AudioFilter/filterAudioSubscriber.cpp +++ b/AudioFilter/FilterAudioSubscriber.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "filterAudioSubscriber.h" +#include "FilterAudioSubscriber.h" extern "C" { #include <libavcodec/avcodec.h> diff --git a/AudioFilter/filterAudioSubscriber.h b/AudioFilter/FilterAudioSubscriber.h similarity index 100% rename from AudioFilter/filterAudioSubscriber.h rename to AudioFilter/FilterAudioSubscriber.h diff --git a/AudioFilter/filterMediaHandler.cpp b/AudioFilter/FilterMediaHandler.cpp similarity index 76% rename from AudioFilter/filterMediaHandler.cpp rename to AudioFilter/FilterMediaHandler.cpp index 2a48e7aa1704ec29497231216d610394c9463bc1..0c85734bd123ee5653d97d94c8cf4829d8b9a30a 100644 --- a/AudioFilter/filterMediaHandler.cpp +++ b/AudioFilter/FilterMediaHandler.cpp @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "filterMediaHandler.h" +#include "FilterMediaHandler.h" #include "pluglog.h" +#include <string_view> const char sep = separator(); const std::string TAG = "filter"; @@ -29,28 +30,28 @@ const std::string TAG = "filter"; namespace jami { -filterMediaHandler::filterMediaHandler(std::map<std::string, std::string>&& ppm, +FilterMediaHandler::FilterMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& datapath) : datapath_ {datapath} - , ppm_ {ppm} + , preferences_ {preferences} { setId(datapath_); - auto it = ppm_.find("irFile"); - if (it != ppm_.end()) + auto it = preferences_.find("irFile"); + if (it != preferences_.end()) mAS = std::make_shared<FilterAudioSubscriber>(datapath_, it->second); } void -filterMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) +FilterMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) { if (!mAS) return; std::ostringstream oss; - std::string direction = data.direction ? "Receive" : "Preview"; + std::string_view direction = data.direction ? "Receive" : "Preview"; oss << "NEW SUBJECT: [" << data.id << "," << direction << "]" << std::endl; bool preferredStreamDirection = false; // false for output; true for input - auto it = ppm_.find("streamlist"); - if (it != ppm_.end()) { + auto it = preferences_.find("streamlist"); + if (it != preferences_.end()) { preferredStreamDirection = it->second == "in"; } oss << "preferredStreamDirection " << preferredStreamDirection << std::endl; @@ -70,7 +71,7 @@ filterMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubject } std::map<std::string, std::string> -filterMediaHandler::getCallMediaHandlerDetails() +FilterMediaHandler::getCallMediaHandlerDetails() { return {{"name", NAME}, {"iconPath", datapath_ + sep + "icon.png"}, @@ -80,10 +81,10 @@ filterMediaHandler::getCallMediaHandlerDetails() } void -filterMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value) +FilterMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value) { - auto it = ppm_.find(key); - if (it != ppm_.end() && it->second != value) { + auto it = preferences_.find(key); + if (it != preferences_.end() && it->second != value) { it->second = value; if (key == "irFile") mAS->setIRFile(value); @@ -91,7 +92,7 @@ filterMediaHandler::setPreferenceAttribute(const std::string& key, const std::st } bool -filterMediaHandler::preferenceMapHasKey(const std::string& key) +FilterMediaHandler::preferenceMapHasKey(const std::string& key) { if (key == "irFile") return true; @@ -99,16 +100,16 @@ filterMediaHandler::preferenceMapHasKey(const std::string& key) } void -filterMediaHandler::detach() +FilterMediaHandler::detach() { attached_ = '0'; mAS->detach(); } -filterMediaHandler::~filterMediaHandler() +FilterMediaHandler::~FilterMediaHandler() { std::ostringstream oss; - oss << " ~filterMediaHandler from AudioFilter Plugin" << std::endl; + oss << " ~FilterMediaHandler from AudioFilter Plugin" << std::endl; Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); detach(); } diff --git a/AudioFilter/filterMediaHandler.h b/AudioFilter/FilterMediaHandler.h similarity index 85% rename from AudioFilter/filterMediaHandler.h rename to AudioFilter/FilterMediaHandler.h index fefa821bbc8da456b62db0cd8b15478a97768a10..273c56e5e3027f68534fd3665ed479c73bc6aa98 100644 --- a/AudioFilter/filterMediaHandler.h +++ b/AudioFilter/FilterMediaHandler.h @@ -20,7 +20,7 @@ #pragma once -#include "filterAudioSubscriber.h" +#include "FilterAudioSubscriber.h" #include "plugin/jamiplugin.h" #include "plugin/mediahandler.h" @@ -29,11 +29,11 @@ using avSubjectPtr = std::weak_ptr<jami::Observable<AVFrame*>>; namespace jami { -class filterMediaHandler : public CallMediaHandler +class FilterMediaHandler : public CallMediaHandler { public: - filterMediaHandler(std::map<std::string, std::string>&& ppm, std::string&& dataPath); - ~filterMediaHandler(); + FilterMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& dataPath); + ~FilterMediaHandler(); virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) override; virtual std::map<std::string, std::string> getCallMediaHandlerDetails() override; @@ -45,7 +45,7 @@ public: private: const std::string datapath_; - std::map<std::string, std::string> ppm_; + std::map<std::string, std::string> preferences_; std::string attached_ {'0'}; }; } // namespace jami diff --git a/AudioFilter/build.sh b/AudioFilter/build.sh index 3e1fb7487cd16dfa45b1c536cc2e8086ee8770ec..d54e9227b70a1c890e5a01a09c247449e00c5443 100755 --- a/AudioFilter/build.sh +++ b/AudioFilter/build.sh @@ -1,5 +1,6 @@ #! /bin/bash # Build the plugin for the project +set -e export OSTYPE ARCH=$(arch) EXTRAPATH='' @@ -65,8 +66,8 @@ then -I"${PLUGINS_LIB}" \ ./../lib/frameFilter.cpp \ ./../lib/frameUtils.cpp \ - filterMediaHandler.cpp \ - filterAudioSubscriber.cpp \ + FilterMediaHandler.cpp \ + FilterAudioSubscriber.cpp \ main.cpp \ -L"${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib/" \ -l:libavfilter.a \ @@ -196,8 +197,8 @@ then -I"${PLUGINS_LIB}" \ ./../lib/frameFilter.cpp \ ./../lib/frameUtils.cpp \ - filterMediaHandler.cpp \ - filterAudioSubscriber.cpp \ + FilterMediaHandler.cpp \ + FilterAudioSubscriber.cpp \ main.cpp \ -L"${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib/" \ -lavfilter \ diff --git a/AudioFilter/main.cpp b/AudioFilter/main.cpp index 045a9092e7af58111b1bca065a434fb91dd6c756..fc98fd33c4702eeb982ba57eae454eb2894d7ba1 100644 --- a/AudioFilter/main.cpp +++ b/AudioFilter/main.cpp @@ -24,7 +24,7 @@ #include <memory> #include <plugin/jamiplugin.h> -#include "filterMediaHandler.h" +#include "FilterMediaHandler.h" #ifdef WIN32 #define EXPORT_PLUGIN __declspec(dllexport) @@ -53,14 +53,14 @@ JAMI_dynPluginInit(const JAMI_PluginAPI* api) // If invokeService doesn't return an error if (api) { - std::map<std::string, std::string> ppm; - api->invokeService(api, "getPluginPreferences", &ppm); + std::map<std::string, std::string> preferences; + api->invokeService(api, "getPluginPreferences", &preferences); std::string dataPath; api->invokeService(api, "getPluginDataPath", &dataPath); - auto fmpfilterMediaHandler = std::make_unique<jami::filterMediaHandler>(std::move(ppm), + auto fmpFilterMediaHandler = std::make_unique<jami::FilterMediaHandler>(std::move(preferences), std::move(dataPath)); - if (api->manageComponent(api, "CallMediaHandlerManager", fmpfilterMediaHandler.release())) { + if (api->manageComponent(api, "CallMediaHandlerManager", fmpFilterMediaHandler.release())) { return nullptr; } } diff --git a/AutoAnswer/botchathandler.cpp b/AutoAnswer/BotChatHandler.cpp similarity index 76% rename from AutoAnswer/botchathandler.cpp rename to AutoAnswer/BotChatHandler.cpp index fce506ab1d2cad1bc3577b9f069577164d4119a6..371e51ce1179374198aec96bc9520b0ba2f74aaf 100644 --- a/AutoAnswer/botchathandler.cpp +++ b/AutoAnswer/BotChatHandler.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "botchathandler.h" +#include "BotChatHandler.h" #include "pluglog.h" @@ -29,19 +29,19 @@ const std::string TAG = "bot"; namespace jami { -botChatHandler::botChatHandler(const JAMI_PluginAPI* api, - std::map<std::string, std::string>&& ppm, +BotChatHandler::BotChatHandler(const JAMI_PluginAPI* api, + std::map<std::string, std::string>&& preferences, std::string&& dataPath) : api_ {api} , datapath_ {dataPath} { - ppm_ = ppm; + preferences_ = preferences; setId(datapath_); - peerChatSubscriber_ = std::make_shared<botPeerChatSubscriber>(api_, dataPath); + peerChatSubscriber_ = std::make_shared<BotPeerChatSubscriber>(api_, dataPath); }; void -botChatHandler::notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, +BotChatHandler::notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, chatSubjectPtr subject) { if (subjects.find(subject) == subjects.end()) { @@ -55,30 +55,30 @@ botChatHandler::notifyChatSubject(std::pair<std::string, std::string>& subjectCo } std::map<std::string, std::string> -botChatHandler::getChatHandlerDetails() +BotChatHandler::getChatHandlerDetails() { return {{"name", NAME}, {"iconPath", datapath_ + sep + "icon.png"}, {"pluginId", id()}}; } void -botChatHandler::setPreferenceAttribute(const std::string& key, const std::string& value) +BotChatHandler::setPreferenceAttribute(const std::string& key, const std::string& value) { - auto it = ppm_.find(key); - if (it != ppm_.end()) { - if (ppm_[key] != value) { - ppm_[key] = value; + auto it = preferences_.find(key); + if (it != preferences_.end()) { + if (preferences_[key] != value) { + preferences_[key] = value; } } } bool -botChatHandler::preferenceMapHasKey(const std::string& key) +BotChatHandler::preferenceMapHasKey(const std::string& key) { return false; } void -botChatHandler::detach(chatSubjectPtr subject) +BotChatHandler::detach(chatSubjectPtr subject) { if (subjects.find(subject) != subjects.end()) { subject->detach(peerChatSubscriber_.get()); @@ -86,7 +86,7 @@ botChatHandler::detach(chatSubjectPtr subject) } } -botChatHandler::~botChatHandler() +BotChatHandler::~BotChatHandler() { auto& copy(subjects); for (const auto& subject : copy) { diff --git a/AutoAnswer/botchathandler.h b/AutoAnswer/BotChatHandler.h similarity index 83% rename from AutoAnswer/botchathandler.h rename to AutoAnswer/BotChatHandler.h index 7c11346c0accda99632c92772dd0012f95d82493..ee0f72fbca0fff0f7c435d523531b9ad9c2970e6 100644 --- a/AutoAnswer/botchathandler.h +++ b/AutoAnswer/BotChatHandler.h @@ -20,7 +20,7 @@ #pragma once -#include "botPeerChatSubscriber.h" +#include "BotPeerChatSubscriber.h" #include "plugin/jamiplugin.h" #include "plugin/chathandler.h" @@ -34,13 +34,13 @@ using chatSubjectPtr = std::shared_ptr<jami::PublishObservable<jami::pluginMessa namespace jami { -class botChatHandler : public jami::ChatHandler +class BotChatHandler : public jami::ChatHandler { public: - botChatHandler(const JAMI_PluginAPI* api, - std::map<std::string, std::string>&& ppm, + BotChatHandler(const JAMI_PluginAPI* api, + std::map<std::string, std::string>&& preferences, std::string&& dataPath); - ~botChatHandler() override; + ~BotChatHandler() override; virtual void notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, chatSubjectPtr subject) override; @@ -49,12 +49,12 @@ public: virtual void setPreferenceAttribute(const std::string& key, const std::string& value) override; virtual bool preferenceMapHasKey(const std::string& key) override; - std::shared_ptr<botPeerChatSubscriber> peerChatSubscriber_; + std::shared_ptr<BotPeerChatSubscriber> peerChatSubscriber_; private: const JAMI_PluginAPI* api_; const std::string datapath_; - std::map<std::string, std::string> ppm_; + std::map<std::string, std::string> preferences_; std::set<chatSubjectPtr> subjects; }; } // namespace jami diff --git a/AutoAnswer/botPeerChatSubscriber.cpp b/AutoAnswer/BotPeerChatSubscriber.cpp similarity index 84% rename from AutoAnswer/botPeerChatSubscriber.cpp rename to AutoAnswer/BotPeerChatSubscriber.cpp index 046f1f9f6ba9dbff4c39642dc7d8df973d91d36d..0d30eb65362f57279644d6ea2feec6a2899c3059 100644 --- a/AutoAnswer/botPeerChatSubscriber.cpp +++ b/AutoAnswer/BotPeerChatSubscriber.cpp @@ -18,19 +18,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "botPeerChatSubscriber.h" +#include "BotPeerChatSubscriber.h" #include "pluglog.h" const std::string TAG = "bot"; namespace jami { -botPeerChatSubscriber::botPeerChatSubscriber(const JAMI_PluginAPI* api, std::string& textAnswer) +BotPeerChatSubscriber::BotPeerChatSubscriber(const JAMI_PluginAPI* api, std::string& textAnswer) : api_ {api} , textAnswer_ {textAnswer} {} -botPeerChatSubscriber::~botPeerChatSubscriber() +BotPeerChatSubscriber::~BotPeerChatSubscriber() { std::ostringstream oss; oss << "~botChatProcessor" << std::endl; @@ -38,10 +38,10 @@ botPeerChatSubscriber::~botPeerChatSubscriber() } void -botPeerChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessagePtr& message) +BotPeerChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessagePtr& message) { if (isAttached) { - if (message->direction == "0") { + if (message->direction) { std::map<std::string, std::string> sendMsg; for (auto& pair : message->data) { if (pair.first == "text/plain" && pair.second == "hi") { @@ -58,7 +58,7 @@ botPeerChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessage } void -botPeerChatSubscriber::attached(Observable<pluginMessagePtr>* observable) +BotPeerChatSubscriber::attached(Observable<pluginMessagePtr>* observable) { if (observables_.find(observable) == observables_.end()) { std::ostringstream oss; @@ -70,7 +70,7 @@ botPeerChatSubscriber::attached(Observable<pluginMessagePtr>* observable) } void -botPeerChatSubscriber::detached(Observable<pluginMessagePtr>* observable) +BotPeerChatSubscriber::detached(Observable<pluginMessagePtr>* observable) { if (observables_.find(observable) != observables_.end()) { observables_.erase(observable); @@ -83,11 +83,11 @@ botPeerChatSubscriber::detached(Observable<pluginMessagePtr>* observable) } void -botPeerChatSubscriber::sendText(std::string& accountId, +BotPeerChatSubscriber::sendText(std::string& accountId, std::string& peerId, std::map<std::string, std::string>& sendMsg) { - pluginMessagePtr botAnswer = std::make_shared<JamiMessage>(accountId, peerId, "0", sendMsg, true); + pluginMessagePtr botAnswer = std::make_shared<JamiMessage>(accountId, peerId, false, sendMsg, true); api_->invokeService(api_, "sendTextMessage", botAnswer.get()); } } // namespace jami diff --git a/AutoAnswer/botPeerChatSubscriber.h b/AutoAnswer/BotPeerChatSubscriber.h similarity index 91% rename from AutoAnswer/botPeerChatSubscriber.h rename to AutoAnswer/BotPeerChatSubscriber.h index a319904f68a3bb569d0c0c69db93e6f07a964d9c..faaffd3a2728904ce8060eba01c0c1a49e43bf5f 100644 --- a/AutoAnswer/botPeerChatSubscriber.h +++ b/AutoAnswer/BotPeerChatSubscriber.h @@ -31,11 +31,11 @@ namespace jami { -class botPeerChatSubscriber : public Observer<pluginMessagePtr> +class BotPeerChatSubscriber : public Observer<pluginMessagePtr> { public: - botPeerChatSubscriber(const JAMI_PluginAPI* api, std::string& textAnswer); - ~botPeerChatSubscriber(); + BotPeerChatSubscriber(const JAMI_PluginAPI* api, std::string& textAnswer); + ~BotPeerChatSubscriber(); virtual void update(Observable<pluginMessagePtr>*, pluginMessagePtr const&) override; virtual void attached(Observable<pluginMessagePtr>*) override; virtual void detached(Observable<pluginMessagePtr>*) override; diff --git a/AutoAnswer/CMakeLists.txt b/AutoAnswer/CMakeLists.txt index 6e893e307471f4a391d9ae2c1b665e68cdd29c80..176cb6151483d811b2917cd5a0087d07c39a0862 100644 --- a/AutoAnswer/CMakeLists.txt +++ b/AutoAnswer/CMakeLists.txt @@ -36,13 +36,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") -set(plugin_SRC botchathandler.cpp - botPeerChatSubscriber.cpp +set(plugin_SRC BotChatHandler.cpp + BotPeerChatSubscriber.cpp main.cpp ) -set(plugin_HDR botchathandler.h - botPeerChatSubscriber.h +set(plugin_HDR BotChatHandler.h + BotPeerChatSubscriber.h ./../lib/pluglog.h ) diff --git a/AutoAnswer/build.sh b/AutoAnswer/build.sh index c4193ab93f846545ad1676b9404b75b995438b4f..5369dbc138a8e7971530257f878602797b111443 100755 --- a/AutoAnswer/build.sh +++ b/AutoAnswer/build.sh @@ -1,5 +1,6 @@ #! /bin/bash # Build the plugin for the project +set -e export OSTYPE ARCH=$(arch) EXTRAPATH='' @@ -63,8 +64,8 @@ then -I"${DAEMON_SRC}" \ -I"${CONTRIB_PATH}/${CONTRIB_PLATFORM}/include" \ -I"${PLUGINS_LIB}" \ - botchathandler.cpp \ - botPeerChatSubscriber.cpp \ + BotChatHandler.cpp \ + BotPeerChatSubscriber.cpp \ main.cpp \ -L"${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib/" \ -o "build-local/jpl/lib/${CONTRIB_PLATFORM_CURT}-linux-gnu/${SO_FILE_NAME}" @@ -183,8 +184,8 @@ then -I"${DAEMON_SRC}" \ -I"${CONTRIB_PATH}/${CONTRIB_PLATFORM}/include" \ -I"${PLUGINS_LIB}" \ - botchathandler.cpp \ - botPeerChatSubscriber.cpp \ + BotChatHandler.cpp \ + BotPeerChatSubscriber.cpp \ main.cpp \ -L"${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib/" \ -llog -lz \ diff --git a/AutoAnswer/main.cpp b/AutoAnswer/main.cpp index 5c4ed2fb613e3c70dc094fd6ce1178236c0c1277..27bcca946f35bacfeff8523bb885d5496af1a017 100644 --- a/AutoAnswer/main.cpp +++ b/AutoAnswer/main.cpp @@ -24,7 +24,7 @@ #include <memory> #include <map> #include "plugin/jamiplugin.h" -#include "botchathandler.h" +#include "BotChatHandler.h" #ifdef WIN32 #define EXPORT_PLUGIN __declspec(dllexport) @@ -53,15 +53,15 @@ JAMI_dynPluginInit(const JAMI_PluginAPI* api) // If invokeService doesn't return an error if (api) { - std::map<std::string, std::string> ppm; - api->invokeService(api, "getPluginPreferences", &ppm); + std::map<std::string, std::string> preferences; + api->invokeService(api, "getPluginPreferences", &preferences); std::string dataPath; api->invokeService(api, "getPluginDataPath", &dataPath); - auto fmpbotChatHandler = std::make_unique<jami::botChatHandler>(api, - std::move(ppm), + auto fmpBotChatHandler = std::make_unique<jami::BotChatHandler>(api, + std::move(preferences), std::move(dataPath)); - if (api->manageComponent(api, "ChatHandlerManager", fmpbotChatHandler.release())) { + if (api->manageComponent(api, "ChatHandlerManager", fmpBotChatHandler.release())) { return nullptr; } } diff --git a/GreenScreen/build.sh b/GreenScreen/build.sh index 85733fde06273b935e99929dc38363c59f8853d4..fd936e8efc8bd7367a31e6f9f1880bfa0e3d2b84 100755 --- a/GreenScreen/build.sh +++ b/GreenScreen/build.sh @@ -1,5 +1,6 @@ #! /bin/bash # Build the plugin for the project +set -e export OSTYPE ARCH=$(arch) EXTRAPATH='' diff --git a/GreenScreen/main.cpp b/GreenScreen/main.cpp index d669ded0615665a8521117b9b3e0e8e5b5981358..406c7ced48889b3568cc71413b10dc6bb886bfc7 100644 --- a/GreenScreen/main.cpp +++ b/GreenScreen/main.cpp @@ -52,11 +52,11 @@ JAMI_dynPluginInit(const JAMI_PluginAPI* api) // If invokeService doesn't return an error if (api) { - std::map<std::string, std::string> ppm; - api->invokeService(api, "getPluginPreferences", &ppm); + std::map<std::string, std::string> preferences; + api->invokeService(api, "getPluginPreferences", &preferences); std::string dataPath; api->invokeService(api, "getPluginDataPath", &dataPath); - auto fmp = std::make_unique<jami::PluginMediaHandler>(std::move(ppm), std::move(dataPath)); + auto fmp = std::make_unique<jami::PluginMediaHandler>(std::move(preferences), std::move(dataPath)); if (!api->manageComponent(api, "CallMediaHandlerManager", fmp.release())) { return pluginExit; diff --git a/GreenScreen/pluginMediaHandler.cpp b/GreenScreen/pluginMediaHandler.cpp index fe6ab4616b31de4da60432d4f12784ee25542794..44d68c75b63cf0e0ff9b6f3f57ec2bdcf3f2c38c 100644 --- a/GreenScreen/pluginMediaHandler.cpp +++ b/GreenScreen/pluginMediaHandler.cpp @@ -22,6 +22,7 @@ #include "pluginMediaHandler.h" // Logger #include "pluglog.h" +#include <string_view> const char sep = separator(); const std::string TAG = "FORESEG"; @@ -29,12 +30,12 @@ const std::string TAG = "FORESEG"; namespace jami { -PluginMediaHandler::PluginMediaHandler(std::map<std::string, std::string>&& ppm, +PluginMediaHandler::PluginMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& datapath) : datapath_ {datapath} - , ppm_ {ppm} + , preferences_ {preferences} { - setGlobalPluginParameters(ppm_); + setGlobalPluginParameters(preferences_); setId(datapath_); mVS = std::make_shared<VideoSubscriber>(datapath_); } @@ -43,12 +44,12 @@ void PluginMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) { std::ostringstream oss; - std::string direction = data.direction ? "Receive" : "Preview"; + std::string_view direction = data.direction ? "Receive" : "Preview"; oss << "NEW SUBJECT: [" << data.id << "," << direction << "]" << std::endl; bool preferredStreamDirection = false; - auto it = ppm_.find("streamslist"); - if (it != ppm_.end()) { + auto it = preferences_.find("streamslist"); + if (it != preferences_.end()) { Plog::log(Plog::LogPriority::INFO, TAG, "SET PARAMETERS"); preferredStreamDirection = it->second == "in"; } @@ -80,8 +81,8 @@ PluginMediaHandler::getCallMediaHandlerDetails() void PluginMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value) { - auto it = ppm_.find(key); - if (it != ppm_.end() && it->second != value) { + auto it = preferences_.find(key); + if (it != preferences_.end() && it->second != value) { it->second = value; if (key == "background") { mVS->setBackground(value); diff --git a/GreenScreen/pluginMediaHandler.h b/GreenScreen/pluginMediaHandler.h index 41a1693b4446f289deca6beafe612f6a09df579e..3962246230d1b1dbe4bb837996a509e3943b2de1 100644 --- a/GreenScreen/pluginMediaHandler.h +++ b/GreenScreen/pluginMediaHandler.h @@ -35,7 +35,7 @@ namespace jami { class PluginMediaHandler : public jami::CallMediaHandler { public: - PluginMediaHandler(std::map<std::string, std::string>&& ppm, std::string&& dataPath); + PluginMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& dataPath); ~PluginMediaHandler(); virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) override; @@ -49,7 +49,7 @@ public: private: const std::string datapath_; - std::map<std::string, std::string> ppm_; + std::map<std::string, std::string> preferences_; std::string attached_ {'0'}; }; } // namespace jami diff --git a/HelloWorld/CenterCircleMediaHandler.cpp b/HelloWorld/CenterCircleMediaHandler.cpp index 8f3f1bbbfa7874302b1faf5ab4daaa768bca8161..2703347f6c0d3ad131cc62d489337e9b6bccbb4b 100644 --- a/HelloWorld/CenterCircleMediaHandler.cpp +++ b/HelloWorld/CenterCircleMediaHandler.cpp @@ -21,6 +21,7 @@ #include "CenterCircleMediaHandler.h" #include "pluglog.h" +#include <string_view> const char sep = separator(); const std::string TAG = "CenterCircle"; @@ -29,15 +30,15 @@ const std::string TAG = "CenterCircle"; namespace jami { -CenterCircleMediaHandler::CenterCircleMediaHandler(std::map<std::string, std::string>&& ppm, +CenterCircleMediaHandler::CenterCircleMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& datapath) : datapath_ {datapath} - , ppm_ {ppm} + , preferences_ {preferences} { setId(datapath_); mVS = std::make_shared<CenterCircleVideoSubscriber>(datapath_); - auto it = ppm_.find("color"); - if (it != ppm_.end()) { + auto it = preferences_.find("color"); + if (it != preferences_.end()) { mVS->setColor(it->second); } else { mVS->setColor("#0000FF"); @@ -48,12 +49,12 @@ void CenterCircleMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) { std::ostringstream oss; - std::string direction = data.direction ? "Receive" : "Preview"; + std::string_view direction = data.direction ? "Receive" : "Preview"; oss << "NEW SUBJECT: [" << data.id << "," << direction << "]" << std::endl; bool preferredStreamDirection = false; // false for output; true for input - auto it = ppm_.find("videostream"); - if (it != ppm_.end()) { + auto it = preferences_.find("videostream"); + if (it != preferences_.end()) { preferredStreamDirection = it->second == "1"; } oss << "preferredStreamDirection " << preferredStreamDirection << std::endl; @@ -85,8 +86,8 @@ CenterCircleMediaHandler::getCallMediaHandlerDetails() void CenterCircleMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value) { - auto it = ppm_.find(key); - if (it != ppm_.end() && it->second != value) { + auto it = preferences_.find(key); + if (it != preferences_.end() && it->second != value) { it->second = value; if (key == "color") { diff --git a/HelloWorld/CenterCircleMediaHandler.h b/HelloWorld/CenterCircleMediaHandler.h index f8836f91960fdb43e6c6c7ed83ff018e406951ca..ae0bd28d83fc32e7d1e665099693051047125134 100644 --- a/HelloWorld/CenterCircleMediaHandler.h +++ b/HelloWorld/CenterCircleMediaHandler.h @@ -31,7 +31,7 @@ namespace jami { class CenterCircleMediaHandler : public jami::CallMediaHandler { public: - CenterCircleMediaHandler(std::map<std::string, std::string>&& ppm, std::string&& dataPath); + CenterCircleMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& dataPath); ~CenterCircleMediaHandler(); virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) override; @@ -45,7 +45,7 @@ public: private: const std::string datapath_; - std::map<std::string, std::string> ppm_; + std::map<std::string, std::string> preferences_; std::string attached_ {"0"}; }; } // namespace jami diff --git a/HelloWorld/CoinCircleMediaHandler.cpp b/HelloWorld/CoinCircleMediaHandler.cpp index ae31281b23a85c92ec723e8fbe69dae2a2e8d561..8da2fd290164d5317ebb8005d1f4fdf13379f35f 100644 --- a/HelloWorld/CoinCircleMediaHandler.cpp +++ b/HelloWorld/CoinCircleMediaHandler.cpp @@ -20,6 +20,7 @@ #include "CoinCircleMediaHandler.h" #include "pluglog.h" +#include <string_view> const char sep = separator(); const std::string TAG = "CoinCircle"; @@ -28,15 +29,15 @@ const std::string TAG = "CoinCircle"; namespace jami { -CoinCircleMediaHandler::CoinCircleMediaHandler(std::map<std::string, std::string>&& ppm, +CoinCircleMediaHandler::CoinCircleMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& datapath) : datapath_ {datapath} - , ppm_ {ppm} + , preferences_ {preferences} { setId(datapath_); mVS = std::make_shared<CoinCircleVideoSubscriber>(datapath_); - auto it = ppm_.find("color"); - if (it != ppm_.end()) { + auto it = preferences_.find("color"); + if (it != preferences_.end()) { mVS->setColor(it->second); } else { mVS->setColor("#0000FF"); @@ -47,12 +48,12 @@ void CoinCircleMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) { std::ostringstream oss; - std::string direction = data.direction ? "Receive" : "Preview"; + std::string_view direction = data.direction ? "Receive" : "Preview"; oss << "NEW SUBJECT: [" << data.id << "," << direction << "]" << std::endl; bool preferredStreamDirection = false; // false for output; true for input - auto it = ppm_.find("videostream"); - if (it != ppm_.end()) { + auto it = preferences_.find("videostream"); + if (it != preferences_.end()) { preferredStreamDirection = it->second == "1"; } oss << "preferredStreamDirection " << preferredStreamDirection << std::endl; @@ -84,8 +85,8 @@ CoinCircleMediaHandler::getCallMediaHandlerDetails() void CoinCircleMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value) { - auto it = ppm_.find(key); - if (it != ppm_.end() && it->second != value) { + auto it = preferences_.find(key); + if (it != preferences_.end() && it->second != value) { it->second = value; } } diff --git a/HelloWorld/CoinCircleMediaHandler.h b/HelloWorld/CoinCircleMediaHandler.h index d14c63f2c78512b3008bcc6bd04aee40df7f12dc..84653c8416bf3f36fc0cf26d8343381beacca5a5 100644 --- a/HelloWorld/CoinCircleMediaHandler.h +++ b/HelloWorld/CoinCircleMediaHandler.h @@ -31,7 +31,7 @@ namespace jami { class CoinCircleMediaHandler : public jami::CallMediaHandler { public: - CoinCircleMediaHandler(std::map<std::string, std::string>&& ppm, std::string&& dataPath); + CoinCircleMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& dataPath); ~CoinCircleMediaHandler(); virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) override; @@ -45,7 +45,7 @@ public: private: const std::string datapath_; - std::map<std::string, std::string> ppm_; + std::map<std::string, std::string> preferences_; std::string attached_ {"0"}; }; } // namespace jami diff --git a/HelloWorld/main.cpp b/HelloWorld/main.cpp index 4e924f00d3c7f3a316dea39f9847ff6fa53a21c4..8ad0a353077698bf80d9f5dfe713780841d2aaf5 100644 --- a/HelloWorld/main.cpp +++ b/HelloWorld/main.cpp @@ -53,13 +53,13 @@ JAMI_dynPluginInit(const JAMI_PluginAPI* api) // If invokeService doesn't return an error if (api) { - std::map<std::string, std::string> ppm; - api->invokeService(api, "getPluginPreferences", &ppm); + std::map<std::string, std::string> preferences; + api->invokeService(api, "getPluginPreferences", &preferences); std::string dataPath; api->invokeService(api, "getPluginDataPath", &dataPath); auto fmpCenterCircleMediaHandler - = std::make_unique<jami::CenterCircleMediaHandler>(std::move(ppm), std::move(dataPath)); + = std::make_unique<jami::CenterCircleMediaHandler>(std::move(preferences), std::move(dataPath)); if (api->manageComponent(api, "CallMediaHandlerManager", fmpCenterCircleMediaHandler.release())) { @@ -67,7 +67,7 @@ JAMI_dynPluginInit(const JAMI_PluginAPI* api) } auto fmpCoinCircleMediaHandler - = std::make_unique<jami::CoinCircleMediaHandler>(std::move(ppm), std::move(dataPath)); + = std::make_unique<jami::CoinCircleMediaHandler>(std::move(preferences), std::move(dataPath)); if (api->manageComponent(api, "CallMediaHandlerManager", fmpCoinCircleMediaHandler.release())) { diff --git a/SDK/Docs/buildHelper.txt b/SDK/Docs/buildHelper.txt index 4121eb681f7634e1d159b6b4aa7b4a0ebf3b5390..696ad7102ce5586a8561609ccd9139a523fdf1fe 100644 --- a/SDK/Docs/buildHelper.txt +++ b/SDK/Docs/buildHelper.txt @@ -20,7 +20,7 @@ As build files creation tool: pre-assembling, building and assembling the final jpl. For Windows, the environment expects a CMakeLists.txt and package.json with custom build rules for cmake. - For pratical examples and further developpment of those files, you may peek at our + For pratical examples and further development of those files, you may peek at our available plugins at https://git.jami.net/savoirfairelinux/jami-plugins . Alternatively, you can ignore this SDK and build your plugin using the build-plugin.py diff --git a/SDK/Docs/preferencePath.txt b/SDK/Docs/preferencePath.txt index f9f78c44da1f8962c3a27ad53db42ad7a7b1c2a5..b5433a0a535f725198789146cf48f8e454dce5df 100644 --- a/SDK/Docs/preferencePath.txt +++ b/SDK/Docs/preferencePath.txt @@ -11,7 +11,7 @@ Path preference formation example: "title": "Background image", -> user choice; "summary": "Select the image background to use", -> user choice; "defaultValue": "data/backgrounds/background2.png", -> must be a relative path within the plugin - developpment directory. More specifically any + development directory. More specifically any file introduced by the developper must be inside <jami-plugins>/<PLUGINNAME>/data directory; "scope": "plugin, foo" -> if a preference value may be changed while the diff --git a/SDK/Templates/audioUpdate.txt b/SDK/Templates/audioUpdate.txt index 3d8adf2960ded62eb5aa331fd7ee1a52780e2784..39ea8da7ffc41211e07a9514c62ad63380531183 100644 --- a/SDK/Templates/audioUpdate.txt +++ b/SDK/Templates/audioUpdate.txt @@ -7,7 +7,7 @@ firstRun = false; } - AVFrame* processedFrame = nullptr; + AVFrame* processedFrame{}; // IMPLEMENT PROCESS diff --git a/SDK/Templates/build.sh b/SDK/Templates/build.sh index c6ebb739b56f06c2f0aee8c67ee77ab5d05f3f90..22533278ab076fef6c96125ad324b7f7cba9e65e 100644 --- a/SDK/Templates/build.sh +++ b/SDK/Templates/build.sh @@ -1,5 +1,6 @@ #! /bin/bash # Build the plugin for the project +set -e export OSTYPE ARCH=$(arch) EXTRAPATH='' diff --git a/SDK/Templates/genericChatHandler.cpp b/SDK/Templates/genericChatHandler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9010214bff916265b6770a0f5581250867b9203e --- /dev/null +++ b/SDK/Templates/genericChatHandler.cpp @@ -0,0 +1,84 @@ +HEADER + +#include "GENERICChatHandler.h" + +#include "pluglog.h" + +const char sep = separator(); +const std::string TAG = "GENERIC"; + +#define NAME "GENERIC" + +namespace jami { + +GENERICChatHandler::GENERICChatHandler(const JAMI_PluginAPI* api, + std::map<std::string, std::string>&& preferences, + std::string&& dataPath) + : api_ {api} + , datapath_ {dataPath} +{ + preferences_ = preferences; + setId(datapath_); + GENERICChatSubscriber_ = std::make_shared<GENERICChatSubscriber>(api_); +}; + +void +GENERICChatHandler::notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, + chatSubjectPtr subject) +{ + if (subjects.find(subject) == subjects.end()) { + std::ostringstream oss; + oss << "NEW SUBJECT: account = " << subjectConnection.first + << " peer = " << subjectConnection.second << std::endl; + Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); + subject->attach(GENERICChatSubscriber_.get()); + subjects.insert(subject); + } +} + +std::map<std::string, std::string> +GENERICChatHandler::getChatHandlerDetails() +{ + return { {"name", NAME}, + {"iconPath", datapath_ + sep + "icon.png"}, + {"pluginId", id()} }; +} + +void +GENERICChatHandler::setPreferenceAttribute(const std::string& key, const std::string& value) +{ + auto it = preferences_.find(key); + if (it != preferences_.end() && it->second != value) { + it->second = value;---------------- + if (key == "PREFERENCE1") { + // use preference + return; + }---------------- + } +} + +bool +GENERICChatHandler::preferenceMapHasKey(const std::string& key) +{---------------- + if (key == "PREFERENCE2") { return true; }---------------- + return false; +} + +void +GENERICChatHandler::detach(chatSubjectPtr subject) +{ + if (subjects.find(subject) != subjects.end()) { + subject->detach(GENERICChatSubscriber_.get()); + subjects.erase(subject); + } +} + +GENERICChatHandler::~GENERICChatHandler() +{ + auto& copy(subjects); + for (const auto& subject : copy) { + detach(subject); + } + copy.clear(); +} +} // namespace jami diff --git a/SDK/Templates/genericChatHandler.h b/SDK/Templates/genericChatHandler.h new file mode 100644 index 0000000000000000000000000000000000000000..b080b3423b232426475c93145440628927895b60 --- /dev/null +++ b/SDK/Templates/genericChatHandler.h @@ -0,0 +1,42 @@ +HEADER + +#pragma once +// Project +#include "GENERICChatSubscriber.h" +// Jami plugin +#include "plugin/jamiplugin.h" +#include "plugin/chathandler.h" + +#include <string> +#include <map> +#include <memory> +#include <set> + +using chatSubjectPtr = std::shared_ptr<jami::PublishObservable<jami::pluginMessagePtr>>; + +namespace jami { + +class GENERICChatHandler : public jami::ChatHandler +{ +public: + GENERICChatHandler(const JAMI_PluginAPI* api, + std::map<std::string, std::string>&& preferences, + std::string&& dataPath); + ~GENERICChatHandler(); + + virtual void notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, + chatSubjectPtr subject) override; + virtual std::map<std::string, std::string> getChatHandlerDetails() override; + virtual void detach(chatSubjectPtr subject) override; + virtual void setPreferenceAttribute(const std::string& key, const std::string& value) override; + virtual bool preferenceMapHasKey(const std::string& key) override; + + std::shared_ptr<GENERICChatSubscriber> GENERICChatSubscriber_; + +private: + const JAMI_PluginAPI* api_; + const std::string datapath_; + std::map<std::string, std::string> preferences_; + std::set<chatSubjectPtr> subjects; +}; +} // namespace jami diff --git a/SDK/Templates/genericChatSubscriber.cpp b/SDK/Templates/genericChatSubscriber.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d83ed56244515c8b6e897afa24e72c2e0d8676e8 --- /dev/null +++ b/SDK/Templates/genericChatSubscriber.cpp @@ -0,0 +1,67 @@ +HEADER + +#include "GENERICChatSubscriber.h" +#include "pluglog.h" + +const std::string TAG = "GENERIC"; + +namespace jami { + +GENERICChatSubscriber::GENERICChatSubscriber(const JAMI_PluginAPI* api) + : api_ {api} +{} + +GENERICChatSubscriber::~GENERICChatSubscriber() +{ + std::ostringstream oss; + oss << "~GENERICChatProcessor" << std::endl; + Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); +} + +void +GENERICChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessagePtr& message) +{ + if (isAttached) { + if (message->direction == "0") { // "0" for input message; "1" for output message + for (auto& pair : message->data) { + // READ THE MESSAGE + } + // DO SOMETHING WITH YOUR TEXT + } + } +} + +void +GENERICChatSubscriber::attached(Observable<pluginMessagePtr>* observable) +{ + if (observables_.find(observable) == observables_.end()) { + std::ostringstream oss; + oss << "::Attached ! " << std::endl; + Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); + observables_.insert(observable); + isAttached = true; + } +} + +void +GENERICChatSubscriber::detached(Observable<pluginMessagePtr>* observable) +{ + if (observables_.find(observable) != observables_.end()) { + observables_.erase(observable); + std::ostringstream oss; + oss << "::Detached()" << std::endl; + Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); + if (observables_.empty()) + isAttached = false; + } +} + +void +GENERICChatSubscriber::sendText(std::string& accountId, + std::string& peerId, + std::map<std::string, std::string>& sendMsg) +{ + pluginMessagePtr GENERICAnswer = std::make_shared<JamiMessage>(accountId, peerId, "0", sendMsg, true); + api_->invokeService(api_, "sendTextMessage", GENERICAnswer.get()); +} +} // namespace jami diff --git a/SDK/Templates/genericChatSubscriber.h b/SDK/Templates/genericChatSubscriber.h new file mode 100644 index 0000000000000000000000000000000000000000..577f7899b9f59e89f41558aa9afe64c33a37f40c --- /dev/null +++ b/SDK/Templates/genericChatSubscriber.h @@ -0,0 +1,36 @@ +HEADER + +#pragma once + +#include "observer.h" + +#include "plugin/streamdata.h" +#include "plugin/jamiplugin.h" +#include "plugin/chathandler.h" + +#include <map> +#include <set> + +namespace jami { + +class GENERICChatSubscriber : public Observer<pluginMessagePtr> +{ +public: + GENERICChatSubscriber(const JAMI_PluginAPI* api); + ~GENERICChatSubscriber(); + virtual void update(Observable<pluginMessagePtr>*, pluginMessagePtr const&) override; + virtual void attached(Observable<pluginMessagePtr>*) override; + virtual void detached(Observable<pluginMessagePtr>*) override; + + void sendText(std::string& accountId, + std::string& peerId, + std::map<std::string, std::string>& sendMsg); + +protected: + // Observer pattern + std::set<Observable<pluginMessagePtr>*> observables_; + bool isAttached {false}; + const JAMI_PluginAPI* api_; + std::string textAnswer_{}; +}; +} // namespace jami diff --git a/SDK/Templates/genericConversationHandler.h b/SDK/Templates/genericConversationHandler.h deleted file mode 100644 index dd434f6479d9caa7e02457e617ed2eb282521344..0000000000000000000000000000000000000000 --- a/SDK/Templates/genericConversationHandler.h +++ /dev/null @@ -1,21 +0,0 @@ -HEADER - -#pragma once -// Project -#include "chatsubscriber.h" -// Jami plugin -#include "plugin/jamiplugin.h" -#include "plugin/chathandler.h" - -class GENERICChatHandler : public jami::ChatHandler -{ -public: - GENERICChatHandler(const JAMI_PluginAPI* api, std::string&& dataPath); - ~GENERICChatHandler(); - void detach(); - virtual void notifyStrMapSubject(const bool direction, jami::strMapSubjectPtr subject) override; - -private: - std::string dataPath_; - std::shared_ptr<ChatSubscriber> css; -}; diff --git a/SDK/Templates/genericMediaHandler.cpp b/SDK/Templates/genericMediaHandler.cpp index 32549257981c7f3a31111d5285dfa6c1e1fdda20..4a6ee78c998b047c8762d1004c068c524106f021 100644 --- a/SDK/Templates/genericMediaHandler.cpp +++ b/SDK/Templates/genericMediaHandler.cpp @@ -3,6 +3,7 @@ HEADER #include "GENERICMediaHandler.h" #include "pluglog.h" +#include <string_view> const char sep = separator(); const std::string TAG = "GENERIC"; @@ -11,10 +12,10 @@ const std::string TAG = "GENERIC"; namespace jami { -GENERICMediaHandler::GENERICMediaHandler(std::map<std::string, std::string>&& ppm, +GENERICMediaHandler::GENERICMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& datapath) : datapath_ {datapath} - , ppm_ {ppm} + , preferences_ {preferences} { setId(datapath_); mediaSubscriber_ = std::make_shared<GENERICDATATYPESubscriber>(datapath_); @@ -24,7 +25,7 @@ void GENERICMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) { std::ostringstream oss; - std::string direction = data.direction ? "Receive" : "Preview"; + std::string_view direction = data.direction ? "Receive" : "Preview"; oss << "NEW SUBJECT: [" << data.id << "," << direction << "]" << std::endl; bool preferredStreamDirection = false; // false for output; true for input @@ -57,8 +58,8 @@ GENERICMediaHandler::getCallMediaHandlerDetails() void GENERICMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value) { - auto it = ppm_.find(key); - if (it != ppm_.end() && it->second != value) { + auto it = preferences_.find(key); + if (it != preferences_.end() && it->second != value) { it->second = value;---------------- if (key == "PREFERENCE1") { // use preference @@ -69,9 +70,9 @@ GENERICMediaHandler::setPreferenceAttribute(const std::string& key, const std::s bool GENERICMediaHandler::preferenceMapHasKey(const std::string& key) -{ - ----------------if (key == "PREFERENCE2") { return true; } - ----------------return false; +{---------------- + if (key == "PREFERENCE2") { return true; }---------------- + return false; } void diff --git a/SDK/Templates/genericMediaHandler.h b/SDK/Templates/genericMediaHandler.h index 4a001b9b2b72ea082c6ac4b6da5d3a7c5410752f..2e806b9605400a0d2bffc44703cff8bb8aa9f583 100644 --- a/SDK/Templates/genericMediaHandler.h +++ b/SDK/Templates/genericMediaHandler.h @@ -14,7 +14,7 @@ namespace jami { class GENERICMediaHandler : public jami::CallMediaHandler { public: - GENERICMediaHandler(std::map<std::string, std::string>&& ppm, std::string&& dataPath); + GENERICMediaHandler(std::map<std::string, std::string>&& preferences, std::string&& dataPath); ~GENERICMediaHandler(); virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) override; @@ -28,7 +28,7 @@ public: private: const std::string datapath_; - std::map<std::string, std::string> ppm_; + std::map<std::string, std::string> preferences_; std::string attached_ {'0'}; }; } // namespace jami diff --git a/SDK/Templates/genericMediaSubscriber.h b/SDK/Templates/genericMediaSubscriber.h index 412d6f1e8384d00071fc984152688f32f8d9fcfb..c716844dd4f54c8ad4e6a13290ee687a2d73c0a1 100644 --- a/SDK/Templates/genericMediaSubscriber.h +++ b/SDK/Templates/genericMediaSubscriber.h @@ -25,7 +25,7 @@ public: private: // Observer pattern - Observable<AVFrame*>* observable_ = nullptr; + Observable<AVFrame*>* observable_{}; // Data std::string path_;--- diff --git a/SDK/Templates/genericVideoSubscriber.cpp b/SDK/Templates/genericVideoSubscriber.cpp deleted file mode 100644 index 5837eea0ef57759b0afc1584a532e796a68bead5..0000000000000000000000000000000000000000 --- a/SDK/Templates/genericVideoSubscriber.cpp +++ /dev/null @@ -1,117 +0,0 @@ -HEADER - -#include "GENERICVideoSubscriber.h" - -extern "C" { -#include <libavutil/display.h> -} -#include <accel.h> -#include <pluglog.h> -#include <frameUtils.h> - -const std::string TAG = "GENERIC"; -const char sep = separator(); - -namespace jami { - -GENERICVideoSubscriber::GENERICVideoSubscriber(const std::string& dataPath) - : path_ {dataPath} -{} - -GENERICVideoSubscriber::~GENERICVideoSubscriber() -{ - std::ostringstream oss; - oss << "~GENERICMediaProcessor" << std::endl; - Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); -} - -void -GENERICVideoSubscriber::update(jami::Observable<AVFrame*>*, AVFrame* const& iFrame) -{ - if (!iFrame) - return; - AVFrame* pluginFrame = const_cast<AVFrame*>(iFrame); - - //====================================================================================== - // GET FRAME ROTATION - AVFrameSideData* side_data = av_frame_get_side_data(iFrame, AV_FRAME_DATA_DISPLAYMATRIX); - - int angle {0}; - if (side_data) { - auto matrix_rotation = reinterpret_cast<int32_t*>(side_data->data); - angle = static_cast<int>(av_display_rotation_get(matrix_rotation)); - } - - //====================================================================================== - // GET RAW FRAME - // Use a non-const Frame - // Convert input frame to RGB - int inputHeight = pluginFrame->height; - int inputWidth = pluginFrame->width; - AVFrame* temp = transferToMainMemory(pluginFrame, AV_PIX_FMT_NV12); - AVFrame* bgrFrame = scaler.convertFormat(temp, AV_PIX_FMT_RGB24); - av_frame_unref(temp); - av_frame_free(&temp); - if (!bgrFrame) - return; - // transferToMainMemory USED TO COPY FRAME TO MAIN MEMORY IF HW ACCEL IS ENABLED - // NOT NEEDED TO BE USED IF ALL YOUR PROCESS WILL BE DONE WITHIN A - // HW ACCEL PLATFORM - - if (firstRun) { - // IMPLEMENT CODE TO CONFIGURE - // VARIABLES UPON FIRST RUN - firstRun = false; - } - - // IMPLEMENT PROCESS - - //====================================================================================== - // REPLACE AVFRAME DATA WITH FRAME DATA - if (bgrFrame->data[0]) { - uint8_t* frameData = bgrFrame->data[0]; - if (angle == 90 || angle == -90) { - std::memmove(frameData, - frameData, // PUT HERE YOUR PROCESSED FRAME VARIABLE DATA! - static_cast<size_t>(pluginFrame->width * pluginFrame->height * 3) - * sizeof(uint8_t)); - } - - av_frame_copy_props(bgrFrame, pluginFrame); - moveFrom(pluginFrame, bgrFrame); - } - av_frame_unref(bgrFrame); - av_frame_free(&bgrFrame); -} - -void -GENERICVideoSubscriber::attached(jami::Observable<AVFrame*>* observable) -{ - std::ostringstream oss; - oss << "::Attached ! " << std::endl; - Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); - observable_ = observable; -} - -void -GENERICVideoSubscriber::detached(jami::Observable<AVFrame*>*) -{ - firstRun = true; - observable_ = nullptr; - std::ostringstream oss; - oss << "::Detached()" << std::endl; - Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); -} - -void -GENERICVideoSubscriber::detach() -{ - if (observable_) { - firstRun = true; - std::ostringstream oss; - oss << "::Calling detach()" << std::endl; - Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); - observable_->detach(this); - } -} -} // namespace jami diff --git a/SDK/Templates/main.cpp b/SDK/Templates/main.cpp index 46cc4e681281e9648cb21bbb3908a2f6f2a46005..21f64eabe146006f7051b216e7e14fd68be280fa 100644 --- a/SDK/Templates/main.cpp +++ b/SDK/Templates/main.cpp @@ -35,12 +35,12 @@ JAMI_dynPluginInit(const JAMI_PluginAPI* api) // If invokeService doesn't return an error if (api) { - std::map<std::string, std::string> ppm; - api->invokeService(api, "getPluginPreferences", &ppm); + std::map<std::string, std::string> preferences; + api->invokeService(api, "getPluginPreferences", &preferences); std::string dataPath; api->invokeService(api, "getPluginDataPath", &dataPath); ---------------- - auto fmpPLUGINAPI = std::make_unique<jami::PLUGINAPI>(std::move(ppm), std::move(dataPath)); + auto fmpPLUGINAPI = std::make_unique<jami::PLUGINAPI>(CHATHANDLERstd::move(preferences), std::move(dataPath)); if (api->manageComponent(api, "APIMANAGER", fmpPLUGINAPI.release())) { return nullptr; } diff --git a/SDK/preferencesProfile.py b/SDK/preferencesProfile.py index 43a9a9c70a40cc4b1bad2814e0395effda0f9408..cf3a4478618f6f60268b95d8637a4c9e76bff9aa 100644 --- a/SDK/preferencesProfile.py +++ b/SDK/preferencesProfile.py @@ -162,7 +162,7 @@ class Preferences(Manifest): "\nAll available scopes have been added to this preference!\ncontinuing ...", "yellow")) addScope = "n" - preferenceSkeleton[item] = ", ".join(scopeStr) + preferenceSkeleton[item] = ",".join(scopeStr) elif (preferenceSkeleton["type"] == "List" and item in [ "entries", "entryValues"]): if (item == 'entryValues'): diff --git a/SDK/skeletonSrcProfile.py b/SDK/skeletonSrcProfile.py index 52d779b2bd00316d80f8617655122ac2ac090bd1..61470ff66731e058296a14fd58066cc5a8e69c91 100644 --- a/SDK/skeletonSrcProfile.py +++ b/SDK/skeletonSrcProfile.py @@ -177,9 +177,11 @@ class SkeletonSourceFiles(Preferences): if (self.apis[i] == PLUGINS_APIS["MEDIA_HANDLER"]): temp = split.replace("PLUGINAPI", f"{name}MediaHandler") temp = temp.replace("APIMANAGER", "CallMediaHandlerManager") + temp = temp.replace("CHATHANDLER", "") elif (self.apis[i] == PLUGINS_APIS["CHAT_HANDLER"]): temp = split.replace("PLUGINAPI", f"{name}ChatHandler") - temp = temp.replace("APIMANAGER", "ChatManager") + temp = temp.replace("APIMANAGER", "ChatHandlerManager") + temp = temp.replace("CHATHANDLER", "api, ") createStr += temp return createStr @@ -198,6 +200,7 @@ class SkeletonSourceFiles(Preferences): print("\nAvailable APIs: ") print("(1) video during a call (Media Handler API)") print("(2) audio during a call (Media Handler API)") + print("(3) chat messages (Chat Handler API)") print( colored( "For more information about the API, call help preferences.", @@ -210,6 +213,7 @@ class SkeletonSourceFiles(Preferences): self.dataTypes.append(list(DATA_TYPES.values())[int(apiType)-1]) if (apiType == PLUGINS_APIS["MEDIA_HANDLER_AUDIO"]): apiType = PLUGINS_APIS["MEDIA_HANDLER"] + functionName = functionName.capitalize() self.names.append(functionName) self.newNames.append(functionName) self.apis.append(apiType) @@ -278,7 +282,15 @@ class SkeletonSourceFiles(Preferences): data = data.replace("HEADER", self.header) data = data.replace('GENERIC', self.names[j]) f.close() - with open(f"{self.pluginDirectory}/{self.names[j]}ChatHandler.h", 'w') as f: + with open(f"{self.pluginDirectory}/{self.names[j]}{self.dataTypes[j]}Handler.h", 'w') as f: + f.write(data) + f.close() + with open('./Templates/genericChatSubscriber.h', 'r') as f: + data = f.read() + data = data.replace("HEADER", self.header) + data = data.replace("GENERIC", self.names[j]) + f.close() + with open(f"{self.pluginDirectory}/{self.names[j]}{self.dataTypes[j]}Subscriber.h", 'w') as f: f.write(data) f.close() @@ -337,7 +349,15 @@ class SkeletonSourceFiles(Preferences): data = data.replace("HEADER", self.header) data = data.replace("GENERIC", self.names[j]) f.close() - with open(f"{self.pluginDirectory}/{self.names[j]}ChatHandler.cpp", 'w') as f: + with open(f"{self.pluginDirectory}/{self.names[j]}{self.dataTypes[j]}Handler.cpp", 'w') as f: + f.write(data) + f.close() + with open('./Templates/genericChatSubscriber.cpp', 'r') as f: + data = f.read() + data = data.replace("HEADER", self.header) + data = data.replace("GENERIC", self.names[j]) + f.close() + with open(f"{self.pluginDirectory}/{self.names[j]}{self.dataTypes[j]}Subscriber.cpp", 'w') as f: f.write(data) f.close() self.createPreferences(self.names) @@ -485,7 +505,7 @@ class SkeletonSourceFiles(Preferences): if (fileType): splits[i] += tempString.replace("FFMPEGLIBS", f"{item} ") else: - splits[i] += tempString.replace("FFMPEGLIBS", f"-l:lib{item}.a") + splits[i] += tempString.replace("FFMPEGLIBS", f"l:lib{item}.a") inputStr = ''.join(splits) return inputStr