#include <QFileDialog>
#include <QMessageBox>
#include <QMouseEvent>
+#include <QNetworkReply>
#include <QShortcut>
#include <QTimer>
#include <QWheelEvent>
global_mainwindow = this;
ui->setupUi(this);
- // Load settings from database if needed.
+ // Load settings from database.
+ SettingsProto settings = db.get_settings();
if (!global_flags.interpolation_quality_set) {
- SettingsProto settings = db.get_settings();
if (settings.interpolation_quality() != 0) {
global_flags.interpolation_quality = settings.interpolation_quality() - 1;
}
}
+ if (!global_flags.cue_point_padding_set) {
+ global_flags.cue_point_padding_seconds = settings.cue_point_padding_seconds(); // Default 0 is fine.
+ }
if (global_flags.interpolation_quality == 0) {
// Allocate something just for simplicity; we won't be using it
// unless the user changes runtime, in which case 1 is fine.
connect(ui->quality_3_action, &QAction::toggled, bind(&MainWindow::quality_toggled, this, 3, _1));
connect(ui->quality_4_action, &QAction::toggled, bind(&MainWindow::quality_toggled, this, 4, _1));
+ // The cue point padding group.
+ QActionGroup *padding_group = new QActionGroup(ui->interpolation_menu);
+ padding_group->addAction(ui->padding_0_action);
+ padding_group->addAction(ui->padding_1_action);
+ padding_group->addAction(ui->padding_2_action);
+ padding_group->addAction(ui->padding_5_action);
+ if (global_flags.cue_point_padding_seconds <= 1e-3) {
+ ui->padding_0_action->setChecked(true);
+ } else if (fabs(global_flags.cue_point_padding_seconds - 1.0) < 1e-3) {
+ ui->padding_1_action->setChecked(true);
+ } else if (fabs(global_flags.cue_point_padding_seconds - 2.0) < 1e-3) {
+ ui->padding_2_action->setChecked(true);
+ } else if (fabs(global_flags.cue_point_padding_seconds - 5.0) < 1e-3) {
+ ui->padding_5_action->setChecked(true);
+ } else {
+ // Nothing to check, which is fine.
+ }
+ connect(ui->padding_0_action, &QAction::toggled, bind(&MainWindow::padding_toggled, this, 0.0, _1));
+ connect(ui->padding_1_action, &QAction::toggled, bind(&MainWindow::padding_toggled, this, 1.0, _1));
+ connect(ui->padding_2_action, &QAction::toggled, bind(&MainWindow::padding_toggled, this, 2.0, _1));
+ connect(ui->padding_5_action, &QAction::toggled, bind(&MainWindow::padding_toggled, this, 5.0, _1));
+
global_disk_space_estimator = new DiskSpaceEstimator(bind(&MainWindow::report_disk_space, this, _1, _2));
disk_free_label = new QLabel(this);
disk_free_label->setStyleSheet("QLabel {padding-right: 5px;}");
this, &MainWindow::clip_list_selection_changed);
// Find out how many cameras we have in the existing frames;
- // if none, we start with a single camera.
- num_cameras = 1;
+ // if none, we start with two cameras.
+ num_cameras = 2;
{
lock_guard<mutex> lock(frame_mu);
- for (size_t stream_idx = 1; stream_idx < MAX_STREAMS; ++stream_idx) {
+ for (size_t stream_idx = 2; stream_idx < MAX_STREAMS; ++stream_idx) {
if (!frames[stream_idx].empty()) {
num_cameras = stream_idx + 1;
}
}
}
change_num_cameras();
+
+ if (!global_flags.tally_url.empty()) {
+ start_tally();
+ }
}
void MainWindow::change_num_cameras()
return;
}
Clip clip;
- clip.pts_in = current_pts;
+ clip.pts_in = max<int64_t>(current_pts - lrint(global_flags.cue_point_padding_seconds * TIMEBASE), 0);
cliplist_clips->add_clip(clip);
playlist_selection_changed();
ui->clip_list->scrollToBottom();
void MainWindow::cue_out_clicked()
{
if (!cliplist_clips->empty()) {
- cliplist_clips->mutable_back()->pts_out = current_pts;
+ cliplist_clips->mutable_back()->pts_out = current_pts + lrint(global_flags.cue_point_padding_seconds * TIMEBASE);
// TODO: select the row in the clip list?
}
}
{
SettingsProto settings;
settings.set_interpolation_quality(global_flags.interpolation_quality + 1);
+ settings.set_cue_point_padding_seconds(global_flags.cue_point_padding_seconds);
db.store_settings(settings);
}
save_settings();
}
+void MainWindow::padding_toggled(double seconds, bool checked)
+{
+ if (!checked) {
+ return;
+ }
+ global_flags.cue_point_padding_seconds = seconds;
+ save_settings();
+}
+
void MainWindow::highlight_camera_input(int stream_idx)
{
for (unsigned i = 0; i < num_cameras; ++i) {
- if (stream_idx == i) {
+ if (unsigned(stream_idx) == i) {
displays[i].frame->setStyleSheet("background: rgb(0,255,0)");
} else {
displays[i].frame->setStyleSheet("");
*model = new_model;
connect(new_model, &Model::any_content_changed, this, &MainWindow::content_changed);
}
+
+void MainWindow::start_tally()
+{
+ http_reply = http.get(QNetworkRequest(QString::fromStdString(global_flags.tally_url)));
+ connect(http_reply, &QNetworkReply::finished, this, &MainWindow::tally_received);
+}
+
+void MainWindow::tally_received()
+{
+ unsigned time_to_next_tally_ms;
+ if (http_reply->error()) {
+ fprintf(stderr, "HTTP get of '%s' failed: %s\n", global_flags.tally_url.c_str(),
+ http_reply->errorString().toStdString().c_str());
+ ui->live_frame->setStyleSheet("");
+ time_to_next_tally_ms = 1000;
+ } else {
+ string contents = http_reply->readAll().toStdString();
+ ui->live_frame->setStyleSheet(QString::fromStdString("background: " + contents));
+ time_to_next_tally_ms = 100;
+ }
+ http_reply->deleteLater();
+ http_reply = nullptr;
+
+ QTimer::singleShot(time_to_next_tally_ms, this, &MainWindow::start_tally);
+}