~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/src/client/dbus/video_controls.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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>
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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.
 
20
 *
 
21
 *  Additional permission under GNU GPL version 3 section 7:
 
22
 *
 
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.
 
31
 */
 
32
 
 
33
#include "video_controls.h"
 
34
#include "video/libav_utils.h"
 
35
#include "video/video_camera.h"
 
36
#include "account.h"
 
37
#include "logger.h"
 
38
#include "manager.h"
 
39
 
 
40
namespace {
 
41
const char * const SERVER_PATH = "/org/sflphone/SFLphone/VideoControls";
 
42
}
 
43
 
 
44
VideoControls::VideoControls(DBus::Connection& connection) :
 
45
    DBus::ObjectAdaptor(connection, SERVER_PATH)
 
46
    , videoCamera_()
 
47
    , videoPreference_()
 
48
    , cameraClients_(0)
 
49
{
 
50
    // initialize libav libraries
 
51
    libav_utils::sfl_avcodec_init();
 
52
}
 
53
 
 
54
VideoPreference &
 
55
VideoControls::getVideoPreferences()
 
56
{
 
57
    return videoPreference_;
 
58
}
 
59
 
 
60
std::vector<std::map<std::string, std::string> >
 
61
VideoControls::getCodecs(const std::string &accountID)
 
62
{
 
63
    Account *acc = Manager::instance().getAccount(accountID);
 
64
 
 
65
    if (acc != NULL)
 
66
        return acc->getAllVideoCodecs();
 
67
    else
 
68
        return std::vector<std::map<std::string, std::string> >();
 
69
}
 
70
 
 
71
void
 
72
VideoControls::setCodecs(const std::string& accountID,
 
73
                         const std::vector<std::map<std::string, std::string> > &details)
 
74
{
 
75
    Account *acc = Manager::instance().getAccount(accountID);
 
76
    if (acc != NULL) {
 
77
        acc->setVideoCodecs(details);
 
78
        Manager::instance().saveConfig();
 
79
    }
 
80
}
 
81
 
 
82
std::vector<std::string>
 
83
VideoControls::getDeviceList()
 
84
{
 
85
    return videoPreference_.getDeviceList();
 
86
}
 
87
 
 
88
std::vector<std::string>
 
89
VideoControls::getDeviceChannelList(const std::string &dev)
 
90
{
 
91
    return videoPreference_.getChannelList(dev);
 
92
}
 
93
 
 
94
std::vector<std::string>
 
95
VideoControls::getDeviceSizeList(const std::string &dev, const std::string &channel)
 
96
{
 
97
    return videoPreference_.getSizeList(dev, channel);
 
98
}
 
99
 
 
100
std::vector<std::string>
 
101
VideoControls::getDeviceRateList(const std::string &dev, const std::string &channel, const std::string &size)
 
102
{
 
103
    return videoPreference_.getRateList(dev, channel, size);
 
104
}
 
105
 
 
106
std::string
 
107
VideoControls::getActiveDevice()
 
108
{
 
109
    return videoPreference_.getDevice();
 
110
}
 
111
 
 
112
std::string
 
113
VideoControls::getActiveDeviceChannel()
 
114
{
 
115
    return videoPreference_.getChannel();
 
116
}
 
117
 
 
118
std::string
 
119
VideoControls::getActiveDeviceSize()
 
120
{
 
121
    return videoPreference_.getSize();
 
122
}
 
123
 
 
124
std::string
 
125
VideoControls::getActiveDeviceRate()
 
126
{
 
127
    return videoPreference_.getRate();
 
128
}
 
129
 
 
130
void
 
131
VideoControls::setActiveDevice(const std::string &device)
 
132
{
 
133
    DEBUG("Setting device to %s", device.c_str());
 
134
    videoPreference_.setDevice(device);
 
135
}
 
136
 
 
137
void
 
138
VideoControls::setActiveDeviceChannel(const std::string &channel)
 
139
{
 
140
    videoPreference_.setChannel(channel);
 
141
}
 
142
 
 
143
void
 
144
VideoControls::setActiveDeviceSize(const std::string &size)
 
145
{
 
146
    videoPreference_.setSize(size);
 
147
}
 
148
 
 
149
void
 
150
VideoControls::setActiveDeviceRate(const std::string &rate)
 
151
{
 
152
    videoPreference_.setRate(rate);
 
153
}
 
154
 
 
155
std::map<std::string, std::string>
 
156
VideoControls::getSettings() {
 
157
    return videoPreference_.getSettings();
 
158
}
 
159
 
 
160
void
 
161
VideoControls::startCamera()
 
162
{
 
163
    cameraClients_++;
 
164
    if (videoCamera_) {
 
165
        WARN("Video preview was already started!");
 
166
        return;
 
167
    }
 
168
 
 
169
    using std::map;
 
170
    using std::string;
 
171
 
 
172
    map<string, string> args(videoPreference_.getSettings());
 
173
    videoCamera_.reset(new sfl_video::VideoCamera(args));
 
174
}
 
175
 
 
176
void
 
177
VideoControls::stopCamera()
 
178
{
 
179
    if (videoCamera_) {
 
180
        DEBUG("Stopping video preview");
 
181
        cameraClients_--;
 
182
        if (cameraClients_ <= 0)
 
183
            videoCamera_.reset();
 
184
    } else {
 
185
        WARN("Video preview was already stopped");
 
186
    }
 
187
}
 
188
 
 
189
std::weak_ptr<sfl_video::VideoFrameActiveWriter>
 
190
VideoControls::getVideoCamera()
 
191
{
 
192
    return videoCamera_;
 
193
}
 
194
 
 
195
bool
 
196
VideoControls::hasCameraStarted()
 
197
{
 
198
    // see http://stackoverflow.com/a/7580064/21185
 
199
    return static_cast<bool>(videoCamera_);
 
200
}
 
201
 
 
202
std::string
 
203
VideoControls::getCurrentCodecName(const std::string &callID)
 
204
{
 
205
    return Manager::instance().getCurrentVideoCodecName(callID);
 
206
}