footage: merge video and image streams and improve image sequence import process

Image streams were initially separated from video streams, but they're now
joined with a parameter defining if they're a still image, image sequence,
or regular video. The image sequence import process has also improved so
that if images from the same sequence are imported too, they'll either be
ignored or the user won't be asked again for those if they should be an
image sequence (fixes #1193). Also shifts decoder "probe" process to return
an item, useful if the decoder returns a non-footage item.
This commit is contained in:
itsmattkc
2020-09-26 19:45:07 +10:00
parent 85abd6c6b4
commit 6db591e89f
37 changed files with 613 additions and 779 deletions
+18 -20
View File
@@ -98,23 +98,20 @@ QVector<DecoderPtr> ReceiveListOfAllDecoders() {
return decoders;
}
bool Decoder::ProbeMedia(Footage *f, const QAtomicInt* cancelled)
ItemPtr Decoder::ProbeMedia(const QString &filename, const QAtomicInt* cancelled)
{
// Check for a valid filename
if (f->filename().isEmpty()) {
if (filename.isEmpty()) {
qWarning() << "Tried to probe media with an empty filename";
return false;
return nullptr;
}
// Check file exists
if (!QFileInfo::exists(f->filename())) {
qWarning() << "Tried to probe file that doesn't exist:" << f->filename();
return false;
if (!QFileInfo::exists(filename)) {
qWarning() << "Tried to probe file that doesn't exist:" << filename;
return nullptr;
}
// Reset Footage state for probing
f->Clear();
// Create list to iterate through
QVector<DecoderPtr> decoder_list = ReceiveListOfAllDecoders();
@@ -122,30 +119,31 @@ bool Decoder::ProbeMedia(Footage *f, const QAtomicInt* cancelled)
for (int i=0;i<decoder_list.size();i++) {
if (cancelled && *cancelled) {
return false;
return nullptr;
}
DecoderPtr decoder = decoder_list.at(i);
if (decoder->Probe(f, cancelled)) {
ItemPtr item = decoder->Probe(filename, cancelled);
// We found a Decoder, so we can set this media as valid
f->set_status(Footage::kReady);
if (item) {
if (item->type() == Item::kFootage) {
// Attach the successful Decoder to this Footage object
FootagePtr footage = std::static_pointer_cast<Footage>(item);
footage->set_decoder(decoder->id());
footage->SetValid();
}
// Attach the successful Decoder to this Footage object
f->set_decoder(decoder->id());
// FIXME: Cache the results so we don't have to probe if this media is added a second time
return true;
return item;
}
}
// We aren't able to use this Footage
f->set_status(Footage::kInvalid);
f->set_decoder(QString());
return false;
return nullptr;
}
DecoderPtr Decoder::CreateFromID(const QString &id)