- maybe_add_text<dcp::ReelSubtitleAsset> (_subtitle_asset, reel_picture_asset->actual_duration(), reel, refs, fonts, _film, _period);
- for (map<DCPTextTrack, shared_ptr<dcp::SubtitleAsset> >::const_iterator i = _closed_caption_assets.begin(); i != _closed_caption_assets.end(); ++i) {
- shared_ptr<dcp::ReelClosedCaptionAsset> a = maybe_add_text<dcp::ReelClosedCaptionAsset> (
- i->second, reel_picture_asset->actual_duration(), reel, refs, fonts, _film, _period
+void
+ReelWriter::create_reel_text (
+ shared_ptr<dcp::Reel> reel,
+ list<ReferencedReelAsset> const & refs,
+ FontIdMap const& fonts,
+ shared_ptr<dcpomatic::Font> chosen_interop_font,
+ int64_t duration,
+ boost::filesystem::path output_dcp,
+ bool ensure_subtitles,
+ set<DCPTextTrack> ensure_closed_captions
+ ) const
+{
+ auto subtitle = maybe_add_text<dcp::ReelInteropSubtitleAsset, dcp::ReelSMPTESubtitleAsset, dcp::ReelSubtitleAsset> (
+ _subtitle_asset, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, chosen_interop_font, _default_font, film(), _period, output_dcp, _text_only
+ );
+
+ if (subtitle) {
+ /* We have a subtitle asset that we either made or are referencing */
+ if (auto main_language = film()->subtitle_languages().first) {
+ subtitle->set_language (*main_language);
+ }
+ } else if (ensure_subtitles) {
+ /* We had no subtitle asset, but we've been asked to make sure there is one */
+ subtitle = maybe_add_text<dcp::ReelInteropSubtitleAsset, dcp::ReelSMPTESubtitleAsset, dcp::ReelSubtitleAsset> (
+ empty_text_asset(TextType::OPEN_SUBTITLE, optional<DCPTextTrack>(), true),
+ duration,
+ reel,
+ _reel_index,
+ _reel_count,
+ _content_summary,
+ refs,
+ fonts,
+ chosen_interop_font,
+ _default_font,
+ film(),
+ _period,
+ output_dcp,
+ _text_only
+ );
+ }
+
+ for (auto const& i: _closed_caption_assets) {
+ auto a = maybe_add_text<dcp::ReelInteropClosedCaptionAsset, dcp::ReelSMPTEClosedCaptionAsset, dcp::ReelClosedCaptionAsset> (
+ i.second, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, chosen_interop_font, _default_font, film(), _period, output_dcp, _text_only
+ );
+ DCPOMATIC_ASSERT (a);
+ a->set_annotation_text (i.first.name);
+ if (i.first.language) {
+ a->set_language (i.first.language.get());
+ }
+
+ ensure_closed_captions.erase (i.first);
+ }
+
+ /* Make empty tracks for anything we've been asked to ensure but that we haven't added */
+ for (auto i: ensure_closed_captions) {
+ auto a = maybe_add_text<dcp::ReelInteropClosedCaptionAsset, dcp::ReelSMPTEClosedCaptionAsset, dcp::ReelClosedCaptionAsset> (
+ empty_text_asset(TextType::CLOSED_CAPTION, i, true),
+ duration,
+ reel,
+ _reel_index,
+ _reel_count,
+ _content_summary,
+ refs,
+ fonts,
+ chosen_interop_font,
+ _default_font,
+ film(),
+ _period,
+ output_dcp,
+ _text_only