3
* Ekiga -- A VoIP and Video-Conferencing application
4
* Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version. This program is distributed in the hope
10
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
11
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
* Ekiga is licensed under the GPL license and as a special exception, you
19
* have permission to link or otherwise combine this program with the
20
* programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
21
* applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
22
* programs, as long as you do follow the requirements of the GNU GPL for all
23
* the rest of the software thus combined.
28
* videoinput-gmconf-bridge.cpp - description
29
* -------------------------------------------
30
* begin : written in 2008 by Matthias Schneider
31
* copyright : (c) 2008 by Matthias Schneider
32
* description : Declaration of the bridge between the gmconf
33
* and the videoinput-core..
39
#include "videoinput-gmconf-bridge.h"
40
#include "videoinput-core.h"
42
#define VIDEO_DEVICES_KEY "/apps/" PACKAGE_NAME "/devices/video/"
43
#define VIDEO_CODECS_KEY "/apps/" PACKAGE_NAME "/codecs/video/"
45
using namespace Ekiga;
47
VideoInputCoreConfBridge::VideoInputCoreConfBridge (Ekiga::Service & _service)
48
: Ekiga::ConfBridge (_service)
51
property_changed.connect (sigc::mem_fun (this, &VideoInputCoreConfBridge::on_property_changed));
53
keys.push_back (VIDEO_DEVICES_KEY "size");
54
keys.push_back (VIDEO_DEVICES_KEY "max_frame_rate");
55
keys.push_back (VIDEO_DEVICES_KEY "input_device");
56
keys.push_back (VIDEO_DEVICES_KEY "channel");
57
keys.push_back (VIDEO_DEVICES_KEY "format");
58
keys.push_back (VIDEO_DEVICES_KEY "image");
59
keys.push_back (VIDEO_DEVICES_KEY "enable_preview");
63
void VideoInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry * /*entry*/)
65
VideoInputCore & videoinput_core = (VideoInputCore &) service;
67
if ( (key == VIDEO_DEVICES_KEY "size") ||
68
(key == VIDEO_DEVICES_KEY "max_frame_rate") ) {
70
PTRACE(4, "VidInputCoreConfBridge\tUpdating preview size and fps");
72
unsigned size = gm_conf_get_int (VIDEO_DEVICES_KEY "size");
73
if (size >= NB_VIDEO_SIZES) {
74
PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "size" << " out of range, ajusting to 0");
78
unsigned max_frame_rate = gm_conf_get_int (VIDEO_DEVICES_KEY "max_frame_rate");
79
if ( (max_frame_rate < 1) || (max_frame_rate > 30) ) {
80
PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "max_frame_rate" << " out of range, ajusting to 30");
83
videoinput_core.set_preview_config (VideoSizes[size].width,
84
VideoSizes[size].height,
87
else if ( (key == VIDEO_DEVICES_KEY "input_device") ||
88
(key == VIDEO_DEVICES_KEY "channel") ||
89
(key == VIDEO_DEVICES_KEY "format") ) {
91
PTRACE(4, "VidInputCoreConfBridge\tUpdating device");
93
VideoInputDevice device;
94
gchar *input_device = NULL;
95
input_device = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
96
if (input_device == NULL) {
97
PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "input_device" << " is NULL");
100
device.SetFromString(input_device);
101
g_free (input_device);
104
if ( (device.type == "" ) ||
105
(device.source == "") ||
106
(device.name == "" ) ) {
107
PTRACE(1, "VidinputCore\tTried to set malformed device");
108
device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
109
device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
110
device.name = VIDEO_INPUT_FALLBACK_DEVICE_NAME;
113
unsigned video_format = gm_conf_get_int (VIDEO_DEVICES_KEY "format");
114
if (video_format >= VI_FORMAT_MAX) {
115
PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "format" << " out of range, ajusting to 3");
119
videoinput_core.set_device (device, gm_conf_get_int (VIDEO_DEVICES_KEY "channel") ,(VideoInputFormat) video_format);
121
else if (key == VIDEO_DEVICES_KEY "enable_preview") {
123
PTRACE(4, "VidInputCoreConfBridge\tUpdating preview");
124
if (gm_conf_get_bool ( VIDEO_DEVICES_KEY "enable_preview"))
125
videoinput_core.start_preview();
127
videoinput_core.stop_preview();
129
else if (key == VIDEO_DEVICES_KEY "image") {
130
PTRACE(4, "VidInputCoreConfBridge\tUpdating image");