emit any_content_changed();
}
-void PlayList::set_currently_playing(int index, double progress)
-{
- int old_index = currently_playing_index;
- int column = int(Column::PLAYING);
- if (index != old_index) {
- currently_playing_index = index;
- play_progress = progress;
- if (old_index != -1) {
- emit dataChanged(this->index(old_index, column), this->index(old_index, column));
- }
- if (index != -1) {
- emit dataChanged(this->index(index, column), this->index(index, column));
- }
- } else if (index != -1 && fabs(progress - play_progress) > 1e-3) {
- play_progress = progress;
- emit dataChanged(this->index(index, column), this->index(index, column));
- }
-}
-
void PlayList::set_progress(const map<size_t, double> &progress)
{
const int column = int(Column::PLAYING);
ClipProxy mutable_back() { return mutable_clip(size() - 1); }
const Clip *back() const { return clip(size() - 1); }
- // TODO: Move these out of PlayList.
- void set_currently_playing(int index, double progress); // -1 = none.
- int get_currently_playing() const { return currently_playing_index; }
-
void set_progress(const std::map<size_t, double> &progress);
ClipListProto serialize() const;
private:
std::vector<Clip> clips;
- int currently_playing_index = -1;
double play_progress = 0.0;
std::map<size_t, double> current_progress;
size_t num_cameras = 2;
promise<void> done_promise;
future<void> done = done_promise.get_future();
std::atomic<double> current_value{ 0.0 };
- size_t clip_idx = 0;
Player player(/*destination=*/nullptr, Player::FILE_STREAM_OUTPUT, closer.release());
- player.set_done_callback([&done_promise, &clip_idx, &clips] {
- if (clip_idx >= clips.size()) {
- done_promise.set_value();
- }
+ player.set_done_callback([&done_promise] {
+ done_promise.set_value();
});
player.set_progress_callback([¤t_value, &clips, total_length](const std::map<size_t, double> &player_progress, double time_remaining) {
current_value = 1.0 - time_remaining / total_length;
live_player.reset(new Player(ui->live_display, Player::HTTPD_STREAM_OUTPUT));
live_player->set_done_callback([this] {
post_to_main_thread([this] {
- live_player_clip_done();
+ live_player_done();
});
});
live_player->set_progress_callback([this](const map<size_t, double> &progress, double time_remaining) {
}
live_player->play(clips);
playlist_clips->set_progress({ { start_row, 0.0f } });
- playlist_clips->set_currently_playing(start_row, 0.0f);
playlist_selection_changed();
ui->stop_btn->setEnabled(true);
Clip fake_clip;
fake_clip.pts_in = 0;
fake_clip.pts_out = 0;
- size_t last_row = playlist_clips->size() - 1;
- playlist_clips->set_currently_playing(last_row, 0.0f);
live_player->play(fake_clip);
}
-void MainWindow::live_player_clip_done()
+void MainWindow::live_player_done()
{
- int row = playlist_clips->get_currently_playing();
- if (row == -1 || row == int(playlist_clips->size()) - 1) {
- set_output_status("paused");
- playlist_clips->set_progress({});
- playlist_clips->set_currently_playing(-1, 0.0f);
- ui->stop_btn->setEnabled(false);
- } else {
- playlist_clips->set_progress({ { row + 1, 0.0f } });
- playlist_clips->set_currently_playing(row + 1, 0.0f);
- }
+ set_output_status("paused");
+ playlist_clips->set_progress({});
+ ui->stop_btn->setEnabled(false);
}
static string format_duration(double t)
void preview_angle_clicked(unsigned stream_idx);
void play_clicked();
void stop_clicked();
- void live_player_clip_done();
+ void live_player_done();
void live_player_clip_progress(const std::map<size_t, double> &progress, double time_remaining);
void set_output_status(const std::string &status);
void playlist_duplicate();
while (!should_quit) {
play_playlist_once();
+ if (done_callback != nullptr) {
+ done_callback();
+ }
}
}
if (should_quit) {
return;
}
- if (done_callback != nullptr) {
- done_callback();
- }
// Start the next clip from the point where the fade went out.
if (next_clip != nullptr) {
in_pts_origin = next_clip->pts_in + lrint(next_clip_fade_time * TIMEBASE * clip.speed);
}
}
-
- if (done_callback != nullptr) {
- done_callback();
- }
}
void Player::display_single_frame(int primary_stream_idx, const FrameOnDisk &primary_frame, int secondary_stream_idx, const FrameOnDisk &secondary_frame, double fade_alpha, steady_clock::time_point frame_start, bool snapped)