footage combobox returns streams rather than footage
This commit is contained in:
@@ -95,9 +95,9 @@ NodeOutput *MediaInput::texture_output()
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
void MediaInput::SetFootage(Footage *f)
|
||||
void MediaInput::SetFootage(StreamPtr f)
|
||||
{
|
||||
footage_input_->set_value(PtrToValue(f));
|
||||
footage_input_->set_value(QVariant::fromValue(f));
|
||||
}
|
||||
|
||||
void MediaInput::Hash(QCryptographicHash *hash, NodeOutput *from, const rational &time)
|
||||
@@ -284,10 +284,10 @@ bool MediaInput::SetupDecoder()
|
||||
}
|
||||
|
||||
// Get currently selected Footage
|
||||
Footage* footage = ValueToPtr<Footage>(footage_input_->get_value(0));
|
||||
StreamPtr stream = footage_input_->get_value(0).value<StreamPtr>();
|
||||
|
||||
// If no footage is selected, return nothing
|
||||
if (footage == nullptr) {
|
||||
if (stream == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -295,13 +295,12 @@ bool MediaInput::SetupDecoder()
|
||||
|
||||
// Determine which decoder to use
|
||||
if (decoder_ == nullptr
|
||||
&& (decoder_ = Decoder::CreateFromID(footage->decoder())) == nullptr) {
|
||||
&& (decoder_ = Decoder::CreateFromID(stream->footage()->decoder())) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (decoder_->stream() == nullptr) {
|
||||
// FIXME: Hardcoded stream 0
|
||||
decoder_->set_stream(footage->stream(0));
|
||||
decoder_->set_stream(stream);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
NodeOutput* texture_output();
|
||||
|
||||
void SetFootage(Footage* f);
|
||||
void SetFootage(StreamPtr f);
|
||||
|
||||
virtual void Hash(QCryptographicHash *hash, NodeOutput* from, const rational &time) override;
|
||||
|
||||
|
||||
@@ -25,6 +25,13 @@ AudioStream::AudioStream()
|
||||
set_type(kAudio);
|
||||
}
|
||||
|
||||
QString AudioStream::description()
|
||||
{
|
||||
return QCoreApplication::translate("Stream", "%1: Audio - %2 Channels, %3Hz").arg(QString::number(index()),
|
||||
QString::number(channels()),
|
||||
QString::number(sample_rate()));
|
||||
}
|
||||
|
||||
const int &AudioStream::channels()
|
||||
{
|
||||
return channels_;
|
||||
|
||||
@@ -32,6 +32,8 @@ class AudioStream : public Stream
|
||||
public:
|
||||
AudioStream();
|
||||
|
||||
virtual QString description() override;
|
||||
|
||||
const int& channels();
|
||||
void set_channels(const int& channels);
|
||||
|
||||
|
||||
@@ -91,6 +91,11 @@ StreamPtr Footage::stream(int index)
|
||||
return streams_.at(index);
|
||||
}
|
||||
|
||||
const QList<StreamPtr> &Footage::streams()
|
||||
{
|
||||
return streams_;
|
||||
}
|
||||
|
||||
int Footage::stream_count()
|
||||
{
|
||||
return streams_.size();
|
||||
|
||||
@@ -174,6 +174,11 @@ public:
|
||||
*/
|
||||
StreamPtr stream(int index);
|
||||
|
||||
/**
|
||||
* @brief Returns a list of the streams in this Footage
|
||||
*/
|
||||
const QList<StreamPtr>& streams();
|
||||
|
||||
/**
|
||||
* @brief Retrieve total number of streams in this Footage file
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,13 @@ ImageStream::ImageStream()
|
||||
set_type(kImage);
|
||||
}
|
||||
|
||||
QString ImageStream::description()
|
||||
{
|
||||
return QCoreApplication::translate("Stream", "%1: Image - %2x%3").arg(QString::number(index()),
|
||||
QString::number(width()),
|
||||
QString::number(height()));
|
||||
}
|
||||
|
||||
const int &ImageStream::width()
|
||||
{
|
||||
return width_;
|
||||
|
||||
@@ -31,6 +31,8 @@ class ImageStream : public Stream
|
||||
public:
|
||||
ImageStream();
|
||||
|
||||
virtual QString description() override;
|
||||
|
||||
const int& width();
|
||||
void set_width(const int& width);
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "stream.h"
|
||||
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
Stream::Stream() :
|
||||
footage_(nullptr),
|
||||
type_(kUnknown)
|
||||
@@ -31,6 +33,11 @@ Stream::~Stream()
|
||||
{
|
||||
}
|
||||
|
||||
QString Stream::description()
|
||||
{
|
||||
return QCoreApplication::translate("Stream", "%1: Unknown").arg(index());
|
||||
}
|
||||
|
||||
const Stream::Type &Stream::type()
|
||||
{
|
||||
return type_;
|
||||
@@ -80,3 +87,19 @@ void Stream::set_duration(const int64_t &duration)
|
||||
{
|
||||
duration_ = duration;
|
||||
}
|
||||
|
||||
QIcon Stream::IconFromType(const Stream::Type &type)
|
||||
{
|
||||
switch (type) {
|
||||
case Stream::kVideo:
|
||||
return olive::icon::Video;
|
||||
case Stream::kImage:
|
||||
return olive::icon::Image;
|
||||
case Stream::kAudio:
|
||||
return olive::icon::Audio;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#define STREAM_H
|
||||
|
||||
#include <memory>
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
|
||||
#include "common/rational.h"
|
||||
|
||||
@@ -59,6 +61,8 @@ public:
|
||||
*/
|
||||
virtual ~Stream();
|
||||
|
||||
virtual QString description();
|
||||
|
||||
const Type& type();
|
||||
void set_type(const Type& type);
|
||||
|
||||
@@ -74,6 +78,8 @@ public:
|
||||
const int64_t& duration() const;
|
||||
void set_duration(const int64_t& duration);
|
||||
|
||||
static QIcon IconFromType(const Type& type);
|
||||
|
||||
private:
|
||||
Footage* footage_;
|
||||
|
||||
|
||||
@@ -24,3 +24,10 @@ VideoStream::VideoStream()
|
||||
{
|
||||
set_type(kVideo);
|
||||
}
|
||||
|
||||
QString VideoStream::description()
|
||||
{
|
||||
return QCoreApplication::translate("Stream", "%1: Video - %2x%3").arg(QString::number(index()),
|
||||
QString::number(width()),
|
||||
QString::number(height()));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ class VideoStream : public ImageStream
|
||||
{
|
||||
public:
|
||||
VideoStream();
|
||||
|
||||
virtual QString description() override;
|
||||
};
|
||||
|
||||
using VideoStreamPtr = std::shared_ptr<VideoStream>;
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
FootageComboBox::FootageComboBox(QWidget *parent) :
|
||||
QComboBox(parent),
|
||||
root_(nullptr),
|
||||
footage_(nullptr),
|
||||
only_show_ready_footage_(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FootageComboBox::showPopup()
|
||||
@@ -33,7 +34,7 @@ void FootageComboBox::showPopup()
|
||||
|
||||
addItem(selected->text());
|
||||
|
||||
footage_ = reinterpret_cast<Footage*>(selected->data().value<quintptr>());
|
||||
footage_ = selected->data().value<StreamPtr>();
|
||||
|
||||
emit FootageChanged(footage_);
|
||||
}
|
||||
@@ -51,12 +52,12 @@ void FootageComboBox::SetOnlyShowReadyFootage(bool e)
|
||||
only_show_ready_footage_ = e;
|
||||
}
|
||||
|
||||
Footage *FootageComboBox::SelectedFootage()
|
||||
StreamPtr FootageComboBox::SelectedFootage()
|
||||
{
|
||||
return footage_;
|
||||
}
|
||||
|
||||
void FootageComboBox::SetFootage(Footage *f)
|
||||
void FootageComboBox::SetFootage(StreamPtr f)
|
||||
{
|
||||
// Remove existing single item used to show the footage name
|
||||
clear();
|
||||
@@ -65,7 +66,7 @@ void FootageComboBox::SetFootage(Footage *f)
|
||||
|
||||
if (footage_ != nullptr) {
|
||||
// Use combobox functions to show the footage name
|
||||
addItem(footage_->name());
|
||||
addItem(footage_->footage()->name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +84,13 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
|
||||
Footage* footage = static_cast<Footage*>(child);
|
||||
|
||||
if (!only_show_ready_footage_ || footage->status() == Footage::kReady) {
|
||||
QAction* footage_action = m->addAction(child->name());
|
||||
footage_action->setData(reinterpret_cast<quintptr>(child));
|
||||
QMenu* stream_menu = m->addMenu(footage->name());
|
||||
|
||||
foreach (StreamPtr stream, footage->streams()) {
|
||||
QAction* stream_action = stream_menu->addAction(stream->description());
|
||||
stream_action->setData(QVariant::fromValue(stream));
|
||||
stream_action->setIcon(Stream::IconFromType(stream->type()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,20 +19,20 @@ public:
|
||||
|
||||
void SetOnlyShowReadyFootage(bool e);
|
||||
|
||||
Footage* SelectedFootage();
|
||||
StreamPtr SelectedFootage();
|
||||
|
||||
public slots:
|
||||
void SetFootage(Footage* f);
|
||||
void SetFootage(StreamPtr f);
|
||||
|
||||
signals:
|
||||
void FootageChanged(Footage* f);
|
||||
void FootageChanged(StreamPtr f);
|
||||
|
||||
private:
|
||||
void TraverseFolder(const Folder *f, QMenu* m);
|
||||
|
||||
const Folder* root_;
|
||||
|
||||
Footage* footage_;
|
||||
StreamPtr footage_;
|
||||
|
||||
bool only_show_ready_footage_;
|
||||
};
|
||||
|
||||
@@ -175,9 +175,9 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
footage_combobox->SetRoot(pp->project()->root());
|
||||
|
||||
// Use multiple values
|
||||
footage_combobox->SetFootage(Node::ValueToPtr<Footage>(base_input->get_value(0)));
|
||||
footage_combobox->SetFootage(base_input->get_value(0).value<StreamPtr>());
|
||||
|
||||
connect(footage_combobox, SIGNAL(FootageChanged(Footage*)), this, SLOT(WidgetCallback()));
|
||||
connect(footage_combobox, SIGNAL(FootageChanged(StreamPtr)), this, SLOT(WidgetCallback()));
|
||||
// End test code
|
||||
|
||||
widgets_.append(footage_combobox);
|
||||
@@ -308,7 +308,7 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
{
|
||||
// Widget is a FootageComboBox
|
||||
FootageComboBox* footage_combobox = static_cast<FootageComboBox*>(sender());
|
||||
input->set_value(Node::PtrToValue(footage_combobox->SelectedFootage()));
|
||||
input->set_value(QVariant::fromValue(footage_combobox->SelectedFootage()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ void TimelineView::ImportTool::DragDrop(QDropEvent *event)
|
||||
opacity->setParent(&node_memory_manager);
|
||||
|
||||
clip->set_length(ghost->Length());
|
||||
media->SetFootage(ghost->data(0).value<StreamPtr>()->footage());
|
||||
media->SetFootage(ghost->data(0).value<StreamPtr>());
|
||||
|
||||
NodeParam::ConnectEdge(opacity->texture_output(), clip->texture_input());
|
||||
NodeParam::ConnectEdge(media->texture_output(), opacity->texture_input());
|
||||
|
||||
Reference in New Issue
Block a user