implement entire project in nodes
Project items are now represented directly in nodes opening up more versatility and possibilities. This is the first iteration of this and will be buggy. Need to test thoroughly.
This commit is contained in:
@@ -32,12 +32,6 @@ FootageViewerWidget::FootageViewerWidget(QWidget *parent) :
|
||||
ViewerWidget(parent),
|
||||
footage_(nullptr)
|
||||
{
|
||||
video_node_ = new MediaInput();
|
||||
video_node_->setParent(&sequence_);
|
||||
|
||||
audio_node_ = new MediaInput();
|
||||
audio_node_->setParent(&sequence_);
|
||||
|
||||
connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, &FootageViewerWidget::StartFootageDrag);
|
||||
|
||||
controls_->SetAudioVideoDragButtonsVisible(true);
|
||||
@@ -57,56 +51,25 @@ void FootageViewerWidget::SetFootage(Footage *footage)
|
||||
|
||||
ConnectViewerNode(nullptr);
|
||||
|
||||
video_node_->SetStream(nullptr);
|
||||
audio_node_->SetStream(nullptr);
|
||||
|
||||
Node::DisconnectEdge(video_node_, NodeInput(sequence_.viewer_output(), ViewerOutput::kTextureInput));
|
||||
Node::DisconnectEdge(audio_node_, NodeInput(sequence_.viewer_output(), ViewerOutput::kSamplesInput));
|
||||
Node::DisconnectEdge(sequence_.GetConnectedOutput(ViewerOutput::kTextureInput), NodeInput(&sequence_, ViewerOutput::kTextureInput));
|
||||
Node::DisconnectEdge(sequence_.GetConnectedOutput(ViewerOutput::kSamplesInput), NodeInput(&sequence_, ViewerOutput::kSamplesInput));
|
||||
}
|
||||
|
||||
footage_ = footage;
|
||||
|
||||
if (footage_) {
|
||||
// Update sequence media name
|
||||
sequence_.viewer_output()->SetLabel(footage_->name());
|
||||
sequence_.SetLabel(footage_->GetLabel());
|
||||
|
||||
// Reset parameters and then attempt to set from footage
|
||||
sequence_.set_default_parameters();
|
||||
sequence_.set_parameters_from_footage({footage_});
|
||||
|
||||
// Use first of each stream
|
||||
VideoStream* video_stream = nullptr;
|
||||
AudioStream* audio_stream = nullptr;
|
||||
// Try to connect video stream
|
||||
TryConnectingType(footage, Stream::kVideo);
|
||||
TryConnectingType(footage, Stream::kAudio);
|
||||
|
||||
foreach (Stream* s, footage_->streams()) {
|
||||
if (!s->enabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!audio_stream && s->type() == Stream::kAudio) {
|
||||
audio_stream = static_cast<AudioStream*>(s);
|
||||
}
|
||||
|
||||
if (!video_stream && s->type() == Stream::kVideo) {
|
||||
video_stream = static_cast<VideoStream*>(s);
|
||||
}
|
||||
|
||||
if (audio_stream && video_stream) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (video_stream) {
|
||||
video_node_->SetStream(video_stream);
|
||||
Node::ConnectEdge(video_node_, NodeInput(sequence_.viewer_output(), ViewerOutput::kTextureInput));
|
||||
}
|
||||
|
||||
if (audio_stream) {
|
||||
audio_node_->SetStream(audio_stream);
|
||||
Node::ConnectEdge(audio_node_, NodeInput(sequence_.viewer_output(), ViewerOutput::kSamplesInput));
|
||||
}
|
||||
|
||||
ConnectViewerNode(sequence_.viewer_output(), footage_->project()->color_manager());
|
||||
ConnectViewerNode(&sequence_, footage_->project()->color_manager());
|
||||
|
||||
SetTimestamp(cached_timestamps_.value(footage_, 0));
|
||||
} else {
|
||||
@@ -134,7 +97,7 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl
|
||||
QMimeData* mimedata = new QMimeData();
|
||||
|
||||
QByteArray encoded_data;
|
||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
||||
QDataStream data_stream(&encoded_data, QIODevice::WriteOnly);
|
||||
|
||||
quint64 enabled_stream_flags = GetFootage()->get_enabled_stream_flags();
|
||||
|
||||
@@ -142,9 +105,11 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl
|
||||
if (!enable_video || !enable_audio) {
|
||||
quint64 stream_disabler = 0x1;
|
||||
|
||||
foreach (Stream* s, GetFootage()->streams()) {
|
||||
if ((s->type() == Stream::kVideo && !enable_video)
|
||||
|| (s->type() == Stream::kAudio && !enable_audio)) {
|
||||
for (int i=0; i<GetFootage()->GetStreamCount(); i++) {
|
||||
Stream stream = GetFootage()->GetStreamAt(i);
|
||||
|
||||
if ((stream.type() == Stream::kVideo && !enable_video)
|
||||
|| (stream.type() == Stream::kAudio && !enable_audio)) {
|
||||
enabled_stream_flags &= ~stream_disabler;
|
||||
}
|
||||
|
||||
@@ -152,7 +117,7 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl
|
||||
}
|
||||
}
|
||||
|
||||
stream << enabled_stream_flags << -1 << reinterpret_cast<quintptr>(GetFootage());
|
||||
data_stream << enabled_stream_flags << -1 << reinterpret_cast<quintptr>(GetFootage());
|
||||
|
||||
mimedata->setData("application/x-oliveprojectitemdata", encoded_data);
|
||||
drag->setMimeData(mimedata);
|
||||
@@ -160,6 +125,32 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enabl
|
||||
drag->exec();
|
||||
}
|
||||
|
||||
void FootageViewerWidget::TryConnectingType(Footage *footage, Stream::Type type)
|
||||
{
|
||||
for (int i=0; ; i++) {
|
||||
Stream stream = footage_->GetStreamAt(type, i);
|
||||
|
||||
// Found end of stream list
|
||||
if (!stream.IsValid()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (stream.enabled()) {
|
||||
QString s = Footage::GetStringFromReference(type, i);
|
||||
|
||||
QString input_param;
|
||||
|
||||
if (type == Stream::kVideo) {
|
||||
input_param = ViewerOutput::kTextureInput;
|
||||
} else {
|
||||
input_param = ViewerOutput::kSamplesInput;
|
||||
}
|
||||
|
||||
Node::ConnectEdge(NodeOutput(footage, s), NodeInput(&sequence_, input_param));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FootageViewerWidget::StartFootageDrag()
|
||||
{
|
||||
StartFootageDragInternal(true, true);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#ifndef FOOTAGEVIEWERWIDGET_H
|
||||
#define FOOTAGEVIEWERWIDGET_H
|
||||
|
||||
#include "node/input/media/media.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
#include "viewer.h"
|
||||
|
||||
@@ -44,14 +43,12 @@ protected:
|
||||
private:
|
||||
void StartFootageDragInternal(bool enable_video, bool enable_audio);
|
||||
|
||||
void TryConnectingType(Footage* footage, Stream::Type type);
|
||||
|
||||
Footage* footage_;
|
||||
|
||||
Sequence sequence_;
|
||||
|
||||
MediaInput* video_node_;
|
||||
|
||||
MediaInput* audio_node_;
|
||||
|
||||
QHash<Footage*, int64_t> cached_timestamps_;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
QVariant GizmoTraverser::ProcessVideoFootage(VideoStream *stream, const rational &input_time)
|
||||
QVariant GizmoTraverser::ProcessVideoFootage(const Footage::StreamReference &ref, const rational &input_time)
|
||||
{
|
||||
Q_UNUSED(input_time)
|
||||
|
||||
VideoStream* image_stream = static_cast<VideoStream*>(stream);
|
||||
Stream stream = ref.GetStream();
|
||||
|
||||
return QVector2D(image_stream->width() * image_stream->pixel_aspect_ratio().toDouble(),
|
||||
image_stream->height());
|
||||
return QVector2D(stream.width() * stream.pixel_aspect_ratio().toDouble(),
|
||||
stream.height());
|
||||
}
|
||||
|
||||
QVariant GizmoTraverser::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job)
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual QVariant ProcessVideoFootage(VideoStream* stream, const rational &input_time) override;
|
||||
virtual QVariant ProcessVideoFootage(const Footage::StreamReference& stream, const rational &input_time) override;
|
||||
|
||||
virtual QVariant ProcessShader(const Node *node, const TimeRange &range, const ShaderJob& job) override;
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ void ViewerWidget::TimeChangedEvent(const int64_t &i)
|
||||
last_time_ = i;
|
||||
}
|
||||
|
||||
void ViewerWidget::ConnectNodeInternal(ViewerOutput *n)
|
||||
void ViewerWidget::ConnectNodeInternal(Sequence *n)
|
||||
{
|
||||
connect(n, &ViewerOutput::SizeChanged, this, &ViewerWidget::SetViewerResolution);
|
||||
connect(n, &ViewerOutput::PixelAspectChanged, this, &ViewerWidget::SetViewerPixelAspect);
|
||||
@@ -193,7 +193,7 @@ void ViewerWidget::ConnectNodeInternal(ViewerOutput *n)
|
||||
if (override_color_manager_) {
|
||||
using_manager = override_color_manager_;
|
||||
} else if (n->parent()) {
|
||||
using_manager = static_cast<Sequence*>(n->parent())->project()->color_manager();
|
||||
using_manager = n->project()->color_manager();
|
||||
} else {
|
||||
qWarning() << "Failed to find a suitable color manager for the connected viewer node";
|
||||
using_manager = nullptr;
|
||||
@@ -220,7 +220,7 @@ void ViewerWidget::ConnectNodeInternal(ViewerOutput *n)
|
||||
ForceUpdate();
|
||||
}
|
||||
|
||||
void ViewerWidget::DisconnectNodeInternal(ViewerOutput *n)
|
||||
void ViewerWidget::DisconnectNodeInternal(Sequence *n)
|
||||
{
|
||||
PauseInternal();
|
||||
|
||||
@@ -252,7 +252,7 @@ void ViewerWidget::DisconnectNodeInternal(ViewerOutput *n)
|
||||
QMetaObject::invokeMethod(this, "UpdateStack", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void ViewerWidget::ConnectedNodeChanged(ViewerOutput *n)
|
||||
void ViewerWidget::ConnectedNodeChanged(Sequence *n)
|
||||
{
|
||||
auto_cacher_.SetViewerNode(n);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ bool ViewerWidget::IsPlaying() const
|
||||
return playback_speed_ != 0;
|
||||
}
|
||||
|
||||
void ViewerWidget::ConnectViewerNode(ViewerOutput *node, ColorManager* color_manager)
|
||||
void ViewerWidget::ConnectViewerNode(Sequence *node, ColorManager* color_manager)
|
||||
{
|
||||
override_color_manager_ = color_manager;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
bool IsPlaying() const;
|
||||
|
||||
void ConnectViewerNode(ViewerOutput* node, ColorManager *color_manager = nullptr);
|
||||
void ConnectViewerNode(Sequence *node, ColorManager *color_manager = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the color management menu
|
||||
@@ -153,9 +153,9 @@ protected:
|
||||
virtual void TimebaseChangedEvent(const rational &) override;
|
||||
virtual void TimeChangedEvent(const int64_t &) override;
|
||||
|
||||
virtual void ConnectNodeInternal(ViewerOutput *) override;
|
||||
virtual void DisconnectNodeInternal(ViewerOutput *) override;
|
||||
virtual void ConnectedNodeChanged(ViewerOutput*n) override;
|
||||
virtual void ConnectNodeInternal(Sequence *) override;
|
||||
virtual void DisconnectNodeInternal(Sequence *) override;
|
||||
virtual void ConnectedNodeChanged(Sequence*n) override;
|
||||
|
||||
virtual void ScaleChangedEvent(const double& s) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user