change: change code style to Linux style except indent.
This commit is contained in:
@@ -20,35 +20,42 @@
|
||||
|
||||
#include "conform.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ConformTask::ConformTask(const QString &decoder_id, const Decoder::CodecStream &stream, const AudioParams& params, const QVector<QString> &output_filenames) :
|
||||
decoder_id_(decoder_id),
|
||||
stream_(stream),
|
||||
params_(params),
|
||||
output_filenames_(output_filenames)
|
||||
namespace olive
|
||||
{
|
||||
SetTitle(tr("Conforming Audio %1:%2").arg(stream.filename(), QString::number(stream.stream())));
|
||||
|
||||
ConformTask::ConformTask(const QString &decoder_id,
|
||||
const Decoder::CodecStream &stream,
|
||||
const AudioParams ¶ms,
|
||||
const QVector<QString> &output_filenames)
|
||||
: decoder_id_(decoder_id)
|
||||
, stream_(stream)
|
||||
, params_(params)
|
||||
, output_filenames_(output_filenames)
|
||||
{
|
||||
SetTitle(tr("Conforming Audio %1:%2")
|
||||
.arg(stream.filename(), QString::number(stream.stream())));
|
||||
}
|
||||
|
||||
bool ConformTask::Run()
|
||||
{
|
||||
DecoderPtr decoder = Decoder::CreateFromID(decoder_id_);
|
||||
DecoderPtr decoder = Decoder::CreateFromID(decoder_id_);
|
||||
|
||||
if (!decoder->Open(stream_)) {
|
||||
SetError(tr("Failed to open decoder for audio conform"));
|
||||
return false;
|
||||
}
|
||||
if (!decoder->Open(stream_)) {
|
||||
SetError(tr("Failed to open decoder for audio conform"));
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(decoder.get(), &Decoder::IndexProgress, this, &ConformTask::ProgressChanged);
|
||||
connect(decoder.get(), &Decoder::IndexProgress, this,
|
||||
&ConformTask::ProgressChanged);
|
||||
|
||||
qDebug() << "Starting conform of" << stream_.filename() << stream_.stream();
|
||||
qDebug() << "Starting conform of" << stream_.filename() << stream_.stream();
|
||||
|
||||
bool ret = decoder->ConformAudio(output_filenames_, params_, GetCancelAtom());
|
||||
bool ret =
|
||||
decoder->ConformAudio(output_filenames_, params_, GetCancelAtom());
|
||||
|
||||
decoder->Close();
|
||||
decoder->Close();
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-11
@@ -25,26 +25,27 @@
|
||||
#include "node/project/footage/footage.h"
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ConformTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ConformTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConformTask(const QString &decoder_id, const Decoder::CodecStream &stream, const AudioParams& params, const QVector<QString> &output_filenames);
|
||||
ConformTask(const QString &decoder_id, const Decoder::CodecStream &stream,
|
||||
const AudioParams ¶ms,
|
||||
const QVector<QString> &output_filenames);
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
private:
|
||||
QString decoder_id_;
|
||||
QString decoder_id_;
|
||||
|
||||
Decoder::CodecStream stream_;
|
||||
Decoder::CodecStream stream_;
|
||||
|
||||
AudioParams params_;
|
||||
|
||||
QVector<QString> output_filenames_;
|
||||
AudioParams params_;
|
||||
|
||||
QVector<QString> output_filenames_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,43 +20,44 @@
|
||||
|
||||
#include "customcachetask.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
CustomCacheTask::CustomCacheTask(const QString &sequence_name) :
|
||||
cancelled_through_finish_(false)
|
||||
namespace olive
|
||||
{
|
||||
SetTitle(tr("Caching custom range for \"%1\"").arg(sequence_name));
|
||||
|
||||
CustomCacheTask::CustomCacheTask(const QString &sequence_name)
|
||||
: cancelled_through_finish_(false)
|
||||
{
|
||||
SetTitle(tr("Caching custom range for \"%1\"").arg(sequence_name));
|
||||
}
|
||||
|
||||
void CustomCacheTask::Finish()
|
||||
{
|
||||
mutex_.lock();
|
||||
mutex_.lock();
|
||||
|
||||
cancelled_through_finish_ = true;
|
||||
Cancel();
|
||||
cancelled_through_finish_ = true;
|
||||
Cancel();
|
||||
|
||||
mutex_.unlock();
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
||||
bool CustomCacheTask::Run()
|
||||
{
|
||||
mutex_.lock();
|
||||
mutex_.lock();
|
||||
|
||||
while (!IsCancelled()) {
|
||||
wait_cond_.wait(&mutex_);
|
||||
}
|
||||
while (!IsCancelled()) {
|
||||
wait_cond_.wait(&mutex_);
|
||||
}
|
||||
|
||||
mutex_.unlock();
|
||||
mutex_.unlock();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CustomCacheTask::CancelEvent()
|
||||
{
|
||||
if (!cancelled_through_finish_) {
|
||||
emit Cancelled();
|
||||
}
|
||||
wait_cond_.wakeOne();
|
||||
if (!cancelled_through_finish_) {
|
||||
emit Cancelled();
|
||||
}
|
||||
wait_cond_.wakeOne();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,31 +26,30 @@
|
||||
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class CustomCacheTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CustomCacheTask(const QString &sequence_name);
|
||||
|
||||
void Finish();
|
||||
class CustomCacheTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CustomCacheTask(const QString &sequence_name);
|
||||
|
||||
void Finish();
|
||||
|
||||
signals:
|
||||
void Cancelled();
|
||||
void Cancelled();
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
virtual void CancelEvent() override;
|
||||
virtual void CancelEvent() override;
|
||||
|
||||
private:
|
||||
QMutex mutex_;
|
||||
QMutex mutex_;
|
||||
|
||||
QWaitCondition wait_cond_;
|
||||
|
||||
bool cancelled_through_finish_;
|
||||
QWaitCondition wait_cond_;
|
||||
|
||||
bool cancelled_through_finish_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+208
-198
@@ -22,266 +22,276 @@
|
||||
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ExportTask::ExportTask(ViewerOutput *viewer_node,
|
||||
ColorManager* color_manager,
|
||||
const EncodingParams& params) :
|
||||
params_(params)
|
||||
namespace olive
|
||||
{
|
||||
// Create a copy of the project
|
||||
copier_ = new ProjectCopier(this);
|
||||
copier_->SetProject(viewer_node->project());
|
||||
|
||||
set_viewer(copier_->GetCopy(viewer_node));
|
||||
color_manager_ = copier_->GetCopiedProject()->color_manager();
|
||||
ExportTask::ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager,
|
||||
const EncodingParams ¶ms)
|
||||
: params_(params)
|
||||
{
|
||||
// Create a copy of the project
|
||||
copier_ = new ProjectCopier(this);
|
||||
copier_->SetProject(viewer_node->project());
|
||||
|
||||
// Adjust video params to have no divider
|
||||
VideoParams vp = viewer_node->GetVideoParams();
|
||||
vp.set_divider(1);
|
||||
vp.set_time_base(params.video_params().time_base());
|
||||
vp.set_frame_rate(params.video_params().frame_rate());
|
||||
set_video_params(vp);
|
||||
set_viewer(copier_->GetCopy(viewer_node));
|
||||
color_manager_ = copier_->GetCopiedProject()->color_manager();
|
||||
|
||||
set_audio_params(viewer_node->GetAudioParams());
|
||||
// Adjust video params to have no divider
|
||||
VideoParams vp = viewer_node->GetVideoParams();
|
||||
vp.set_divider(1);
|
||||
vp.set_time_base(params.video_params().time_base());
|
||||
vp.set_frame_rate(params.video_params().frame_rate());
|
||||
set_video_params(vp);
|
||||
|
||||
SetTitle(tr("Exporting \"%1\"").arg(viewer_node->GetLabel()));
|
||||
SetNativeProgressSignallingEnabled(false);
|
||||
set_audio_params(viewer_node->GetAudioParams());
|
||||
|
||||
SetTitle(tr("Exporting \"%1\"").arg(viewer_node->GetLabel()));
|
||||
SetNativeProgressSignallingEnabled(false);
|
||||
}
|
||||
|
||||
bool ExportTask::Run()
|
||||
{
|
||||
// For safety, if we're overwriting, we save to a temporary filename and then only overwrite it
|
||||
// at the end
|
||||
QString real_filename = params_.filename();
|
||||
if (QFileInfo::exists(params_.filename())) {
|
||||
// Generate a filename that definitely doesn't exist
|
||||
params_.SetFilename(FileFunctions::GetSafeTemporaryFilename(real_filename));
|
||||
}
|
||||
// For safety, if we're overwriting, we save to a temporary filename and then only overwrite it
|
||||
// at the end
|
||||
QString real_filename = params_.filename();
|
||||
if (QFileInfo::exists(params_.filename())) {
|
||||
// Generate a filename that definitely doesn't exist
|
||||
params_.SetFilename(
|
||||
FileFunctions::GetSafeTemporaryFilename(real_filename));
|
||||
}
|
||||
|
||||
// If we're exporting to a sidecar subtitle file, disable the subtitles in the main encoder
|
||||
bool subtitles_enabled = params_.subtitles_enabled();
|
||||
EncodingParams sidecar_params = params_;
|
||||
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
|
||||
params_.DisableSubtitles();
|
||||
}
|
||||
// If we're exporting to a sidecar subtitle file, disable the subtitles in the main encoder
|
||||
bool subtitles_enabled = params_.subtitles_enabled();
|
||||
EncodingParams sidecar_params = params_;
|
||||
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
|
||||
params_.DisableSubtitles();
|
||||
}
|
||||
|
||||
encoder_ = std::shared_ptr<Encoder>(Encoder::CreateFromParams(params_));
|
||||
encoder_ = std::shared_ptr<Encoder>(Encoder::CreateFromParams(params_));
|
||||
|
||||
if (!encoder_) {
|
||||
SetError(tr("Failed to create encoder"));
|
||||
return false;
|
||||
}
|
||||
if (!encoder_) {
|
||||
SetError(tr("Failed to create encoder"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!encoder_->Open()) {
|
||||
SetError(tr("Failed to open file: %1").arg(encoder_->GetError()));
|
||||
return false;
|
||||
}
|
||||
if (!encoder_->Open()) {
|
||||
SetError(tr("Failed to open file: %1").arg(encoder_->GetError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
|
||||
// Construct sidecar params
|
||||
sidecar_params.DisableVideo();
|
||||
sidecar_params.DisableAudio();
|
||||
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
|
||||
// Construct sidecar params
|
||||
sidecar_params.DisableVideo();
|
||||
sidecar_params.DisableAudio();
|
||||
|
||||
QString sidecar_filename;
|
||||
{
|
||||
QFileInfo fi(real_filename);
|
||||
sidecar_filename = fi.completeBaseName();
|
||||
sidecar_filename.append('.');
|
||||
sidecar_filename.append(ExportFormat::GetExtension(sidecar_params.subtitle_sidecar_fmt()));
|
||||
sidecar_filename = fi.dir().filePath(sidecar_filename);
|
||||
}
|
||||
sidecar_params.SetFilename(sidecar_filename);
|
||||
QString sidecar_filename;
|
||||
{
|
||||
QFileInfo fi(real_filename);
|
||||
sidecar_filename = fi.completeBaseName();
|
||||
sidecar_filename.append('.');
|
||||
sidecar_filename.append(ExportFormat::GetExtension(
|
||||
sidecar_params.subtitle_sidecar_fmt()));
|
||||
sidecar_filename = fi.dir().filePath(sidecar_filename);
|
||||
}
|
||||
sidecar_params.SetFilename(sidecar_filename);
|
||||
|
||||
subtitle_encoder_ = std::shared_ptr<Encoder>(Encoder::CreateFromFormat(sidecar_params.subtitle_sidecar_fmt(), sidecar_params));
|
||||
if (!subtitle_encoder_) {
|
||||
SetError(tr("Failed to create subtitle encoder"));
|
||||
return false;
|
||||
}
|
||||
subtitle_encoder_ = std::shared_ptr<Encoder>(Encoder::CreateFromFormat(
|
||||
sidecar_params.subtitle_sidecar_fmt(), sidecar_params));
|
||||
if (!subtitle_encoder_) {
|
||||
SetError(tr("Failed to create subtitle encoder"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!subtitle_encoder_->Open()) {
|
||||
SetError(tr("Failed to open subtitle sidecar file: %1").arg(sidecar_filename));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
subtitle_encoder_ = encoder_;
|
||||
}
|
||||
if (!subtitle_encoder_->Open()) {
|
||||
SetError(tr("Failed to open subtitle sidecar file: %1")
|
||||
.arg(sidecar_filename));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
subtitle_encoder_ = encoder_;
|
||||
}
|
||||
|
||||
if (params_.has_custom_range()) {
|
||||
// Render custom range only
|
||||
export_range_ = params_.custom_range();
|
||||
} else {
|
||||
// Render entire sequence
|
||||
export_range_ = TimeRange(0, viewer()->GetLength());
|
||||
}
|
||||
if (params_.has_custom_range()) {
|
||||
// Render custom range only
|
||||
export_range_ = params_.custom_range();
|
||||
} else {
|
||||
// Render entire sequence
|
||||
export_range_ = TimeRange(0, viewer()->GetLength());
|
||||
}
|
||||
|
||||
frame_time_ = 0;
|
||||
frame_time_ = 0;
|
||||
|
||||
QSize video_force_size;
|
||||
QMatrix4x4 video_force_matrix;
|
||||
QSize video_force_size;
|
||||
QMatrix4x4 video_force_matrix;
|
||||
|
||||
if (params_.video_enabled()) {
|
||||
if (params_.video_enabled()) {
|
||||
// If a transformation matrix is applied to this video, create it here
|
||||
if (video_params().width() != params_.video_params().width() ||
|
||||
video_params().height() != params_.video_params().height()) {
|
||||
video_force_size = QSize(params_.video_params().width(),
|
||||
params_.video_params().height());
|
||||
|
||||
// If a transformation matrix is applied to this video, create it here
|
||||
if (video_params().width() != params_.video_params().width()
|
||||
|| video_params().height() != params_.video_params().height()) {
|
||||
video_force_size = QSize(params_.video_params().width(), params_.video_params().height());
|
||||
if (params_.video_scaling_method() != EncodingParams::kStretch) {
|
||||
video_force_matrix = EncodingParams::GenerateMatrix(
|
||||
params_.video_scaling_method(), video_params().width(),
|
||||
video_params().height(), params_.video_params().width(),
|
||||
params_.video_params().height());
|
||||
}
|
||||
} else {
|
||||
// Disables forcing size in the renderer
|
||||
video_force_size = QSize(0, 0);
|
||||
}
|
||||
|
||||
if (params_.video_scaling_method() != EncodingParams::kStretch) {
|
||||
video_force_matrix = EncodingParams::GenerateMatrix(params_.video_scaling_method(),
|
||||
video_params().width(),
|
||||
video_params().height(),
|
||||
params_.video_params().width(),
|
||||
params_.video_params().height());
|
||||
}
|
||||
} else {
|
||||
// Disables forcing size in the renderer
|
||||
video_force_size = QSize(0, 0);
|
||||
}
|
||||
// Create color processor
|
||||
color_processor_ = ColorProcessor::Create(
|
||||
color_manager_, color_manager_->GetReferenceColorSpace(),
|
||||
params_.color_transform());
|
||||
}
|
||||
|
||||
// Create color processor
|
||||
color_processor_ = ColorProcessor::Create(color_manager_,
|
||||
color_manager_->GetReferenceColorSpace(),
|
||||
params_.color_transform());
|
||||
}
|
||||
// Start render process
|
||||
TimeRangeList video_range, audio_range;
|
||||
TimeRange subtitle_range;
|
||||
|
||||
// Start render process
|
||||
TimeRangeList video_range, audio_range;
|
||||
TimeRange subtitle_range;
|
||||
if (params_.video_enabled()) {
|
||||
if (export_range_.in() > 0) {
|
||||
export_range_.set_in(Timecode::snap_time_to_timebase(
|
||||
export_range_.in(), video_params().frame_rate_as_time_base()));
|
||||
}
|
||||
|
||||
if (params_.video_enabled()) {
|
||||
if (export_range_.in() > 0) {
|
||||
export_range_.set_in(Timecode::snap_time_to_timebase(export_range_.in(), video_params().frame_rate_as_time_base()));
|
||||
}
|
||||
video_range = { export_range_ };
|
||||
}
|
||||
|
||||
video_range = {export_range_};
|
||||
}
|
||||
if (params_.audio_enabled()) {
|
||||
audio_range = { export_range_ };
|
||||
}
|
||||
|
||||
if (params_.audio_enabled()) {
|
||||
audio_range = {export_range_};
|
||||
}
|
||||
if (subtitles_enabled) {
|
||||
subtitle_range = export_range_;
|
||||
}
|
||||
|
||||
if (subtitles_enabled) {
|
||||
subtitle_range = export_range_;
|
||||
}
|
||||
Render(color_manager_, video_range, audio_range, subtitle_range,
|
||||
RenderMode::kOnline, nullptr, video_force_size, video_force_matrix,
|
||||
encoder_->GetDesiredPixelFormat(), VideoParams::kRGBAChannelCount,
|
||||
color_processor_);
|
||||
|
||||
Render(color_manager_, video_range, audio_range, subtitle_range, RenderMode::kOnline, nullptr,
|
||||
video_force_size, video_force_matrix, encoder_->GetDesiredPixelFormat(),
|
||||
VideoParams::kRGBAChannelCount, color_processor_);
|
||||
bool success = true;
|
||||
|
||||
bool success = true;
|
||||
encoder_->Close();
|
||||
if (!encoder_->GetError().isEmpty()) {
|
||||
SetError(encoder_->GetError());
|
||||
success = false;
|
||||
}
|
||||
|
||||
encoder_->Close();
|
||||
if (!encoder_->GetError().isEmpty()) {
|
||||
SetError(encoder_->GetError());
|
||||
success = false;
|
||||
}
|
||||
if (subtitle_encoder_ != encoder_) {
|
||||
subtitle_encoder_->Close();
|
||||
if (!subtitle_encoder_->GetError().isEmpty()) {
|
||||
SetError(subtitle_encoder_->GetError());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (subtitle_encoder_ != encoder_) {
|
||||
subtitle_encoder_->Close();
|
||||
if (!subtitle_encoder_->GetError().isEmpty()) {
|
||||
SetError(subtitle_encoder_->GetError());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
// If cancelled, delete the file we made, which is always a file we created since we write to a
|
||||
// temp file during the actual encoding process
|
||||
if (IsCancelled()) {
|
||||
QFile::remove(params_.filename());
|
||||
} else if (params_.filename() != real_filename) {
|
||||
// If we were writing to a temp file, overwrite now
|
||||
if (!FileFunctions::RenameFileAllowOverwrite(params_.filename(),
|
||||
real_filename)) {
|
||||
SetError(
|
||||
tr("Failed to overwrite \"%1\". Export has been saved as \"%2\" instead.")
|
||||
.arg(real_filename, params_.filename()));
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// If cancelled, delete the file we made, which is always a file we created since we write to a
|
||||
// temp file during the actual encoding process
|
||||
if (IsCancelled()) {
|
||||
QFile::remove(params_.filename());
|
||||
} else if (params_.filename() != real_filename) {
|
||||
// If we were writing to a temp file, overwrite now
|
||||
if (!FileFunctions::RenameFileAllowOverwrite(params_.filename(), real_filename)) {
|
||||
SetError(tr("Failed to overwrite \"%1\". Export has been saved as \"%2\" instead.")
|
||||
.arg(real_filename, params_.filename()));
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ExportTask::FrameDownloaded(FramePtr f, const rational &time)
|
||||
{
|
||||
rational actual_time = time - export_range_.in();
|
||||
rational actual_time = time - export_range_.in();
|
||||
|
||||
time_map_.insert(actual_time, f);
|
||||
time_map_.insert(actual_time, f);
|
||||
|
||||
while (!IsCancelled()) {
|
||||
rational real_time = Timecode::timestamp_to_time(frame_time_,
|
||||
video_params().frame_rate_as_time_base());
|
||||
while (!IsCancelled()) {
|
||||
rational real_time = Timecode::timestamp_to_time(
|
||||
frame_time_, video_params().frame_rate_as_time_base());
|
||||
|
||||
if (!time_map_.contains(real_time)) {
|
||||
break;
|
||||
}
|
||||
if (!time_map_.contains(real_time)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Unfortunately this can't be done in another thread since the frames need to be sent
|
||||
// one after the other chronologically.
|
||||
if (!encoder_->WriteFrame(time_map_.take(real_time), real_time)) {
|
||||
SetError(encoder_->GetError());
|
||||
return false;
|
||||
}
|
||||
// Unfortunately this can't be done in another thread since the frames need to be sent
|
||||
// one after the other chronologically.
|
||||
if (!encoder_->WriteFrame(time_map_.take(real_time), real_time)) {
|
||||
SetError(encoder_->GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
frame_time_++;
|
||||
emit ProgressChanged(double(frame_time_) / double(GetTotalNumberOfFrames()));
|
||||
}
|
||||
frame_time_++;
|
||||
emit ProgressChanged(double(frame_time_) /
|
||||
double(GetTotalNumberOfFrames()));
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExportTask::AudioDownloaded(const TimeRange &range, const SampleBuffer &samples)
|
||||
bool ExportTask::AudioDownloaded(const TimeRange &range,
|
||||
const SampleBuffer &samples)
|
||||
{
|
||||
TimeRange adjusted_range = range - export_range_.in();
|
||||
TimeRange adjusted_range = range - export_range_.in();
|
||||
|
||||
if (adjusted_range.in() == audio_time_) {
|
||||
if (!WriteAudioLoop(adjusted_range, samples)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
audio_map_.insert(adjusted_range, samples);
|
||||
}
|
||||
if (adjusted_range.in() == audio_time_) {
|
||||
if (!WriteAudioLoop(adjusted_range, samples)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
audio_map_.insert(adjusted_range, samples);
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExportTask::EncodeSubtitle(const SubtitleBlock *sub)
|
||||
{
|
||||
if (!subtitle_encoder_->WriteSubtitle(sub)) {
|
||||
SetError(subtitle_encoder_->GetError());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (!subtitle_encoder_->WriteSubtitle(sub)) {
|
||||
SetError(subtitle_encoder_->GetError());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ExportTask::WriteAudioLoop(const TimeRange& time, const SampleBuffer &samples)
|
||||
bool ExportTask::WriteAudioLoop(const TimeRange &time,
|
||||
const SampleBuffer &samples)
|
||||
{
|
||||
if (!encoder_->WriteAudio(samples)) {
|
||||
SetError(encoder_->GetError());
|
||||
return false;
|
||||
}
|
||||
if (!encoder_->WriteAudio(samples)) {
|
||||
SetError(encoder_->GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
audio_time_ = time.out();
|
||||
audio_time_ = time.out();
|
||||
|
||||
for (auto it=audio_map_.begin(); it!=audio_map_.end(); it++) {
|
||||
TimeRange t = it.key();
|
||||
SampleBuffer s = it.value();
|
||||
for (auto it = audio_map_.begin(); it != audio_map_.end(); it++) {
|
||||
TimeRange t = it.key();
|
||||
SampleBuffer s = it.value();
|
||||
|
||||
if (t.in() == audio_time_) {
|
||||
// Erase from audio map since we're just about to write it
|
||||
audio_map_.erase(it);
|
||||
if (t.in() == audio_time_) {
|
||||
// Erase from audio map since we're just about to write it
|
||||
audio_map_.erase(it);
|
||||
|
||||
// Call recursively to write the next sample buffer
|
||||
if (!WriteAudioLoop(t, s)) {
|
||||
return false;
|
||||
}
|
||||
// Call recursively to write the next sample buffer
|
||||
if (!WriteAudioLoop(t, s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Break out of loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Break out of loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+27
-26
@@ -28,53 +28,54 @@
|
||||
#include "task/render/render.h"
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ExportTask : public RenderTask
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ExportTask : public RenderTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager, const EncodingParams ¶ms);
|
||||
ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager,
|
||||
const EncodingParams ¶ms);
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
virtual bool FrameDownloaded(FramePtr frame, const rational &time) override;
|
||||
virtual bool FrameDownloaded(FramePtr frame, const rational &time) override;
|
||||
|
||||
virtual bool AudioDownloaded(const TimeRange& range, const SampleBuffer &samples) override;
|
||||
virtual bool AudioDownloaded(const TimeRange &range,
|
||||
const SampleBuffer &samples) override;
|
||||
|
||||
virtual bool EncodeSubtitle(const SubtitleBlock *sub) override;
|
||||
virtual bool EncodeSubtitle(const SubtitleBlock *sub) override;
|
||||
|
||||
virtual bool TwoStepFrameRendering() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool TwoStepFrameRendering() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool WriteAudioLoop(const TimeRange &time, const SampleBuffer &samples);
|
||||
bool WriteAudioLoop(const TimeRange &time, const SampleBuffer &samples);
|
||||
|
||||
ProjectCopier *copier_;
|
||||
ProjectCopier *copier_;
|
||||
|
||||
QHash<rational, FramePtr> time_map_;
|
||||
QHash<rational, FramePtr> time_map_;
|
||||
|
||||
QHash<TimeRange, SampleBuffer> audio_map_;
|
||||
QHash<TimeRange, SampleBuffer> audio_map_;
|
||||
|
||||
ColorManager* color_manager_;
|
||||
ColorManager *color_manager_;
|
||||
|
||||
EncodingParams params_;
|
||||
EncodingParams params_;
|
||||
|
||||
std::shared_ptr<Encoder> encoder_;
|
||||
std::shared_ptr<Encoder> encoder_;
|
||||
|
||||
std::shared_ptr<Encoder> subtitle_encoder_;
|
||||
std::shared_ptr<Encoder> subtitle_encoder_;
|
||||
|
||||
ColorProcessorPtr color_processor_;
|
||||
ColorProcessorPtr color_processor_;
|
||||
|
||||
int64_t frame_time_;
|
||||
int64_t frame_time_;
|
||||
|
||||
rational audio_time_;
|
||||
|
||||
TimeRange export_range_;
|
||||
rational audio_time_;
|
||||
|
||||
TimeRange export_range_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,87 +22,91 @@
|
||||
|
||||
#include "node/project.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence* sequence)
|
||||
namespace olive
|
||||
{
|
||||
// Set video and audio params
|
||||
set_video_params(sequence->GetVideoParams());
|
||||
set_audio_params(sequence->GetAudioParams());
|
||||
|
||||
// Create new project
|
||||
project_ = new Project();
|
||||
PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence *sequence)
|
||||
{
|
||||
// Set video and audio params
|
||||
set_video_params(sequence->GetVideoParams());
|
||||
set_audio_params(sequence->GetAudioParams());
|
||||
|
||||
// Create viewer with same parameters as the sequence
|
||||
set_viewer(new ViewerOutput());
|
||||
viewer()->setParent(project_);
|
||||
viewer()->SetVideoParams(sequence->GetVideoParams());
|
||||
viewer()->SetAudioParams(sequence->GetAudioParams());
|
||||
// Create new project
|
||||
project_ = new Project();
|
||||
|
||||
// Copy project config nodes
|
||||
Project::CopySettings(footage->project(), project_);
|
||||
// Create viewer with same parameters as the sequence
|
||||
set_viewer(new ViewerOutput());
|
||||
viewer()->setParent(project_);
|
||||
viewer()->SetVideoParams(sequence->GetVideoParams());
|
||||
viewer()->SetAudioParams(sequence->GetAudioParams());
|
||||
|
||||
// Copy footage node so it can precache without any modifications from the user screwing it up
|
||||
footage_ = static_cast<Footage*>(footage->copy());
|
||||
footage_->setParent(project_);
|
||||
Node::CopyInputs(footage, footage_, false);
|
||||
// Copy project config nodes
|
||||
Project::CopySettings(footage->project(), project_);
|
||||
|
||||
Node::ConnectEdge(footage_, NodeInput(viewer(), ViewerOutput::kTextureInput));
|
||||
viewer()->SetValueHintForInput(ViewerOutput::kTextureInput, Node::ValueHint({NodeValue::kTexture}, Track::Reference(Track::kVideo, index).ToString()));
|
||||
// Copy footage node so it can precache without any modifications from the user screwing it up
|
||||
footage_ = static_cast<Footage *>(footage->copy());
|
||||
footage_->setParent(project_);
|
||||
Node::CopyInputs(footage, footage_, false);
|
||||
|
||||
SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename(), QString::number(index)));
|
||||
Node::ConnectEdge(footage_,
|
||||
NodeInput(viewer(), ViewerOutput::kTextureInput));
|
||||
viewer()->SetValueHintForInput(
|
||||
ViewerOutput::kTextureInput,
|
||||
Node::ValueHint({ NodeValue::kTexture },
|
||||
Track::Reference(Track::kVideo, index).ToString()));
|
||||
|
||||
SetTitle(tr("Pre-caching %1:%2")
|
||||
.arg(footage_->filename(), QString::number(index)));
|
||||
}
|
||||
|
||||
PreCacheTask::~PreCacheTask()
|
||||
{
|
||||
// This should delete the footage we copied and the viewer we created
|
||||
delete project_;
|
||||
// This should delete the footage we copied and the viewer we created
|
||||
delete project_;
|
||||
}
|
||||
|
||||
bool PreCacheTask::Run()
|
||||
{
|
||||
// Get list of invalidated ranges
|
||||
TimeRange intersection;
|
||||
// Get list of invalidated ranges
|
||||
TimeRange intersection;
|
||||
|
||||
if (footage_->GetWorkArea()->enabled()) {
|
||||
// If we're caching only in-out, limit the range to that
|
||||
intersection = footage_->GetWorkArea()->range();
|
||||
} else {
|
||||
// Otherwise use full length
|
||||
intersection = TimeRange(0, footage_->GetVideoLength());
|
||||
}
|
||||
if (footage_->GetWorkArea()->enabled()) {
|
||||
// If we're caching only in-out, limit the range to that
|
||||
intersection = footage_->GetWorkArea()->range();
|
||||
} else {
|
||||
// Otherwise use full length
|
||||
intersection = TimeRange(0, footage_->GetVideoLength());
|
||||
}
|
||||
|
||||
TimeRangeList video_range = viewer()->video_frame_cache()->GetInvalidatedRanges(intersection);
|
||||
TimeRangeList video_range =
|
||||
viewer()->video_frame_cache()->GetInvalidatedRanges(intersection);
|
||||
|
||||
Render(project_->color_manager(),
|
||||
video_range,
|
||||
TimeRangeList(),
|
||||
TimeRange(),
|
||||
RenderMode::kOnline,
|
||||
viewer()->video_frame_cache());
|
||||
Render(project_->color_manager(), video_range, TimeRangeList(), TimeRange(),
|
||||
RenderMode::kOnline, viewer()->video_frame_cache());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PreCacheTask::FrameDownloaded(FramePtr frame, const rational &time)
|
||||
{
|
||||
// Do nothing. Pre-cache essentially just creates more frames in the cache, it doesn't need to do
|
||||
// anything else.
|
||||
// Do nothing. Pre-cache essentially just creates more frames in the cache, it doesn't need to do
|
||||
// anything else.
|
||||
|
||||
Q_UNUSED(frame)
|
||||
Q_UNUSED(time)
|
||||
Q_UNUSED(frame)
|
||||
Q_UNUSED(time)
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PreCacheTask::AudioDownloaded(const TimeRange &range, const SampleBuffer &samples)
|
||||
bool PreCacheTask::AudioDownloaded(const TimeRange &range,
|
||||
const SampleBuffer &samples)
|
||||
{
|
||||
// Pre-cache doesn't cache any audio
|
||||
// Pre-cache doesn't cache any audio
|
||||
|
||||
Q_UNUSED(range)
|
||||
Q_UNUSED(samples)
|
||||
Q_UNUSED(range)
|
||||
Q_UNUSED(samples)
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,28 +25,29 @@
|
||||
#include "node/project/sequence/sequence.h"
|
||||
#include "task/render/render.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class PreCacheTask : public RenderTask
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreCacheTask(Footage* footage, int index, Sequence* sequence);
|
||||
|
||||
virtual ~PreCacheTask() override;
|
||||
class PreCacheTask : public RenderTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreCacheTask(Footage *footage, int index, Sequence *sequence);
|
||||
|
||||
virtual ~PreCacheTask() override;
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
virtual bool FrameDownloaded(FramePtr frame, const rational ×) override;
|
||||
virtual bool FrameDownloaded(FramePtr frame,
|
||||
const rational ×) override;
|
||||
|
||||
virtual bool AudioDownloaded(const TimeRange& range, const SampleBuffer &samples) override;
|
||||
virtual bool AudioDownloaded(const TimeRange &range,
|
||||
const SampleBuffer &samples) override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
|
||||
Footage* footage_;
|
||||
Project *project_;
|
||||
|
||||
Footage *footage_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+194
-178
@@ -28,258 +28,274 @@
|
||||
#include "node/nodeundo.h"
|
||||
#include "node/project/footage/footage.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ProjectImportTask::ProjectImportTask(Folder *folder, const QStringList &filenames) :
|
||||
command_(nullptr),
|
||||
folder_(folder)
|
||||
namespace olive
|
||||
{
|
||||
foreach (const QString& f, filenames) {
|
||||
filenames_.append(QFileInfo(f));
|
||||
}
|
||||
|
||||
file_count_ = Core::CountFilesInFileList(filenames_);
|
||||
ProjectImportTask::ProjectImportTask(Folder *folder,
|
||||
const QStringList &filenames)
|
||||
: command_(nullptr)
|
||||
, folder_(folder)
|
||||
{
|
||||
foreach (const QString &f, filenames) {
|
||||
filenames_.append(QFileInfo(f));
|
||||
}
|
||||
|
||||
SetTitle(tr("Importing %n file(s)", nullptr, file_count_));
|
||||
file_count_ = Core::CountFilesInFileList(filenames_);
|
||||
|
||||
SetTitle(tr("Importing %n file(s)", nullptr, file_count_));
|
||||
}
|
||||
|
||||
const int &ProjectImportTask::GetFileCount() const
|
||||
{
|
||||
return file_count_;
|
||||
return file_count_;
|
||||
}
|
||||
|
||||
bool ProjectImportTask::Run()
|
||||
{
|
||||
command_ = new MultiUndoCommand();
|
||||
command_ = new MultiUndoCommand();
|
||||
|
||||
int imported = 0;
|
||||
int imported = 0;
|
||||
|
||||
Import(folder_, filenames_, imported, command_);
|
||||
Import(folder_, filenames_, imported, command_);
|
||||
|
||||
if (IsCancelled()) {
|
||||
delete command_;
|
||||
command_ = nullptr;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (IsCancelled()) {
|
||||
delete command_;
|
||||
command_ = nullptr;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counter, MultiUndoCommand* parent_command)
|
||||
void ProjectImportTask::Import(Folder *folder, QFileInfoList import,
|
||||
int &counter, MultiUndoCommand *parent_command)
|
||||
{
|
||||
for (int i=0; i<import.size(); i++) {
|
||||
if (IsCancelled()) {
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < import.size(); i++) {
|
||||
if (IsCancelled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
const QFileInfo& file_info = import.at(i);
|
||||
const QFileInfo &file_info = import.at(i);
|
||||
|
||||
// Check if this file is a directory
|
||||
if (file_info.isDir()) {
|
||||
// Check if this file is a directory
|
||||
if (file_info.isDir()) {
|
||||
// QDir::entryList only returns filenames, we can use entryInfoList() to get full paths
|
||||
QFileInfoList entry_list =
|
||||
QDir(file_info.absoluteFilePath()).entryInfoList();
|
||||
|
||||
// QDir::entryList only returns filenames, we can use entryInfoList() to get full paths
|
||||
QFileInfoList entry_list = QDir(file_info.absoluteFilePath()).entryInfoList();
|
||||
// Strip out "." and ".." (for some reason QDir::NoDotAndDotDot doesn't work with entryInfoList, so we have to
|
||||
// check manually)
|
||||
for (int j = 0; j < entry_list.size(); j++) {
|
||||
if (entry_list.at(j).fileName() == QStringLiteral(".") ||
|
||||
entry_list.at(j).fileName() == QStringLiteral("..")) {
|
||||
entry_list.removeAt(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
// Strip out "." and ".." (for some reason QDir::NoDotAndDotDot doesn't work with entryInfoList, so we have to
|
||||
// check manually)
|
||||
for (int j=0;j<entry_list.size();j++) {
|
||||
if (entry_list.at(j).fileName() == QStringLiteral(".")
|
||||
|| entry_list.at(j).fileName() == QStringLiteral("..")) {
|
||||
entry_list.removeAt(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
// Only proceed if the empty actually has files in it
|
||||
if (!entry_list.isEmpty()) {
|
||||
// Create a folder corresponding to the directory
|
||||
Folder *f = new Folder();
|
||||
|
||||
// Only proceed if the empty actually has files in it
|
||||
if (!entry_list.isEmpty()) {
|
||||
// Create a folder corresponding to the directory
|
||||
Folder* f = new Folder();
|
||||
f->SetLabel(file_info.fileName());
|
||||
|
||||
f->SetLabel(file_info.fileName());
|
||||
// Create undoable command that adds the items to the model
|
||||
AddItemToFolder(folder, f, parent_command);
|
||||
|
||||
// Create undoable command that adds the items to the model
|
||||
AddItemToFolder(folder, f, parent_command);
|
||||
// Recursively follow this path
|
||||
Import(f, entry_list, counter, parent_command);
|
||||
}
|
||||
|
||||
// Recursively follow this path
|
||||
Import(f, entry_list, counter, parent_command);
|
||||
}
|
||||
} else {
|
||||
Footage *footage = new Footage();
|
||||
|
||||
} else {
|
||||
footage->SetCancelPointer(this->GetCancelAtom());
|
||||
|
||||
Footage* footage = new Footage();
|
||||
footage->set_filename(file_info.absoluteFilePath());
|
||||
footage->SetLabel(file_info.fileName());
|
||||
|
||||
footage->SetCancelPointer(this->GetCancelAtom());
|
||||
footage->SetCancelPointer(nullptr);
|
||||
|
||||
footage->set_filename(file_info.absoluteFilePath());
|
||||
footage->SetLabel(file_info.fileName());
|
||||
if (footage->IsValid()) {
|
||||
// See if this footage is an image sequence
|
||||
ValidateImageSequence(footage, import, i);
|
||||
|
||||
footage->SetCancelPointer(nullptr);
|
||||
// Create undoable command that adds the items to the model
|
||||
AddItemToFolder(folder, footage, parent_command);
|
||||
|
||||
if (footage->IsValid()) {
|
||||
// See if this footage is an image sequence
|
||||
ValidateImageSequence(footage, import, i);
|
||||
// Add to vector
|
||||
imported_footage_.push_back(footage);
|
||||
} else {
|
||||
// Add to list so we can tell the user about it later
|
||||
invalid_files_.append(file_info.absoluteFilePath());
|
||||
|
||||
// Create undoable command that adds the items to the model
|
||||
AddItemToFolder(folder, footage, parent_command);
|
||||
delete footage;
|
||||
}
|
||||
|
||||
// Add to vector
|
||||
imported_footage_.push_back(footage);
|
||||
} else {
|
||||
// Add to list so we can tell the user about it later
|
||||
invalid_files_.append(file_info.absoluteFilePath());
|
||||
counter++;
|
||||
|
||||
delete footage;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
emit ProgressChanged(static_cast<double>(counter) / static_cast<double>(file_count_));
|
||||
|
||||
}
|
||||
}
|
||||
emit ProgressChanged(static_cast<double>(counter) /
|
||||
static_cast<double>(file_count_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& info_list, int index)
|
||||
void ProjectImportTask::ValidateImageSequence(Footage *footage,
|
||||
QFileInfoList &info_list,
|
||||
int index)
|
||||
{
|
||||
// Heuristically determine whether this file is part of an image sequence or not
|
||||
//
|
||||
// By this point we've established that video contains a single still image stream. Now we'll
|
||||
// see if it ends with numbers.
|
||||
if (Decoder::GetImageSequenceDigitCount(footage->filename()) > 0
|
||||
&& !image_sequence_ignore_files_.contains(footage->filename())
|
||||
&& footage->InputArraySize(Footage::kVideoParamsInput)) {
|
||||
VideoParams video_stream = footage->GetVideoParams(0);
|
||||
QSize dim(video_stream.width(), video_stream.height());
|
||||
// Heuristically determine whether this file is part of an image sequence or not
|
||||
//
|
||||
// By this point we've established that video contains a single still image stream. Now we'll
|
||||
// see if it ends with numbers.
|
||||
if (Decoder::GetImageSequenceDigitCount(footage->filename()) > 0 &&
|
||||
!image_sequence_ignore_files_.contains(footage->filename()) &&
|
||||
footage->InputArraySize(Footage::kVideoParamsInput)) {
|
||||
VideoParams video_stream = footage->GetVideoParams(0);
|
||||
QSize dim(video_stream.width(), video_stream.height());
|
||||
|
||||
int64_t ind = Decoder::GetImageSequenceIndex(footage->filename());
|
||||
int64_t ind = Decoder::GetImageSequenceIndex(footage->filename());
|
||||
|
||||
// Check if files around exist around it with that follow a sequence
|
||||
QString previous_img_fn = Decoder::TransformImageSequenceFileName(footage->filename(), ind - 1);
|
||||
QString next_img_fn = Decoder::TransformImageSequenceFileName(footage->filename(), ind + 1);
|
||||
// Check if files around exist around it with that follow a sequence
|
||||
QString previous_img_fn = Decoder::TransformImageSequenceFileName(
|
||||
footage->filename(), ind - 1);
|
||||
QString next_img_fn = Decoder::TransformImageSequenceFileName(
|
||||
footage->filename(), ind + 1);
|
||||
|
||||
Footage* previous_file = new Footage(previous_img_fn);
|
||||
Footage* next_file = new Footage(next_img_fn);
|
||||
Footage *previous_file = new Footage(previous_img_fn);
|
||||
Footage *next_file = new Footage(next_img_fn);
|
||||
|
||||
// Finally see if these files have the same dimensions
|
||||
if ((previous_file->IsValid() && CompareStillImageSize(previous_file, dim))
|
||||
|| (next_file->IsValid() && CompareStillImageSize(next_file, dim))) {
|
||||
// By this point, we've established this file is a still image with a number at the end of
|
||||
// the filename surrounded by adjacent numbers. It could be a still image! But let's ask the
|
||||
// user just in case...
|
||||
bool is_sequence;
|
||||
// Finally see if these files have the same dimensions
|
||||
if ((previous_file->IsValid() &&
|
||||
CompareStillImageSize(previous_file, dim)) ||
|
||||
(next_file->IsValid() && CompareStillImageSize(next_file, dim))) {
|
||||
// By this point, we've established this file is a still image with a number at the end of
|
||||
// the filename surrounded by adjacent numbers. It could be a still image! But let's ask the
|
||||
// user just in case...
|
||||
bool is_sequence;
|
||||
|
||||
QMetaObject::invokeMethod(Core::instance(),
|
||||
"ConfirmImageSequence",
|
||||
Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, is_sequence),
|
||||
Q_ARG(QString, footage->filename()));
|
||||
QMetaObject::invokeMethod(Core::instance(), "ConfirmImageSequence",
|
||||
Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, is_sequence),
|
||||
Q_ARG(QString, footage->filename()));
|
||||
|
||||
int64_t seq_index = Decoder::GetImageSequenceIndex(footage->filename());
|
||||
int64_t seq_index =
|
||||
Decoder::GetImageSequenceIndex(footage->filename());
|
||||
|
||||
// Heuristic to find the first and last images (users can always override this later in
|
||||
// FootagePropertiesDialog)
|
||||
int64_t start_index = GetImageSequenceLimit(footage->filename(), seq_index, false);
|
||||
int64_t end_index = GetImageSequenceLimit(footage->filename(), seq_index, true);
|
||||
// Heuristic to find the first and last images (users can always override this later in
|
||||
// FootagePropertiesDialog)
|
||||
int64_t start_index =
|
||||
GetImageSequenceLimit(footage->filename(), seq_index, false);
|
||||
int64_t end_index =
|
||||
GetImageSequenceLimit(footage->filename(), seq_index, true);
|
||||
|
||||
// Depending on the user's choice, either remove them from the list or don't ask for the
|
||||
// remainders
|
||||
for (int64_t j=start_index; j<=end_index; j++) {
|
||||
QString entry_fn = Decoder::TransformImageSequenceFileName(footage->filename(), j);
|
||||
// Depending on the user's choice, either remove them from the list or don't ask for the
|
||||
// remainders
|
||||
for (int64_t j = start_index; j <= end_index; j++) {
|
||||
QString entry_fn = Decoder::TransformImageSequenceFileName(
|
||||
footage->filename(), j);
|
||||
|
||||
if (is_sequence) {
|
||||
// If this is part of the sequence we're importing here, remove it
|
||||
for (int i=index+1; i<info_list.size(); i++) {
|
||||
if (info_list.at(i).absoluteFilePath() == entry_fn) {
|
||||
if (is_sequence) {
|
||||
info_list.removeAt(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
image_sequence_ignore_files_.append(entry_fn);
|
||||
}
|
||||
}
|
||||
if (is_sequence) {
|
||||
// If this is part of the sequence we're importing here, remove it
|
||||
for (int i = index + 1; i < info_list.size(); i++) {
|
||||
if (info_list.at(i).absoluteFilePath() == entry_fn) {
|
||||
if (is_sequence) {
|
||||
info_list.removeAt(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
image_sequence_ignore_files_.append(entry_fn);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_sequence) {
|
||||
// User has confirmed it is a still image, let's set it accordingly.
|
||||
video_stream.set_video_type(VideoParams::kVideoTypeImageSequence);
|
||||
if (is_sequence) {
|
||||
// User has confirmed it is a still image, let's set it accordingly.
|
||||
video_stream.set_video_type(
|
||||
VideoParams::kVideoTypeImageSequence);
|
||||
|
||||
rational default_timebase = OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>();
|
||||
video_stream.set_time_base(default_timebase);
|
||||
video_stream.set_frame_rate(default_timebase.flipped());
|
||||
rational default_timebase =
|
||||
OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>();
|
||||
video_stream.set_time_base(default_timebase);
|
||||
video_stream.set_frame_rate(default_timebase.flipped());
|
||||
|
||||
video_stream.set_start_time(start_index);
|
||||
video_stream.set_duration(end_index - start_index + 1);
|
||||
video_stream.set_start_time(start_index);
|
||||
video_stream.set_duration(end_index - start_index + 1);
|
||||
|
||||
footage->SetVideoParams(video_stream, 0);
|
||||
}
|
||||
}
|
||||
footage->SetVideoParams(video_stream, 0);
|
||||
}
|
||||
}
|
||||
|
||||
delete previous_file;
|
||||
delete next_file;
|
||||
}
|
||||
delete previous_file;
|
||||
delete next_file;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectImportTask::AddItemToFolder(Folder *folder, Node *item, MultiUndoCommand *command)
|
||||
void ProjectImportTask::AddItemToFolder(Folder *folder, Node *item,
|
||||
MultiUndoCommand *command)
|
||||
{
|
||||
// Create undoable command that adds the items to the model
|
||||
Project* project = folder_->project();
|
||||
// Create undoable command that adds the items to the model
|
||||
Project *project = folder_->project();
|
||||
|
||||
NodeAddCommand* nac = new NodeAddCommand(project, item);
|
||||
nac->PushToThread(project->thread());
|
||||
command->add_child(nac);
|
||||
NodeAddCommand *nac = new NodeAddCommand(project, item);
|
||||
nac->PushToThread(project->thread());
|
||||
command->add_child(nac);
|
||||
|
||||
command->add_child(new FolderAddChild(folder, item));
|
||||
command->add_child(new FolderAddChild(folder, item));
|
||||
}
|
||||
|
||||
bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage* footage)
|
||||
bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage *footage)
|
||||
{
|
||||
if (footage->GetTotalStreamCount() != 1) {
|
||||
// Footage with more than one stream (usually video+audio) most likely isn't an image sequence
|
||||
return false;
|
||||
}
|
||||
if (footage->GetTotalStreamCount() != 1) {
|
||||
// Footage with more than one stream (usually video+audio) most likely isn't an image sequence
|
||||
return false;
|
||||
}
|
||||
|
||||
VideoParams vp = footage->GetVideoParams(0);
|
||||
VideoParams vp = footage->GetVideoParams(0);
|
||||
|
||||
// Footage must be valid and video stream must be a still image to be an image sequence
|
||||
return vp.is_valid() && vp.video_type() == VideoParams::kVideoTypeStill;
|
||||
// Footage must be valid and video stream must be a still image to be an image sequence
|
||||
return vp.is_valid() && vp.video_type() == VideoParams::kVideoTypeStill;
|
||||
}
|
||||
|
||||
bool ProjectImportTask::CompareStillImageSize(Footage* footage, const QSize &sz)
|
||||
bool ProjectImportTask::CompareStillImageSize(Footage *footage, const QSize &sz)
|
||||
{
|
||||
if (!ItemIsStillImageFootageOnly(footage)) {
|
||||
return false;
|
||||
}
|
||||
if (!ItemIsStillImageFootageOnly(footage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VideoParams stream = footage->GetVideoParams(0);
|
||||
VideoParams stream = footage->GetVideoParams(0);
|
||||
|
||||
return stream.width() == sz.width() && stream.height() == sz.height();
|
||||
return stream.width() == sz.width() && stream.height() == sz.height();
|
||||
}
|
||||
|
||||
int64_t ProjectImportTask::GetImageSequenceLimit(const QString& start_fn, int64_t start, bool up)
|
||||
int64_t ProjectImportTask::GetImageSequenceLimit(const QString &start_fn,
|
||||
int64_t start, bool up)
|
||||
{
|
||||
QString test_filename;
|
||||
int test_index;
|
||||
QString test_filename;
|
||||
int test_index;
|
||||
|
||||
forever {
|
||||
if (up) {
|
||||
test_index = start + 1;
|
||||
} else {
|
||||
test_index = start - 1;
|
||||
}
|
||||
forever
|
||||
{
|
||||
if (up) {
|
||||
test_index = start + 1;
|
||||
} else {
|
||||
test_index = start - 1;
|
||||
}
|
||||
|
||||
test_filename = Decoder::TransformImageSequenceFileName(start_fn, test_index);
|
||||
test_filename =
|
||||
Decoder::TransformImageSequenceFileName(start_fn, test_index);
|
||||
|
||||
if (!QFileInfo::exists(test_filename)) {
|
||||
// Reached end of index
|
||||
break;
|
||||
}
|
||||
if (!QFileInfo::exists(test_filename)) {
|
||||
// Reached end of index
|
||||
break;
|
||||
}
|
||||
|
||||
start = test_index;
|
||||
}
|
||||
start = test_index;
|
||||
}
|
||||
|
||||
return start;
|
||||
return start;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,63 +28,68 @@
|
||||
#include "task/task.h"
|
||||
#include "widget/projectexplorer/projectviewmodel.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ProjectImportTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ProjectImportTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectImportTask(Folder* folder, const QStringList& filenames);
|
||||
ProjectImportTask(Folder *folder, const QStringList &filenames);
|
||||
|
||||
const int& GetFileCount() const;
|
||||
const int &GetFileCount() const;
|
||||
|
||||
MultiUndoCommand* GetCommand() const
|
||||
{
|
||||
return command_;
|
||||
}
|
||||
MultiUndoCommand *GetCommand() const
|
||||
{
|
||||
return command_;
|
||||
}
|
||||
|
||||
const QStringList& GetInvalidFiles() const
|
||||
{
|
||||
return invalid_files_;
|
||||
}
|
||||
const QStringList &GetInvalidFiles() const
|
||||
{
|
||||
return invalid_files_;
|
||||
}
|
||||
|
||||
bool HasInvalidFiles() const
|
||||
{
|
||||
return !invalid_files_.isEmpty();
|
||||
}
|
||||
bool HasInvalidFiles() const
|
||||
{
|
||||
return !invalid_files_.isEmpty();
|
||||
}
|
||||
|
||||
const QVector<Footage*> &GetImportedFootage() const { return imported_footage_; }
|
||||
const QVector<Footage *> &GetImportedFootage() const
|
||||
{
|
||||
return imported_footage_;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
private:
|
||||
void Import(Folder* folder, QFileInfoList import, int& counter, MultiUndoCommand *parent_command);
|
||||
void Import(Folder *folder, QFileInfoList import, int &counter,
|
||||
MultiUndoCommand *parent_command);
|
||||
|
||||
void ValidateImageSequence(Footage *footage, QFileInfoList &info_list, int index);
|
||||
void ValidateImageSequence(Footage *footage, QFileInfoList &info_list,
|
||||
int index);
|
||||
|
||||
void AddItemToFolder(Folder* folder, Node* item, MultiUndoCommand* command);
|
||||
void AddItemToFolder(Folder *folder, Node *item, MultiUndoCommand *command);
|
||||
|
||||
static bool ItemIsStillImageFootageOnly(Footage *footage);
|
||||
static bool ItemIsStillImageFootageOnly(Footage *footage);
|
||||
|
||||
static bool CompareStillImageSize(Footage *footage, const QSize& sz);
|
||||
static bool CompareStillImageSize(Footage *footage, const QSize &sz);
|
||||
|
||||
static int64_t GetImageSequenceLimit(const QString &start_fn, int64_t start, bool up);
|
||||
static int64_t GetImageSequenceLimit(const QString &start_fn, int64_t start,
|
||||
bool up);
|
||||
|
||||
MultiUndoCommand* command_;
|
||||
MultiUndoCommand *command_;
|
||||
|
||||
Folder* folder_;
|
||||
Folder *folder_;
|
||||
|
||||
QFileInfoList filenames_;
|
||||
QFileInfoList filenames_;
|
||||
|
||||
int file_count_;
|
||||
int file_count_;
|
||||
|
||||
QStringList invalid_files_;
|
||||
QStringList invalid_files_;
|
||||
|
||||
QList<QString> image_sequence_ignore_files_;
|
||||
|
||||
QVector<Footage*> imported_footage_;
|
||||
QList<QString> image_sequence_ignore_files_;
|
||||
|
||||
QVector<Footage *> imported_footage_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -25,29 +25,33 @@
|
||||
#include <QListWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace olive {
|
||||
|
||||
ProjectImportErrorDialog::ProjectImportErrorDialog(const QStringList& filenames, QWidget* parent) :
|
||||
QDialog(parent)
|
||||
namespace olive
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
setWindowTitle(tr("Import Error"));
|
||||
ProjectImportErrorDialog::ProjectImportErrorDialog(const QStringList &filenames,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
|
||||
layout->addWidget(new QLabel(tr("The following files failed to import. Olive likely does not "
|
||||
"support their formats.")));
|
||||
setWindowTitle(tr("Import Error"));
|
||||
|
||||
QListWidget* list_widget = new QListWidget();
|
||||
foreach (const QString& s, filenames) {
|
||||
list_widget->addItem(s);
|
||||
}
|
||||
layout->addWidget(list_widget);
|
||||
layout->addWidget(new QLabel(
|
||||
tr("The following files failed to import. Olive likely does not "
|
||||
"support their formats.")));
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox();
|
||||
buttons->setStandardButtons(QDialogButtonBox::Ok);
|
||||
buttons->setCenterButtons(true);
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &ProjectImportErrorDialog::accept);
|
||||
layout->addWidget(buttons);
|
||||
QListWidget *list_widget = new QListWidget();
|
||||
foreach (const QString &s, filenames) {
|
||||
list_widget->addItem(s);
|
||||
}
|
||||
layout->addWidget(list_widget);
|
||||
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox();
|
||||
buttons->setStandardButtons(QDialogButtonBox::Ok);
|
||||
buttons->setCenterButtons(true);
|
||||
connect(buttons, &QDialogButtonBox::accepted, this,
|
||||
&ProjectImportErrorDialog::accept);
|
||||
layout->addWidget(buttons);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ProjectImportErrorDialog : public QDialog
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectImportErrorDialog(const QStringList& filenames, QWidget* parent = nullptr);
|
||||
|
||||
class ProjectImportErrorDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectImportErrorDialog(const QStringList &filenames,
|
||||
QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,58 +24,65 @@
|
||||
|
||||
#include "node/project/serializer/serializer.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
ProjectLoadTask::ProjectLoadTask(const QString &filename) :
|
||||
ProjectLoadBaseTask(filename)
|
||||
ProjectLoadTask::ProjectLoadTask(const QString &filename)
|
||||
: ProjectLoadBaseTask(filename)
|
||||
{
|
||||
}
|
||||
|
||||
bool ProjectLoadTask::Run()
|
||||
{
|
||||
project_ = new Project();
|
||||
project_ = new Project();
|
||||
|
||||
project_->set_filename(GetFilename());
|
||||
project_->set_filename(GetFilename());
|
||||
|
||||
ProjectSerializer::Result result = ProjectSerializer::Load(project_, GetFilename(), ProjectSerializer::kProject);
|
||||
ProjectSerializer::Result result = ProjectSerializer::Load(
|
||||
project_, GetFilename(), ProjectSerializer::kProject);
|
||||
|
||||
layout_ = result.GetLoadData().layout;
|
||||
layout_ = result.GetLoadData().layout;
|
||||
|
||||
switch (result.code()) {
|
||||
case ProjectSerializer::kSuccess:
|
||||
break;
|
||||
case ProjectSerializer::kProjectTooOld:
|
||||
SetError(tr("This project is from a version of Olive that is no longer supported in this version."));
|
||||
break;
|
||||
case ProjectSerializer::kProjectTooNew:
|
||||
SetError(tr("This project is from a newer version of Olive and cannot be opened in this version."));
|
||||
break;
|
||||
case ProjectSerializer::kUnknownVersion:
|
||||
SetError(tr("Failed to determine project version."));
|
||||
break;
|
||||
case ProjectSerializer::kFileError:
|
||||
SetError(tr("Failed to read file \"%1\" for reading.").arg(GetFilename()));
|
||||
break;
|
||||
case ProjectSerializer::kXmlError:
|
||||
SetError(tr("Failed to read XML document. File may be corrupt. Error was: %1").arg(result.GetDetails()));
|
||||
break;
|
||||
case ProjectSerializer::kNoData:
|
||||
SetError(tr("Failed to find any data to parse."));
|
||||
break;
|
||||
switch (result.code()) {
|
||||
case ProjectSerializer::kSuccess:
|
||||
break;
|
||||
case ProjectSerializer::kProjectTooOld:
|
||||
SetError(tr(
|
||||
"This project is from a version of Olive that is no longer supported in this version."));
|
||||
break;
|
||||
case ProjectSerializer::kProjectTooNew:
|
||||
SetError(tr(
|
||||
"This project is from a newer version of Olive and cannot be opened in this version."));
|
||||
break;
|
||||
case ProjectSerializer::kUnknownVersion:
|
||||
SetError(tr("Failed to determine project version."));
|
||||
break;
|
||||
case ProjectSerializer::kFileError:
|
||||
SetError(
|
||||
tr("Failed to read file \"%1\" for reading.").arg(GetFilename()));
|
||||
break;
|
||||
case ProjectSerializer::kXmlError:
|
||||
SetError(
|
||||
tr("Failed to read XML document. File may be corrupt. Error was: %1")
|
||||
.arg(result.GetDetails()));
|
||||
break;
|
||||
case ProjectSerializer::kNoData:
|
||||
SetError(tr("Failed to find any data to parse."));
|
||||
break;
|
||||
|
||||
// Errors that should never be thrown by a load
|
||||
case ProjectSerializer::kOverwriteError:
|
||||
SetError(tr("Unknown error."));
|
||||
break;
|
||||
}
|
||||
// Errors that should never be thrown by a load
|
||||
case ProjectSerializer::kOverwriteError:
|
||||
SetError(tr("Unknown error."));
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == ProjectSerializer::kSuccess) {
|
||||
project_->moveToThread(qApp->thread());
|
||||
return true;
|
||||
} else {
|
||||
delete project_;
|
||||
return false;
|
||||
}
|
||||
if (result == ProjectSerializer::kSuccess) {
|
||||
project_->moveToThread(qApp->thread());
|
||||
return true;
|
||||
} else {
|
||||
delete project_;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,17 +24,16 @@
|
||||
#include "loadbasetask.h"
|
||||
#include "window/mainwindow/mainwindowlayoutinfo.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ProjectLoadTask : public ProjectLoadBaseTask
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ProjectLoadTask : public ProjectLoadBaseTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectLoadTask(const QString& filename);
|
||||
ProjectLoadTask(const QString &filename);
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
|
||||
virtual bool Run() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
|
||||
#include "loadbasetask.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ProjectLoadBaseTask::ProjectLoadBaseTask(const QString &filename) :
|
||||
project_(nullptr),
|
||||
filename_(filename)
|
||||
namespace olive
|
||||
{
|
||||
SetTitle(tr("Loading '%1'").arg(filename));
|
||||
|
||||
ProjectLoadBaseTask::ProjectLoadBaseTask(const QString &filename)
|
||||
: project_(nullptr)
|
||||
, filename_(filename)
|
||||
{
|
||||
SetTitle(tr("Loading '%1'").arg(filename));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,37 +24,36 @@
|
||||
#include "node/project.h"
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ProjectLoadBaseTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ProjectLoadBaseTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectLoadBaseTask(const QString& filename);
|
||||
ProjectLoadBaseTask(const QString &filename);
|
||||
|
||||
Project* GetLoadedProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
Project *GetLoadedProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
const QString& GetFilename() const
|
||||
{
|
||||
return filename_;
|
||||
}
|
||||
const QString &GetFilename() const
|
||||
{
|
||||
return filename_;
|
||||
}
|
||||
|
||||
const MainWindowLayoutInfo &GetLoadedLayout() const
|
||||
{
|
||||
return layout_;
|
||||
}
|
||||
const MainWindowLayoutInfo &GetLoadedLayout() const
|
||||
{
|
||||
return layout_;
|
||||
}
|
||||
|
||||
protected:
|
||||
Project* project_;
|
||||
Project *project_;
|
||||
|
||||
MainWindowLayoutInfo layout_;
|
||||
MainWindowLayoutInfo layout_;
|
||||
|
||||
private:
|
||||
QString filename_;
|
||||
|
||||
QString filename_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -47,287 +47,327 @@
|
||||
#include "timeline/timelineundogeneral.h"
|
||||
#include "window/mainwindow/mainwindowundo.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
LoadOTIOTask::LoadOTIOTask(const QString& s) :
|
||||
ProjectLoadBaseTask(s)
|
||||
LoadOTIOTask::LoadOTIOTask(const QString &s)
|
||||
: ProjectLoadBaseTask(s)
|
||||
{
|
||||
}
|
||||
|
||||
bool LoadOTIOTask::Run()
|
||||
{
|
||||
OTIO::ErrorStatus es;
|
||||
OTIO::ErrorStatus es;
|
||||
|
||||
auto root = OTIO::SerializableObjectWithMetadata::from_json_file(GetFilename().toStdString(), &es);
|
||||
auto root = OTIO::SerializableObjectWithMetadata::from_json_file(
|
||||
GetFilename().toStdString(), &es);
|
||||
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
SetError(tr("Failed to load OpenTimelineIO from file \"%1\" \n\nOpenTimelineIO Error:\n\n%2")
|
||||
.arg(GetFilename(), QString::fromStdString(es.full_description)));
|
||||
return false;
|
||||
}
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
SetError(
|
||||
tr("Failed to load OpenTimelineIO from file \"%1\" \n\nOpenTimelineIO Error:\n\n%2")
|
||||
.arg(GetFilename(),
|
||||
QString::fromStdString(es.full_description)));
|
||||
return false;
|
||||
}
|
||||
|
||||
project_ = new Project();
|
||||
project_->Initialize();
|
||||
project_->set_modified(true);
|
||||
project_ = new Project();
|
||||
project_->Initialize();
|
||||
project_->set_modified(true);
|
||||
|
||||
std::vector<OTIO::Timeline*> timelines;
|
||||
std::vector<OTIO::Timeline *> timelines;
|
||||
|
||||
if (root->schema_name() == "SerializableCollection") {
|
||||
// This is a number of timelines
|
||||
std::vector<OTIO::SerializableObject::Retainer<OTIO::SerializableObject>>& root_children = static_cast<OTIO::SerializableCollection*>(root)->children();
|
||||
if (root->schema_name() == "SerializableCollection") {
|
||||
// This is a number of timelines
|
||||
std::vector<OTIO::SerializableObject::Retainer<OTIO::SerializableObject>>
|
||||
&root_children =
|
||||
static_cast<OTIO::SerializableCollection *>(root)->children();
|
||||
|
||||
timelines.resize(root_children.size());
|
||||
for (size_t j=0; j<root_children.size(); j++) {
|
||||
timelines[j] = static_cast<OTIO::Timeline*>(root_children[j].value);
|
||||
}
|
||||
} else if (root->schema_name() == "Timeline") {
|
||||
// This is a single timeline
|
||||
timelines.push_back(static_cast<OTIO::Timeline*>(root));
|
||||
} else {
|
||||
// Unknown root, we don't know what to do with this
|
||||
SetError(tr("Unknown OpenTimelineIO root element"));
|
||||
return false;
|
||||
}
|
||||
timelines.resize(root_children.size());
|
||||
for (size_t j = 0; j < root_children.size(); j++) {
|
||||
timelines[j] =
|
||||
static_cast<OTIO::Timeline *>(root_children[j].value);
|
||||
}
|
||||
} else if (root->schema_name() == "Timeline") {
|
||||
// This is a single timeline
|
||||
timelines.push_back(static_cast<OTIO::Timeline *>(root));
|
||||
} else {
|
||||
// Unknown root, we don't know what to do with this
|
||||
SetError(tr("Unknown OpenTimelineIO root element"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Keep track of imported footage
|
||||
QMap<QString, Footage*> imported_footage;
|
||||
QMap<OTIO::Timeline*, Sequence*> timeline_sequnce_map;
|
||||
// Keep track of imported footage
|
||||
QMap<QString, Footage *> imported_footage;
|
||||
QMap<OTIO::Timeline *, Sequence *> timeline_sequnce_map;
|
||||
|
||||
// Variables used for loading bar
|
||||
float number_of_clips = 0;
|
||||
float clips_done = 0;
|
||||
// Variables used for loading bar
|
||||
float number_of_clips = 0;
|
||||
float clips_done = 0;
|
||||
|
||||
// Generate a list of sequences with the same names as the timelines.
|
||||
// Assumes each timeline has a unique name.
|
||||
int unnamed_sequence_count = 0;
|
||||
foreach (auto timeline, timelines) {
|
||||
Sequence* sequence = new Sequence();
|
||||
if (!timeline->name().empty()) {
|
||||
sequence->SetLabel(QString::fromStdString(timeline->name()));
|
||||
} else {
|
||||
// If the otio timeline does not provide a name, create a default one here
|
||||
unnamed_sequence_count++;
|
||||
QString label = tr("Sequence %1").arg(unnamed_sequence_count);
|
||||
sequence->SetLabel(QString::fromStdString(label.toStdString()));
|
||||
}
|
||||
// Set default params incase they aren't edited.
|
||||
sequence->set_default_parameters();
|
||||
timeline_sequnce_map.insert(timeline, sequence);
|
||||
// Generate a list of sequences with the same names as the timelines.
|
||||
// Assumes each timeline has a unique name.
|
||||
int unnamed_sequence_count = 0;
|
||||
foreach (auto timeline, timelines) {
|
||||
Sequence *sequence = new Sequence();
|
||||
if (!timeline->name().empty()) {
|
||||
sequence->SetLabel(QString::fromStdString(timeline->name()));
|
||||
} else {
|
||||
// If the otio timeline does not provide a name, create a default one here
|
||||
unnamed_sequence_count++;
|
||||
QString label = tr("Sequence %1").arg(unnamed_sequence_count);
|
||||
sequence->SetLabel(QString::fromStdString(label.toStdString()));
|
||||
}
|
||||
// Set default params incase they aren't edited.
|
||||
sequence->set_default_parameters();
|
||||
timeline_sequnce_map.insert(timeline, sequence);
|
||||
|
||||
// Get number of clips for loading bar
|
||||
foreach (auto track, timeline->tracks()->children()) {
|
||||
auto otio_track = static_cast<OTIO::Track*>(track.value);
|
||||
number_of_clips += otio_track->children().size();
|
||||
}
|
||||
}
|
||||
// Get number of clips for loading bar
|
||||
foreach (auto track, timeline->tracks()->children()) {
|
||||
auto otio_track = static_cast<OTIO::Track *>(track.value);
|
||||
number_of_clips += otio_track->children().size();
|
||||
}
|
||||
}
|
||||
|
||||
// Dialog has to be called from the main thread so we pass the list of sequences here.
|
||||
bool accepted = false;
|
||||
QMetaObject::invokeMethod(Core::instance(),
|
||||
"DialogImportOTIOShow",
|
||||
Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, accepted),
|
||||
Q_ARG(QList<Sequence*>,timeline_sequnce_map.values()));
|
||||
// Dialog has to be called from the main thread so we pass the list of sequences here.
|
||||
bool accepted = false;
|
||||
QMetaObject::invokeMethod(
|
||||
Core::instance(), "DialogImportOTIOShow", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, accepted),
|
||||
Q_ARG(QList<Sequence *>, timeline_sequnce_map.values()));
|
||||
|
||||
if (!accepted) {
|
||||
// Cancel to indicate to caller that this task did not complete and to simply dispose of it
|
||||
Cancel();
|
||||
qDeleteAll(timeline_sequnce_map); // Clear sequences
|
||||
return true;
|
||||
}
|
||||
if (!accepted) {
|
||||
// Cancel to indicate to caller that this task did not complete and to simply dispose of it
|
||||
Cancel();
|
||||
qDeleteAll(timeline_sequnce_map); // Clear sequences
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (auto timeline, timeline_sequnce_map.keys()) {
|
||||
Sequence* sequence = timeline_sequnce_map.value(timeline);
|
||||
sequence->setParent(project_);
|
||||
FolderAddChild(project_->root(), sequence).redo_now();
|
||||
foreach (auto timeline, timeline_sequnce_map.keys()) {
|
||||
Sequence *sequence = timeline_sequnce_map.value(timeline);
|
||||
sequence->setParent(project_);
|
||||
FolderAddChild(project_->root(), sequence).redo_now();
|
||||
|
||||
// Create a folder for this sequence's footage
|
||||
Folder* sequence_footage = new Folder();
|
||||
sequence_footage->SetLabel(QString::fromStdString(timeline->name()));
|
||||
sequence_footage->setParent(project_);
|
||||
FolderAddChild(project_->root(), sequence_footage).redo_now();
|
||||
// Create a folder for this sequence's footage
|
||||
Folder *sequence_footage = new Folder();
|
||||
sequence_footage->SetLabel(QString::fromStdString(timeline->name()));
|
||||
sequence_footage->setParent(project_);
|
||||
FolderAddChild(project_->root(), sequence_footage).redo_now();
|
||||
|
||||
// Iterate through tracks
|
||||
for (auto c : timeline->tracks()->children()) {
|
||||
auto otio_track = static_cast<OTIO::Track*>(c.value);
|
||||
// Iterate through tracks
|
||||
for (auto c : timeline->tracks()->children()) {
|
||||
auto otio_track = static_cast<OTIO::Track *>(c.value);
|
||||
|
||||
// Create a new track
|
||||
Track* track = nullptr;
|
||||
// Create a new track
|
||||
Track *track = nullptr;
|
||||
|
||||
// Determine what kind of track it is
|
||||
if (otio_track->kind() == "Video" || otio_track->kind() == "Audio") {
|
||||
Track::Type type;
|
||||
// Determine what kind of track it is
|
||||
if (otio_track->kind() == "Video" ||
|
||||
otio_track->kind() == "Audio") {
|
||||
Track::Type type;
|
||||
|
||||
if (otio_track->kind() == "Video") {
|
||||
type = Track::kVideo;
|
||||
} else {
|
||||
type = Track::kAudio;
|
||||
}
|
||||
if (otio_track->kind() == "Video") {
|
||||
type = Track::kVideo;
|
||||
} else {
|
||||
type = Track::kAudio;
|
||||
}
|
||||
|
||||
// Create track
|
||||
TimelineAddTrackCommand t(sequence->track_list(type));
|
||||
t.redo_now();
|
||||
track = t.track();
|
||||
} else {
|
||||
qWarning() << "Found unknown track type:" << otio_track->kind().c_str();
|
||||
continue;
|
||||
}
|
||||
// Create track
|
||||
TimelineAddTrackCommand t(sequence->track_list(type));
|
||||
t.redo_now();
|
||||
track = t.track();
|
||||
} else {
|
||||
qWarning() << "Found unknown track type:"
|
||||
<< otio_track->kind().c_str();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get clips from track
|
||||
auto clip_map = otio_track->children();
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
SetError(tr("Failed to load clip"));
|
||||
return false;
|
||||
}
|
||||
// Get clips from track
|
||||
auto clip_map = otio_track->children();
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
SetError(tr("Failed to load clip"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Block* previous_block = nullptr;
|
||||
bool prev_block_transition = false;
|
||||
Block *previous_block = nullptr;
|
||||
bool prev_block_transition = false;
|
||||
|
||||
for (auto otio_block_retainer : clip_map) {
|
||||
for (auto otio_block_retainer : clip_map) {
|
||||
auto otio_block = otio_block_retainer.value;
|
||||
|
||||
auto otio_block = otio_block_retainer.value;
|
||||
Block *block = nullptr;
|
||||
|
||||
Block* block = nullptr;
|
||||
if (otio_block->schema_name() == "Clip") {
|
||||
block = new ClipBlock();
|
||||
|
||||
if (otio_block->schema_name() == "Clip") {
|
||||
} else if (otio_block->schema_name() == "Gap") {
|
||||
block = new GapBlock();
|
||||
|
||||
block = new ClipBlock();
|
||||
} else if (otio_block->schema_name() == "Transition") {
|
||||
// Todo: Look into OTIO supported transitions and add them to Olive
|
||||
block = new CrossDissolveTransition();
|
||||
|
||||
} else if (otio_block->schema_name() == "Gap") {
|
||||
} else {
|
||||
// We don't know what this is yet, just create a gap for now so that *something* is there
|
||||
qWarning() << "Found unknown block type:"
|
||||
<< otio_block->schema_name().c_str();
|
||||
block = new GapBlock();
|
||||
}
|
||||
|
||||
block = new GapBlock();
|
||||
block->setParent(project_);
|
||||
block->SetLabel(QString::fromStdString(otio_block->name()));
|
||||
|
||||
} else if (otio_block->schema_name() == "Transition") {
|
||||
track->AppendBlock(block);
|
||||
|
||||
// Todo: Look into OTIO supported transitions and add them to Olive
|
||||
block = new CrossDissolveTransition();
|
||||
rational start_time;
|
||||
rational duration;
|
||||
|
||||
} else {
|
||||
if (otio_block->schema_name() == "Clip" ||
|
||||
otio_block->schema_name() == "Gap") {
|
||||
start_time = rational::fromDouble(
|
||||
static_cast<OTIO::Item *>(otio_block)
|
||||
->source_range()
|
||||
->start_time()
|
||||
.to_seconds());
|
||||
duration = rational::fromDouble(
|
||||
static_cast<OTIO::Item *>(otio_block)
|
||||
->source_range()
|
||||
->duration()
|
||||
.to_seconds());
|
||||
|
||||
// We don't know what this is yet, just create a gap for now so that *something* is there
|
||||
qWarning() << "Found unknown block type:" << otio_block->schema_name().c_str();
|
||||
block = new GapBlock();
|
||||
}
|
||||
if (otio_block->schema_name() == "Clip") {
|
||||
static_cast<ClipBlock *>(block)->set_media_in(
|
||||
start_time);
|
||||
}
|
||||
block->set_length_and_media_out(duration);
|
||||
}
|
||||
|
||||
block->setParent(project_);
|
||||
block->SetLabel(QString::fromStdString(otio_block->name()));
|
||||
// If the previous block was a transition, connect the current block to it
|
||||
if (prev_block_transition) {
|
||||
TransitionBlock *previous_transition_block =
|
||||
static_cast<TransitionBlock *>(previous_block);
|
||||
Node::ConnectEdge(
|
||||
block, NodeInput(previous_transition_block,
|
||||
TransitionBlock::kInBlockInput));
|
||||
prev_block_transition = false;
|
||||
}
|
||||
|
||||
track->AppendBlock(block);
|
||||
if (otio_block->schema_name() == "Transition") {
|
||||
TransitionBlock *transition_block =
|
||||
static_cast<TransitionBlock *>(block);
|
||||
OTIO::Transition *otio_block_transition =
|
||||
static_cast<OTIO::Transition *>(otio_block);
|
||||
|
||||
rational start_time;
|
||||
rational duration;
|
||||
// Set how far the transition eats into the previous clip
|
||||
transition_block->set_offsets_and_length(
|
||||
rational::fromRationalTime(
|
||||
otio_block_transition->in_offset()),
|
||||
rational::fromRationalTime(
|
||||
otio_block_transition->out_offset()));
|
||||
|
||||
if (otio_block->schema_name() == "Clip" || otio_block->schema_name() == "Gap") {
|
||||
start_time =
|
||||
rational::fromDouble(static_cast<OTIO::Item*>(otio_block)->source_range()->start_time().to_seconds());
|
||||
duration =
|
||||
rational::fromDouble(static_cast<OTIO::Item*>(otio_block)->source_range()->duration().to_seconds());
|
||||
if (previous_block) {
|
||||
Node::ConnectEdge(
|
||||
previous_block,
|
||||
NodeInput(transition_block,
|
||||
TransitionBlock::kOutBlockInput));
|
||||
}
|
||||
prev_block_transition = true;
|
||||
|
||||
if (otio_block->schema_name() == "Clip") {
|
||||
static_cast<ClipBlock*>(block)->set_media_in(start_time);
|
||||
}
|
||||
block->set_length_and_media_out(duration);
|
||||
}
|
||||
// Add nodes to the graph and set up contexts
|
||||
block->setParent(sequence->parent());
|
||||
|
||||
// If the previous block was a transition, connect the current block to it
|
||||
if (prev_block_transition) {
|
||||
TransitionBlock* previous_transition_block = static_cast<TransitionBlock*>(previous_block);
|
||||
Node::ConnectEdge(block, NodeInput(previous_transition_block, TransitionBlock::kInBlockInput));
|
||||
prev_block_transition = false;
|
||||
}
|
||||
// Position transition in its own context
|
||||
block->SetNodePositionInContext(block, QPointF(0, 0));
|
||||
}
|
||||
|
||||
if (otio_block->schema_name() == "Transition") {
|
||||
TransitionBlock* transition_block = static_cast<TransitionBlock*>(block);
|
||||
OTIO::Transition* otio_block_transition = static_cast<OTIO::Transition*>(otio_block);
|
||||
if (otio_block->schema_name() == "Gap") {
|
||||
// Add nodes to the graph and set up contexts
|
||||
block->setParent(sequence->parent());
|
||||
|
||||
// Set how far the transition eats into the previous clip
|
||||
transition_block->set_offsets_and_length(rational::fromRationalTime(otio_block_transition->in_offset()), rational::fromRationalTime(otio_block_transition->out_offset()));
|
||||
// Position transition in its own context
|
||||
block->SetNodePositionInContext(block, QPointF(0, 0));
|
||||
}
|
||||
|
||||
if (previous_block) {
|
||||
Node::ConnectEdge(previous_block, NodeInput(transition_block, TransitionBlock::kOutBlockInput));
|
||||
}
|
||||
prev_block_transition = true;
|
||||
// Update this after it's used but before any continue statements
|
||||
previous_block = block;
|
||||
|
||||
// Add nodes to the graph and set up contexts
|
||||
block->setParent(sequence->parent());
|
||||
if (otio_block->schema_name() == "Clip") {
|
||||
auto otio_clip = static_cast<OTIO::Clip *>(otio_block);
|
||||
if (!otio_clip->media_reference()) {
|
||||
continue;
|
||||
}
|
||||
if (otio_clip->media_reference()->schema_name() ==
|
||||
"ExternalReference") {
|
||||
// Link footage
|
||||
QString footage_url = QString::fromStdString(
|
||||
static_cast<OTIO::ExternalReference *>(
|
||||
otio_clip->media_reference())
|
||||
->target_url());
|
||||
|
||||
// Position transition in its own context
|
||||
block->SetNodePositionInContext(block, QPointF(0, 0));
|
||||
}
|
||||
Footage *probed_item;
|
||||
|
||||
if (otio_block->schema_name() == "Gap") {
|
||||
// Add nodes to the graph and set up contexts
|
||||
block->setParent(sequence->parent());
|
||||
if (imported_footage.contains(footage_url)) {
|
||||
probed_item = imported_footage.value(footage_url);
|
||||
} else {
|
||||
probed_item = new Footage(footage_url);
|
||||
imported_footage.insert(footage_url, probed_item);
|
||||
probed_item->setParent(project_);
|
||||
|
||||
// Position transition in its own context
|
||||
block->SetNodePositionInContext(block, QPointF(0, 0));
|
||||
}
|
||||
QFileInfo info(probed_item->filename());
|
||||
probed_item->SetLabel(info.fileName());
|
||||
|
||||
// Update this after it's used but before any continue statements
|
||||
previous_block = block;
|
||||
FolderAddChild add(sequence_footage, probed_item);
|
||||
add.redo_now();
|
||||
}
|
||||
|
||||
if (otio_block->schema_name() == "Clip") {
|
||||
auto otio_clip = static_cast<OTIO::Clip*>(otio_block);
|
||||
if (!otio_clip->media_reference()) {
|
||||
continue;
|
||||
}
|
||||
if (otio_clip->media_reference()->schema_name() == "ExternalReference") {
|
||||
// Link footage
|
||||
QString footage_url = QString::fromStdString(static_cast<OTIO::ExternalReference*>(otio_clip->media_reference())->target_url());
|
||||
// Add nodes to the graph and set up contexts
|
||||
block->setParent(sequence->parent());
|
||||
|
||||
Footage* probed_item;
|
||||
// Position clip in its own context
|
||||
block->SetNodePositionInContext(block, QPointF(0, 0));
|
||||
|
||||
if (imported_footage.contains(footage_url)) {
|
||||
probed_item = imported_footage.value(footage_url);
|
||||
} else {
|
||||
probed_item = new Footage(footage_url);
|
||||
imported_footage.insert(footage_url, probed_item);
|
||||
probed_item->setParent(project_);
|
||||
// Position footage in its context
|
||||
block->SetNodePositionInContext(probed_item,
|
||||
QPointF(-2, 0));
|
||||
|
||||
if (track->type() == Track::kVideo) {
|
||||
TransformDistortNode *transform =
|
||||
new TransformDistortNode();
|
||||
transform->setParent(sequence->parent());
|
||||
|
||||
QFileInfo info(probed_item->filename());
|
||||
probed_item->SetLabel(info.fileName());
|
||||
Node::ConnectEdge(
|
||||
probed_item,
|
||||
NodeInput(transform,
|
||||
TransformDistortNode::kTextureInput));
|
||||
Node::ConnectEdge(transform,
|
||||
NodeInput(block,
|
||||
ClipBlock::kBufferIn));
|
||||
block->SetNodePositionInContext(transform,
|
||||
QPointF(-1, 0));
|
||||
} else {
|
||||
VolumeNode *volume_node = new VolumeNode();
|
||||
volume_node->setParent(sequence->parent());
|
||||
|
||||
FolderAddChild add(sequence_footage, probed_item);
|
||||
add.redo_now();
|
||||
}
|
||||
Node::ConnectEdge(
|
||||
probed_item,
|
||||
NodeInput(volume_node,
|
||||
VolumeNode::kSamplesInput));
|
||||
Node::ConnectEdge(volume_node,
|
||||
NodeInput(block,
|
||||
ClipBlock::kBufferIn));
|
||||
block->SetNodePositionInContext(volume_node,
|
||||
QPointF(-1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
clips_done++;
|
||||
emit ProgressChanged(clips_done / number_of_clips);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add nodes to the graph and set up contexts
|
||||
block->setParent(sequence->parent());
|
||||
project_->moveToThread(qApp->thread());
|
||||
|
||||
// Position clip in its own context
|
||||
block->SetNodePositionInContext(block, QPointF(0, 0));
|
||||
|
||||
// Position footage in its context
|
||||
block->SetNodePositionInContext(probed_item, QPointF(-2, 0));
|
||||
|
||||
|
||||
if (track->type() == Track::kVideo) {
|
||||
TransformDistortNode* transform = new TransformDistortNode();
|
||||
transform->setParent(sequence->parent());
|
||||
|
||||
Node::ConnectEdge(probed_item, NodeInput(transform, TransformDistortNode::kTextureInput));
|
||||
Node::ConnectEdge(transform, NodeInput(block, ClipBlock::kBufferIn));
|
||||
block->SetNodePositionInContext(transform, QPointF(-1, 0));
|
||||
} else {
|
||||
VolumeNode* volume_node = new VolumeNode();
|
||||
volume_node->setParent(sequence->parent());
|
||||
|
||||
Node::ConnectEdge(probed_item, NodeInput(volume_node, VolumeNode::kSamplesInput));
|
||||
Node::ConnectEdge(volume_node, NodeInput(block, ClipBlock::kBufferIn));
|
||||
block->SetNodePositionInContext(volume_node, QPointF(-1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
clips_done++;
|
||||
emit ProgressChanged(clips_done / number_of_clips);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project_->moveToThread(qApp->thread());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,17 +27,16 @@
|
||||
#include "node/project.h"
|
||||
#include "task/project/load/loadbasetask.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class LoadOTIOTask : public ProjectLoadBaseTask
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class LoadOTIOTask : public ProjectLoadBaseTask {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoadOTIOTask(const QString& filename);
|
||||
LoadOTIOTask(const QString &filename);
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
|
||||
virtual bool Run() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,55 +28,61 @@
|
||||
#include "core.h"
|
||||
#include "node/project/serializer/serializer.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
ProjectSaveTask::ProjectSaveTask(Project *project, bool use_compression) :
|
||||
project_(project),
|
||||
use_compression_(use_compression)
|
||||
namespace olive
|
||||
{
|
||||
SetTitle(tr("Saving '%1'").arg(project->filename()));
|
||||
|
||||
ProjectSaveTask::ProjectSaveTask(Project *project, bool use_compression)
|
||||
: project_(project)
|
||||
, use_compression_(use_compression)
|
||||
{
|
||||
SetTitle(tr("Saving '%1'").arg(project->filename()));
|
||||
}
|
||||
|
||||
bool ProjectSaveTask::Run()
|
||||
{
|
||||
QString using_filename = override_filename_.isEmpty() ? project_->filename() : override_filename_;
|
||||
QString using_filename = override_filename_.isEmpty() ?
|
||||
project_->filename() :
|
||||
override_filename_;
|
||||
|
||||
ProjectSerializer::SaveData data(ProjectSerializer::kProject);
|
||||
ProjectSerializer::SaveData data(ProjectSerializer::kProject);
|
||||
|
||||
data.SetFilename(using_filename);
|
||||
data.SetProject(project_);
|
||||
data.SetLayout(layout_);
|
||||
data.SetFilename(using_filename);
|
||||
data.SetProject(project_);
|
||||
data.SetLayout(layout_);
|
||||
|
||||
ProjectSerializer::Result result = ProjectSerializer::Save(data, use_compression_);
|
||||
ProjectSerializer::Result result =
|
||||
ProjectSerializer::Save(data, use_compression_);
|
||||
|
||||
bool success = false;
|
||||
bool success = false;
|
||||
|
||||
switch (result.code()) {
|
||||
case ProjectSerializer::kSuccess:
|
||||
success = true;
|
||||
break;
|
||||
case ProjectSerializer::kXmlError:
|
||||
SetError(tr("Failed to write XML data."));
|
||||
break;
|
||||
case ProjectSerializer::kFileError:
|
||||
SetError(tr("Failed to open file \"%1\" for writing.").arg(result.GetDetails()));
|
||||
break;
|
||||
case ProjectSerializer::kOverwriteError:
|
||||
SetError(tr("Failed to overwrite \"%1\". Project has been saved as \"%2\" instead.")
|
||||
.arg(using_filename, result.GetDetails()));
|
||||
success = true;
|
||||
break;
|
||||
switch (result.code()) {
|
||||
case ProjectSerializer::kSuccess:
|
||||
success = true;
|
||||
break;
|
||||
case ProjectSerializer::kXmlError:
|
||||
SetError(tr("Failed to write XML data."));
|
||||
break;
|
||||
case ProjectSerializer::kFileError:
|
||||
SetError(tr("Failed to open file \"%1\" for writing.")
|
||||
.arg(result.GetDetails()));
|
||||
break;
|
||||
case ProjectSerializer::kOverwriteError:
|
||||
SetError(
|
||||
tr("Failed to overwrite \"%1\". Project has been saved as \"%2\" instead.")
|
||||
.arg(using_filename, result.GetDetails()));
|
||||
success = true;
|
||||
break;
|
||||
|
||||
// Errors that should never be thrown by a save
|
||||
case ProjectSerializer::kProjectTooNew:
|
||||
case ProjectSerializer::kProjectTooOld:
|
||||
case ProjectSerializer::kUnknownVersion:
|
||||
case ProjectSerializer::kNoData:
|
||||
SetError(tr("Unknown error."));
|
||||
break;
|
||||
}
|
||||
// Errors that should never be thrown by a save
|
||||
case ProjectSerializer::kProjectTooNew:
|
||||
case ProjectSerializer::kProjectTooOld:
|
||||
case ProjectSerializer::kUnknownVersion:
|
||||
case ProjectSerializer::kNoData:
|
||||
SetError(tr("Unknown error."));
|
||||
break;
|
||||
}
|
||||
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,41 +24,40 @@
|
||||
#include "node/project.h"
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ProjectSaveTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class ProjectSaveTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectSaveTask(Project* project, bool use_compression);
|
||||
ProjectSaveTask(Project *project, bool use_compression);
|
||||
|
||||
Project* GetProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
Project *GetProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
void SetOverrideFilename(const QString& filename)
|
||||
{
|
||||
override_filename_ = filename;
|
||||
}
|
||||
void SetOverrideFilename(const QString &filename)
|
||||
{
|
||||
override_filename_ = filename;
|
||||
}
|
||||
|
||||
void SetLayout(const MainWindowLayoutInfo &layout)
|
||||
{
|
||||
layout_ = layout;
|
||||
}
|
||||
void SetLayout(const MainWindowLayoutInfo &layout)
|
||||
{
|
||||
layout_ = layout;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
Project *project_;
|
||||
|
||||
QString override_filename_;
|
||||
QString override_filename_;
|
||||
|
||||
bool use_compression_;
|
||||
|
||||
MainWindowLayoutInfo layout_;
|
||||
bool use_compression_;
|
||||
|
||||
MainWindowLayoutInfo layout_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -34,213 +34,242 @@
|
||||
#include "node/block/transition/transition.h"
|
||||
#include "node/project/footage/footage.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
SaveOTIOTask::SaveOTIOTask(Project *project) :
|
||||
project_(project)
|
||||
namespace olive
|
||||
{
|
||||
SetTitle(tr("Exporting project to OpenTimelineIO"));
|
||||
|
||||
SaveOTIOTask::SaveOTIOTask(Project *project)
|
||||
: project_(project)
|
||||
{
|
||||
SetTitle(tr("Exporting project to OpenTimelineIO"));
|
||||
}
|
||||
|
||||
bool SaveOTIOTask::Run()
|
||||
{
|
||||
QVector<Sequence*> sequences = project_->root()->ListChildrenOfType<Sequence>();
|
||||
QVector<Sequence *> sequences =
|
||||
project_->root()->ListChildrenOfType<Sequence>();
|
||||
|
||||
if (sequences.isEmpty()) {
|
||||
SetError(tr("Project contains no sequences to export."));
|
||||
return false;
|
||||
}
|
||||
if (sequences.isEmpty()) {
|
||||
SetError(tr("Project contains no sequences to export."));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<OTIO::SerializableObject*> serialized;
|
||||
std::vector<OTIO::SerializableObject *> serialized;
|
||||
|
||||
foreach (Sequence* seq, sequences) {
|
||||
auto otio_timeline = SerializeTimeline(seq);
|
||||
foreach (Sequence *seq, sequences) {
|
||||
auto otio_timeline = SerializeTimeline(seq);
|
||||
|
||||
if (otio_timeline) {
|
||||
// Append to list
|
||||
serialized.push_back(otio_timeline);
|
||||
} else {
|
||||
// Delete all existing timelines
|
||||
foreach (auto s, serialized) {
|
||||
s->possibly_delete();
|
||||
}
|
||||
if (otio_timeline) {
|
||||
// Append to list
|
||||
serialized.push_back(otio_timeline);
|
||||
} else {
|
||||
// Delete all existing timelines
|
||||
foreach (auto s, serialized) {
|
||||
s->possibly_delete();
|
||||
}
|
||||
|
||||
// Error out of function
|
||||
SetError(tr("Failed to serialize sequence \"%1\"").arg(seq->GetLabel()));
|
||||
// Error out of function
|
||||
SetError(
|
||||
tr("Failed to serialize sequence \"%1\"").arg(seq->GetLabel()));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
OTIO::ErrorStatus es;
|
||||
OTIO::ErrorStatus es;
|
||||
|
||||
if (serialized.size() == 1) {
|
||||
// Serialize timeline on its own
|
||||
auto t = serialized.front();
|
||||
t->to_json_file(project_->filename().toStdString(), &es);
|
||||
t->possibly_delete();
|
||||
} else {
|
||||
// Serialize all into a SerializableCollection
|
||||
auto collection = new OTIO::SerializableCollection("Sequences", serialized);
|
||||
collection->to_json_file(project_->filename().toStdString(), &es);
|
||||
collection->possibly_delete();
|
||||
if (serialized.size() == 1) {
|
||||
// Serialize timeline on its own
|
||||
auto t = serialized.front();
|
||||
t->to_json_file(project_->filename().toStdString(), &es);
|
||||
t->possibly_delete();
|
||||
} else {
|
||||
// Serialize all into a SerializableCollection
|
||||
auto collection =
|
||||
new OTIO::SerializableCollection("Sequences", serialized);
|
||||
collection->to_json_file(project_->filename().toStdString(), &es);
|
||||
collection->possibly_delete();
|
||||
|
||||
// Delete all existing timelines
|
||||
foreach (auto s, serialized) {
|
||||
s->possibly_delete();
|
||||
}
|
||||
}
|
||||
// Delete all existing timelines
|
||||
foreach (auto s, serialized) {
|
||||
s->possibly_delete();
|
||||
}
|
||||
}
|
||||
|
||||
return (es.outcome == OTIO::ErrorStatus::Outcome::OK);
|
||||
return (es.outcome == OTIO::ErrorStatus::Outcome::OK);
|
||||
}
|
||||
|
||||
OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
|
||||
{
|
||||
auto otio_timeline = new OTIO::Timeline(sequence->GetLabel().toStdString());
|
||||
// Retainers clean themselves up when the final user is removed
|
||||
OTIO::Timeline::Retainer<OTIO::Timeline>* timeline_retainer = new OTIO::Timeline::Retainer<OTIO::Timeline>(otio_timeline);
|
||||
// Suppress unused variable warning
|
||||
Q_UNUSED(timeline_retainer);
|
||||
auto otio_timeline = new OTIO::Timeline(sequence->GetLabel().toStdString());
|
||||
// Retainers clean themselves up when the final user is removed
|
||||
OTIO::Timeline::Retainer<OTIO::Timeline> *timeline_retainer =
|
||||
new OTIO::Timeline::Retainer<OTIO::Timeline>(otio_timeline);
|
||||
// Suppress unused variable warning
|
||||
Q_UNUSED(timeline_retainer);
|
||||
|
||||
double rate = sequence->GetVideoParams().frame_rate().toDouble();
|
||||
if (qIsNaN(rate)) {
|
||||
return nullptr;
|
||||
}
|
||||
double rate = sequence->GetVideoParams().frame_rate().toDouble();
|
||||
if (qIsNaN(rate)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!SerializeTrackList(sequence->track_list(Track::kVideo), otio_timeline, rate)
|
||||
|| !SerializeTrackList(sequence->track_list(Track::kAudio), otio_timeline, rate)) {
|
||||
otio_timeline->possibly_delete();
|
||||
return nullptr;
|
||||
}
|
||||
if (!SerializeTrackList(sequence->track_list(Track::kVideo), otio_timeline,
|
||||
rate) ||
|
||||
!SerializeTrackList(sequence->track_list(Track::kAudio), otio_timeline,
|
||||
rate)) {
|
||||
otio_timeline->possibly_delete();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return otio_timeline;
|
||||
return otio_timeline;
|
||||
}
|
||||
|
||||
OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track, double sequence_rate, rational max_track_length)
|
||||
OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track, double sequence_rate,
|
||||
rational max_track_length)
|
||||
{
|
||||
auto otio_track = new OTIO::Track();
|
||||
auto otio_track = new OTIO::Track();
|
||||
|
||||
OTIO::ErrorStatus es;
|
||||
OTIO::ErrorStatus es;
|
||||
|
||||
switch (track->type()) {
|
||||
case Track::kVideo:
|
||||
otio_track->set_kind("Video");
|
||||
break;
|
||||
case Track::kAudio:
|
||||
otio_track->set_kind("Audio");
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Don't know OTIO track kind for native type" << track->type();
|
||||
goto fail;
|
||||
}
|
||||
switch (track->type()) {
|
||||
case Track::kVideo:
|
||||
otio_track->set_kind("Video");
|
||||
break;
|
||||
case Track::kAudio:
|
||||
otio_track->set_kind("Audio");
|
||||
break;
|
||||
default:
|
||||
qWarning()
|
||||
<< "Don't know OTIO track kind for native type" << track->type();
|
||||
goto fail;
|
||||
}
|
||||
|
||||
foreach (Block* block, track->Blocks()) {
|
||||
OTIO::Composable* otio_block = nullptr;
|
||||
foreach (Block *block, track->Blocks()) {
|
||||
OTIO::Composable *otio_block = nullptr;
|
||||
|
||||
if (dynamic_cast<ClipBlock*>(block)) {
|
||||
auto otio_clip = new OTIO::Clip(block->GetLabel().toStdString());
|
||||
if (dynamic_cast<ClipBlock *>(block)) {
|
||||
auto otio_clip = new OTIO::Clip(block->GetLabel().toStdString());
|
||||
|
||||
otio_clip->set_source_range(OTIO::TimeRange(block->in().toRationalTime(sequence_rate),
|
||||
block->length().toRationalTime(sequence_rate)));
|
||||
otio_clip->set_source_range(
|
||||
OTIO::TimeRange(block->in().toRationalTime(sequence_rate),
|
||||
block->length().toRationalTime(sequence_rate)));
|
||||
|
||||
QVector<Footage*> media_nodes = block->FindInputNodes<Footage>();
|
||||
if (!media_nodes.isEmpty()) {
|
||||
QVector<Footage *> media_nodes = block->FindInputNodes<Footage>();
|
||||
if (!media_nodes.isEmpty()) {
|
||||
OTIO::TimeRange available_range;
|
||||
if (otio_track->kind().compare("Video") == 0) {
|
||||
// OTIO ExternalReference uses the source clips frame rate (or sample rate) as opposed to
|
||||
// the sequences rate
|
||||
double source_frame_rate = static_cast<ClipBlock *>(block)
|
||||
->connected_viewer()
|
||||
->GetVideoParams()
|
||||
.frame_rate()
|
||||
.toDouble();
|
||||
available_range = OTIO::TimeRange(
|
||||
OTIO::RationalTime(0, source_frame_rate),
|
||||
OTIO::RationalTime(
|
||||
media_nodes.first()->GetVideoParams().duration(),
|
||||
source_frame_rate));
|
||||
} else if (otio_track->kind().compare("Audio") == 0) {
|
||||
available_range = OTIO::TimeRange(
|
||||
OTIO::RationalTime(
|
||||
0,
|
||||
media_nodes.first()->GetAudioParams().sample_rate()),
|
||||
OTIO::RationalTime(
|
||||
media_nodes.first()->GetAudioParams().duration(),
|
||||
media_nodes.first()->GetAudioParams().sample_rate()));
|
||||
}
|
||||
auto media_ref = new OTIO::ExternalReference(
|
||||
media_nodes.first()->filename().toStdString(),
|
||||
available_range);
|
||||
otio_clip->set_media_reference(media_ref);
|
||||
}
|
||||
|
||||
OTIO::TimeRange available_range;
|
||||
if (otio_track->kind().compare("Video") == 0) {
|
||||
// OTIO ExternalReference uses the source clips frame rate (or sample rate) as opposed to
|
||||
// the sequences rate
|
||||
double source_frame_rate = static_cast<ClipBlock*>(block)->connected_viewer()->GetVideoParams().frame_rate().toDouble();
|
||||
available_range = OTIO::TimeRange(OTIO::RationalTime(0, source_frame_rate),
|
||||
OTIO::RationalTime(media_nodes.first()->GetVideoParams().duration(),
|
||||
source_frame_rate));
|
||||
} else if (otio_track->kind().compare("Audio") == 0) {
|
||||
available_range = OTIO::TimeRange(OTIO::RationalTime(0, media_nodes.first()->GetAudioParams().sample_rate()),
|
||||
OTIO::RationalTime(media_nodes.first()->GetAudioParams().duration(),
|
||||
media_nodes.first()->GetAudioParams().sample_rate()));
|
||||
}
|
||||
auto media_ref = new OTIO::ExternalReference(media_nodes.first()->filename().toStdString(), available_range);
|
||||
otio_clip->set_media_reference(media_ref);
|
||||
}
|
||||
otio_block = otio_clip;
|
||||
} else if (dynamic_cast<GapBlock *>(block)) {
|
||||
otio_block =
|
||||
new OTIO::Gap(OTIO::TimeRange(block->in().toRationalTime(),
|
||||
block->length().toRationalTime()),
|
||||
block->GetLabel().toStdString());
|
||||
} else if (dynamic_cast<TransitionBlock *>(block)) {
|
||||
auto otio_transition =
|
||||
new OTIO::Transition(block->GetLabel().toStdString());
|
||||
|
||||
otio_block = otio_clip;
|
||||
} else if (dynamic_cast<GapBlock*>(block)) {
|
||||
otio_block = new OTIO::Gap(OTIO::TimeRange(block->in().toRationalTime(),
|
||||
block->length().toRationalTime()),
|
||||
block->GetLabel().toStdString()
|
||||
);
|
||||
} else if (dynamic_cast<TransitionBlock*>(block)) {
|
||||
auto otio_transition = new OTIO::Transition(block->GetLabel().toStdString());
|
||||
TransitionBlock *our_transition =
|
||||
static_cast<TransitionBlock *>(block);
|
||||
|
||||
TransitionBlock* our_transition = static_cast<TransitionBlock*>(block);
|
||||
otio_transition->set_in_offset(
|
||||
our_transition->in_offset().toRationalTime());
|
||||
otio_transition->set_out_offset(
|
||||
our_transition->out_offset().toRationalTime());
|
||||
|
||||
otio_transition->set_in_offset(our_transition->in_offset().toRationalTime());
|
||||
otio_transition->set_out_offset(our_transition->out_offset().toRationalTime());
|
||||
otio_block = new OTIO::Transition();
|
||||
}
|
||||
|
||||
otio_block = new OTIO::Transition();
|
||||
}
|
||||
if (!otio_block) {
|
||||
// We shouldn't ever get here, but catch without crashing if we ever do
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!otio_block) {
|
||||
// We shouldn't ever get here, but catch without crashing if we ever do
|
||||
goto fail;
|
||||
}
|
||||
otio_track->append_child(otio_block, &es);
|
||||
|
||||
otio_track->append_child(otio_block, &es);
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
// All OTIO tracks must have the same duration so we add a Gap to fill the remaining time
|
||||
if (otio_track->duration(&es).to_seconds() < max_track_length.toDouble()) {
|
||||
double time_left = max_track_length.toDouble() -
|
||||
otio_track->duration(&es).to_seconds();
|
||||
|
||||
// All OTIO tracks must have the same duration so we add a Gap to fill the remaining time
|
||||
if (otio_track->duration(&es).to_seconds() < max_track_length.toDouble()) {
|
||||
double time_left = max_track_length.toDouble() - otio_track->duration(&es).to_seconds();
|
||||
OTIO::Gap *gap = new OTIO::Gap(OTIO::TimeRange(
|
||||
otio_track->duration(&es), OTIO::RationalTime(time_left, 1.0)));
|
||||
otio_track->append_child(gap, &es);
|
||||
|
||||
OTIO::Gap* gap = new OTIO::Gap(OTIO::TimeRange(otio_track->duration(&es),
|
||||
OTIO::RationalTime(time_left, 1.0)));
|
||||
otio_track->append_child(gap, &es);
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return otio_track;
|
||||
return otio_track;
|
||||
|
||||
fail:
|
||||
otio_track->possibly_delete();
|
||||
otio_track->possibly_delete();
|
||||
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SaveOTIOTask::SerializeTrackList(TrackList *list, OTIO::Timeline* otio_timeline, double sequence_rate)
|
||||
bool SaveOTIOTask::SerializeTrackList(TrackList *list,
|
||||
OTIO::Timeline *otio_timeline,
|
||||
double sequence_rate)
|
||||
{
|
||||
OTIO::ErrorStatus es;
|
||||
OTIO::ErrorStatus es;
|
||||
|
||||
rational max_track_length = RATIONAL_MIN;
|
||||
rational max_track_length = RATIONAL_MIN;
|
||||
|
||||
foreach (Track* track, list->GetTracks()) {
|
||||
if (track->track_length() > max_track_length) {
|
||||
max_track_length = track->track_length();
|
||||
}
|
||||
}
|
||||
foreach (Track *track, list->GetTracks()) {
|
||||
if (track->track_length() > max_track_length) {
|
||||
max_track_length = track->track_length();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Track* track, list->GetTracks()) {
|
||||
auto otio_track = SerializeTrack(track, sequence_rate, max_track_length);
|
||||
foreach (Track *track, list->GetTracks()) {
|
||||
auto otio_track =
|
||||
SerializeTrack(track, sequence_rate, max_track_length);
|
||||
|
||||
if (!otio_track) {
|
||||
return false;
|
||||
}
|
||||
if (!otio_track) {
|
||||
return false;
|
||||
}
|
||||
|
||||
otio_timeline->tracks()->append_child(otio_track, &es);
|
||||
otio_timeline->tracks()->append_child(otio_track, &es);
|
||||
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
otio_track->possibly_delete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
|
||||
otio_track->possibly_delete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,26 +30,27 @@
|
||||
#include "node/project.h"
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class SaveOTIOTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class SaveOTIOTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SaveOTIOTask(Project* project);
|
||||
SaveOTIOTask(Project *project);
|
||||
|
||||
protected:
|
||||
virtual bool Run() override;
|
||||
virtual bool Run() override;
|
||||
|
||||
private:
|
||||
OTIO::Timeline* SerializeTimeline(Sequence* sequence);
|
||||
OTIO::Timeline *SerializeTimeline(Sequence *sequence);
|
||||
|
||||
OTIO::Track* SerializeTrack(Track* track, double sequence_rate, rational max_track_length);
|
||||
OTIO::Track *SerializeTrack(Track *track, double sequence_rate,
|
||||
rational max_track_length);
|
||||
|
||||
bool SerializeTrackList(TrackList* list, OTIO::Timeline *otio_timeline, double sequence_rate);
|
||||
|
||||
Project* project_;
|
||||
bool SerializeTrackList(TrackList *list, OTIO::Timeline *otio_timeline,
|
||||
double sequence_rate);
|
||||
|
||||
Project *project_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+243
-209
@@ -23,11 +23,12 @@
|
||||
#include "node/project/sequence/sequence.h"
|
||||
#include "render/rendermanager.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
RenderTask::RenderTask() :
|
||||
running_tickets_(0),
|
||||
native_progress_signalling_(true)
|
||||
RenderTask::RenderTask()
|
||||
: running_tickets_(0)
|
||||
, native_progress_signalling_(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,279 +36,312 @@ RenderTask::~RenderTask()
|
||||
{
|
||||
}
|
||||
|
||||
bool RenderTask::Render(ColorManager* manager,
|
||||
const TimeRangeList& video_range,
|
||||
const TimeRangeList &audio_range, const TimeRange &subtitle_range,
|
||||
RenderMode::Mode mode,
|
||||
FrameHashCache* cache, const QSize &force_size,
|
||||
const QMatrix4x4 &force_matrix, PixelFormat force_format,
|
||||
int force_channel_count, ColorProcessorPtr force_color_output)
|
||||
bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range,
|
||||
const TimeRangeList &audio_range,
|
||||
const TimeRange &subtitle_range, RenderMode::Mode mode,
|
||||
FrameHashCache *cache, const QSize &force_size,
|
||||
const QMatrix4x4 &force_matrix,
|
||||
PixelFormat force_format, int force_channel_count,
|
||||
ColorProcessorPtr force_color_output)
|
||||
{
|
||||
QMetaObject::invokeMethod(RenderManager::instance(), "SetAggressiveGarbageCollection", Q_ARG(bool, true));
|
||||
QMetaObject::invokeMethod(RenderManager::instance(),
|
||||
"SetAggressiveGarbageCollection",
|
||||
Q_ARG(bool, true));
|
||||
|
||||
// Run watchers in another thread so they can accept signals even while this thread is blocked
|
||||
QThread watcher_thread;
|
||||
watcher_thread.start();
|
||||
// Run watchers in another thread so they can accept signals even while this thread is blocked
|
||||
QThread watcher_thread;
|
||||
watcher_thread.start();
|
||||
|
||||
double progress_counter = 0;
|
||||
double total_length = 0;
|
||||
double progress_counter = 0;
|
||||
double total_length = 0;
|
||||
|
||||
// Store real time before any rendering takes place
|
||||
// Queue audio jobs
|
||||
foreach (const TimeRange& range, audio_range) {
|
||||
// Don't count audio progress, since it's generally a lot faster than video and is weighted at
|
||||
// 50%, which makes the progress bar look weird to the uninitiated
|
||||
//total_length += r.length().toDouble();
|
||||
// Store real time before any rendering takes place
|
||||
// Queue audio jobs
|
||||
foreach (const TimeRange &range, audio_range) {
|
||||
// Don't count audio progress, since it's generally a lot faster than video and is weighted at
|
||||
// 50%, which makes the progress bar look weird to the uninitiated
|
||||
//total_length += r.length().toDouble();
|
||||
|
||||
RenderManager::RenderAudioParams rap(viewer_->GetConnectedSampleOutput(),
|
||||
range,
|
||||
audio_params_,
|
||||
RenderMode::kOnline);
|
||||
RenderManager::RenderAudioParams rap(
|
||||
viewer_->GetConnectedSampleOutput(), range, audio_params_,
|
||||
RenderMode::kOnline);
|
||||
|
||||
RenderTicketWatcher* watcher = new RenderTicketWatcher();
|
||||
watcher->setProperty("range", QVariant::fromValue(range));
|
||||
PrepareWatcher(watcher, &watcher_thread);
|
||||
IncrementRunningTickets();
|
||||
watcher->SetTicket(RenderManager::instance()->RenderAudio(rap));
|
||||
}
|
||||
RenderTicketWatcher *watcher = new RenderTicketWatcher();
|
||||
watcher->setProperty("range", QVariant::fromValue(range));
|
||||
PrepareWatcher(watcher, &watcher_thread);
|
||||
IncrementRunningTickets();
|
||||
watcher->SetTicket(RenderManager::instance()->RenderAudio(rap));
|
||||
}
|
||||
|
||||
// Look up hashes
|
||||
TimeRangeListFrameIterator iterator(video_range, video_params().frame_rate_as_time_base());
|
||||
total_number_of_frames_ = iterator.size();
|
||||
total_length += total_number_of_frames_;
|
||||
// Look up hashes
|
||||
TimeRangeListFrameIterator iterator(
|
||||
video_range, video_params().frame_rate_as_time_base());
|
||||
total_number_of_frames_ = iterator.size();
|
||||
total_length += total_number_of_frames_;
|
||||
|
||||
// Start a render of a limited amount, and then render one frame for each frame that gets
|
||||
// finished. This prevents rendered frames from stacking up in memory indefinitely while the
|
||||
// encoder is processing them. The amount is kind of arbitrary, but we use the thread count so
|
||||
// each of the system's threads are utilized as memory allows.
|
||||
const int maximum_rendered_frames = QThread::idealThreadCount();
|
||||
// Start a render of a limited amount, and then render one frame for each frame that gets
|
||||
// finished. This prevents rendered frames from stacking up in memory indefinitely while the
|
||||
// encoder is processing them. The amount is kind of arbitrary, but we use the thread count so
|
||||
// each of the system's threads are utilized as memory allows.
|
||||
const int maximum_rendered_frames = QThread::idealThreadCount();
|
||||
|
||||
rational next_frame;
|
||||
for (int i=0; i<maximum_rendered_frames && iterator.GetNext(&next_frame); i++) {
|
||||
StartTicket(&watcher_thread, manager, next_frame, mode, cache, force_size, force_matrix, force_format, force_channel_count, force_color_output);
|
||||
}
|
||||
rational next_frame;
|
||||
for (int i = 0;
|
||||
i < maximum_rendered_frames && iterator.GetNext(&next_frame); i++) {
|
||||
StartTicket(&watcher_thread, manager, next_frame, mode, cache,
|
||||
force_size, force_matrix, force_format, force_channel_count,
|
||||
force_color_output);
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
bool result = true;
|
||||
|
||||
// Subtitle loop, loops over all blocks in sequence on all tracks
|
||||
if (!subtitle_range.length().isNull()) {
|
||||
if (Sequence *sequence = dynamic_cast<Sequence*>(viewer_)) {
|
||||
TrackList *list = sequence->track_list(Track::kSubtitle);
|
||||
QVector<int> block_indexes(list->GetTrackCount(), 0);
|
||||
// Subtitle loop, loops over all blocks in sequence on all tracks
|
||||
if (!subtitle_range.length().isNull()) {
|
||||
if (Sequence *sequence = dynamic_cast<Sequence *>(viewer_)) {
|
||||
TrackList *list = sequence->track_list(Track::kSubtitle);
|
||||
QVector<int> block_indexes(list->GetTrackCount(), 0);
|
||||
|
||||
QVector<int> tracks_to_push;
|
||||
do {
|
||||
tracks_to_push.clear();
|
||||
QVector<int> tracks_to_push;
|
||||
do {
|
||||
tracks_to_push.clear();
|
||||
|
||||
for (int i=0; i<block_indexes.size(); i++) {
|
||||
Track *this_track = list->GetTrackAt(i);
|
||||
if (this_track->IsMuted()) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < block_indexes.size(); i++) {
|
||||
Track *this_track = list->GetTrackAt(i);
|
||||
if (this_track->IsMuted()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int &this_block_index = block_indexes[i];
|
||||
if (this_block_index >= this_track->Blocks().size()) {
|
||||
continue;
|
||||
}
|
||||
Block *this_block = this_track->Blocks().at(this_block_index);
|
||||
int &this_block_index = block_indexes[i];
|
||||
if (this_block_index >= this_track->Blocks().size()) {
|
||||
continue;
|
||||
}
|
||||
Block *this_block =
|
||||
this_track->Blocks().at(this_block_index);
|
||||
|
||||
Track *compare_track = tracks_to_push.isEmpty() ? nullptr : list->GetTrackAt(tracks_to_push.first());
|
||||
const int &compare_block_index = tracks_to_push.isEmpty() ? -1 : block_indexes.at(tracks_to_push.first());
|
||||
Block *compare_block = compare_track ? compare_track->Blocks().at(compare_block_index) : nullptr;
|
||||
if (!compare_track || compare_block->in() >= this_block->in()) {
|
||||
if (compare_track && compare_block->in() != this_block->in()) {
|
||||
tracks_to_push.clear();
|
||||
}
|
||||
tracks_to_push.append(i);
|
||||
}
|
||||
}
|
||||
Track *compare_track =
|
||||
tracks_to_push.isEmpty() ?
|
||||
nullptr :
|
||||
list->GetTrackAt(tracks_to_push.first());
|
||||
const int &compare_block_index =
|
||||
tracks_to_push.isEmpty() ?
|
||||
-1 :
|
||||
block_indexes.at(tracks_to_push.first());
|
||||
Block *compare_block =
|
||||
compare_track ?
|
||||
compare_track->Blocks().at(compare_block_index) :
|
||||
nullptr;
|
||||
if (!compare_track ||
|
||||
compare_block->in() >= this_block->in()) {
|
||||
if (compare_track &&
|
||||
compare_block->in() != this_block->in()) {
|
||||
tracks_to_push.clear();
|
||||
}
|
||||
tracks_to_push.append(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<tracks_to_push.size(); i++) {
|
||||
Track *this_track = list->GetTrackAt(tracks_to_push.at(i));
|
||||
Block *this_block = this_track->Blocks().at(block_indexes.at(tracks_to_push.at(i)));
|
||||
for (int i = 0; i < tracks_to_push.size(); i++) {
|
||||
Track *this_track = list->GetTrackAt(tracks_to_push.at(i));
|
||||
Block *this_block = this_track->Blocks().at(
|
||||
block_indexes.at(tracks_to_push.at(i)));
|
||||
|
||||
if (const SubtitleBlock *sub = dynamic_cast<const SubtitleBlock*>(this_block)) {
|
||||
if (sub->is_enabled()) {
|
||||
if (!EncodeSubtitle(sub)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const SubtitleBlock *sub =
|
||||
dynamic_cast<const SubtitleBlock *>(this_block)) {
|
||||
if (sub->is_enabled()) {
|
||||
if (!EncodeSubtitle(sub)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
block_indexes[tracks_to_push.at(i)]++;
|
||||
}
|
||||
} while (!tracks_to_push.isEmpty());
|
||||
}
|
||||
}
|
||||
block_indexes[tracks_to_push.at(i)]++;
|
||||
}
|
||||
} while (!tracks_to_push.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
finished_watcher_mutex_.lock();
|
||||
finished_watcher_mutex_.lock();
|
||||
|
||||
while (result && !IsCancelled()) {
|
||||
while (!finished_watchers_.empty() && !IsCancelled() && result) {
|
||||
RenderTicketWatcher* watcher = finished_watchers_.front();
|
||||
finished_watchers_.pop_front();
|
||||
while (result && !IsCancelled()) {
|
||||
while (!finished_watchers_.empty() && !IsCancelled() && result) {
|
||||
RenderTicketWatcher *watcher = finished_watchers_.front();
|
||||
finished_watchers_.pop_front();
|
||||
|
||||
finished_watcher_mutex_.unlock();
|
||||
finished_watcher_mutex_.unlock();
|
||||
|
||||
// Analyze watcher here
|
||||
RenderManager::TicketType ticket_type = watcher->GetTicket()->property("type").value<RenderManager::TicketType>();
|
||||
// Analyze watcher here
|
||||
RenderManager::TicketType ticket_type =
|
||||
watcher->GetTicket()
|
||||
->property("type")
|
||||
.value<RenderManager::TicketType>();
|
||||
|
||||
if (ticket_type == RenderManager::kTypeAudio) {
|
||||
if (ticket_type == RenderManager::kTypeAudio) {
|
||||
TimeRange range = watcher->property("range").value<TimeRange>();
|
||||
|
||||
TimeRange range = watcher->property("range").value<TimeRange>();
|
||||
if (!AudioDownloaded(range,
|
||||
watcher->Get().value<SampleBuffer>())) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (!AudioDownloaded(range, watcher->Get().value<SampleBuffer>())) {
|
||||
result = false;
|
||||
}
|
||||
// Don't count audio progress, since it's generally a lot faster than video and is weighted at
|
||||
// 50%, which makes the progress bar look weird to the uninitiated
|
||||
//progress_counter += range.length().toDouble();
|
||||
//emit ProgressChanged(progress_counter / total_length);
|
||||
|
||||
// Don't count audio progress, since it's generally a lot faster than video and is weighted at
|
||||
// 50%, which makes the progress bar look weird to the uninitiated
|
||||
//progress_counter += range.length().toDouble();
|
||||
//emit ProgressChanged(progress_counter / total_length);
|
||||
} else if (ticket_type == RenderManager::kTypeVideo &&
|
||||
TwoStepFrameRendering()) {
|
||||
if (!DownloadFrame(
|
||||
&watcher_thread, watcher->Get().value<FramePtr>(),
|
||||
watcher->property("time").value<rational>())) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
} else if (ticket_type == RenderManager::kTypeVideo && TwoStepFrameRendering()) {
|
||||
if (native_progress_signalling_) {
|
||||
progress_counter += 0.5;
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
}
|
||||
|
||||
if (!DownloadFrame(&watcher_thread, watcher->Get().value<FramePtr>(), watcher->property("time").value<rational>())) {
|
||||
result = false;
|
||||
}
|
||||
} else {
|
||||
// Assume single-step video or video download ticket
|
||||
if (!FrameDownloaded(
|
||||
watcher->Get().value<FramePtr>(),
|
||||
watcher->property("time").value<rational>())) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (native_progress_signalling_) {
|
||||
progress_counter += 0.5;
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
}
|
||||
if (native_progress_signalling_) {
|
||||
double progress_to_add = 1.0;
|
||||
if (TwoStepFrameRendering()) {
|
||||
progress_to_add *= 0.5;
|
||||
}
|
||||
progress_counter += progress_to_add;
|
||||
|
||||
} else {
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
}
|
||||
|
||||
// Assume single-step video or video download ticket
|
||||
if (!FrameDownloaded(watcher->Get().value<FramePtr>(), watcher->property("time").value<rational>())) {
|
||||
result = false;
|
||||
}
|
||||
if (iterator.GetNext(&next_frame)) {
|
||||
StartTicket(&watcher_thread, manager, next_frame, mode,
|
||||
cache, force_size, force_matrix, force_format,
|
||||
force_channel_count, force_color_output);
|
||||
}
|
||||
}
|
||||
|
||||
if (native_progress_signalling_) {
|
||||
double progress_to_add = 1.0;
|
||||
if (TwoStepFrameRendering()) {
|
||||
progress_to_add *= 0.5;
|
||||
}
|
||||
progress_counter += progress_to_add;
|
||||
delete watcher;
|
||||
running_watchers_.removeOne(watcher);
|
||||
|
||||
emit ProgressChanged(progress_counter / total_length);
|
||||
}
|
||||
finished_watcher_mutex_.lock();
|
||||
}
|
||||
|
||||
if (iterator.GetNext(&next_frame)) {
|
||||
StartTicket(&watcher_thread, manager, next_frame, mode, cache, force_size, force_matrix, force_format, force_channel_count, force_color_output);
|
||||
}
|
||||
if (IsCancelled() || !result) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// Run out of finished watchers. If we still have running tickets, wait for the next one to finish.
|
||||
if (running_tickets_ > 0) {
|
||||
finished_watcher_wait_cond_.wait(&finished_watcher_mutex_);
|
||||
} else {
|
||||
// No more running tickets or finished tickets, wem ust be
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete watcher;
|
||||
running_watchers_.removeOne(watcher);
|
||||
finished_watcher_mutex_.unlock();
|
||||
|
||||
finished_watcher_mutex_.lock();
|
||||
}
|
||||
if (IsCancelled() || !result) {
|
||||
// Cancel every watcher we created
|
||||
foreach (RenderTicketWatcher *watcher, running_watchers_) {
|
||||
watcher->Cancel();
|
||||
disconnect(watcher, &RenderTicketWatcher::Finished, this,
|
||||
&RenderTask::TicketDone);
|
||||
RenderManager::instance()->RemoveTicket(watcher->GetTicket());
|
||||
}
|
||||
|
||||
if (IsCancelled() || !result) {
|
||||
break;
|
||||
}
|
||||
foreach (RenderTicketWatcher *watcher, running_watchers_) {
|
||||
watcher->WaitForFinished();
|
||||
}
|
||||
}
|
||||
|
||||
// Run out of finished watchers. If we still have running tickets, wait for the next one to finish.
|
||||
if (running_tickets_ > 0) {
|
||||
finished_watcher_wait_cond_.wait(&finished_watcher_mutex_);
|
||||
} else {
|
||||
// No more running tickets or finished tickets, wem ust be
|
||||
break;
|
||||
}
|
||||
}
|
||||
watcher_thread.quit();
|
||||
watcher_thread.wait();
|
||||
|
||||
finished_watcher_mutex_.unlock();
|
||||
QMetaObject::invokeMethod(RenderManager::instance(),
|
||||
"SetAggressiveGarbageCollection",
|
||||
Q_ARG(bool, false));
|
||||
|
||||
if (IsCancelled() || !result) {
|
||||
// Cancel every watcher we created
|
||||
foreach (RenderTicketWatcher* watcher, running_watchers_) {
|
||||
watcher->Cancel();
|
||||
disconnect(watcher, &RenderTicketWatcher::Finished, this, &RenderTask::TicketDone);
|
||||
RenderManager::instance()->RemoveTicket(watcher->GetTicket());
|
||||
}
|
||||
|
||||
foreach (RenderTicketWatcher* watcher, running_watchers_) {
|
||||
watcher->WaitForFinished();
|
||||
}
|
||||
}
|
||||
|
||||
watcher_thread.quit();
|
||||
watcher_thread.wait();
|
||||
|
||||
QMetaObject::invokeMethod(RenderManager::instance(), "SetAggressiveGarbageCollection", Q_ARG(bool, false));
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RenderTask::DownloadFrame(QThread *thread, FramePtr frame, const rational &time)
|
||||
bool RenderTask::DownloadFrame(QThread *thread, FramePtr frame,
|
||||
const rational &time)
|
||||
{
|
||||
//RenderTicketWatcher* watcher = new RenderTicketWatcher();
|
||||
//PrepareWatcher(watcher, thread);
|
||||
//RenderTicketWatcher* watcher = new RenderTicketWatcher();
|
||||
//PrepareWatcher(watcher, thread);
|
||||
|
||||
//IncrementRunningTickets();
|
||||
//IncrementRunningTickets();
|
||||
|
||||
//watcher->SetTicket(RenderManager::instance()->SaveFrameToCache(viewer_->video_frame_cache(), frame, time));
|
||||
//watcher->SetTicket(RenderManager::instance()->SaveFrameToCache(viewer_->video_frame_cache(), frame, time));
|
||||
|
||||
// NOTE: Doesn't reflect the actual return result of SaveFrameToCache
|
||||
return true;
|
||||
// NOTE: Doesn't reflect the actual return result of SaveFrameToCache
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderTask::EncodeSubtitle(const SubtitleBlock *subtitle)
|
||||
{
|
||||
Q_UNUSED(subtitle)
|
||||
return true;
|
||||
Q_UNUSED(subtitle)
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderTask::PrepareWatcher(RenderTicketWatcher *watcher, QThread *thread)
|
||||
{
|
||||
watcher->moveToThread(thread);
|
||||
connect(watcher, &RenderTicketWatcher::Finished, this, &RenderTask::TicketDone, Qt::DirectConnection);
|
||||
running_watchers_.append(watcher);
|
||||
watcher->moveToThread(thread);
|
||||
connect(watcher, &RenderTicketWatcher::Finished, this,
|
||||
&RenderTask::TicketDone, Qt::DirectConnection);
|
||||
running_watchers_.append(watcher);
|
||||
}
|
||||
|
||||
void RenderTask::IncrementRunningTickets()
|
||||
{
|
||||
finished_watcher_mutex_.lock();
|
||||
running_tickets_++;
|
||||
finished_watcher_mutex_.unlock();
|
||||
finished_watcher_mutex_.lock();
|
||||
running_tickets_++;
|
||||
finished_watcher_mutex_.unlock();
|
||||
}
|
||||
|
||||
void RenderTask::StartTicket(QThread* watcher_thread, ColorManager* manager,
|
||||
const rational& time, RenderMode::Mode mode, FrameHashCache* cache,
|
||||
const QSize &force_size, const QMatrix4x4 &force_matrix,
|
||||
PixelFormat force_format, int force_channel_count,
|
||||
ColorProcessorPtr force_color_output)
|
||||
void RenderTask::StartTicket(QThread *watcher_thread, ColorManager *manager,
|
||||
const rational &time, RenderMode::Mode mode,
|
||||
FrameHashCache *cache, const QSize &force_size,
|
||||
const QMatrix4x4 &force_matrix,
|
||||
PixelFormat force_format, int force_channel_count,
|
||||
ColorProcessorPtr force_color_output)
|
||||
{
|
||||
RenderManager::RenderVideoParams rvp(viewer_->GetConnectedTextureOutput(), video_params_, audio_params_,
|
||||
time, manager, mode);
|
||||
RenderManager::RenderVideoParams rvp(viewer_->GetConnectedTextureOutput(),
|
||||
video_params_, audio_params_, time,
|
||||
manager, mode);
|
||||
|
||||
rvp.force_size = force_size;
|
||||
rvp.force_matrix = force_matrix;
|
||||
rvp.force_format = force_format;
|
||||
rvp.force_color_output = force_color_output;
|
||||
rvp.force_channel_count = force_channel_count;
|
||||
rvp.force_size = force_size;
|
||||
rvp.force_matrix = force_matrix;
|
||||
rvp.force_format = force_format;
|
||||
rvp.force_color_output = force_color_output;
|
||||
rvp.force_channel_count = force_channel_count;
|
||||
|
||||
if (cache) {
|
||||
rvp.AddCache(cache);
|
||||
}
|
||||
if (cache) {
|
||||
rvp.AddCache(cache);
|
||||
}
|
||||
|
||||
RenderTicketWatcher* watcher = new RenderTicketWatcher();
|
||||
watcher->setProperty("time", QVariant::fromValue(time));
|
||||
PrepareWatcher(watcher, watcher_thread);
|
||||
IncrementRunningTickets();
|
||||
watcher->SetTicket(RenderManager::instance()->RenderFrame(rvp));
|
||||
RenderTicketWatcher *watcher = new RenderTicketWatcher();
|
||||
watcher->setProperty("time", QVariant::fromValue(time));
|
||||
PrepareWatcher(watcher, watcher_thread);
|
||||
IncrementRunningTickets();
|
||||
watcher->SetTicket(RenderManager::instance()->RenderFrame(rvp));
|
||||
}
|
||||
|
||||
void RenderTask::TicketDone(RenderTicketWatcher* watcher)
|
||||
void RenderTask::TicketDone(RenderTicketWatcher *watcher)
|
||||
{
|
||||
finished_watcher_mutex_.lock();
|
||||
finished_watchers_.push_back(watcher);
|
||||
finished_watcher_wait_cond_.wakeAll();
|
||||
running_tickets_--;
|
||||
finished_watcher_mutex_.unlock();
|
||||
finished_watcher_mutex_.lock();
|
||||
finished_watchers_.push_back(watcher);
|
||||
finished_watcher_wait_cond_.wakeAll();
|
||||
running_tickets_--;
|
||||
finished_watcher_mutex_.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+83
-76
@@ -29,114 +29,121 @@
|
||||
#include "task/task.h"
|
||||
#include "render/renderticket.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class RenderTask : public Task
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RenderTask();
|
||||
|
||||
virtual ~RenderTask() override;
|
||||
class RenderTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RenderTask();
|
||||
|
||||
virtual ~RenderTask() override;
|
||||
|
||||
protected:
|
||||
bool Render(ColorManager *manager, const TimeRangeList &video_range,
|
||||
const TimeRangeList &audio_range, const TimeRange &subtitle_range,
|
||||
RenderMode::Mode mode,
|
||||
FrameHashCache *cache, const QSize& force_size = QSize(0, 0),
|
||||
const QMatrix4x4& force_matrix = QMatrix4x4(),
|
||||
PixelFormat force_format = PixelFormat::INVALID,
|
||||
int force_channel_count = 0, ColorProcessorPtr force_color_output = nullptr);
|
||||
bool Render(ColorManager *manager, const TimeRangeList &video_range,
|
||||
const TimeRangeList &audio_range,
|
||||
const TimeRange &subtitle_range, RenderMode::Mode mode,
|
||||
FrameHashCache *cache, const QSize &force_size = QSize(0, 0),
|
||||
const QMatrix4x4 &force_matrix = QMatrix4x4(),
|
||||
PixelFormat force_format = PixelFormat::INVALID,
|
||||
int force_channel_count = 0,
|
||||
ColorProcessorPtr force_color_output = nullptr);
|
||||
|
||||
virtual bool DownloadFrame(QThread* thread, FramePtr frame, const rational &time);
|
||||
virtual bool DownloadFrame(QThread *thread, FramePtr frame,
|
||||
const rational &time);
|
||||
|
||||
virtual bool FrameDownloaded(FramePtr frame, const rational &time) = 0;
|
||||
virtual bool FrameDownloaded(FramePtr frame, const rational &time) = 0;
|
||||
|
||||
virtual bool AudioDownloaded(const TimeRange& range, const SampleBuffer &samples) = 0;
|
||||
virtual bool AudioDownloaded(const TimeRange &range,
|
||||
const SampleBuffer &samples) = 0;
|
||||
|
||||
virtual bool EncodeSubtitle(const SubtitleBlock *subtitle);
|
||||
virtual bool EncodeSubtitle(const SubtitleBlock *subtitle);
|
||||
|
||||
ViewerOutput* viewer() const
|
||||
{
|
||||
return viewer_;
|
||||
}
|
||||
ViewerOutput *viewer() const
|
||||
{
|
||||
return viewer_;
|
||||
}
|
||||
|
||||
void set_viewer(ViewerOutput *v)
|
||||
{
|
||||
viewer_ = v;
|
||||
}
|
||||
void set_viewer(ViewerOutput *v)
|
||||
{
|
||||
viewer_ = v;
|
||||
}
|
||||
|
||||
const VideoParams& video_params() const
|
||||
{
|
||||
return video_params_;
|
||||
}
|
||||
const VideoParams &video_params() const
|
||||
{
|
||||
return video_params_;
|
||||
}
|
||||
|
||||
void set_video_params(const VideoParams& video_params)
|
||||
{
|
||||
video_params_ = video_params;
|
||||
}
|
||||
void set_video_params(const VideoParams &video_params)
|
||||
{
|
||||
video_params_ = video_params;
|
||||
}
|
||||
|
||||
const AudioParams& audio_params() const
|
||||
{
|
||||
return audio_params_;
|
||||
}
|
||||
const AudioParams &audio_params() const
|
||||
{
|
||||
return audio_params_;
|
||||
}
|
||||
|
||||
void set_audio_params(const AudioParams& audio_params)
|
||||
{
|
||||
audio_params_ = audio_params;
|
||||
}
|
||||
void set_audio_params(const AudioParams &audio_params)
|
||||
{
|
||||
audio_params_ = audio_params;
|
||||
}
|
||||
|
||||
virtual void CancelEvent() override
|
||||
{
|
||||
finished_watcher_mutex_.lock();
|
||||
finished_watcher_wait_cond_.wakeAll();
|
||||
finished_watcher_mutex_.unlock();
|
||||
}
|
||||
virtual void CancelEvent() override
|
||||
{
|
||||
finished_watcher_mutex_.lock();
|
||||
finished_watcher_wait_cond_.wakeAll();
|
||||
finished_watcher_mutex_.unlock();
|
||||
}
|
||||
|
||||
virtual bool TwoStepFrameRendering() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool TwoStepFrameRendering() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetNativeProgressSignallingEnabled(bool e)
|
||||
{
|
||||
native_progress_signalling_ = e;
|
||||
}
|
||||
void SetNativeProgressSignallingEnabled(bool e)
|
||||
{
|
||||
native_progress_signalling_ = e;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Only valid after Render() is called
|
||||
*/
|
||||
int64_t GetTotalNumberOfFrames() const
|
||||
{
|
||||
return total_number_of_frames_;
|
||||
}
|
||||
int64_t GetTotalNumberOfFrames() const
|
||||
{
|
||||
return total_number_of_frames_;
|
||||
}
|
||||
|
||||
private:
|
||||
void PrepareWatcher(RenderTicketWatcher* watcher, QThread *thread);
|
||||
void PrepareWatcher(RenderTicketWatcher *watcher, QThread *thread);
|
||||
|
||||
void IncrementRunningTickets();
|
||||
void IncrementRunningTickets();
|
||||
|
||||
void StartTicket(QThread *watcher_thread, ColorManager *manager, const rational &time, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size, const QMatrix4x4 &force_matrix, PixelFormat force_format, int force_channel_count, ColorProcessorPtr force_color_output);
|
||||
void StartTicket(QThread *watcher_thread, ColorManager *manager,
|
||||
const rational &time, RenderMode::Mode mode,
|
||||
FrameHashCache *cache, const QSize &force_size,
|
||||
const QMatrix4x4 &force_matrix, PixelFormat force_format,
|
||||
int force_channel_count,
|
||||
ColorProcessorPtr force_color_output);
|
||||
|
||||
ViewerOutput* viewer_;
|
||||
ViewerOutput *viewer_;
|
||||
|
||||
VideoParams video_params_;
|
||||
VideoParams video_params_;
|
||||
|
||||
AudioParams audio_params_;
|
||||
AudioParams audio_params_;
|
||||
|
||||
QVector<RenderTicketWatcher*> running_watchers_;
|
||||
std::list<RenderTicketWatcher*> finished_watchers_;
|
||||
int running_tickets_;
|
||||
QMutex finished_watcher_mutex_;
|
||||
QWaitCondition finished_watcher_wait_cond_;
|
||||
QVector<RenderTicketWatcher *> running_watchers_;
|
||||
std::list<RenderTicketWatcher *> finished_watchers_;
|
||||
int running_tickets_;
|
||||
QMutex finished_watcher_mutex_;
|
||||
QWaitCondition finished_watcher_wait_cond_;
|
||||
|
||||
bool native_progress_signalling_;
|
||||
bool native_progress_signalling_;
|
||||
|
||||
int64_t total_number_of_frames_;
|
||||
int64_t total_number_of_frames_;
|
||||
|
||||
private slots:
|
||||
void TicketDone(RenderTicketWatcher *watcher);
|
||||
|
||||
void TicketDone(RenderTicketWatcher *watcher);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+65
-63
@@ -28,7 +28,8 @@
|
||||
|
||||
#include "common/cancelableobject.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A base class for background tasks running in Olive.
|
||||
@@ -47,113 +48,115 @@ namespace olive {
|
||||
*
|
||||
* Tasks support "dependency tasks", i.e. a Task that should be complete before another Task begins.
|
||||
*/
|
||||
class Task : public QObject, public CancelableObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class Task : public QObject, public CancelableObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* @brief Task Constructor
|
||||
*/
|
||||
Task() :
|
||||
title_(tr("Task")),
|
||||
error_(tr("Unknown error")),
|
||||
start_time_(0)
|
||||
{
|
||||
}
|
||||
Task()
|
||||
: title_(tr("Task"))
|
||||
, error_(tr("Unknown error"))
|
||||
, start_time_(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Retrieve the current title of this Task
|
||||
*/
|
||||
const QString& GetTitle() const
|
||||
{
|
||||
return title_;
|
||||
}
|
||||
const QString &GetTitle() const
|
||||
{
|
||||
return title_;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Returns the error that occurred if Run() returns false
|
||||
*/
|
||||
const QString& GetError() const
|
||||
{
|
||||
return error_;
|
||||
}
|
||||
const QString &GetError() const
|
||||
{
|
||||
return error_;
|
||||
}
|
||||
|
||||
const qint64& GetStartTime() const
|
||||
{
|
||||
return start_time_;
|
||||
}
|
||||
const qint64 &GetStartTime() const
|
||||
{
|
||||
return start_time_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
/**
|
||||
/**
|
||||
* @brief Run this task
|
||||
*
|
||||
* @return True if the task completed successfully, false if not.
|
||||
*
|
||||
* \see GetError() if this returns false.
|
||||
*/
|
||||
bool Start()
|
||||
{
|
||||
start_time_ = QDateTime::currentMSecsSinceEpoch();
|
||||
emit Started(start_time_);
|
||||
bool Start()
|
||||
{
|
||||
start_time_ = QDateTime::currentMSecsSinceEpoch();
|
||||
emit Started(start_time_);
|
||||
|
||||
bool ret = Run();
|
||||
bool ret = Run();
|
||||
|
||||
// Print how long this task took for debugging purposes
|
||||
qDebug() << this << "took" << (QDateTime::currentMSecsSinceEpoch() - start_time_);
|
||||
// Print how long this task took for debugging purposes
|
||||
qDebug() << this << "took"
|
||||
<< (QDateTime::currentMSecsSinceEpoch() - start_time_);
|
||||
|
||||
emit Finished(this, ret);
|
||||
emit Finished(this, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Reset state so that Run() can be called again.
|
||||
*
|
||||
* Override this if your class holds any persistent state that should be cleared/modified before
|
||||
* it's safe for Run() to run again.
|
||||
*/
|
||||
virtual void Reset(){}
|
||||
virtual void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Cancel the Task
|
||||
*
|
||||
* Sends a signal to the Task to stop as soon as possible. Always call this directly or connect
|
||||
* with Qt::DirectConnection, or else it'll be queued *after* the task has already finished.
|
||||
*/
|
||||
void Cancel()
|
||||
{
|
||||
CancelableObject::Cancel();
|
||||
}
|
||||
void Cancel()
|
||||
{
|
||||
CancelableObject::Cancel();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool Run() = 0;
|
||||
virtual bool Run() = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Set the error message
|
||||
*
|
||||
* It is recommended to use this if your Action() function ever returns FALSE to tell the user why the failure
|
||||
* occurred.
|
||||
*/
|
||||
void SetError(const QString& s)
|
||||
{
|
||||
error_ = s;
|
||||
}
|
||||
void SetError(const QString &s)
|
||||
{
|
||||
error_ = s;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Set the Task title
|
||||
*
|
||||
* Used in the UI Task Manager to distinguish Tasks from each other. Generally this should be set in the constructor
|
||||
* and shouldn't need to change during the life of the Task. To show an error message, it's recommended to use
|
||||
* set_error() instead.
|
||||
*/
|
||||
void SetTitle(const QString& s)
|
||||
{
|
||||
title_ = s;
|
||||
}
|
||||
void SetTitle(const QString &s)
|
||||
{
|
||||
title_ = s;
|
||||
}
|
||||
|
||||
signals:
|
||||
void Started(qint64 start_time);
|
||||
void Started(qint64 start_time);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Signal emitted whenever progress is made
|
||||
*
|
||||
* Emit this throughout Action() to update any attached ProgressBars on the progress of this Task.
|
||||
@@ -162,22 +165,21 @@ signals:
|
||||
*
|
||||
* A progress value between 0.0 and 1.0.
|
||||
*/
|
||||
void ProgressChanged(double d);
|
||||
void ProgressChanged(double d);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Emitted when task is finished
|
||||
*
|
||||
* Do NOT delete immediately after this signal, call deleteLater() instead.
|
||||
*/
|
||||
void Finished(Task *task, bool succeeded);
|
||||
void Finished(Task *task, bool succeeded);
|
||||
|
||||
private:
|
||||
QString title_;
|
||||
QString title_;
|
||||
|
||||
QString error_;
|
||||
|
||||
qint64 start_time_;
|
||||
QString error_;
|
||||
|
||||
qint64 start_time_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+62
-58
@@ -23,121 +23,125 @@
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
TaskManager* TaskManager::instance_ = nullptr;
|
||||
TaskManager *TaskManager::instance_ = nullptr;
|
||||
|
||||
TaskManager::TaskManager()
|
||||
{
|
||||
thread_pool_.setMaxThreadCount(1);
|
||||
thread_pool_.setMaxThreadCount(1);
|
||||
}
|
||||
|
||||
TaskManager::~TaskManager()
|
||||
{
|
||||
thread_pool_.clear();
|
||||
thread_pool_.clear();
|
||||
|
||||
foreach (Task* t, tasks_) {
|
||||
t->Cancel();
|
||||
}
|
||||
foreach (Task *t, tasks_) {
|
||||
t->Cancel();
|
||||
}
|
||||
|
||||
thread_pool_.waitForDone();
|
||||
thread_pool_.waitForDone();
|
||||
|
||||
foreach (Task* t, tasks_) {
|
||||
t->deleteLater();
|
||||
}
|
||||
foreach (Task *t, tasks_) {
|
||||
t->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskManager::CreateInstance()
|
||||
{
|
||||
instance_ = new TaskManager();
|
||||
instance_ = new TaskManager();
|
||||
}
|
||||
|
||||
void TaskManager::DestroyInstance()
|
||||
{
|
||||
delete instance_;
|
||||
instance_ = nullptr;
|
||||
delete instance_;
|
||||
instance_ = nullptr;
|
||||
}
|
||||
|
||||
TaskManager *TaskManager::instance()
|
||||
{
|
||||
return instance_;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
int TaskManager::GetTaskCount() const
|
||||
{
|
||||
return tasks_.size();
|
||||
return tasks_.size();
|
||||
}
|
||||
|
||||
Task *TaskManager::GetFirstTask() const
|
||||
{
|
||||
return tasks_.begin().value();
|
||||
return tasks_.begin().value();
|
||||
}
|
||||
|
||||
void TaskManager::CancelTaskAndWait(Task* t)
|
||||
void TaskManager::CancelTaskAndWait(Task *t)
|
||||
{
|
||||
t->Cancel();
|
||||
t->Cancel();
|
||||
|
||||
QFutureWatcher<bool>* w = tasks_.key(t);
|
||||
QFutureWatcher<bool> *w = tasks_.key(t);
|
||||
|
||||
if (w) {
|
||||
w->waitForFinished();
|
||||
}
|
||||
if (w) {
|
||||
w->waitForFinished();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskManager::AddTask(Task* t)
|
||||
void TaskManager::AddTask(Task *t)
|
||||
{
|
||||
// Create a watcher for signalling
|
||||
QFutureWatcher<bool>* watcher = new QFutureWatcher<bool>();
|
||||
connect(watcher, &QFutureWatcher<bool>::finished, this, &TaskManager::TaskFinished);
|
||||
// Create a watcher for signalling
|
||||
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>();
|
||||
connect(watcher, &QFutureWatcher<bool>::finished, this,
|
||||
&TaskManager::TaskFinished);
|
||||
|
||||
// Add the Task to the queue
|
||||
tasks_.insert(watcher, t);
|
||||
// Add the Task to the queue
|
||||
tasks_.insert(watcher, t);
|
||||
|
||||
// Run task concurrently
|
||||
watcher->setFuture(
|
||||
// Run task concurrently
|
||||
watcher->setFuture(
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
QtConcurrent::run(&thread_pool_, &Task::Start, t)
|
||||
QtConcurrent::run(&thread_pool_, &Task::Start, t)
|
||||
#else
|
||||
QtConcurrent::run(&thread_pool_, t, &Task::Start)
|
||||
QtConcurrent::run(&thread_pool_, t, &Task::Start)
|
||||
#endif
|
||||
);
|
||||
);
|
||||
|
||||
// Emit signal that a Task was added
|
||||
emit TaskAdded(t);
|
||||
emit TaskListChanged();
|
||||
// Emit signal that a Task was added
|
||||
emit TaskAdded(t);
|
||||
emit TaskListChanged();
|
||||
}
|
||||
|
||||
void TaskManager::CancelTask(Task *t)
|
||||
{
|
||||
if (std::find(failed_tasks_.begin(), failed_tasks_.end(), t) != failed_tasks_.end()) {
|
||||
failed_tasks_.remove(t);
|
||||
emit TaskRemoved(t);
|
||||
t->deleteLater();
|
||||
} else {
|
||||
t->Cancel();
|
||||
}
|
||||
if (std::find(failed_tasks_.begin(), failed_tasks_.end(), t) !=
|
||||
failed_tasks_.end()) {
|
||||
failed_tasks_.remove(t);
|
||||
emit TaskRemoved(t);
|
||||
t->deleteLater();
|
||||
} else {
|
||||
t->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskManager::TaskFinished()
|
||||
{
|
||||
QFutureWatcher<bool>* watcher = static_cast<QFutureWatcher<bool>*>(sender());
|
||||
Task* t = tasks_.value(watcher);
|
||||
QFutureWatcher<bool> *watcher =
|
||||
static_cast<QFutureWatcher<bool> *>(sender());
|
||||
Task *t = tasks_.value(watcher);
|
||||
|
||||
tasks_.remove(watcher);
|
||||
tasks_.remove(watcher);
|
||||
|
||||
if (watcher->result()) {
|
||||
// Task completed successfully
|
||||
emit TaskRemoved(t);
|
||||
t->deleteLater();
|
||||
} else {
|
||||
// Task failed, keep it so the user can see the error message
|
||||
emit TaskFailed(t);
|
||||
failed_tasks_.push_back(t);
|
||||
}
|
||||
if (watcher->result()) {
|
||||
// Task completed successfully
|
||||
emit TaskRemoved(t);
|
||||
t->deleteLater();
|
||||
} else {
|
||||
// Task failed, keep it so the user can see the error message
|
||||
emit TaskFailed(t);
|
||||
failed_tasks_.push_back(t);
|
||||
}
|
||||
|
||||
watcher->deleteLater();
|
||||
watcher->deleteLater();
|
||||
|
||||
emit TaskListChanged();
|
||||
emit TaskListChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+34
-35
@@ -27,7 +27,8 @@
|
||||
|
||||
#include "task/task.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief An object that manages background Task objects, handling their start and end
|
||||
@@ -37,36 +38,35 @@ namespace olive {
|
||||
* for it to run. Currently, TaskManager will run no more Tasks than there are threads on the system (one task per
|
||||
* thread). As Tasks finished, TaskManager will start the next in the queue.
|
||||
*/
|
||||
class TaskManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class TaskManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* @brief TaskManager Constructor
|
||||
*/
|
||||
TaskManager();
|
||||
TaskManager();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief TaskManager Destructor
|
||||
*
|
||||
* Ensures all Tasks are deleted
|
||||
*/
|
||||
virtual ~TaskManager();
|
||||
virtual ~TaskManager();
|
||||
|
||||
static void CreateInstance();
|
||||
static void CreateInstance();
|
||||
|
||||
static void DestroyInstance();
|
||||
static void DestroyInstance();
|
||||
|
||||
static TaskManager* instance();
|
||||
static TaskManager *instance();
|
||||
|
||||
int GetTaskCount() const;
|
||||
int GetTaskCount() const;
|
||||
|
||||
Task* GetFirstTask() const;
|
||||
Task *GetFirstTask() const;
|
||||
|
||||
void CancelTaskAndWait(Task* t);
|
||||
void CancelTaskAndWait(Task *t);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
/**
|
||||
* @brief Add a new Task
|
||||
*
|
||||
* Adds a new Task to the queue. If there are available threads to run it, it'll also run immediately. Otherwise,
|
||||
@@ -81,59 +81,58 @@ public slots:
|
||||
*
|
||||
* The task to add and run. TaskManager takes ownership of this Task and will be responsible for freeing it.
|
||||
*/
|
||||
void AddTask(Task *t);
|
||||
void AddTask(Task *t);
|
||||
|
||||
void CancelTask(Task* t);
|
||||
void CancelTask(Task *t);
|
||||
|
||||
signals:
|
||||
/**
|
||||
/**
|
||||
* @brief Signal emitted when a Task is added by AddTask()
|
||||
*
|
||||
* @param t
|
||||
*
|
||||
* Task that was added
|
||||
*/
|
||||
void TaskAdded(Task* t);
|
||||
void TaskAdded(Task *t);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Signal emitted when any change to the running task list has been made
|
||||
*/
|
||||
void TaskListChanged();
|
||||
void TaskListChanged();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Signal emitted when a task is deleted
|
||||
*/
|
||||
void TaskRemoved(Task* t);
|
||||
void TaskRemoved(Task *t);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Signal emitted when a task fails
|
||||
*/
|
||||
void TaskFailed(Task* t);
|
||||
void TaskFailed(Task *t);
|
||||
|
||||
private:
|
||||
/**
|
||||
/**
|
||||
* @brief Internal task array
|
||||
*/
|
||||
QHash<QFutureWatcher<bool>*, Task*> tasks_;
|
||||
QHash<QFutureWatcher<bool> *, Task *> tasks_;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Internal list of failed tasks
|
||||
*/
|
||||
std::list<Task*> failed_tasks_;
|
||||
std::list<Task *> failed_tasks_;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Task thread pool
|
||||
*/
|
||||
QThreadPool thread_pool_;
|
||||
QThreadPool thread_pool_;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief TaskManager singleton instance
|
||||
*/
|
||||
static TaskManager* instance_;
|
||||
static TaskManager *instance_;
|
||||
|
||||
private slots:
|
||||
void TaskFinished();
|
||||
|
||||
void TaskFinished();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user