2
* Copyright (C) 2004-2013 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_camera.h"
41
const char * const SERVER_PATH = "/org/sflphone/SFLphone/VideoControls";
44
VideoControls::VideoControls(DBus::Connection& connection) :
45
DBus::ObjectAdaptor(connection, SERVER_PATH)
50
// initialize libav libraries
51
libav_utils::sfl_avcodec_init();
55
VideoControls::getVideoPreferences()
57
return videoPreference_;
60
std::vector<std::map<std::string, std::string> >
61
VideoControls::getCodecs(const std::string &accountID)
63
Account *acc = Manager::instance().getAccount(accountID);
66
return acc->getAllVideoCodecs();
68
return std::vector<std::map<std::string, std::string> >();
72
VideoControls::setCodecs(const std::string& accountID,
73
const std::vector<std::map<std::string, std::string> > &details)
75
Account *acc = Manager::instance().getAccount(accountID);
77
acc->setVideoCodecs(details);
78
Manager::instance().saveConfig();
82
std::vector<std::string>
83
VideoControls::getDeviceList()
85
return videoPreference_.getDeviceList();
88
std::vector<std::string>
89
VideoControls::getDeviceChannelList(const std::string &dev)
91
return videoPreference_.getChannelList(dev);
94
std::vector<std::string>
95
VideoControls::getDeviceSizeList(const std::string &dev, const std::string &channel)
97
return videoPreference_.getSizeList(dev, channel);
100
std::vector<std::string>
101
VideoControls::getDeviceRateList(const std::string &dev, const std::string &channel, const std::string &size)
103
return videoPreference_.getRateList(dev, channel, size);
107
VideoControls::getActiveDevice()
109
return videoPreference_.getDevice();
113
VideoControls::getActiveDeviceChannel()
115
return videoPreference_.getChannel();
119
VideoControls::getActiveDeviceSize()
121
return videoPreference_.getSize();
125
VideoControls::getActiveDeviceRate()
127
return videoPreference_.getRate();
131
VideoControls::setActiveDevice(const std::string &device)
133
DEBUG("Setting device to %s", device.c_str());
134
videoPreference_.setDevice(device);
138
VideoControls::setActiveDeviceChannel(const std::string &channel)
140
videoPreference_.setChannel(channel);
144
VideoControls::setActiveDeviceSize(const std::string &size)
146
videoPreference_.setSize(size);
150
VideoControls::setActiveDeviceRate(const std::string &rate)
152
videoPreference_.setRate(rate);
155
std::map<std::string, std::string>
156
VideoControls::getSettings() {
157
return videoPreference_.getSettings();
161
VideoControls::startCamera()
165
WARN("Video preview was already started!");
172
map<string, string> args(videoPreference_.getSettings());
173
videoCamera_.reset(new sfl_video::VideoCamera(args));
177
VideoControls::stopCamera()
180
DEBUG("Stopping video preview");
182
if (cameraClients_ <= 0)
183
videoCamera_.reset();
185
WARN("Video preview was already stopped");
189
std::weak_ptr<sfl_video::VideoFrameActiveWriter>
190
VideoControls::getVideoCamera()
196
VideoControls::hasCameraStarted()
198
// see http://stackoverflow.com/a/7580064/21185
199
return static_cast<bool>(videoCamera_);
203
VideoControls::getCurrentCodecName(const std::string &callID)
205
return Manager::instance().getCurrentVideoCodecName(callID);