blob: b8113e3f63d19f9a395619fd073e1ddeb9ab98a1 [file] [log] [blame]
agsantos4bb4bc52021-03-08 14:21:45 -05001/**
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"
agsantos3fcc6212021-08-18 17:11:29 -030028#include "PluginPreferenceHandler.h"
agsantos4bb4bc52021-03-08 14:21:45 -050029
30#ifdef WIN32
31#define EXPORT_PLUGIN __declspec(dllexport)
32#else
33#define EXPORT_PLUGIN
34#endif
35
agsantos3fcc6212021-08-18 17:11:29 -030036#define WaterMark_VERSION_MAJOR 2
agsantos4bb4bc52021-03-08 14:21:45 -050037#define WaterMark_VERSION_MINOR 0
38#define WaterMark_VERSION_PATCH 0
39
40extern "C" {
41
42void
43pluginExit(void)
44{}
45
46EXPORT_PLUGIN JAMI_PluginExitFunc
47JAMI_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
agsantos4bb4bc52021-03-08 14:21:45 -050055 if (api) {
agsantos3fcc6212021-08-18 17:11:29 -030056 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);
agsantos4bb4bc52021-03-08 14:21:45 -050061 std::string dataPath;
62 api->invokeService(api, "getPluginDataPath", &dataPath);
63
agsantos3fcc6212021-08-18 17:11:29 -030064 auto fmpPluginPreferenceHandler
65 = std::make_unique<jami::PluginPreferenceHandler>(api, std::move(preferences), dataPath);
agsantos4bb4bc52021-03-08 14:21:45 -050066 auto fmpWatermarkMediaHandler
agsantos3fcc6212021-08-18 17:11:29 -030067 = std::make_unique<jami::WatermarkMediaHandler>(std::move(dataPath),
68 fmpPluginPreferenceHandler.get());
69 fmpPluginPreferenceHandler->setWaterMarkHandler(fmpWatermarkMediaHandler.get());
agsantos4bb4bc52021-03-08 14:21:45 -050070 if (api->manageComponent(api,
71 "CallMediaHandlerManager",
72 fmpWatermarkMediaHandler.release())) {
73 return nullptr;
74 }
agsantos3fcc6212021-08-18 17:11:29 -030075 if (api->manageComponent(api,
76 "PreferenceHandlerManager",
77 fmpPluginPreferenceHandler.release())) {
78 return nullptr;
79 }
agsantos4bb4bc52021-03-08 14:21:45 -050080 }
81 return pluginExit;
82}
83}