/* Copyright (C) 2012-2015 Carl Hetherington This program 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, 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. */ #include "../exceptions.h" #include "../raw_convert.h" #include "subtitle.h" #include #include #include using std::string; using std::vector; using std::list; using boost::optional; using boost::shared_ptr; using boost::lexical_cast; using boost::is_any_of; using namespace sub; dcp::Subtitle::Subtitle (boost::shared_ptr node, optional tcr) { if (tcr) { in = smpte_time (node, "TimeIn", tcr.get ()).get (); out = smpte_time (node, "TimeOut", tcr.get ()).get (); } else { in = interop_time (node, "TimeIn").get (); out = interop_time (node, "TimeOut").get (); } if (tcr) { fade_up_time = smpte_time (node, "FadeUpTime", tcr.get ()).get_value_or (Time::from_hmsf (0, 0, 0, 2, Rational (tcr.get(), 1))); fade_down_time = smpte_time (node, "FadeDownTime", tcr.get ()).get_value_or (Time::from_hmsf (0, 0, 0, 2, Rational (tcr.get (), 1))); } else { fade_up_time = interop_time (node, "FadeUpTime").get_value_or (Time::from_hms (0, 0, 0, 80)); if (fade_up_time > Time::from_hms (0, 0, 8, 0)) { fade_up_time = Time::from_hms (0, 0, 8, 0); } fade_down_time = interop_time (node, "FadeDownTime").get_value_or (Time::from_hms (0, 0, 0, 80)); if (fade_down_time > Time::from_hms (0, 0, 8, 0)) { fade_down_time = Time::from_hms (0, 0, 8, 0); } } } optional