+ DCPOMATIC_ASSERT (a);
+ a->set_annotation_text (i.name);
+ if (i.language) {
+ a->set_language (i.language.get());
+ }
+ }
+}
+
+
+void
+ReelWriter::create_reel_markers (shared_ptr<dcp::Reel> reel) const
+{
+ auto markers = film()->markers();
+ film()->add_ffoc_lfoc(markers);
+ Film::Markers reel_markers;
+ for (auto const& i: markers) {
+ if (_period.contains(i.second)) {
+ reel_markers[i.first] = i.second;
+ }
+ }
+
+ if (!reel_markers.empty ()) {
+ auto ma = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(film()->video_frame_rate(), 1), reel->duration());
+ for (auto const& i: reel_markers) {
+ DCPTime relative = i.second - _period.from;
+ auto hmsf = relative.split (film()->video_frame_rate());
+ ma->set (i.first, dcp::Time(hmsf.h, hmsf.m, hmsf.s, hmsf.f, film()->video_frame_rate()));
+ }
+ reel->add (ma);
+ }
+}
+
+
+/** @param ensure_subtitles true to make sure the reel has a subtitle asset.
+ * @param ensure_closed_captions make sure the reel has these closed caption tracks.
+ */
+shared_ptr<dcp::Reel>
+ReelWriter::create_reel (
+ list<ReferencedReelAsset> const & refs,
+ FontIdMap const & fonts,
+ shared_ptr<dcpomatic::Font> chosen_interop_font,
+ boost::filesystem::path output_dcp,
+ bool ensure_subtitles,
+ set<DCPTextTrack> ensure_closed_captions
+ )
+{
+ LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count);
+
+ auto reel = make_shared<dcp::Reel>();
+
+ /* This is a bit of a hack; in the strange `_text_only' mode we have no picture, so we don't know
+ * how long the subtitle / CCAP assets should be. However, since we're only writing them to see
+ * how big they are, we don't care about that.
+ */
+ int64_t duration = 0;
+ if (!_text_only) {
+ auto reel_picture_asset = create_reel_picture (reel, refs);
+ duration = reel_picture_asset->actual_duration ();
+ create_reel_sound (reel, refs);
+ create_reel_markers (reel);
+ }
+
+ create_reel_text (reel, refs, fonts, chosen_interop_font, duration, output_dcp, ensure_subtitles, ensure_closed_captions);
+
+ if (_atmos_asset) {
+ reel->add (make_shared<dcp::ReelAtmosAsset>(_atmos_asset, 0));