-list<ReferencedReelAsset>
-Player::get_reel_assets ()
-{
- /* Does not require a lock on _mutex as it's only called from DCPEncoder */
-
- list<ReferencedReelAsset> a;
-
- BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) {
- shared_ptr<DCPContent> j = dynamic_pointer_cast<DCPContent> (i);
- if (!j) {
- continue;
- }
-
- scoped_ptr<DCPDecoder> decoder;
- try {
- decoder.reset (new DCPDecoder (_film, j, false, false, shared_ptr<DCPDecoder>()));
- } catch (...) {
- return a;
- }
-
- DCPOMATIC_ASSERT (j->video_frame_rate ());
- double const cfr = j->video_frame_rate().get();
- Frame const trim_start = j->trim_start().frames_round (cfr);
- Frame const trim_end = j->trim_end().frames_round (cfr);
- int const ffr = _film->video_frame_rate ();
-
- /* position in the asset from the start */
- int64_t offset_from_start = 0;
- /* position in the asset from the end */
- int64_t offset_from_end = 0;
- BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder->reels()) {
- /* Assume that main picture duration is the length of the reel */
- offset_from_end += k->main_picture()->actual_duration();
- }
-
- BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder->reels()) {
-
- /* Assume that main picture duration is the length of the reel */
- int64_t const reel_duration = k->main_picture()->actual_duration();
-
- /* See doc/design/trim_reels.svg */
- Frame const reel_trim_start = min(reel_duration, max(int64_t(0), trim_start - offset_from_start));
- Frame const reel_trim_end = min(reel_duration, max(int64_t(0), reel_duration - (offset_from_end - trim_end)));
-
- DCPTime const from = i->position() + DCPTime::from_frames (offset_from_start, _film->video_frame_rate());
- if (j->reference_video ()) {
- maybe_add_asset (a, k->main_picture(), reel_trim_start, reel_trim_end, from, ffr);
- }
-
- if (j->reference_audio ()) {
- maybe_add_asset (a, k->main_sound(), reel_trim_start, reel_trim_end, from, ffr);
- }
-
- if (j->reference_text (TEXT_OPEN_SUBTITLE)) {
- maybe_add_asset (a, k->main_subtitle(), reel_trim_start, reel_trim_end, from, ffr);
- }
-
- if (j->reference_text (TEXT_CLOSED_CAPTION)) {
- BOOST_FOREACH (shared_ptr<dcp::ReelClosedCaptionAsset> l, k->closed_captions()) {
- maybe_add_asset (a, l, reel_trim_start, reel_trim_end, from, ffr);
- }
- }
-
- offset_from_start += reel_duration;
- offset_from_end -= reel_duration;
- }
- }
-
- return a;
-}