summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-29 23:15:26 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-29 23:15:26 +0100
commit49fc9b8c4282d0e973ac1f4e31357735cf6be218 (patch)
tree45c8818a324d5628d70de82e80aed2441ea06b7e /src/lib
parentf4964573a60155545e02cbbebc47199f7480cf14 (diff)
Add reel index/count to DCP filename format.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/reel_writer.cc17
-rw-r--r--src/lib/reel_writer.h6
-rw-r--r--src/lib/util.cc8
-rw-r--r--src/lib/util.h4
-rw-r--r--src/lib/writer.cc6
5 files changed, 27 insertions, 14 deletions
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc
index d576eb2a0..b712ac3c5 100644
--- a/src/lib/reel_writer.cc
+++ b/src/lib/reel_writer.cc
@@ -1,5 +1,5 @@
/*
- 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.
@@ -60,13 +60,15 @@ 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)
: _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)
{
/* Create our picture asset in a subdirectory, named according to those
film's parameters which affect the video output. We will hard-link
@@ -111,7 +113,7 @@ ReelWriter::ReelWriter (shared_ptr<const Film> film, DCPTimePeriod period, share
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),
_film->interop() ? dcp::INTEROP : dcp::SMPTE
);
}
@@ -266,7 +268,7 @@ ReelWriter::finish ()
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);
boost::system::error_code ec;
boost::filesystem::create_hard_link (video_from, video_to, ec);
@@ -286,13 +288,14 @@ ReelWriter::finish ()
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);
+ 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
);
}
diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h
index 9dc740171..a80f51dc2 100644
--- a/src/lib/reel_writer.h
+++ b/src/lib/reel_writer.h
@@ -47,7 +47,7 @@ namespace dcp {
class ReelWriter
{
public:
- ReelWriter (boost::shared_ptr<const Film> film, DCPTimePeriod period, boost::shared_ptr<Job> job);
+ ReelWriter (boost::shared_ptr<const Film> film, DCPTimePeriod period, boost::shared_ptr<Job> job, int reel_index, int reel_count);
void write (boost::optional<dcp::Data> encoded, Frame frame, Eyes eyes);
void fake_write (Frame frame, Eyes eyes, int size);
@@ -102,6 +102,10 @@ private:
Eyes _last_written_eyes;
/** the number of audio frames that have been written to the reel */
int _total_written_audio_frames;
+ /** index of this reel within the DCP (starting from 0) */
+ int _reel_index;
+ /** number of reels in the DCP */
+ int _reel_count;
boost::shared_ptr<dcp::PictureAsset> _picture_asset;
boost::shared_ptr<dcp::PictureAssetWriter> _picture_asset_writer;
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 59974c24c..c8d0561be 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -617,20 +617,24 @@ split_get_request (string url)
}
string
-video_asset_filename (shared_ptr<dcp::PictureAsset> asset)
+video_asset_filename (shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count)
{
dcp::NameFormat::Map values;
values['t'] = "j2c";
values['i'] = asset->id();
+ values['r'] = raw_convert<string> (reel_index + 1);
+ values['n'] = raw_convert<string> (reel_count);
return Config::instance()->dcp_filename_format().get(values) + ".mxf";
}
string
-audio_asset_filename (shared_ptr<dcp::SoundAsset> asset)
+audio_asset_filename (shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count)
{
dcp::NameFormat::Map values;
values['t'] = "pcm";
values['i'] = asset->id();
+ values['r'] = raw_convert<string> (reel_index + 1);
+ values['n'] = raw_convert<string> (reel_count);
return Config::instance()->dcp_filename_format().get(values) + ".mxf";
}
diff --git a/src/lib/util.h b/src/lib/util.h
index c94d0fc9f..b3621bb13 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -74,8 +74,8 @@ extern int stride_round_up (int, int const *, int);
extern void* wrapped_av_malloc (size_t);
extern void set_backtrace_file (boost::filesystem::path);
extern std::map<std::string, std::string> split_get_request (std::string url);
-extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset);
-extern std::string audio_asset_filename (boost::shared_ptr<dcp::SoundAsset> asset);
+extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count);
+extern std::string audio_asset_filename (boost::shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count);
extern float relaxed_string_to_float (std::string);
extern bool string_not_empty (std::string);
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 00dfcdcbe..9aee7d92f 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -84,8 +84,10 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
shared_ptr<Job> job = _job.lock ();
DCPOMATIC_ASSERT (job);
- BOOST_FOREACH (DCPTimePeriod p, _film->reels ()) {
- _reels.push_back (ReelWriter (film, p, job));
+ int reel_index = 0;
+ list<DCPTimePeriod> const reels = _film->reels ();
+ BOOST_FOREACH (DCPTimePeriod p, reels) {
+ _reels.push_back (ReelWriter (film, p, job, reel_index++, reels.size()));
}
/* We can keep track of the current audio and subtitle reels easily because audio