2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <libcxml/cxml.h>
21 #include "image_content.h"
22 #include "image_examiner.h"
24 #include "compose.hpp"
32 using std::stringstream;
33 using boost::shared_ptr;
35 ImageContent::ImageContent (shared_ptr<const Film> f, boost::filesystem::path p)
39 if (boost::filesystem::is_regular_file (p)) {
42 for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
43 if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) {
44 _paths.push_back (i->path ());
48 sort (_paths.begin(), _paths.end());
53 ImageContent::ImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node, int)
55 , VideoContent (f, node)
61 ImageContent::summary () const
63 string s = path_summary () + " ";
64 /* Get the string() here so that the name does not have quotes around it */
68 s += _("[moving images]");
75 ImageContent::technical_summary () const
77 string s = Content::technical_summary() + " - "
78 + VideoContent::technical_summary() + " - ";
90 ImageContent::as_xml (xmlpp::Node* node) const
92 node->add_child("Type")->add_child_text ("Image");
93 Content::as_xml (node);
94 VideoContent::as_xml (node);
98 ImageContent::examine (shared_ptr<Job> job)
100 job->sub (_("Computing digest"));
101 Content::examine (job);
103 shared_ptr<const Film> film = _film.lock ();
106 shared_ptr<ImageExaminer> examiner (new ImageExaminer (film, shared_from_this(), job));
108 take_from_video_examiner (examiner);
109 set_video_length (examiner->video_length ());
113 ImageContent::set_video_length (VideoContent::Frame len)
116 boost::mutex::scoped_lock lm (_mutex);
120 signal_changed (ContentProperty::LENGTH);
124 ImageContent::full_length () const
126 shared_ptr<const Film> film = _film.lock ();
129 FrameRateChange frc (video_frame_rate(), film->video_frame_rate ());
130 return video_length() * frc.factor() * TIME_HZ / video_frame_rate();
134 ImageContent::identifier () const
137 s << VideoContent::identifier ();
138 s << "_" << video_length();
143 ImageContent::still () const
145 return number_of_paths() == 1;