This is a natural step on the way to fade support.
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; }
live_player_clip_done();
});
});
+ live_player->set_next_clip_callback(bind(&MainWindow::live_player_get_next_clip, this));
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::live_player_clip_done()
{
+ int row = playlist_clips->get_currently_playing();
+ if (row == -1 || row == int(playlist_clips->size()) - 1) {
+ ui->live_label->setText("Current output (paused)");
+ playlist_clips->set_currently_playing(-1, 0.0f);
+ } else {
+ playlist_clips->set_currently_playing(row + 1, 0.0f);
+ }
+}
+
+Clip MainWindow::live_player_get_next_clip()
+{
+ // FIXME: threading
int row = playlist_clips->get_currently_playing();
if (row != -1 && row < int(playlist_clips->size()) - 1) {
- ++row;
- const Clip &clip = *playlist_clips->clip(row);
- live_player->play_clip(clip, clip.stream_idx);
- playlist_clips->set_currently_playing(row, 0.0f);
+ return *playlist_clips->clip(row + 1);
} else {
- playlist_clips->set_currently_playing(-1, 0.0f);
- ui->live_label->setText("Current output (paused)");
+ return Clip();
}
}
#include <QLabel>
#include <QMainWindow>
+#include "clip_list.h"
#include "db.h"
#include "state.pb.h"
void preview_angle_clicked(unsigned stream_idx);
void play_clicked();
void live_player_clip_done();
+ Clip live_player_get_next_clip();
void live_player_clip_progress(double played_this_clip, double total_length);
void playlist_duplicate();
void playlist_remove();
clip = current_clip;
stream_idx = current_stream_idx;
}
+got_clip:
steady_clock::time_point origin = steady_clock::now();
int64_t in_pts_origin = clip.pts_in;
int64_t out_pts_origin = pts;
}
}
+ if (next_clip_callback != nullptr) {
+ Clip next_clip = next_clip_callback();
+ if (next_clip.pts_in != -1) {
+ clip = next_clip;
+ stream_idx = next_clip.stream_idx; // Override is used for previews only, and next_clip is used for live ony.
+ if (done_callback != nullptr) {
+ done_callback();
+ }
+ goto got_clip;
+ }
+ }
+
{
unique_lock<mutex> lock(queue_state_mu);
playing = false;
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 next_clip_callback_func = std::function<Clip()>;
+ void set_next_clip_callback(next_clip_callback_func cb) { next_clip_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)>;
JPEGFrameView *destination;
done_callback_func done_callback;
+ next_clip_callback_func next_clip_callback;
progress_callback_func progress_callback;
std::mutex mu;