X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcontent.cc;h=9280d2e612be094566c183ea6a0340b3179e1f5f;hb=f0c10e92b849566e458bc323f8783a6fe83e52d2;hp=c8f836d18d5dc8edcc8920f7d75963aa9d54d282;hpb=68808da4a0f8c60ac93cd0bbc3ea776d16503a6a;p=dcpomatic.git diff --git a/src/lib/content.cc b/src/lib/content.cc index c8f836d18..9280d2e61 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -1,45 +1,67 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2018 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -#include -#include -#include +/** @file src/lib/content.cc + * @brief Content class. + */ + #include "content.h" +#include "change_signaller.h" #include "util.h" #include "content_factory.h" -#include "ui_signaller.h" +#include "video_content.h" +#include "audio_content.h" +#include "text_content.h" +#include "exceptions.h" +#include "film.h" +#include "job.h" +#include "compose.hpp" +#include +#include +#include +#include +#include +#include + +#include "i18n.h" using std::string; -using std::stringstream; -using std::set; +using std::list; +using std::cout; +using std::vector; +using std::max; +using std::pair; using boost::shared_ptr; -using boost::lexical_cast; +using boost::optional; +using dcp::raw_convert; +using dcp::locale_convert; 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; +int const ContentProperty::VIDEO_FRAME_RATE = 405; -Content::Content (shared_ptr f, Time p) - : _film (f) - , _position (p) +Content::Content () + : _position (0) , _trim_start (0) , _trim_end (0) , _change_signals_frequent (false) @@ -47,163 +69,440 @@ Content::Content (shared_ptr f, Time p) } -Content::Content (shared_ptr f, boost::filesystem::path p) - : _film (f) - , _position (0) +Content::Content (DCPTime p) + : _position (p) , _trim_start (0) , _trim_end (0) , _change_signals_frequent (false) { - _paths.push_back (p); + +} + +Content::Content (boost::filesystem::path p) + : _position (0) + , _trim_start (0) + , _trim_end (0) + , _change_signals_frequent (false) +{ + add_path (p); +} + +Content::Content (cxml::ConstNodePtr node) + : _change_signals_frequent (false) +{ + list path_children = node->node_children ("Path"); + BOOST_FOREACH (cxml::NodePtr i, path_children) { + _paths.push_back (i->content()); + optional const mod = i->optional_number_attribute("mtime"); + if (mod) { + _last_write_times.push_back (*mod); + } else if (boost::filesystem::exists(i->content())) { + _last_write_times.push_back (boost::filesystem::last_write_time(i->content())); + } else { + _last_write_times.push_back (0); + } + } + _digest = node->optional_string_child ("Digest").get_value_or ("X"); + _position = DCPTime (node->number_child ("Position")); + _trim_start = ContentTime (node->number_child ("TrimStart")); + _trim_end = ContentTime (node->number_child ("TrimEnd")); + _video_frame_rate = node->optional_number_child ("VideoFrameRate"); } -Content::Content (shared_ptr f, shared_ptr node) - : _film (f) +Content::Content (vector > c) + : _position (c.front()->position ()) + , _trim_start (c.front()->trim_start ()) + , _trim_end (c.back()->trim_end ()) + , _video_frame_rate (c.front()->video_frame_rate()) , _change_signals_frequent (false) { - _paths.push_back (node->string_child ("Path")); - _digest = node->string_child ("Digest"); - _position = node->number_child