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

« back to all changes in this revision

Viewing changes to daemon/src/video/video_preferences.cpp

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Mark Purcell
  • Date: 2014-10-18 15:08:50 UTC
  • mfrom: (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20141018150850-2exfk34ckb15pcwi
Tags: 1.4.1-0.1
[ Francois Marier ]
* Non-maintainer upload
* New upstream release (closes: #759576, #741130)
  - debian/rules +PJPROJECT_VERSION := 2.2.1
  - add upstream patch to fix broken TLS support
  - add patch to fix pjproject regression

[ Mark Purcell ]
* Build-Depends:
  - sflphone-daemon + libavformat-dev, libavcodec-dev, libswscale-dev,
  libavdevice-dev, libavutil-dev
  - sflphone-gnome + libclutter-gtk-1.0-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: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
4
 
 *
5
 
 *  This program is free software; you can redistribute it and/or modify
6
 
 *  it under the terms of the GNU General Public License as published by
7
 
 *  the Free Software Foundation; either version 3 of the License, or
8
 
 *  (at your option) any later version.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
18
 
 *
19
 
 *  Additional permission under GNU GPL version 3 section 7:
20
 
 *
21
 
 *  If you modify this program, or any covered work, by linking or
22
 
 *  combining it with the OpenSSL project's OpenSSL library (or a
23
 
 *  modified version of that library), containing parts covered by the
24
 
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
25
 
 *  grants you additional permission to convey the resulting work.
26
 
 *  Corresponding Source for a non-source form of such a combination
27
 
 *  shall include the source code for the parts of OpenSSL used as well
28
 
 *  as that of the covered work.
29
 
 */
30
 
 
31
 
#include "video_preferences.h"
32
 
#include "video_v4l2_list.h"
33
 
#include "logger.h"
34
 
#include "config/yamlnode.h"
35
 
#include "config/yamlemitter.h"
36
 
#include <sstream>
37
 
 
38
 
using namespace sfl_video;
39
 
 
40
 
VideoPreference::VideoPreference() :
41
 
    v4l2_list_(new VideoV4l2ListThread), device_(), channel_(), size_(), rate_()
42
 
{
43
 
    v4l2_list_->start();
44
 
}
45
 
 
46
 
std::map<std::string, std::string> VideoPreference::getSettings()
47
 
{
48
 
    std::map<std::string, std::string> args;
49
 
    if (not device_.empty()) {
50
 
        args["input"] = v4l2_list_->getDeviceNode(device_);
51
 
        std::stringstream ss;
52
 
        ss << v4l2_list_->getChannelNum(device_, channel_);
53
 
        args["channel"] = ss.str();
54
 
        args["video_size"] = size_;
55
 
        size_t x_pos = size_.find("x");
56
 
        args["width"] = size_.substr(0, x_pos);
57
 
        args["height"] = size_.substr(x_pos + 1);
58
 
        args["framerate"] = rate_;
59
 
    }
60
 
 
61
 
    return args;
62
 
}
63
 
 
64
 
void VideoPreference::serialize(Conf::YamlEmitter &emitter)
65
 
{
66
 
    Conf::MappingNode preferencemap(NULL);
67
 
 
68
 
    Conf::ScalarNode device(device_);
69
 
    Conf::ScalarNode channel(channel_);
70
 
    Conf::ScalarNode size(size_);
71
 
    Conf::ScalarNode rate(rate_);
72
 
 
73
 
    preferencemap.setKeyValue(videoDeviceKey, &device);
74
 
    preferencemap.setKeyValue(videoChannelKey, &channel);
75
 
    preferencemap.setKeyValue(videoSizeKey, &size);
76
 
    preferencemap.setKeyValue(videoRateKey, &rate);
77
 
 
78
 
    emitter.serializePreference(&preferencemap, "video");
79
 
}
80
 
 
81
 
void VideoPreference::unserialize(const Conf::YamlNode &map)
82
 
{
83
 
    map.getValue(videoDeviceKey, &device_);
84
 
    map.getValue(videoChannelKey, &channel_);
85
 
    map.getValue(videoSizeKey, &size_);
86
 
    map.getValue(videoRateKey, &rate_);
87
 
}
88
 
 
89
 
std::vector<std::string>
90
 
VideoPreference::getDeviceList() {
91
 
    return v4l2_list_->getDeviceList();
92
 
}
93
 
 
94
 
std::vector<std::string>
95
 
VideoPreference::getChannelList(const std::string &dev) {
96
 
    return v4l2_list_->getChannelList(dev);
97
 
}
98
 
 
99
 
std::vector<std::string>
100
 
VideoPreference::getSizeList(const std::string &dev, const std::string &channel) {
101
 
    return v4l2_list_->getSizeList(dev, channel);
102
 
}
103
 
 
104
 
std::vector<std::string>
105
 
VideoPreference::getRateList(const std::string &dev, const std::string &channel, const std::string &size) {
106
 
    return v4l2_list_->getRateList(dev, channel, size);
107
 
}