Skip to content

Commit

Permalink
throw error if no streams were found when importing
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Mar 8, 2019
1 parent 2f1ff27 commit d4df411
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
41 changes: 28 additions & 13 deletions io/previewgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,28 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) {
}

void PreviewGenerator::finalize_media() {
footage_->ready_lock.unlock();
footage_->ready = true;

if (!cancelled_) {
if (footage_->video_tracks.size() == 0) {
bool footage_is_ready = true;

if (footage_->video_tracks.isEmpty() && footage_->audio_tracks.isEmpty()) {
// ERROR
footage_is_ready = false;
invalidate_media(tr("Failed to find any valid video/audio streams"));
} else if (!footage_->video_tracks.isEmpty() && !contains_still_image_) {
// VIDEO
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_VIDEO);
} else if (!footage_->audio_tracks.isEmpty()) {
// AUDIO
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_AUDIO);
} else if (contains_still_image_) {
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_IMAGE);
} else {
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_VIDEO);
// IMAGE
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_IMAGE);
}

if (footage_is_ready) {
footage_->ready_lock.unlock();
footage_->ready = true;
media_->update_tooltip();
}

if (olive::ActiveSequence != nullptr) {
Expand All @@ -214,6 +226,14 @@ void PreviewGenerator::finalize_media() {
}
}

void PreviewGenerator::invalidate_media(const QString &error_msg)
{
media_->update_tooltip(error_msg);
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_ERROR);
footage_->invalid = true;
footage_->ready_lock.unlock();
}

void thumb_data_cleanup(void *info) {
delete [] static_cast<uint8_t*>(info);
}
Expand Down Expand Up @@ -584,12 +604,7 @@ void PreviewGenerator::run() {

if (!cancelled_) {
if (error) {
media_->update_tooltip(errorStr);
olive::media_icon_service->SetMediaIcon(media_, ICON_TYPE_ERROR);
footage_->invalid = true;
footage_->ready_lock.unlock();
} else {
media_->update_tooltip();
invalidate_media(errorStr);
}
}

Expand Down
3 changes: 2 additions & 1 deletion io/previewgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class PreviewGenerator : public QThread
void parse_media();
bool retrieve_preview(const QString &hash);
void generate_waveform();
void finalize_media();
void finalize_media();
void invalidate_media(const QString& error_msg);
QString get_thumbnail_path(const QString &hash, const FootageStream &ms);
QString get_waveform_path(const QString& hash, const FootageStream &ms);

Expand Down

0 comments on commit d4df411

Please sign in to comment.