2
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
4
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
5
* Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
* Additional permission under GNU GPL version 3 section 7:
23
* If you modify this program, or any covered work, by linking or
24
* combining it with the OpenSSL project's OpenSSL library (or a
25
* modified version of that library), containing parts covered by the
26
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
27
* grants you additional permission to convey the resulting work.
28
* Corresponding Source for a non-source form of such a combination
29
* shall include the source code for the parts of OpenSSL used as well
30
* as that of the covered work.
33
#include "video_controls.h"
34
#include "video/libav_utils.h"
35
#include "video/video_preview.h"
41
const char * const SERVER_PATH = "/org/sflphone/SFLphone/VideoControls";
44
VideoControls::VideoControls(DBus::Connection& connection) :
45
DBus::ObjectAdaptor(connection, SERVER_PATH), preview_(), videoPreference_()
47
// initialize libav libraries
48
libav_utils::sfl_avcodec_init();
52
VideoControls::getVideoPreferences()
54
return videoPreference_;
57
std::vector<std::map<std::string, std::string> >
58
VideoControls::getCodecs(const std::string &accountID)
60
Account *acc = Manager::instance().getAccount(accountID);
63
return acc->getAllVideoCodecs();
65
return std::vector<std::map<std::string, std::string> >();
69
VideoControls::setCodecs(const std::string& accountID,
70
const std::vector<std::map<std::string, std::string> > &details)
72
Account *acc = Manager::instance().getAccount(accountID);
74
acc->setVideoCodecs(details);
75
Manager::instance().saveConfig();
79
std::vector<std::string>
80
VideoControls::getDeviceList()
82
return videoPreference_.getDeviceList();
85
std::vector<std::string>
86
VideoControls::getDeviceChannelList(const std::string &dev)
88
return videoPreference_.getChannelList(dev);
91
std::vector<std::string>
92
VideoControls::getDeviceSizeList(const std::string &dev, const std::string &channel)
94
return videoPreference_.getSizeList(dev, channel);
97
std::vector<std::string>
98
VideoControls::getDeviceRateList(const std::string &dev, const std::string &channel, const std::string &size)
100
return videoPreference_.getRateList(dev, channel, size);
104
VideoControls::getActiveDevice()
106
return videoPreference_.getDevice();
110
VideoControls::getActiveDeviceChannel()
112
return videoPreference_.getChannel();
116
VideoControls::getActiveDeviceSize()
118
return videoPreference_.getSize();
122
VideoControls::getActiveDeviceRate()
124
return videoPreference_.getRate();
128
VideoControls::setActiveDevice(const std::string &device)
130
DEBUG("Setting device to %s", device.c_str());
131
videoPreference_.setDevice(device);
135
VideoControls::setActiveDeviceChannel(const std::string &channel)
137
videoPreference_.setChannel(channel);
141
VideoControls::setActiveDeviceSize(const std::string &size)
143
videoPreference_.setSize(size);
147
VideoControls::setActiveDeviceRate(const std::string &rate)
149
videoPreference_.setRate(rate);
152
std::map<std::string, std::string>
153
VideoControls::getSettings() {
154
return videoPreference_.getSettings();
158
VideoControls::startPreview()
160
if (preview_.get()) {
161
ERROR("Video preview was already started!");
168
map<string, string> args(videoPreference_.getSettings());
169
preview_.reset(new sfl_video::VideoPreview(args));
173
VideoControls::stopPreview()
175
if (preview_.get()) {
176
DEBUG("Stopping video preview");
179
WARN("Video preview was already stopped");
184
VideoControls::hasPreviewStarted()
186
return preview_.get() != 0;
190
VideoControls::getCurrentCodecName(const std::string &callID)
192
return Manager::instance().getCurrentVideoCodecName(callID);