2
* Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
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.
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.
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.
19
* Additional permission under GNU GPL version 3 section 7:
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.
31
#include "video_preferences.h"
32
#include "video_v4l2_list.h"
34
#include "config/yamlnode.h"
35
#include "config/yamlemitter.h"
38
using namespace sfl_video;
40
VideoPreference::VideoPreference() :
41
v4l2_list_(new VideoV4l2ListThread), device_(), channel_(), size_(), rate_()
46
std::map<std::string, std::string> VideoPreference::getSettings()
48
std::map<std::string, std::string> args;
49
if (not device_.empty()) {
50
args["input"] = v4l2_list_->getDeviceNode(device_);
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_;
64
void VideoPreference::serialize(Conf::YamlEmitter &emitter)
66
Conf::MappingNode preferencemap(NULL);
68
Conf::ScalarNode device(device_);
69
Conf::ScalarNode channel(channel_);
70
Conf::ScalarNode size(size_);
71
Conf::ScalarNode rate(rate_);
73
preferencemap.setKeyValue(videoDeviceKey, &device);
74
preferencemap.setKeyValue(videoChannelKey, &channel);
75
preferencemap.setKeyValue(videoSizeKey, &size);
76
preferencemap.setKeyValue(videoRateKey, &rate);
78
emitter.serializePreference(&preferencemap, "video");
81
void VideoPreference::unserialize(const Conf::YamlNode &map)
83
map.getValue(videoDeviceKey, &device_);
84
map.getValue(videoChannelKey, &channel_);
85
map.getValue(videoSizeKey, &size_);
86
map.getValue(videoRateKey, &rate_);
89
std::vector<std::string>
90
VideoPreference::getDeviceList() {
91
return v4l2_list_->getDeviceList();
94
std::vector<std::string>
95
VideoPreference::getChannelList(const std::string &dev) {
96
return v4l2_list_->getChannelList(dev);
99
std::vector<std::string>
100
VideoPreference::getSizeList(const std::string &dev, const std::string &channel) {
101
return v4l2_list_->getSizeList(dev, channel);
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);