merged video and audio nodes into a single media node

They performed exactly the same function so I don't think we need the clutter.

Also bumped the project version, but old projects are automatically converted.
This commit is contained in:
itsmattkc
2020-11-18 13:48:14 +11:00
parent aeb7bc02b6
commit b3c3fe0fc8
28 changed files with 62 additions and 306 deletions
+1 -1
View File
@@ -71,7 +71,7 @@
namespace olive {
Core* Core::instance_ = nullptr;
const uint Core::kProjectVersion = 201003;
const uint Core::kProjectVersion = 201118;
Core::Core(const CoreParams& params) :
main_window_(nullptr),
+3 -6
View File
@@ -32,8 +32,7 @@
#include "generator/text/text.h"
#include "filter/blur/blur.h"
#include "filter/stroke/stroke.h"
#include "input/media/video/video.h"
#include "input/media/audio/audio.h"
#include "input/media/media.h"
#include "input/time/timeinput.h"
#include "math/math/math.h"
#include "math/merge/merge.h"
@@ -183,10 +182,8 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
return new PolygonGenerator();
case kMatrixGenerator:
return new MatrixGenerator();
case kVideoInput:
return new VideoInput();
case kAudioInput:
return new AudioInput();
case kFootageInput:
return new MediaInput();
case kTrackOutput:
return new TrackOutput();
case kViewerOutput:
+1 -2
View File
@@ -35,10 +35,9 @@ public:
kViewerOutput,
kClipBlock,
kGapBlock,
kAudioInput,
kPolygonGenerator,
kMatrixGenerator,
kVideoInput,
kFootageInput,
kTrackOutput,
kAudioVolume,
kAudioPanning,
-3
View File
@@ -14,9 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(audio)
add_subdirectory(video)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/input/media/media.h
-22
View File
@@ -1,22 +0,0 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2020 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/input/media/audio/audio.h
node/input/media/audio/audio.cpp
PARENT_SCOPE
)
-55
View File
@@ -1,55 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2020 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "audio.h"
namespace olive {
Node *AudioInput::copy() const
{
return new AudioInput();
}
Stream::Type AudioInput::type() const
{
return Stream::kAudio;
}
QString AudioInput::Name() const
{
return tr("Audio Input");
}
QString AudioInput::ShortName() const
{
return tr("Audio");
}
QString AudioInput::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.audioinput");
}
QString AudioInput::Description() const
{
return tr("Import an audio footage stream.");
}
}
-47
View File
@@ -1,47 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2020 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef AUDIOINPUT_H
#define AUDIOINPUT_H
#include "../media.h"
namespace olive {
class AudioInput : public MediaInput
{
Q_OBJECT
public:
AudioInput() = default;
virtual Node* copy() const override;
virtual Stream::Type type() const override;
virtual QString Name() const override;
virtual QString ShortName() const override;
virtual QString id() const override;
virtual QString Description() const override;
};
}
#endif // AUDIOINPUT_H
+1 -1
View File
@@ -57,7 +57,7 @@ bool MediaInput::IsMedia() const
void MediaInput::Retranslate()
{
footage_input_->set_name(tr("Footage"));
footage_input_->set_name(tr("Media"));
}
NodeValueTable MediaInput::Value(NodeValueDatabase &value) const
+19 -2
View File
@@ -36,7 +36,25 @@ class MediaInput : public Node
public:
MediaInput();
virtual Stream::Type type() const = 0;
virtual QString Name() const override
{
return tr("Media");
}
virtual QString id() const override
{
return QStringLiteral("org.olivevideoeditor.Olive.mediainput");
}
virtual QString Description() const override
{
return tr("Import footage into the node graph.");
}
virtual Node* copy() const override
{
return new MediaInput();
}
virtual QVector<CategoryID> Category() const override;
@@ -45,7 +63,6 @@ public:
virtual bool IsMedia() const override;
virtual void Retranslate() override;
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
-22
View File
@@ -1,22 +0,0 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2020 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/input/media/video/video.h
node/input/media/video/video.cpp
PARENT_SCOPE
)
-63
View File
@@ -1,63 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2020 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "video.h"
#include <QDebug>
#include <QMatrix4x4>
#include <QOpenGLPixelTransferOptions>
#include "codec/ffmpeg/ffmpegdecoder.h"
#include "core.h"
#include "project/item/footage/footage.h"
namespace olive {
Node *VideoInput::copy() const
{
return new VideoInput();
}
Stream::Type VideoInput::type() const
{
return Stream::kVideo;
}
QString VideoInput::Name() const
{
return tr("Video Input");
}
QString VideoInput::ShortName() const
{
return tr("Video");
}
QString VideoInput::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.videoinput");
}
QString VideoInput::Description() const
{
return tr("Import a video footage stream.");
}
}
-50
View File
@@ -1,50 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2020 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef VIDEOINPUT_H
#define VIDEOINPUT_H
#include <QOpenGLTexture>
#include "../media.h"
#include "render/colormanager.h"
namespace olive {
class VideoInput : public MediaInput
{
Q_OBJECT
public:
VideoInput() = default;
virtual Node* copy() const override;
virtual Stream::Type type() const override;
virtual QString Name() const override;
virtual QString ShortName() const override;
virtual QString id() const override;
virtual QString Description() const override;
};
}
#endif // VIDEOINPUT_H
+2 -2
View File
@@ -42,7 +42,7 @@ QIcon Folder::icon()
return icon::Folder;
}
void Folder::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const QAtomicInt *cancelled)
void Folder::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, uint version, const QAtomicInt *cancelled)
{
XMLAttributeLoop(reader, attr) {
if (cancelled && *cancelled) {
@@ -75,7 +75,7 @@ void Folder::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const QA
}
add_child(child);
child->Load(reader, xml_node_data, cancelled);
child->Load(reader, xml_node_data, version, cancelled);
}
}
+1 -1
View File
@@ -44,7 +44,7 @@ public:
virtual QIcon icon() override;
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled) override;
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, uint version, const QAtomicInt *cancelled) override;
virtual void Save(QXmlStreamWriter* writer) const override;
+1 -1
View File
@@ -42,7 +42,7 @@ Footage::~Footage()
ClearStreams();
}
void Footage::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const QAtomicInt* cancelled)
void Footage::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, uint version, const QAtomicInt* cancelled)
{
while (XMLReadNextStartElement(reader)) {
if (cancelled && *cancelled) {
+1 -1
View File
@@ -60,7 +60,7 @@ public:
/**
* @brief Load function
*/
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled) override;
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, uint version, const QAtomicInt *cancelled) override;
/**
* @brief Save function
+1 -1
View File
@@ -67,7 +67,7 @@ public:
DISABLE_COPY_MOVE(Item)
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled) = 0;
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, uint version, const QAtomicInt *cancelled) = 0;
virtual void Save(QXmlStreamWriter* writer) const = 0;
+11 -2
View File
@@ -45,7 +45,7 @@ Sequence::Sequence()
AddNode(viewer_output_);
}
void Sequence::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const QAtomicInt *cancelled)
void Sequence::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, uint version, const QAtomicInt *cancelled)
{
{
XMLAttributeLoop(reader, attr) {
@@ -130,7 +130,16 @@ void Sequence::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const
{
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
node = NodeFactory::CreateFromID(attr.value().toString());
QString id = attr.value().toString();
if (version <= 201003) {
// After version 201003, the video and audio nodes were merged into one media node
if (id == QStringLiteral("org.olivevideoeditor.Olive.audioinput")
|| id == QStringLiteral("org.olivevideoeditor.Olive.videoinput")) {
id = QStringLiteral("org.olivevideoeditor.Olive.mediainput");
}
}
node = NodeFactory::CreateFromID(id);
break;
}
}
+1 -1
View File
@@ -45,7 +45,7 @@ public:
/**
* @brief Load function
*/
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, const QAtomicInt* cancelled) override;
virtual void Load(QXmlStreamReader* reader, XMLNodeData &xml_node_data, uint version, const QAtomicInt* cancelled) override;
/**
* @brief Save function
+2 -2
View File
@@ -43,14 +43,14 @@ Project::Project() :
this, &Project::DefaultColorSpaceChanged);
}
void Project::Load(QXmlStreamReader *reader, MainWindowLayoutInfo* layout, const QAtomicInt* cancelled)
void Project::Load(QXmlStreamReader *reader, MainWindowLayoutInfo* layout, uint version, const QAtomicInt* cancelled)
{
XMLNodeData xml_node_data;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("root")) {
root_.Load(reader, xml_node_data, cancelled);
root_.Load(reader, xml_node_data, version, cancelled);
} else if (reader->name() == QStringLiteral("colormanagement")) {
+1 -1
View File
@@ -47,7 +47,7 @@ class Project : public QObject
public:
Project();
void Load(QXmlStreamReader* reader, MainWindowLayoutInfo *layout, const QAtomicInt* cancelled);
void Load(QXmlStreamReader* reader, MainWindowLayoutInfo *layout, uint version, const QAtomicInt* cancelled);
void Save(QXmlStreamWriter* writer) const;
+1 -1
View File
@@ -31,7 +31,7 @@ PreCacheTask::PreCacheTask(VideoStreamPtr footage, Sequence* sequence) :
viewer()->set_video_params(sequence->video_params());
viewer()->set_audio_params(sequence->audio_params());
video_node_ = new VideoInput();
video_node_ = new MediaInput();
video_node_->SetStream(footage);
NodeParam::ConnectEdge(video_node_->output(), viewer()->texture_input());
+2 -2
View File
@@ -21,7 +21,7 @@
#ifndef PRECACHETASK_H
#define PRECACHETASK_H
#include "node/input/media/video/video.h"
#include "node/input/media/media.h"
#include "project/item/footage/footage.h"
#include "project/item/sequence/sequence.h"
#include "task/render/render.h"
@@ -46,7 +46,7 @@ protected:
private:
VideoStreamPtr footage_;
VideoInput* video_node_;
MediaInput* video_node_;
};
+3 -2
View File
@@ -37,6 +37,7 @@ ProjectLoadTask::ProjectLoadTask(const QString &filename) :
bool ProjectLoadTask::Run()
{
QFile project_file(GetFilename());
uint project_version;
if (project_file.open(QFile::ReadOnly | QFile::Text)) {
QXmlStreamReader reader(&project_file);
@@ -45,7 +46,7 @@ bool ProjectLoadTask::Run()
if (reader.name() == QStringLiteral("olive")) {
while(XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("version")) {
uint project_version = reader.readElementText().toUInt();
project_version = reader.readElementText().toUInt();
if (project_version > Core::kProjectVersion) {
// Project is newer than we support
@@ -63,7 +64,7 @@ bool ProjectLoadTask::Run()
project_->set_filename(GetFilename());
project_->Load(&reader, &layout_info_, &IsCancelled());
project_->Load(&reader, &layout_info_, project_version, &IsCancelled());
// Ensure project is in main thread
project_->moveToThread(qApp->thread());
+2 -5
View File
@@ -29,8 +29,7 @@
#include "node/block/clip/clip.h"
#include "node/block/gap/gap.h"
#include "node/input/media/audio/audio.h"
#include "node/input/media/video/video.h"
#include "node/input/media/media.h"
#include "project/item/folder/folder.h"
#include "project/item/sequence/sequence.h"
@@ -172,12 +171,10 @@ bool LoadOTIOTask::Run()
}
if (probed_item && probed_item->type() == Item::kFootage) {
MediaInput* media;
MediaInput* media = new MediaInput();
if (track->track_type() == Timeline::kTrackTypeVideo) {
media = new VideoInput();
media->SetStream(probed_item->get_first_stream_of_type(Stream::kVideo));
} else {
media = new AudioInput();
media->SetStream(probed_item->get_first_stream_of_type(Stream::kAudio));
}
sequence->AddNode(media);
+3 -4
View File
@@ -31,8 +31,7 @@
#include "dialog/sequence/sequence.h"
#include "node/audio/volume/volume.h"
#include "node/generator/matrix/matrix.h"
#include "node/input/media/audio/audio.h"
#include "node/input/media/video/video.h"
#include "node/input/media/media.h"
#include "node/math/math/math.h"
#include "project/item/sequence/sequence.h"
#include "widget/nodeview/nodeviewundo.h"
@@ -416,7 +415,7 @@ void ImportTool::DropGhosts(bool insert)
switch (footage_stream->type()) {
case Stream::kVideo:
{
VideoInput* video_input = new VideoInput();
MediaInput* video_input = new MediaInput();
video_input->SetStream(footage_stream);
new NodeAddCommand(dst_graph, video_input, command);
@@ -438,7 +437,7 @@ void ImportTool::DropGhosts(bool insert)
}
case Stream::kAudio:
{
AudioInput* audio_input = new AudioInput();
MediaInput* audio_input = new MediaInput();
audio_input->SetStream(footage_stream);
new NodeAddCommand(dst_graph, audio_input, command);
+2 -2
View File
@@ -32,10 +32,10 @@ FootageViewerWidget::FootageViewerWidget(QWidget *parent) :
ViewerWidget(parent),
footage_(nullptr)
{
video_node_ = new VideoInput();
video_node_ = new MediaInput();
sequence_.AddNode(video_node_);
audio_node_ = new AudioInput();
audio_node_ = new MediaInput();
sequence_.AddNode(audio_node_);
connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, &FootageViewerWidget::StartFootageDrag);
+3 -4
View File
@@ -21,8 +21,7 @@
#ifndef FOOTAGEVIEWERWIDGET_H
#define FOOTAGEVIEWERWIDGET_H
#include "node/input/media/audio/audio.h"
#include "node/input/media/video/video.h"
#include "node/input/media/media.h"
#include "node/output/viewer/viewer.h"
#include "viewer.h"
@@ -49,9 +48,9 @@ private:
Sequence sequence_;
VideoInput* video_node_;
MediaInput* video_node_;
AudioInput* audio_node_;
MediaInput* audio_node_;
QHash<Footage*, int64_t> cached_timestamps_;