various: moved time from viewer UI to viewer node

This commit is contained in:
itsmattkc
2022-10-23 20:56:04 -07:00
parent fc56058e8a
commit d1545745d8
47 changed files with 259 additions and 418 deletions
+24 -22
View File
@@ -113,7 +113,7 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) :
// Create waveform view when audio is connected and video isn't
waveform_view_ = new AudioWaveformView();
ConnectTimelineView(waveform_view_, true);
ConnectTimelineView(waveform_view_);
PassWheelEventsToScrollBar(waveform_view_);
layout->addWidget(waveform_view_);
@@ -135,7 +135,6 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) :
connect(controls_, &PlaybackControls::NextFrameClicked, this, &ViewerWidget::NextFrame);
connect(controls_, &PlaybackControls::BeginClicked, this, &ViewerWidget::GoToStart);
connect(controls_, &PlaybackControls::EndClicked, this, &ViewerWidget::GoToEnd);
connect(controls_, &PlaybackControls::TimeChanged, this, &ViewerWidget::SetTimeAndSignal);
layout->addWidget(controls_);
// FIXME: Magic number
@@ -182,7 +181,6 @@ void ViewerWidget::TimeChangedEvent(const rational &time)
}
controls_->SetTime(time);
waveform_view_->SetTime(time);
if (GetConnectedNode() && last_time_ != time) {
if (!IsPlaying()) {
@@ -216,6 +214,8 @@ void ViewerWidget::ConnectNodeEvent(ViewerOutput *n)
connect(n->video_frame_cache(), &FrameHashCache::Invalidated, this, &ViewerWidget::ViewerInvalidatedVideoRange);
connect(n, &ViewerOutput::TextureInputChanged, this, &ViewerWidget::UpdateWaveformViewFromMode);
connect(controls_, &PlaybackControls::TimeChanged, n, &ViewerOutput::SetPlayhead);
VideoParams vp = n->GetVideoParams();
InterlacingChangedSlot(vp.interlacing());
@@ -260,6 +260,8 @@ void ViewerWidget::DisconnectNodeEvent(ViewerOutput *n)
disconnect(n->video_frame_cache(), &FrameHashCache::Invalidated, this, &ViewerWidget::ViewerInvalidatedVideoRange);
disconnect(n, &ViewerOutput::TextureInputChanged, this, &ViewerWidget::UpdateWaveformViewFromMode);
disconnect(controls_, &PlaybackControls::TimeChanged, n, &ViewerOutput::SetPlayhead);
timeline_selected_blocks_.clear();
node_view_selected_.clear();
if (multicam_panel_) {
@@ -417,7 +419,7 @@ void ViewerWidget::SetGizmos(Node *node)
void ViewerWidget::StartCapture(TimelineWidget *source, const TimeRange &time, const Track::Reference &track)
{
SetTimeAndSignal(time.in());
GetConnectedNode()->SetPlayhead(time.in());
ArmForRecording();
recording_callback_ = source;
@@ -480,7 +482,7 @@ void ViewerWidget::SetEmptyImage()
void ViewerWidget::UpdateAutoCacher()
{
auto_cacher_->SetPlayhead(GetTime());
auto_cacher_->SetPlayhead(GetConnectedNode()->GetPlayhead());
}
void ViewerWidget::DecrementPrequeuedAudio()
@@ -523,7 +525,7 @@ void ViewerWidget::CreateAddableAt(const QRectF &f)
Track::Type type = Track::kVideo;
int track_index = -1;
TrackList *list = s->track_list(type);
const rational &in = GetTime();
const rational &in = GetConnectedNode()->GetPlayhead();
rational length = OLIVE_CONFIG("DefaultStillLength").value<rational>();
rational out = in + length;
@@ -597,7 +599,7 @@ void ViewerWidget::RequestNextDryRun()
if (IsPlaying()) {
rational next_time = Timecode::timestamp_to_time(dry_run_next_frame_, timebase());
if (FrameExistsAtTime(next_time)) {
if (next_time > GetTime() + RenderManager::kDryRunInterval) {
if (next_time > GetConnectedNode()->GetPlayhead() + RenderManager::kDryRunInterval) {
QTimer::singleShot(timebase().toDouble() / playback_speed_, this, &ViewerWidget::RequestNextDryRun);
} else {
RenderTicketWatcher *watcher = new RenderTicketWatcher(this);
@@ -612,12 +614,12 @@ void ViewerWidget::RequestNextDryRun()
void ViewerWidget::SaveFrameAsImage()
{
Core::instance()->OpenExportDialogForViewer(GetConnectedNode(), GetTime(), true);
Core::instance()->OpenExportDialogForViewer(GetConnectedNode(), true);
}
void ViewerWidget::DetectMulticamNodeNow()
{
DetectMulticamNode(GetTime());
DetectMulticamNode(GetConnectedNode()->GetPlayhead());
}
void ViewerWidget::CloseAudioProcessor()
@@ -828,7 +830,7 @@ void ViewerWidget::QueueStarved()
queue_starved_start_ = now;
} else if (now > queue_starved_start_ + kMaximumWaitTimeMs) {
if (first_requeue_watcher_) {
if (GetTime() + kMaximumWaitTime < first_requeue_watcher_->property("time").value<rational>()) {
if (GetConnectedNode()->GetPlayhead() + kMaximumWaitTime < first_requeue_watcher_->property("time").value<rational>()) {
// We still have time
return;
}
@@ -874,7 +876,7 @@ void ViewerWidget::UpdateTextureFromNode()
return;
}
rational time = GetTime();
rational time = GetConnectedNode()->GetPlayhead();
bool frame_exists_at_time = FrameExistsAtTime(time);
bool frame_might_be_still = ViewerMightBeAStill();
@@ -933,11 +935,11 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
// If the playhead is beyond the end, restart at 0
if (!recording_) {
rational last_frame = GetConnectedNode()->GetLength() - timebase();
if (!in_to_out_only && GetTime() >= last_frame) {
if (!in_to_out_only && GetConnectedNode()->GetPlayhead() >= last_frame) {
if (speed > 0) {
SetTimeAndSignal(0);
GetConnectedNode()->SetPlayhead(0);
} else {
SetTimeAndSignal(last_frame);
GetConnectedNode()->SetPlayhead(last_frame);
}
}
}
@@ -977,7 +979,7 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
static const int prequeue_count = 2;
prequeuing_audio_ = prequeue_count; // Queue two buffers ahead of time
audio_playback_queue_time_ = GetTime();
audio_playback_queue_time_ = GetConnectedNode()->GetPlayhead();
for (int i=0; i<prequeue_count; i++) {
QueueNextAudioBuffer();
}
@@ -1056,7 +1058,7 @@ void ViewerWidget::PushScrubbedAudio()
RenderTicketWatcher *watcher = new RenderTicketWatcher();
connect(watcher, &RenderTicketWatcher::Finished, this, &ViewerWidget::ReceivedAudioBufferForScrubbing);
audio_scrub_watchers_.push_back(watcher);
watcher->SetTicket(auto_cacher_->GetRangeOfAudio(TimeRange(GetTime(), GetTime() + interval)));
watcher->SetTicket(auto_cacher_->GetRangeOfAudio(TimeRange(GetConnectedNode()->GetPlayhead(), GetConnectedNode()->GetPlayhead() + interval)));
}
}
}
@@ -1173,7 +1175,7 @@ void ViewerWidget::FinishPlayPreprocess()
prequeued_audio_.clear();
AudioMonitor::StartWaveformOnAll(GetConnectedNode()->GetConnectedWaveform(),
GetTime(), playback_speed_);
GetConnectedNode()->GetPlayhead(), playback_speed_);
}
display_widget_->ResetFPSTimer();
@@ -1522,7 +1524,7 @@ void ViewerWidget::Play(bool in_to_out_only)
if (GetConnectedNode()
&& GetConnectedNode()->GetWorkArea()->enabled()) {
// Jump to in point
SetTimeAndSignal(GetConnectedNode()->GetWorkArea()->in());
GetConnectedNode()->SetPlayhead(GetConnectedNode()->GetWorkArea()->in());
} else {
in_to_out_only = false;
}
@@ -1632,7 +1634,7 @@ void ViewerWidget::TimebaseChangedEvent(const rational &timebase)
controls_->SetTimebase(timebase);
controls_->SetTime(ruler()->GetTime());
controls_->SetTime(GetConnectedNode() ? GetConnectedNode()->GetPlayhead() : 0);
LengthChangedSlot(GetConnectedNode() ? GetConnectedNode()->GetLength() : 0);
}
@@ -1717,7 +1719,7 @@ void ViewerWidget::PlaybackTimerUpdate()
// pausing. Even if we pause it later with `end_of_line`, we prefer pausing after setting the time
// so that an audio scrub event, etc. isn't sent.
time_changed_from_timer_ = true;
SetTimeAndSignal(time_to_set);
GetConnectedNode()->SetPlayhead(time_to_set);
time_changed_from_timer_ = false;
if (end_of_line) {
// Cache the current speed
@@ -1767,7 +1769,7 @@ void ViewerWidget::LengthChangedSlot(const rational &length)
controls_->SetEndTime(length);
UpdateMinimumScale();
if (length < last_length_ && GetTime() >= length) {
if (GetConnectedNode() && length < last_length_ && GetConnectedNode()->GetPlayhead() >= length) {
UpdateTextureFromNode();
}
@@ -1813,7 +1815,7 @@ void ViewerWidget::SetZoomFromMenu(QAction *action)
void ViewerWidget::ViewerInvalidatedVideoRange(const TimeRange &range)
{
// If our current frame is within this range, we need to update
if (!IsPlaying() && GetTime() >= range.in() && (GetTime() < range.out() || range.in() == range.out())) {
if (!IsPlaying() && GetConnectedNode()->GetPlayhead() >= range.in() && (GetConnectedNode()->GetPlayhead() < range.out() || range.in() == range.out())) {
QMetaObject::invokeMethod(this, &ViewerWidget::UpdateTextureFromNode, Qt::QueuedConnection);
}
}