/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include <dcp/interop_subtitle_asset.h>
#include <dcp/smpte_subtitle_asset.h>
#include <boost/foreach.hpp>
-#include <boost/make_shared.hpp>
#include "i18n.h"
using std::string;
using std::cout;
using boost::shared_ptr;
-using boost::make_shared;
using boost::optional;
using boost::dynamic_pointer_cast;
using dcp::Data;
int const ReelWriter::_info_size = 48;
-ReelWriter::ReelWriter (shared_ptr<const Film> film, DCPTimePeriod period, shared_ptr<Job> job)
+ReelWriter::ReelWriter (
+ shared_ptr<const Film> film, DCPTimePeriod period, shared_ptr<Job> job, int reel_index, int reel_count, optional<string> content_summary
+ )
: _film (film)
, _period (period)
, _first_nonexistant_frame (0)
, _last_written_video_frame (-1)
, _last_written_eyes (EYES_RIGHT)
, _total_written_audio_frames (0)
+ , _reel_index (reel_index)
+ , _reel_count (reel_count)
+ , _content_summary (content_summary)
{
/* Create our picture asset in a subdirectory, named according to those
film's parameters which affect the video output. We will hard-link
of the DCP directory until the last minute.
*/
_sound_asset_writer = _sound_asset->start_write (
- _film->directory() / audio_asset_filename (_sound_asset),
+ _film->directory() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary),
_film->interop() ? dcp::INTEROP : dcp::SMPTE
);
}
boost::filesystem::path video_from = _picture_asset->file ();
boost::filesystem::path video_to;
video_to /= _film->dir (_film->dcp_name());
- video_to /= video_asset_filename (_picture_asset);
+ video_to /= video_asset_filename (_picture_asset, _reel_index, _reel_count, _content_summary);
boost::system::error_code ec;
boost::filesystem::create_hard_link (video_from, video_to, ec);
if (_sound_asset) {
boost::filesystem::path audio_to;
audio_to /= _film->dir (_film->dcp_name ());
- audio_to /= audio_asset_filename (_sound_asset);
+ string const aaf = audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary);
+ audio_to /= aaf;
boost::system::error_code ec;
- boost::filesystem::rename (_film->file (audio_asset_filename (_sound_asset)), audio_to, ec);
+ boost::filesystem::rename (_film->file (aaf), audio_to, ec);
if (ec) {
throw FileError (
- String::compose (_("could not move audio asset into the DCP (%1)"), ec.value ()), audio_asset_filename (_sound_asset)
+ String::compose (_("could not move audio asset into the DCP (%1)"), ec.value ()), aaf
);
}
shared_ptr<dcp::Reel>
ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts)
{
- shared_ptr<dcp::Reel> reel = make_shared<dcp::Reel> ();
+ shared_ptr<dcp::Reel> reel (new dcp::Reel ());
shared_ptr<dcp::ReelPictureAsset> reel_picture_asset;
}
}
+ DCPOMATIC_ASSERT (reel_picture_asset);
reel->add (reel_picture_asset);
+
/* If we have a hash for this asset in the CPL, assume that it is correct */
if (reel_picture_asset->hash()) {
reel_picture_asset->asset_ref()->set_hash (reel_picture_asset->hash().get());
if (_sound_asset) {
/* We have made a sound asset of our own. Put it into the reel */
- reel->add (make_shared<dcp::ReelSoundAsset> (_sound_asset, 0));
+ reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (_sound_asset, 0)));
} else {
/* We don't have a sound asset of our own; hopefully we have one to reference */
BOOST_FOREACH (ReferencedReelAsset j, refs) {
}
void
-ReelWriter::calculate_digests (shared_ptr<Job> job)
+ReelWriter::calculate_digests (boost::function<void (float)> set_progress)
{
- job->sub (_("Computing image digest"));
if (_picture_asset) {
- _picture_asset->hash (boost::bind (&Job::set_progress, job.get(), _1, false));
+ _picture_asset->hash (set_progress);
}
if (_sound_asset) {
- job->sub (_("Computing audio digest"));
- _sound_asset->hash (boost::bind (&Job::set_progress, job.get(), _1, false));
+ _sound_asset->hash (set_progress);
}
}
lang = "Unknown";
}
if (_film->interop ()) {
- shared_ptr<dcp::InteropSubtitleAsset> s = make_shared<dcp::InteropSubtitleAsset> ();
+ shared_ptr<dcp::InteropSubtitleAsset> s (new dcp::InteropSubtitleAsset ());
s->set_movie_title (_film->name ());
s->set_language (lang);
s->set_reel_number ("1");
_subtitle_asset = s;
} else {
- shared_ptr<dcp::SMPTESubtitleAsset> s = make_shared<dcp::SMPTESubtitleAsset> ();
+ shared_ptr<dcp::SMPTESubtitleAsset> s (new dcp::SMPTESubtitleAsset ());
s->set_content_title_text (_film->name ());
s->set_language (lang);
s->set_edit_rate (dcp::Fraction (_film->video_frame_rate (), 1));