2 Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
34 /** @file src/smpte_subtitle_asset.h
35 * @brief SMPTESubtitleAsset class.
38 #include "subtitle_asset.h"
39 #include "language_tag.h"
40 #include "local_time.h"
42 #include "crypto_context.h"
43 #include <boost/filesystem.hpp>
51 struct verify_invalid_language1;
52 struct verify_invalid_language2;
56 class SMPTELoadFontNode;
58 /** @class SMPTESubtitleAsset
59 * @brief A set of subtitles to be read and/or written in the SMPTE format.
61 class SMPTESubtitleAsset : public SubtitleAsset, public MXF
64 SMPTESubtitleAsset ();
66 /** @param file File name
68 explicit SMPTESubtitleAsset (boost::filesystem::path file);
71 std::shared_ptr<const Asset>,
76 std::vector<std::shared_ptr<LoadFontNode>> load_font_nodes () const;
78 std::string xml_as_string () const;
79 void write (boost::filesystem::path path) const;
80 void add (std::shared_ptr<Subtitle>);
81 void add_font (std::string id, dcp::ArrayData data);
82 void set_key (Key key);
84 void set_content_title_text (std::string t) {
85 _content_title_text = t;
88 void set_language (dcp::LanguageTag l) {
89 _language = l.to_string();
92 void set_issue_date (LocalTime t) {
96 void set_reel_number (int r) {
100 void set_edit_rate (Fraction e) {
104 void set_time_code_rate (int t) {
108 void set_start_time (Time t) {
112 void set_intrinsic_duration (int64_t d) {
113 _intrinsic_duration = d;
116 /** @return title of the film that these subtitles are for,
117 * to be presented to the user.
119 std::string content_title_text () const {
120 return _content_title_text;
123 /** @return Language, if one was set. This should be a xs:language, but
124 * it might not be if a non-compliant DCP was read in.
126 boost::optional<std::string> language () const {
130 /** @return annotation text, to be presented to the user */
131 boost::optional<std::string> annotation_text () const {
132 return _annotation_text;
135 /** @return file creation time and date */
136 LocalTime issue_date () const {
140 boost::optional<int> reel_number () const {
144 Fraction edit_rate () const {
148 /** @return subdivision of 1 second that is used for subtitle times;
149 * e.g. a time_code_rate of 250 means that a subtitle time of 0:0:0:001
152 int time_code_rate () const {
153 return _time_code_rate;
156 boost::optional<Time> start_time () const {
160 std::string xml_id () const {
164 static bool valid_mxf (boost::filesystem::path);
165 static std::string static_pkl_type (Standard) {
166 return "application/mxf";
171 std::string pkl_type (Standard s) const {
172 return static_pkl_type (s);
176 friend struct ::write_smpte_subtitle_test;
177 friend struct ::write_smpte_subtitle_test2;
178 friend struct ::verify_invalid_language1;
179 friend struct ::verify_invalid_language2;
181 void read_fonts (std::shared_ptr<ASDCP::TimedText::MXFReader>);
182 void parse_xml (std::shared_ptr<cxml::Document> xml);
183 void read_mxf_descriptor (std::shared_ptr<ASDCP::TimedText::MXFReader> reader, std::shared_ptr<DecryptionContext> dec);
185 /** The total length of this content in video frames. The amount of
186 * content presented may be less than this.
188 int64_t _intrinsic_duration;
189 /** <ContentTitleText> from the asset */
190 std::string _content_title_text;
191 /** This is stored and returned as a string so that we can tolerate non-RFC-5646 strings,
192 * but must be set as a dcp::LanguageTag to try to ensure that we create compliant output.
194 boost::optional<std::string> _language;
195 boost::optional<std::string> _annotation_text;
196 LocalTime _issue_date;
197 boost::optional<int> _reel_number;
200 boost::optional<Time> _start_time;
202 std::vector<std::shared_ptr<SMPTELoadFontNode>> _load_font_nodes;
203 /** UUID for the XML inside the MXF, which should be different to the ID of the MXF according to
204 * Doremi's 2.8.18 release notes.