blob: 32549257981c7f3a31111d5285dfa6c1e1fdda20 [file] [log] [blame]
HEADER
#include "GENERICMediaHandler.h"
#include "pluglog.h"
const char sep = separator();
const std::string TAG = "GENERIC";
#define NAME "GENERIC"
namespace jami {
GENERICMediaHandler::GENERICMediaHandler(std::map<std::string, std::string>&& ppm,
std::string&& datapath)
: datapath_ {datapath}
, ppm_ {ppm}
{
setId(datapath_);
mediaSubscriber_ = std::make_shared<GENERICDATATYPESubscriber>(datapath_);
}
void
GENERICMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject)
{
std::ostringstream oss;
std::string direction = data.direction ? "Receive" : "Preview";
oss << "NEW SUBJECT: [" << data.id << "," << direction << "]" << std::endl;
bool preferredStreamDirection = false; // false for output; true for input
oss << "preferredStreamDirection " << preferredStreamDirection << std::endl;
if (data.type == StreamType::DataType && !data.direction
&& data.direction == preferredStreamDirection) {
subject->attach(mediaSubscriber_.get()); // your image
oss << "got my sent image attached" << std::endl;
attached_ = "1";
} else if (data.type == StreamType::DataType && data.direction
&& data.direction == preferredStreamDirection) {
subject->attach(mediaSubscriber_.get()); // the image you receive from others on the call
oss << "got received image attached" << std::endl;
attached_ = "1";
}
Plog::log(Plog::LogPriority::INFO, TAG, oss.str());
}
std::map<std::string, std::string>
GENERICMediaHandler::getCallMediaHandlerDetails()
{
return {{"name", NAME},
{"iconPath", datapath_ + sep + "icon.png"},
{"pluginId", id()},
{"attached", attached_},
{"dataType", "1"}};
}
void
GENERICMediaHandler::setPreferenceAttribute(const std::string& key, const std::string& value)
{
auto it = ppm_.find(key);
if (it != ppm_.end() && it->second != value) {
it->second = value;----------------
if (key == "PREFERENCE1") {
// use preference
return;
}----------------
}
}
bool
GENERICMediaHandler::preferenceMapHasKey(const std::string& key)
{
----------------if (key == "PREFERENCE2") { return true; }
----------------return false;
}
void
GENERICMediaHandler::detach()
{
attached_ = "0";
mediaSubscriber_->detach();
}
GENERICMediaHandler::~GENERICMediaHandler()
{
std::ostringstream oss;
oss << " ~GENERICMediaHandler from PLUGINNAME Plugin" << std::endl;
Plog::log(Plog::LogPriority::INFO, TAG, oss.str());
detach();
}
} // namespace jami