Fix multiple video adds to be consecutive.
authorCarl Hetherington <cth@carlh.net>
Mon, 27 May 2013 17:59:43 +0000 (18:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 27 May 2013 17:59:43 +0000 (18:59 +0100)
branch-notes
src/lib/examine_content_job.cc
src/lib/film.cc
src/lib/film.h
src/lib/playlist.cc
src/lib/playlist.h
src/wx/film_editor.cc

index 3695ecfd5764aca8b07450301caa5c6ebd4591cc..f713f5d2aebb646b29be7bcf73e3c5e4d9e87635 100644 (file)
@@ -1,5 +1,3 @@
-ffmpeg content selected stream is really a playlist thing.
-
 things to put back
        frame rate description  
        trust content header?
index 6d5f4faf9e690b754e621883452a1253234c775b..f68a1eea0e7e765301292c6ff1b66496e5b754cd 100644 (file)
@@ -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);
 }
index fc1d2d8a4ee2fa7c98ee7d34ad06a639cf42b38e..26b3962a1fe7c122fd7c03b2f5057afc2725168f 100644 (file)
@@ -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 ()
 {
@@ -812,11 +803,22 @@ Film::content () const
        return _playlist->content ();
 }
 
+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
index 84f0b0233ac6247634a9499b94b2c0cc30f8a934..9d1b863742152961f6eb00080c87c0666dd1b2e1 100644 (file)
@@ -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 *);
index 7ab320558b01324e78cfe2d821f0d6379bbc1eb1..d2df75a09a4a9e045c73c7f4d7f14803518630a0 100644 (file)
@@ -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;
+}
index aff6017fad640101241bf0e3ed8ba9e9fbfe1f7d..f75b4ba63ea9e3e27447de2d52942257fe1c0cb3 100644 (file)
@@ -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;
index e6dd06472d924eaca5347ad640f43eef6fa3e957..d036f318ecf7d0b25966dbbca8a48b423ccf0e37 100644 (file)
@@ -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);
        }
 }