| 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_); |
| mVS = std::make_shared<GENERICVideoSubscriber>(datapath_); |
| } |
| |
| void |
| GENERICMediaHandler::notifyAVFrameSubject(const StreamData& data, jami::avSubjectPtr subject) |
| { |
| Plog::log(Plog::LogPriority::INFO, TAG, "IN AVFRAMESUBJECT"); |
| 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::video && !data.direction |
| && data.direction == preferredStreamDirection) { |
| subject->attach(mVS.get()); // your 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 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"; |
| mVS->detach(); |
| } |
| |
| GENERICMediaHandler::~GENERICMediaHandler() |
| { |
| std::ostringstream oss; |
| oss << " ~GENERICMediaHandler from PLUGINNAME Plugin" << std::endl; |
| Plog::log(Plog::LogPriority::INFO, TAG, oss.str()); |
| detach(); |
| } |
| } // namespace jami |