|
|
|
@ -8,10 +8,12 @@
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include "gui.h"
|
|
|
|
|
#include "video.h"
|
|
|
|
|
#include "filter.h"
|
|
|
|
|
#include "detect.h"
|
|
|
|
|
#include "configuration.h"
|
|
|
|
|
|
|
|
|
|
VideoDev videodev;
|
|
|
|
|
GtkWidget *video_da = NULL;
|
|
|
|
@ -20,7 +22,7 @@ extern GtkBuilder *_builder_; // work around for threads
|
|
|
|
|
extern Detect detect;
|
|
|
|
|
extern int video_enterdata;
|
|
|
|
|
extern position_2d video_enterdata_pos;
|
|
|
|
|
|
|
|
|
|
extern Configuration config;
|
|
|
|
|
|
|
|
|
|
gboolean videoctrl_update(gpointer data) {
|
|
|
|
|
GtkWidget *grid = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "vidctrl-grid"));
|
|
|
|
@ -188,8 +190,9 @@ void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// refresh the possible devices
|
|
|
|
|
/*
|
|
|
|
|
* refresh the possible devices
|
|
|
|
|
*/
|
|
|
|
|
void cb_video_btnrefreshlist (GtkWidget *widget, gpointer data) {
|
|
|
|
|
GtkWidget *cbox = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cb-videodev"));
|
|
|
|
|
GtkListStore *model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(cbox)));
|
|
|
|
@ -216,10 +219,11 @@ void cb_video_btnrefreshlist (GtkWidget *widget, gpointer data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// start recording from the videodev (will start a new thread)
|
|
|
|
|
// load list of controls from the video device and create the GtkGrid
|
|
|
|
|
// with all elements. Also connect the signals to the callback functions.
|
|
|
|
|
/*
|
|
|
|
|
* start recording from the videodev (will start a new thread)
|
|
|
|
|
* load list of controls from the video device and create the GtkGrid
|
|
|
|
|
* with all elements. Also connect the signals to the callback functions.
|
|
|
|
|
*/
|
|
|
|
|
void cb_video_btnrec (GtkWidget *widget, gpointer data) {
|
|
|
|
|
std::list<std::string> list;
|
|
|
|
|
std::list<std::string>::iterator iter;
|
|
|
|
@ -290,8 +294,9 @@ void cb_video_btnrec (GtkWidget *widget, gpointer data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// stop recording from the videodev (will stop the running thread)
|
|
|
|
|
/*
|
|
|
|
|
* stop recording from the videodev (will stop the running thread)
|
|
|
|
|
*/
|
|
|
|
|
void cb_video_btnstop (GtkWidget *widget, gpointer data) {
|
|
|
|
|
GtkWidget *btnstart = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-rec"));
|
|
|
|
|
GtkWidget *btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-stop"));
|
|
|
|
@ -304,9 +309,10 @@ void cb_video_btnstop (GtkWidget *widget, gpointer data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// callback from videodev thread. data will point to the latest VideoFrame.
|
|
|
|
|
// Access to this data must be Locked before use.
|
|
|
|
|
/*
|
|
|
|
|
* callback from videodev thread. data will point to the latest VideoFrame.
|
|
|
|
|
* Access to this data must be Locked before use.
|
|
|
|
|
*/
|
|
|
|
|
gboolean cb_thread_video (gpointer data) {
|
|
|
|
|
GtkWidget *btnstart;
|
|
|
|
|
GtkWidget *btnstop;
|
|
|
|
@ -357,15 +363,17 @@ gboolean cb_thread_video (gpointer data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// set ctrl on the device
|
|
|
|
|
/*
|
|
|
|
|
* set ctrl on the device
|
|
|
|
|
*/
|
|
|
|
|
void videoctrl_set(std::string name, int value) {
|
|
|
|
|
videodev.SetCtrlValue(name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// callback video control scale change
|
|
|
|
|
/*
|
|
|
|
|
* callback video control scale change
|
|
|
|
|
*/
|
|
|
|
|
void cb_vidctrl_scale_change (GtkRange *range, gpointer data) {
|
|
|
|
|
GtkWidget *grid = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "vidctrl-grid"));
|
|
|
|
|
GtkWidget *scale = NULL;
|
|
|
|
@ -382,8 +390,9 @@ void cb_vidctrl_scale_change (GtkRange *range, gpointer data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// callback video control entry change
|
|
|
|
|
/*
|
|
|
|
|
* callback video control entry change
|
|
|
|
|
*/
|
|
|
|
|
void cb_vidctrl_entry_change (GtkWidget *widget, gpointer data) {
|
|
|
|
|
GtkWidget *grid = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "vidctrl-grid"));
|
|
|
|
|
GtkWidget *label = NULL;
|
|
|
|
@ -445,4 +454,97 @@ void cb_videoda_btnrelease (GtkWidget *widget, GdkEvent *event, gpointer data) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* cb_video_pre_click/cb_video_pre_pressed, are needed to detect is we press
|
|
|
|
|
* the button longer as two seconds. If it is, all settings will be saved.
|
|
|
|
|
*/
|
|
|
|
|
#define BTNDOWN_TIME 1.0
|
|
|
|
|
struct {
|
|
|
|
|
int idx;
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
guint timer;
|
|
|
|
|
} presetbtn;
|
|
|
|
|
void cb_video_pre_click (GtkWidget *widget, gpointer data) {
|
|
|
|
|
float pushtime = get_cycletime(&presetbtn.tv);
|
|
|
|
|
std::string s;
|
|
|
|
|
int idx;
|
|
|
|
|
GtkWidget *btn;
|
|
|
|
|
|
|
|
|
|
if (pushtime > BTNDOWN_TIME && presetbtn.idx >= 0 && presetbtn.idx < BTN_PRESET_MAX) {
|
|
|
|
|
//
|
|
|
|
|
// save the settings
|
|
|
|
|
//
|
|
|
|
|
list<VideoDevCtrl> ctrls = videodev.GetCtrlsMinMaxValue();
|
|
|
|
|
config.SetPresetButton(presetbtn.idx, &ctrls);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// reset button label
|
|
|
|
|
//
|
|
|
|
|
for (idx = 0; idx < BTN_PRESET_MAX; idx++) {
|
|
|
|
|
s = "btn-video-pre"+std::to_string(idx+1);
|
|
|
|
|
if ((btn = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), s.c_str()))) != NULL) {
|
|
|
|
|
gtk_button_set_label(GTK_BUTTON(btn), std::to_string(idx+1).c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (presetbtn.idx >= 0 && presetbtn.idx < BTN_PRESET_MAX) {
|
|
|
|
|
//
|
|
|
|
|
// callup settings
|
|
|
|
|
//
|
|
|
|
|
int i, retry = 5, again = 1;
|
|
|
|
|
list<VideoDevCtrl> ctrls = config.GetPresetButton(presetbtn.idx);
|
|
|
|
|
list<VideoDevCtrl>::iterator iter;
|
|
|
|
|
presetbtn.idx = -1;
|
|
|
|
|
|
|
|
|
|
for (retry = 5; retry > 0 && again; retry--) {
|
|
|
|
|
again = 0;
|
|
|
|
|
for (iter = ctrls.begin(); iter != ctrls.end(); iter++) {
|
|
|
|
|
videodev.SetCtrlValue(iter->name, iter->value);
|
|
|
|
|
usleep(10000);
|
|
|
|
|
videodev.GetCtrlMinMaxValue(iter->name, NULL, NULL, &i);
|
|
|
|
|
if (i != iter->value) again = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* should determine the pressed button and save it together with the current
|
|
|
|
|
* time in structure presetbtn.
|
|
|
|
|
*/
|
|
|
|
|
void cb_video_pre_pressed (GtkWidget *widget, gpointer data) {
|
|
|
|
|
int idx = -1;
|
|
|
|
|
std::string s;
|
|
|
|
|
GtkWidget *btn;
|
|
|
|
|
|
|
|
|
|
for (idx = 0; idx < BTN_PRESET_MAX; idx++) {
|
|
|
|
|
s = "btn-video-pre"+std::to_string(idx+1);
|
|
|
|
|
if ((btn = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), s.c_str()))) == widget) {
|
|
|
|
|
if (presetbtn.timer <= 0)
|
|
|
|
|
presetbtn.timer = g_timeout_add((int)(BTNDOWN_TIME*1000.0), video_pre_long, NULL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
presetbtn.idx = idx;
|
|
|
|
|
gettimeofday (&presetbtn.tv, NULL);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* gnome timer callback if any presetbutton was pressed down
|
|
|
|
|
* in case the button is still pressed, we write SAVED in the buttons label.
|
|
|
|
|
*/
|
|
|
|
|
gboolean video_pre_long(gpointer data) {
|
|
|
|
|
std::string s = "btn-video-pre"+std::to_string(presetbtn.idx+1);
|
|
|
|
|
GtkWidget *btn = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), s.c_str()));
|
|
|
|
|
|
|
|
|
|
if (btn && presetbtn.idx >= 0 && presetbtn.idx < BTN_PRESET_MAX)
|
|
|
|
|
gtk_button_set_label(GTK_BUTTON(btn), "Saved");
|
|
|
|
|
|
|
|
|
|
presetbtn.timer = 0;
|
|
|
|
|
return FALSE;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|