/*
- 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 "cross.h"
#include "job.h"
#include "log.h"
-#include "md5_digester.h"
+#include "digester.h"
#include "font.h"
#include "compose.hpp"
#include "audio_buffers.h"
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
);
}
}
}
+ 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 (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (_sound_asset, 0)));
shared_ptr<dcp::ReelSoundAsset> k = dynamic_pointer_cast<dcp::ReelSoundAsset> (j.asset);
if (k && j.period == _period) {
reel->add (k);
+ /* If we have a hash for this asset in the CPL, assume that it is correct */
+ if (k->hash()) {
+ k->asset_ref()->set_hash (k->hash().get());
+ }
}
}
}
shared_ptr<dcp::ReelSubtitleAsset> k = dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j.asset);
if (k && j.period == _period) {
reel->add (k);
+ /* If we have a hash for this asset in the CPL, assume that it is correct */
+ if (k->hash()) {
+ k->asset_ref()->set_hash (k->hash().get());
+ }
}
}
}
}
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);
}
}
LOG_GENERAL ("Existing frame %1 is incomplete", _first_nonexistant_frame);
ok = false;
} else {
- MD5Digester digester;
+ Digester digester;
digester.add (data.data().get(), data.size());
LOG_GENERAL ("Hash %1 vs %2", digester.get(), info.hash);
if (digester.get() != info.hash) {