~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* 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-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>
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_preview.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), preview_(), videoPreference_()
46
 
{
47
 
    // initialize libav libraries
48
 
    libav_utils::sfl_avcodec_init();
49
 
}
50
 
 
51
 
VideoPreference &
52
 
VideoControls::getVideoPreferences()
53
 
{
54
 
    return videoPreference_;
55
 
}
56
 
 
57
 
std::vector<std::map<std::string, std::string> >
58
 
VideoControls::getCodecs(const std::string &accountID)
59
 
{
60
 
    Account *acc = Manager::instance().getAccount(accountID);
61
 
 
62
 
    if (acc != NULL)
63
 
        return acc->getAllVideoCodecs();
64
 
    else
65
 
        return std::vector<std::map<std::string, std::string> >();
66
 
}
67
 
 
68
 
void
69
 
VideoControls::setCodecs(const std::string& accountID,
70
 
                         const std::vector<std::map<std::string, std::string> > &details)
71
 
{
72
 
    Account *acc = Manager::instance().getAccount(accountID);
73
 
    if (acc != NULL) {
74
 
        acc->setVideoCodecs(details);
75
 
        Manager::instance().saveConfig();
76
 
    }
77
 
}
78
 
 
79
 
std::vector<std::string>
80
 
VideoControls::getDeviceList()
81
 
{
82
 
    return videoPreference_.getDeviceList();
83
 
}
84
 
 
85
 
std::vector<std::string>
86
 
VideoControls::getDeviceChannelList(const std::string &dev)
87
 
{
88
 
    return videoPreference_.getChannelList(dev);
89
 
}
90
 
 
91
 
std::vector<std::string>
92
 
VideoControls::getDeviceSizeList(const std::string &dev, const std::string &channel)
93
 
{
94
 
    return videoPreference_.getSizeList(dev, channel);
95
 
}
96
 
 
97
 
std::vector<std::string>
98
 
VideoControls::getDeviceRateList(const std::string &dev, const std::string &channel, const std::string &size)
99
 
{
100
 
    return videoPreference_.getRateList(dev, channel, size);
101
 
}
102
 
 
103
 
std::string
104
 
VideoControls::getActiveDevice()
105
 
{
106
 
    return videoPreference_.getDevice();
107
 
}
108
 
 
109
 
std::string
110
 
VideoControls::getActiveDeviceChannel()
111
 
{
112
 
    return videoPreference_.getChannel();
113
 
}
114
 
 
115
 
std::string
116
 
VideoControls::getActiveDeviceSize()
117
 
{
118
 
    return videoPreference_.getSize();
119
 
}
120
 
 
121
 
std::string
122
 
VideoControls::getActiveDeviceRate()
123
 
{
124
 
    return videoPreference_.getRate();
125
 
}
126
 
 
127
 
void
128
 
VideoControls::setActiveDevice(const std::string &device)
129
 
{
130
 
    DEBUG("Setting device to %s", device.c_str());
131
 
    videoPreference_.setDevice(device);
132
 
}
133
 
 
134
 
void
135
 
VideoControls::setActiveDeviceChannel(const std::string &channel)
136
 
{
137
 
    videoPreference_.setChannel(channel);
138
 
}
139
 
 
140
 
void
141
 
VideoControls::setActiveDeviceSize(const std::string &size)
142
 
{
143
 
    videoPreference_.setSize(size);
144
 
}
145
 
 
146
 
void
147
 
VideoControls::setActiveDeviceRate(const std::string &rate)
148
 
{
149
 
    videoPreference_.setRate(rate);
150
 
}
151
 
 
152
 
std::map<std::string, std::string>
153
 
VideoControls::getSettings() {
154
 
    return videoPreference_.getSettings();
155
 
}
156
 
 
157
 
void
158
 
VideoControls::startPreview()
159
 
{
160
 
    if (preview_.get()) {
161
 
        ERROR("Video preview was already started!");
162
 
        return;
163
 
    }
164
 
 
165
 
    using std::map;
166
 
    using std::string;
167
 
 
168
 
    map<string, string> args(videoPreference_.getSettings());
169
 
    preview_.reset(new sfl_video::VideoPreview(args));
170
 
}
171
 
 
172
 
void
173
 
VideoControls::stopPreview()
174
 
{
175
 
    if (preview_.get()) {
176
 
        DEBUG("Stopping video preview");
177
 
        preview_.reset();
178
 
    } else {
179
 
        WARN("Video preview was already stopped");
180
 
    }
181
 
}
182
 
 
183
 
bool
184
 
VideoControls::hasPreviewStarted()
185
 
{
186
 
    return preview_.get() != 0;
187
 
}
188
 
 
189
 
std::string
190
 
VideoControls::getCurrentCodecName(const std::string &callID)
191
 
{
192
 
    return Manager::instance().getCurrentVideoCodecName(callID);
193
 
}
194