#include "clip_list.h"
#include "player.h"
#include "post_to_main_thread.h"
+#include "timebase.h"
#include "ui_mainwindow.h"
#include <string>
live_player_clip_done();
});
});
+ live_player->set_progress_callback([this](double played_this_clip, double total_length) {
+ post_to_main_thread([this, played_this_clip, total_length] {
+ live_player_clip_progress(played_this_clip, total_length);
+ });
+ });
}
void MainWindow::cue_in_clicked()
playlist_clips->set_currently_playing(row);
} else {
playlist_clips->set_currently_playing(-1);
+ ui->live_label->setText("Current output (paused)");
+ }
+}
+
+void MainWindow::live_player_clip_progress(double played_this_clip, double total_length)
+{
+ double remaining = total_length - played_this_clip;
+ for (int row = playlist_clips->get_currently_playing() + 1; row < int(playlist_clips->size()); ++row) {
+ const Clip clip = *playlist_clips->clip(row);
+ remaining += double(clip.pts_out - clip.pts_in) / TIMEBASE / 0.5; // FIXME: stop hardcoding speed.
}
+ int remaining_ms = lrint(remaining * 1e3);
+
+ int ms = remaining_ms % 1000;
+ remaining_ms /= 1000;
+ int s = remaining_ms % 60;
+ remaining_ms /= 60;
+ int m = remaining_ms;
+
+ char buf[256];
+ snprintf(buf, sizeof(buf), "Current output (%d:%02d.%03d left)", m, s, ms);
+ ui->live_label->setText(buf);
}
void MainWindow::resizeEvent(QResizeEvent *event)
void preview_angle_clicked(unsigned stream_idx);
void play_clicked();
void live_player_clip_done();
+ void live_player_clip_progress(double played_this_clip, double total_length);
void playlist_duplicate();
void playlist_remove();
void playlist_move(int delta);
}
}
+ if (progress_callback != nullptr) {
+ // NOTE: None of this will take into account any snapping done below.
+ double played_this_clip = double(in_pts - clip.pts_in) / TIMEBASE / speed;
+ double total_length = double(clip.pts_out - clip.pts_in) / TIMEBASE / speed;
+ progress_callback(played_this_clip, total_length);
+ }
+
if (in_pts_lower == in_pts_upper) {
destination->setFrame(stream_idx, in_pts_lower, /*interpolated=*/false);
if (video_stream != nullptr) {
using done_callback_func = std::function<void()>;
void set_done_callback(done_callback_func cb) { done_callback = cb; }
+ // Not thread-safe to set concurrently with playing.
+ // Will be called back from the player thread.
+ using progress_callback_func = std::function<void(double played_this_clip, double total_length)>;
+ void set_progress_callback(progress_callback_func cb) { progress_callback = cb; }
+
private:
void thread_func(bool also_output_to_stream);
void open_output_stream();
JPEGFrameView *destination;
done_callback_func done_callback;
+ progress_callback_func progress_callback;
std::mutex mu;
Clip current_clip; // Under mu. Can have pts_in = -1 for no clip.
<widget class="JPEGFrameView" name="live_display" native="true"/>
</item>
<item>
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="live_label">
<property name="text">
- <string>Current output</string>
+ <string>Current output (paused)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>