diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-09-04 00:05:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-09-04 00:05:04 +0100 |
| commit | cb1dfa9ec09af2abf6d10e4bf2764476db83841b (patch) | |
| tree | 5ccd5fd123fa07702b6cf647cedb7df8e8917fa0 /src/lib | |
| parent | dc120d521c740b7f1ec356538139c5769a5f54be (diff) | |
| parent | 4092121ad052f406e8b5c5a2debbd8256321f182 (diff) | |
Merge master.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 16 | ||||
| -rw-r--r-- | src/lib/internet.cc | 4 | ||||
| -rw-r--r-- | src/lib/ratio.cc | 17 | ||||
| -rw-r--r-- | src/lib/ratio.h | 1 | ||||
| -rw-r--r-- | src/lib/ui_signaller.h | 7 |
5 files changed, 39 insertions, 6 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 577c29e3a..475dd6844 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -591,18 +591,22 @@ Film::isdcf_name (bool if_created_now) const d << "_" << container()->isdcf_name(); } - /* XXX: this only works for content which has been scaled to a given ratio, - and uses the first bit of content only. - */ + /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) { ContentList cl = content (); Ratio const * content_ratio = 0; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i); - if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) { - content_ratio = vc->scale().ratio(); + if (vc) { + /* Here's the first piece of video content */ + if (vc->scale().ratio ()) { + content_ratio = vc->scale().ratio (); + } else { + content_ratio = Ratio::from_ratio (vc->video_size().ratio ()); + } + break; } } diff --git a/src/lib/internet.cc b/src/lib/internet.cc index c28e650fd..1c61e96e3 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -56,6 +56,8 @@ get_from_zip_url (string url, string file, function<void (boost::filesystem::pat curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, f); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); + /* Maximum time is 20s */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); CURLcode const cr = curl_easy_perform (curl); @@ -117,6 +119,8 @@ ftp_ls (string url) url += "/"; } curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); + /* 20s timeout */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); string ls_raw; struct curl_slist* commands = 0; diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index bb6963658..fc36415c5 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -56,3 +56,20 @@ Ratio::from_id (string i) return *j; } + +/** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */ +Ratio const * +Ratio::from_ratio (float r) +{ + vector<Ratio const *>::iterator j = _ratios.begin (); + while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) { + ++j; + } + + if (j == _ratios.end ()) { + return 0; + } + + return *j; +} + diff --git a/src/lib/ratio.h b/src/lib/ratio.h index 22fc7662c..69e3726c8 100644 --- a/src/lib/ratio.h +++ b/src/lib/ratio.h @@ -52,6 +52,7 @@ public: static void setup_ratios (); static Ratio const * from_id (std::string i); + static Ratio const * from_ratio (float r); static std::vector<Ratio const *> all () { return _ratios; } diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 1d62547f6..ee4d230d4 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -54,8 +54,15 @@ public: } } + /* Do something next time the UI is idle */ + template <typename T> + void when_idle (T f) { + _service.post (f); + } + /** Call this in the UI when it is idle */ size_t ui_idle () { + /* This executes any functors that have been post()ed to _service */ return _service.poll (); } |
