diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-06 17:46:24 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-26 17:20:25 +0100 |
| commit | 54e2644ed4dcc4faf5135e60926cfdda14886fea (patch) | |
| tree | ca1599fe32e3ace691dffcdb6ded45ad29baea59 /src/lib/fcpxml_content.cc | |
| parent | 1f077d2b791a059ccef4069dca07ead990bd568e (diff) | |
Support FCP XML files containing subtitles (#2909).
Diffstat (limited to 'src/lib/fcpxml_content.cc')
| -rw-r--r-- | src/lib/fcpxml_content.cc | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/lib/fcpxml_content.cc b/src/lib/fcpxml_content.cc new file mode 100644 index 000000000..94d1197df --- /dev/null +++ b/src/lib/fcpxml_content.cc @@ -0,0 +1,108 @@ +/* + Copyright (C) 2024 Carl Hetherington <cth@carlh.net> + + 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. + + 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "fcpxml.h" +#include "fcpxml_content.h" +#include "text_content.h" +#include <dcp/raw_convert.h> + +#include "i18n.h" + + +using std::list; +using std::make_shared; +using std::shared_ptr; +using std::string; +using boost::optional; + + +FCPXMLContent::FCPXMLContent(boost::filesystem::path path) + : Content(path) +{ + text.push_back(make_shared<TextContent>(this, TextType::OPEN_SUBTITLE, TextType::OPEN_SUBTITLE)); +} + + +FCPXMLContent::FCPXMLContent(cxml::ConstNodePtr node, optional<boost::filesystem::path> film_directory, int version, list<string>& notes) + : Content(node, film_directory) +{ + text = TextContent::from_xml(this, node, version, notes); +} + + + +void +FCPXMLContent::examine(shared_ptr<const Film> film, shared_ptr<Job> job) +{ + Content::examine(film, job); + + auto sequence = dcpomatic::fcpxml::load(path(0)); + + boost::mutex::scoped_lock lm(_mutex); + only_text()->set_use(true); + if (!sequence.video.empty()) { + _length = sequence.video.back().period.to; + } +} + + +dcpomatic::DCPTime +FCPXMLContent::full_length(shared_ptr<const Film> film) const +{ + FrameRateChange const frc(film, shared_from_this()); + return { _length, frc }; +} + + +dcpomatic::DCPTime +FCPXMLContent::approximate_length() const +{ + return { _length, {} }; +} + + +string +FCPXMLContent::summary() const +{ + return path_summary() + " " + _("[subtitles]"); +} + + +string +FCPXMLContent::technical_summary() const +{ + return Content::technical_summary() + " - " + _("FCP XML subtitles"); +} + + +void +FCPXMLContent::as_xml(xmlpp::Element* element, bool with_paths, PathBehaviour path_behaviour, optional<boost::filesystem::path> film_directory) const +{ + cxml::add_child(element, "Type", "FCPXML"); + Content::as_xml(element, with_paths, path_behaviour, film_directory); + + if (only_text()) { + only_text()->as_xml(element); + } + + cxml::add_child(element, "Length", dcp::raw_convert<string>(_length.get())); +} + |
