- BOOST_FOREACH (Reel& i, _reels) {
- shared_ptr<dcp::Reel> reel (new dcp::Reel ());
-
- shared_ptr<dcp::ReelPictureAsset> reel_picture_asset;
-
- if (i.picture_asset) {
- /* We have made a picture asset of our own. Put it into the reel */
- shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (i.picture_asset);
- if (mono) {
- reel_picture_asset.reset (new dcp::ReelMonoPictureAsset (mono, 0));
- }
-
- shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (i.picture_asset);
- if (stereo) {
- reel_picture_asset.reset (new dcp::ReelStereoPictureAsset (stereo, 0));
- }
- } else {
- /* We don't have a picture asset of our own; maybe we need to reference one */
- /* XXX: this is all a hack */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
- shared_ptr<dcp::ReelPictureAsset> k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j);
- if (k) {
- reel_picture_asset = k;
- }
- }
- }
-
- reel->add (reel_picture_asset);
-
- if (i.sound_asset) {
- /* We have made a sound asset of our own. Put it into the reel */
- reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (i.sound_asset, 0)));
- } else {
- /* We don't have a sound asset of our own; maybe we need to reference one */
- /* XXX: this is all a hack */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
- if (dynamic_pointer_cast<dcp::ReelSoundAsset> (j)) {
- reel->add (j);
- }
- }
- }
-
- if (i.subtitle_asset) {
- boost::filesystem::path liberation;
- try {
- liberation = shared_path () / "LiberationSans-Regular.ttf";
- } catch (boost::filesystem::filesystem_error& e) {
- /* Hack: try the debian/ubuntu location if getting the shared path failed */
- liberation = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
- }
-
- /* Add all the fonts to the subtitle content */
- BOOST_FOREACH (shared_ptr<Font> j, _fonts) {
- i.subtitle_asset->add_font (j->id(), j->file().get_value_or (liberation));
- }
-
- if (dynamic_pointer_cast<dcp::InteropSubtitleAsset> (i.subtitle_asset)) {
- boost::filesystem::path directory = _film->dir (_film->dcp_name ()) / i.subtitle_asset->id ();
- boost::filesystem::create_directories (directory);
- i.subtitle_asset->write (directory / ("sub_" + i.subtitle_asset->id() + ".xml"));
- } else {
-
- /* All our assets should be the same length; use the picture asset length here
- as a reference to set the subtitle one.
- */
- dynamic_pointer_cast<dcp::SMPTESubtitleAsset>(i.subtitle_asset)->set_intrinsic_duration (
- reel_picture_asset->intrinsic_duration ()
- );
-
- i.subtitle_asset->write (
- _film->dir (_film->dcp_name ()) / ("sub_" + i.subtitle_asset->id() + ".mxf")
- );
- }
-
- reel->add (shared_ptr<dcp::ReelSubtitleAsset> (
- new dcp::ReelSubtitleAsset (
- i.subtitle_asset,
- dcp::Fraction (_film->video_frame_rate(), 1),
- reel_picture_asset->intrinsic_duration (),
- 0
- )
- ));
- } else {
- /* We don't have a subtitle asset of our own; maybe we need to reference one */
- /* XXX: this is all a hack */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
- if (dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j)) {
- reel->add (j);
- }
- }
- }
-
- cpl->add (reel);