GreenScreen: blur functionality
GitLab: #15
Change-Id: Iafc8b410ebe0228eca9b780504382347b38fd8cc
diff --git a/GreenScreen/pluginMediaHandler.cpp b/GreenScreen/pluginMediaHandler.cpp
index 2643d6d..1bc9465 100644
--- a/GreenScreen/pluginMediaHandler.cpp
+++ b/GreenScreen/pluginMediaHandler.cpp
@@ -20,8 +20,8 @@
*/
#include "pluginMediaHandler.h"
-// Logger
-#include "pluglog.h"
+
+#include <pluglog.h>
#include <string_view>
const char sep = separator();
const std::string TAG = "FORESEG";
@@ -32,25 +32,24 @@
PluginMediaHandler::PluginMediaHandler(std::map<std::string, std::string>&& preferences,
std::string&& datapath)
- : datapath_ {datapath}
+ : dataPath_ {datapath}
, preferences_ {preferences}
{
- setId(datapath_);
+ setId(dataPath_);
#ifdef __ANDROID__
- mVS = std::make_shared<VideoSubscriber>(datapath_,
- "mModel.ort",
- preferences_.at("background"),
+ mVS = std::make_shared<VideoSubscriber>(dataPath_ + sep + "model/mModel.ort",
preferences_.at("acceleration") == "1");
#else
#ifdef NVIDIA
- mVS = std::make_shared<VideoSubscriber>(datapath_,
- "mModel.onnx",
- preferences_.at("background"),
+ mVS = std::make_shared<VideoSubscriber>(dataPath_ + sep + "model/mModel.onnx",
preferences_.at("acceleration") == "1");
#else
- mVS = std::make_shared<VideoSubscriber>(datapath_, "mModel.onnx", preferences_.at("background"));
+ mVS = std::make_shared<VideoSubscriber>(dataPath_ + sep + "model/mModel.onnx");
#endif // NVIDIA
#endif // ANDROID
+ mVS->setBackground(preferences_.at("background"));
+ mVS->setBlur(preferences_.at("blur") == "1");
+ mVS->setBlurLevel(preferences_.at("blurlevel"));
}
void
@@ -68,12 +67,14 @@
oss << "preferredStreamDirection " << preferredStreamDirection << std::endl;
if (data.type == StreamType::video && !data.direction
&& data.direction == preferredStreamDirection) {
- subject->attach(mVS.get()); // my image
+ detach();
+ subject->attachPriorityObserver(mVS); // my image
oss << "got my sent image attached" << std::endl;
attached_ = '1';
} else if (data.type == StreamType::video && data.direction
&& data.direction == preferredStreamDirection) {
- subject->attach(mVS.get()); // the image I receive from the others on the call
+ detach();
+ subject->attachPriorityObserver(mVS); // the image I receive from the others on the call
oss << "got my received image attached" << std::endl;
attached_ = '1';
}
@@ -85,7 +86,7 @@
PluginMediaHandler::getCallMediaHandlerDetails()
{
return {{"name", NAME},
- {"iconPath", datapath_ + sep + "icon.svg"},
+ {"iconPath", dataPath_ + sep + "icon.svg"},
{"pluginId", id()},
{"attached", attached_},
{"dataType", "1"}};
@@ -100,16 +101,19 @@
if (key == "background") {
mVS->setBackground(value);
}
+ if (key == "blur") {
+ mVS->setBlur(value == "1");
+ }
+ if (key == "blurlevel") {
+ mVS->setBlurLevel(value);
+ }
}
}
bool
PluginMediaHandler::preferenceMapHasKey(const std::string& key)
{
- if (key == "background") {
- return true;
- }
- return false;
+ return (key == "background" || key == "blur" || key == "blurlevel");
}
void