}
if (film()->audio_channels()) {
- auto langs = film()->audio_languages();
+ auto lang = film()->audio_language();
_sound_asset = make_shared<dcp::SoundAsset> (
dcp::Fraction(film()->video_frame_rate(), 1),
film()->audio_frame_rate(),
film()->audio_channels(),
- langs.empty() ? dcp::LanguageTag("en-US") : langs.front(),
+ lang ? *lang : dcp::LanguageTag("en-US"),
standard
);
}
}
+
+/** Try to make a ReelAsset for a subtitles or closed captions in a given period in the DCP.
+ * A SubtitleAsset can be provided, or we will use one from @ref refs if not.
+ */
template <class Interop, class SMPTE, class Result>
shared_ptr<Result>
maybe_add_text (
} 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>()),
+ empty_text_asset(TextType::OPEN_SUBTITLE, optional<DCPTextTrack>(), true),
duration,
reel,
refs,
/* 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), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
+ empty_text_asset(TextType::CLOSED_CAPTION, i, true), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
);
DCPOMATIC_ASSERT (a);
a->set_annotation_text (i.name);
}
-
void
ReelWriter::create_reel_markers (shared_ptr<dcp::Reel> reel) const
{
}
void
-ReelWriter::calculate_digests (boost::function<void (float)> set_progress)
+ReelWriter::calculate_digests (std::function<void (float)> set_progress)
+try
{
if (_picture_asset) {
_picture_asset->hash (set_progress);
if (_atmos_asset) {
_atmos_asset->hash (set_progress);
}
+} catch (boost::thread_interrupted) {
+ /* set_progress contains an interruption_point, so any of these methods
+ * may throw thread_interrupted, at which point we just give up.
+ */
}
Frame
shared_ptr<dcp::SubtitleAsset>
-ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track) const
+ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track, bool with_dummy) const
{
shared_ptr<dcp::SubtitleAsset> asset;
if (film()->encrypted()) {
s->set_key (film()->key());
}
- s->add (
- std::make_shared<dcp::SubtitleString>(
- optional<std::string>(),
- false,
- false,
- false,
- dcp::Colour(),
- 42,
- 1.0,
- dcp::Time(0, 0, 0, 0, 24),
- dcp::Time(0, 0, 1, 0, 24),
- 0.5,
- dcp::HAlign::CENTER,
- 0.5,
- dcp::VAlign::CENTER,
- dcp::Direction::LTR,
- "",
- dcp::Effect::NONE,
- dcp::Colour(),
- dcp::Time(),
- dcp::Time()
- )
- );
+ if (with_dummy) {
+ s->add (
+ std::make_shared<dcp::SubtitleString>(
+ optional<std::string>(),
+ false,
+ false,
+ false,
+ dcp::Colour(),
+ 42,
+ 1.0,
+ dcp::Time(0, 0, 0, 0, 24),
+ dcp::Time(0, 0, 1, 0, 24),
+ 0.5,
+ dcp::HAlign::CENTER,
+ 0.5,
+ dcp::VAlign::CENTER,
+ dcp::Direction::LTR,
+ " ",
+ dcp::Effect::NONE,
+ dcp::Colour(),
+ dcp::Time(),
+ dcp::Time()
+ )
+ );
+ }
asset = s;
}
}
if (!asset) {
- asset = empty_text_asset (type, track);
+ asset = empty_text_asset (type, track, false);
}
switch (type) {