}
}
+ const string dvd_dir = _film->dir ("dvd");
+
+ string largest_file;
+ uintmax_t largest_size = 0;
+ for (filesystem::directory_iterator i = filesystem::directory_iterator (dvd_dir); i != filesystem::directory_iterator(); ++i) {
+ uintmax_t const s = filesystem::file_size (*i);
+ if (s > largest_size) {
+
+#if BOOST_FILESYSTEM_VERSION == 3
+ largest_file = filesystem::path(*i).generic_string();
+#else
+ largest_file = i->string ();
+#endif
+ largest_size = s;
+ }
+ }
+
+ _film->set_content (largest_file);
+
int const r = pclose (f);
if (WEXITSTATUS (r) != 0) {
set_error ("call to vobcopy failed");
* @brief A class to run through content at high speed to find its length.
*/
+#include <boost/filesystem.hpp>
#include "examine_content_job.h"
#include "options.h"
#include "decoder_factory.h"
}
+ string const tdir = _film->dir ("thumbs");
+ vector<int> thumbs;
+
+ for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) {
+
+ /* Aah, the sweet smell of progress */
+#if BOOST_FILESYSTEM_VERSION == 3
+ string const l = filesystem::path(*i).leaf().generic_string();
+#else
+ string const l = i->leaf ();
+#endif
+
+ size_t const d = l.find (".png");
+ size_t const t = l.find (".tmp");
+ if (d != string::npos && t == string::npos) {
+ thumbs.push_back (atoi (l.substr (0, d).c_str()));
+ }
+ }
+
+ sort (thumbs.begin(), thumbs.end());
+ _film->set_thumbs (thumbs);
+
ascend ();
set_progress (1);
set_state (FINISHED_OK);
JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
}
-void
-Film::copy_from_dvd_post_gui ()
-{
- const string dvd_dir = dir ("dvd");
-
- string largest_file;
- uintmax_t largest_size = 0;
- for (filesystem::directory_iterator i = filesystem::directory_iterator (dvd_dir); i != filesystem::directory_iterator(); ++i) {
- uintmax_t const s = filesystem::file_size (*i);
- if (s > largest_size) {
-
-#if BOOST_FILESYSTEM_VERSION == 3
- largest_file = filesystem::path(*i).generic_string();
-#else
- largest_file = i->string ();
-#endif
- largest_size = s;
- }
- }
-
- set_content (largest_file);
-}
-
/** Start a job to examine our content file */
void
Film::examine_content ()
dir ("thumbs");
_examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
- _examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_post_gui));
+ _examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_finished));
JobManager::instance()->add (_examine_content_job);
}
void
-Film::examine_content_post_gui ()
+Film::examine_content_finished ()
{
- set_length (_examine_content_job->last_video_frame ());
_examine_content_job.reset ();
-
- string const tdir = dir ("thumbs");
- vector<int> thumbs;
-
- for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) {
-
- /* Aah, the sweet smell of progress */
-#if BOOST_FILESYSTEM_VERSION == 3
- string const l = filesystem::path(*i).leaf().generic_string();
-#else
- string const l = i->leaf ();
-#endif
-
- size_t const d = l.find (".png");
- size_t const t = l.find (".tmp");
- if (d != string::npos && t == string::npos) {
- thumbs.push_back (atoi (l.substr (0, d).c_str()));
- }
- }
-
- sort (thumbs.begin(), thumbs.end());
- set_thumbs (thumbs);
}
-
/** @return full paths to any audio files that this Film has */
vector<string>
Film::audio_files () const
Film::copy_from_dvd ()
{
shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
- j->Finished.connect (sigc::mem_fun (*this, &Film::copy_from_dvd_post_gui));
JobManager::instance()->add (j);
}
std::vector<std::string> audio_files () const;
std::pair<Position, std::string> thumb_subtitle (int) const;
- void copy_from_dvd_post_gui ();
void examine_content ();
- void examine_content_post_gui ();
void send_dcp_to_tms ();
void copy_from_dvd ();
std::string thumb_base_for_frame (int) const;
void signal_changed (Property);
std::string file_locked (std::string) const;
+ void examine_content_finished ();
/** Complete path to directory containing the film metadata;
* must not be relative.
if (_state == FINISHED_OK || _state == FINISHED_ERROR) {
_ran_for = elapsed_time ();
+ Finished ();
}
}
-/** A hack to work around our lack of cross-thread
- * signalling; this emits Finished, and listeners
- * assume that it will be emitted in the GUI thread,
- * so this method must be called from the GUI thread.
- */
-void
-Job::emit_finished ()
-{
- Finished ();
-}
-
/** @return Time (in seconds) that this job has been running */
int
Job::elapsed_time () const
void descend (float);
float overall_progress () const;
- void emit_finished ();
-
boost::shared_ptr<Job> required () const {
return _required;
}
- /** Emitted from the GUI thread */
sigc::signal0<void> Finished;
protected:
r.gauge = new wxGauge (_panel, wxID_ANY, 100);
_table->Insert (index + 1, r.gauge, 1, wxEXPAND | wxLEFT | wxRIGHT);
- r.informed_of_finish = false;
r.message = new wxStaticText (_panel, wxID_ANY, std_to_wx (""));
_table->Insert (index + 2, r.message, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
}
}
- /* Hack to work around our lack of cross-thread
- signalling; we tell the job to emit_finished()
- from here (the GUI thread).
- */
-
- if ((*i)->finished () && !_job_records[*i].informed_of_finish) {
+ if ((*i)->finished()) {
_job_records[*i].gauge->SetValue (100);
_job_records[*i].message->SetLabel (std_to_wx (st));
-
- try {
- (*i)->emit_finished ();
- } catch (OpenFileError& e) {
- error_dialog (this, String::compose ("Error: %1", e.what ()));
- }
-
- _job_records[*i].informed_of_finish = true;
}
index += 3;
struct JobRecord {
wxGauge* gauge;
wxStaticText* message;
- bool informed_of_finish;
};
std::map<boost::shared_ptr<Job>, JobRecord> _job_records;