agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2021 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #include <iostream> |
| 22 | #include <string.h> |
| 23 | #include <thread> |
| 24 | #include <memory> |
| 25 | #include <plugin/jamiplugin.h> |
| 26 | |
| 27 | #include "WatermarkMediaHandler.h" |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 28 | #include "PluginPreferenceHandler.h" |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 29 | |
| 30 | #ifdef WIN32 |
| 31 | #define EXPORT_PLUGIN __declspec(dllexport) |
| 32 | #else |
| 33 | #define EXPORT_PLUGIN |
| 34 | #endif |
| 35 | |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 36 | #define WaterMark_VERSION_MAJOR 2 |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 37 | #define WaterMark_VERSION_MINOR 0 |
| 38 | #define WaterMark_VERSION_PATCH 0 |
| 39 | |
| 40 | extern "C" { |
| 41 | |
| 42 | void |
| 43 | pluginExit(void) |
| 44 | {} |
| 45 | |
| 46 | EXPORT_PLUGIN JAMI_PluginExitFunc |
| 47 | JAMI_dynPluginInit(const JAMI_PluginAPI* api) |
| 48 | { |
| 49 | std::cout << "*****************" << std::endl; |
| 50 | std::cout << "** WaterMark **" << std::endl; |
| 51 | std::cout << "*****************" << std::endl << std::endl; |
| 52 | std::cout << "Version " << WaterMark_VERSION_MAJOR << "." << WaterMark_VERSION_MINOR << "." |
| 53 | << WaterMark_VERSION_PATCH << std::endl; |
| 54 | |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 55 | if (api) { |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 56 | if (api->version.api < JAMI_PLUGIN_API_VERSION) |
| 57 | return nullptr; |
| 58 | |
| 59 | std::map<std::string, std::map<std::string, std::string>> preferences; |
| 60 | api->invokeService(api, "getPluginAccPreferences", &preferences); |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 61 | std::string dataPath; |
| 62 | api->invokeService(api, "getPluginDataPath", &dataPath); |
| 63 | |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 64 | auto fmpPluginPreferenceHandler |
| 65 | = std::make_unique<jami::PluginPreferenceHandler>(api, std::move(preferences), dataPath); |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 66 | auto fmpWatermarkMediaHandler |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 67 | = std::make_unique<jami::WatermarkMediaHandler>(std::move(dataPath), |
| 68 | fmpPluginPreferenceHandler.get()); |
| 69 | fmpPluginPreferenceHandler->setWaterMarkHandler(fmpWatermarkMediaHandler.get()); |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 70 | if (api->manageComponent(api, |
| 71 | "CallMediaHandlerManager", |
| 72 | fmpWatermarkMediaHandler.release())) { |
| 73 | return nullptr; |
| 74 | } |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 75 | if (api->manageComponent(api, |
| 76 | "PreferenceHandlerManager", |
| 77 | fmpPluginPreferenceHandler.release())) { |
| 78 | return nullptr; |
| 79 | } |
agsantos | 4bb4bc5 | 2021-03-08 14:21:45 -0500 | [diff] [blame] | 80 | } |
| 81 | return pluginExit; |
| 82 | } |
| 83 | } |