diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/content.cc | 24 | ||||
| -rw-r--r-- | src/lib/content.h | 5 | ||||
| -rw-r--r-- | src/lib/content_factory.cc | 17 | ||||
| -rw-r--r-- | src/lib/content_factory.h | 1 | ||||
| -rw-r--r-- | src/lib/film.cc | 6 | ||||
| -rw-r--r-- | src/lib/film.h | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 12 | ||||
| -rw-r--r-- | src/lib/playlist.h | 2 |
9 files changed, 68 insertions, 5 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc index dbb841200..e3ad42560 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -31,10 +31,11 @@ using std::set; using boost::shared_ptr; using boost::lexical_cast; -int const ContentProperty::POSITION = 400; -int const ContentProperty::LENGTH = 401; -int const ContentProperty::TRIM_START = 402; -int const ContentProperty::TRIM_END = 403; +int const ContentProperty::PATH = 400; +int const ContentProperty::POSITION = 401; +int const ContentProperty::LENGTH = 402; +int const ContentProperty::TRIM_START = 403; +int const ContentProperty::TRIM_END = 404; Content::Content (shared_ptr<const Film> f, Time p) : _film (f) @@ -191,3 +192,18 @@ Content::identifier () const return s.str (); } + +bool +Content::path_valid () const +{ + return boost::filesystem::exists (_path); +} + +void +Content::set_path (boost::filesystem::path path) +{ + _path = path; + signal_changed (ContentProperty::PATH); +} + + diff --git a/src/lib/content.h b/src/lib/content.h index 9c7ad2fc2..c066c61e0 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -38,6 +38,7 @@ class Film; class ContentProperty { public: + static int const PATH; static int const POSITION; static int const LENGTH; static int const TRIM_START; @@ -61,12 +62,16 @@ public: virtual std::string identifier () const; boost::shared_ptr<Content> clone () const; + + void set_path (boost::filesystem::path); boost::filesystem::path path () const { boost::mutex::scoped_lock lm (_mutex); return _path; } + bool path_valid () const; + /** @return MD5 digest of the content's file(s) */ std::string digest () const { boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index 6ed01f174..d42491f7f 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -22,6 +22,7 @@ #include "still_image_content.h" #include "moving_image_content.h" #include "sndfile_content.h" +#include "util.h" using std::string; using boost::shared_ptr; @@ -45,3 +46,19 @@ content_factory (shared_ptr<const Film> film, shared_ptr<cxml::Node> node) return content; } + +shared_ptr<Content> +content_factory (shared_ptr<const Film> film, boost::filesystem::path path) +{ + shared_ptr<Content> content; + + if (valid_image_file (path)) { + content.reset (new StillImageContent (film, path)); + } else if (SndfileContent::valid_file (path)) { + content.reset (new SndfileContent (film, path)); + } else { + content.reset (new FFmpegContent (film, path)); + } + + return content; +} diff --git a/src/lib/content_factory.h b/src/lib/content_factory.h index 27cd36024..93fd98d83 100644 --- a/src/lib/content_factory.h +++ b/src/lib/content_factory.h @@ -20,3 +20,4 @@ class Film; extern boost::shared_ptr<Content> content_factory (boost::shared_ptr<const Film>, boost::shared_ptr<cxml::Node>); +extern boost::shared_ptr<Content> content_factory (boost::shared_ptr<const Film>, boost::filesystem::path); diff --git a/src/lib/film.cc b/src/lib/film.cc index f869289d5..650163efe 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -844,6 +844,12 @@ Film::best_video_frame_rate () const return _playlist->best_dcp_frame_rate (); } +bool +Film::content_paths_valid () const +{ + return _playlist->content_paths_valid (); +} + void Film::playlist_content_changed (boost::weak_ptr<Content> c, int p) { diff --git a/src/lib/film.h b/src/lib/film.h index 8cfc49088..6bd04572b 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -111,10 +111,10 @@ public: /* Proxies for some Playlist methods */ ContentList content () const; - Time length () const; bool has_subtitles () const; OutputVideoFrame best_video_frame_rate () const; + bool content_paths_valid () const; libdcp::KDM make_kdm ( diff --git a/src/lib/player.cc b/src/lib/player.cc index f79265558..310e91b6c 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -480,6 +480,10 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent) ) { Changed (frequent); + + } else if (property == ContentProperty::PATH) { + + Changed (frequent); } } diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 1712dc8ff..621b99dd7 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -390,3 +390,15 @@ Playlist::move_later (shared_ptr<Content> c) Changed (); } + +bool +Playlist::content_paths_valid () const +{ + for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { + if (!(*i)->path_valid ()) { + return false; + } + } + + return true; +} diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 05928ee57..a1ae9b151 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -80,6 +80,8 @@ public: void repeat (ContentList, int); + bool content_paths_valid () const; + mutable boost::signals2::signal<void ()> Changed; /** Third parameter is true if signals are currently being emitted frequently */ mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged; |
