diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-27 18:59:43 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-27 18:59:43 +0100 |
| commit | a4642b6463430175d0f4e1ca284a4bf08bcf4de9 (patch) | |
| tree | 55bcf5cd135ea88a8fedc6931c6a33c4a90b0112 /src | |
| parent | 951a81dbb75db9850ee0226f74a575af7335a576 (diff) | |
Fix multiple video adds to be consecutive.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/examine_content_job.cc | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 24 | ||||
| -rw-r--r-- | src/lib/film.h | 2 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 12 | ||||
| -rw-r--r-- | src/lib/playlist.h | 3 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 10 |
6 files changed, 36 insertions, 17 deletions
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index 6d5f4faf9..f68a1eea0 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -21,6 +21,7 @@ #include "examine_content_job.h" #include "log.h" #include "content.h" +#include "film.h" #include "i18n.h" @@ -48,6 +49,7 @@ void ExamineContentJob::run () { _content->examine (shared_from_this ()); + _film->add_content (_content); set_progress (1); set_state (FINISHED_OK); } diff --git a/src/lib/film.cc b/src/lib/film.cc index fc1d2d8a4..26b3962a1 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1,5 +1,3 @@ -/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ - /* Copyright (C) 2012 Carl Hetherington <cth@carlh.net> @@ -75,6 +73,7 @@ using std::cout; using std::list; using boost::shared_ptr; using boost::lexical_cast; +using boost::dynamic_pointer_cast; using boost::to_upper_copy; using boost::ends_with; using boost::starts_with; @@ -316,14 +315,6 @@ Film::analyse_audio () JobManager::instance()->add (_analyse_audio_job); } -/** Start a job to examine a piece of content */ -void -Film::examine_content (shared_ptr<Content> c) -{ - shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c)); - JobManager::instance()->add (j); -} - void Film::analyse_audio_finished () { @@ -813,10 +804,21 @@ Film::content () const } void +Film::examine_and_add_content (shared_ptr<Content> c) +{ + shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c)); + JobManager::instance()->add (j); +} + +void Film::add_content (shared_ptr<Content> c) { + /* Add video content after any existing content */ + if (dynamic_pointer_cast<VideoContent> (c)) { + c->set_start (_playlist->video_end ()); + } + _playlist->add (c); - examine_content (c); } void diff --git a/src/lib/film.h b/src/lib/film.h index 84f0b0233..9d1b86374 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -66,7 +66,6 @@ public: std::string internal_video_mxf_filename () const; std::string audio_analysis_path () const; - void examine_content (boost::shared_ptr<Content>); std::string dcp_video_mxf_filename () const; std::string dcp_audio_mxf_filename () const; @@ -227,6 +226,7 @@ public: void set_directory (std::string); void set_name (std::string); void set_use_dci_name (bool); + void examine_and_add_content (boost::shared_ptr<Content>); void add_content (boost::shared_ptr<Content>); void remove_content (boost::shared_ptr<Content>); void set_dcp_content_type (DCPContentType const *); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 7ab320558..d2df75a09 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -285,3 +285,15 @@ Playlist::reconnect () } } +Time +Playlist::video_end () const +{ + Time end = 0; + for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { + if (dynamic_pointer_cast<const VideoContent> (*i)) { + end = max (end, (*i)->end ()); + } + } + + return end; +} diff --git a/src/lib/playlist.h b/src/lib/playlist.h index aff6017fa..f75b4ba63 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -1,5 +1,3 @@ -/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ - /* Copyright (C) 2013 Carl Hetherington <cth@carlh.net> @@ -85,6 +83,7 @@ public: Time length () const; int best_dcp_frame_rate () const; + Time video_end () const; mutable boost::signals2::signal<void ()> Changed; mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index e6dd06472..d036f318e 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -1146,13 +1146,17 @@ FilmEditor::content_add_clicked (wxCommandEvent &) for (unsigned int i = 0; i < paths.GetCount(); ++i) { boost::filesystem::path p (wx_to_std (paths[i])); + shared_ptr<Content> c; + if (ImageMagickContent::valid_file (p)) { - _film->add_content (shared_ptr<ImageMagickContent> (new ImageMagickContent (_film, p))); + c.reset (new ImageMagickContent (_film, p)); } else if (SndfileContent::valid_file (p)) { - _film->add_content (shared_ptr<SndfileContent> (new SndfileContent (_film, p))); + c.reset (new SndfileContent (_film, p)); } else { - _film->add_content (shared_ptr<FFmpegContent> (new FFmpegContent (_film, p))); + c.reset (new FFmpegContent (_film, p)); } + + _film->examine_and_add_content (c); } } |
