fixes for checkin 2 times ago
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / videoconfig.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "bchash.h"
23 #include "videoconfig.h"
24 #include "videodevice.inc"
25 #include <string.h>
26
27 #define CLAMP(x, y, z) (x) = ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
28
29 VideoConfig::VideoConfig()
30 {
31 }
32
33 VideoConfig::~VideoConfig()
34 {
35 }
36
37 VideoConfig& VideoConfig::operator=(VideoConfig &that)
38 {
39 // Input
40         video_in_driver = that.video_in_driver;
41         strcpy(screencapture_display, that.screencapture_display);
42         vfirewire_in_port = that.vfirewire_in_port;
43         vfirewire_in_channel = that.vfirewire_in_channel;
44         capture_length = that.capture_length;
45
46 // Output
47         video_out_driver = that.video_out_driver;
48         CLAMP(capture_length, 1, 1000);
49         return *this;
50 }
51
52 int VideoConfig::load_defaults(BC_Hash *defaults)
53 {
54         video_in_driver = defaults->get("VIDEO_IN_DRIVER", VIDEO4LINUX2);
55         sprintf(v4l2_in_device, "/dev/video");
56         sprintf(screencapture_display, "");
57         defaults->get("SCREENCAPTURE_DISPLAY", screencapture_display);
58         vfirewire_in_port = defaults->get("VFIREWIRE_IN_PORT", 0);
59         vfirewire_in_channel = defaults->get("VFIREWIRE_IN_CHANNEL", 63);
60         capture_length = defaults->get("VIDEO_CAPTURE_LENGTH", 30);
61
62         video_out_driver = defaults->get("VIDEO_OUT_DRIVER", PLAYBACK_X11);
63         return 0;
64 }
65
66 int VideoConfig::save_defaults(BC_Hash *defaults)
67 {
68         defaults->update("VIDEO_IN_DRIVER", video_in_driver);
69         defaults->update("SCREENCAPTURE_DISPLAY", screencapture_display);
70         defaults->update("VFIREWIRE_IN_PORT", vfirewire_in_port);
71         defaults->update("VFIREWIRE_IN_CHANNEL", vfirewire_in_channel);
72         defaults->update("VIDEO_CAPTURE_LENGTH", capture_length);
73
74         defaults->update("VIDEO_OUT_DRIVER", video_out_driver);
75 }