#include "format.h"
#include "filter.h"
#include "ab_transcoder.h"
-#include "film_state.h"
#include "encoder_factory.h"
#include "config.h"
using namespace std;
using namespace boost;
-/** @param s FilmState to compare (with filters and/or a non-bicubic scaler).
+/** @param f Film to compare.
* @param o Options.
- * @Param l A log that we can write to.
*/
-ABTranscodeJob::ABTranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
- : Job (s, l, req)
+ABTranscodeJob::ABTranscodeJob (shared_ptr<Film> f, shared_ptr<const Options> o, shared_ptr<Job> req)
+ : Job (f, req)
, _opt (o)
{
- _fs_b.reset (new FilmState (*_fs));
- _fs_b->set_scaler (Config::instance()->reference_scaler ());
- _fs_b->set_filters (Config::instance()->reference_filters ());
+ _film_b.reset (new Film (*_film));
+ _film_b->set_scaler (Config::instance()->reference_scaler ());
+ _film_b->set_filters (Config::instance()->reference_filters ());
}
string
ABTranscodeJob::name () const
{
- return String::compose ("A/B transcode %1", _fs->name());
+ return String::compose ("A/B transcode %1", _film->name());
}
void
ABTranscodeJob::run ()
{
try {
- /* _fs_b is the one with no filters */
- ABTranscoder w (_fs_b, _fs, _opt, this, _log, encoder_factory (_fs, _opt, _log));
+ /* _film_b is the one with reference filters */
+ ABTranscoder w (_film_b, _film, _opt, this, encoder_factory (_film, _opt));
w.go ();
set_progress (1);
set_state (FINISHED_OK);
#include <boost/shared_ptr.hpp>
#include "job.h"
+class Film;
+
/** @class ABTranscodeJob
* @brief Job to run a transcoder which produces output for A/B comparison of various settings.
*
- * The right half of the frame will be processed using the FilmState supplied;
- * the left half will be processed using the same state but *without* filters
- * and with the scaler set to SWS_BICUBIC.
+ * The right half of the frame will be processed using the Film supplied;
+ * the left half will be processed using the same state but with the reference
+ * filters and scaler.
*/
class ABTranscodeJob : public Job
{
public:
- ABTranscodeJob (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l, boost::shared_ptr<Job> req);
+ ABTranscodeJob (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, boost::shared_ptr<Job> req);
std::string name () const;
void run ();
private:
boost::shared_ptr<const Options> _opt;
- /** Copy of our FilmState with filters removed and scaler set back to bicubic;
- * this is the `reference' (left-half-frame) state.
- */
- boost::shared_ptr<FilmState> _fs_b;
+ /** Copy of our Film using the reference filters and scaler */
+ boost::shared_ptr<Film> _film_b;
};
#include "decoder.h"
#include "encoder.h"
#include "job.h"
-#include "film_state.h"
#include "options.h"
#include "image.h"
#include "decoder_factory.h"
/** @file src/ab_transcoder.cc
- * @brief A transcoder which uses one FilmState for the left half of the screen, and a different one
+ * @brief A transcoder which uses one Film for the left half of the screen, and a different one
* for the right half (to facilitate A/B comparisons of settings)
*/
using namespace std;
using namespace boost;
-/** @param a FilmState to use for the left half of the screen.
- * @param b FilmState to use for the right half of the screen.
+/** @param a Film to use for the left half of the screen.
+ * @param b Film to use for the right half of the screen.
* @param o Options.
* @param j Job that we are associated with.
- * @param l Log.
* @param e Encoder to use.
*/
ABTranscoder::ABTranscoder (
- shared_ptr<const FilmState> a, shared_ptr<const FilmState> b, shared_ptr<const Options> o, Job* j, Log* l, shared_ptr<Encoder> e)
- : _fs_a (a)
- , _fs_b (b)
+ shared_ptr<Film> a, shared_ptr<Film> b, shared_ptr<const Options> o, Job* j, shared_ptr<Encoder> e)
+ : _film_a (a)
+ , _film_b (b)
, _opt (o)
, _job (j)
- , _log (l)
, _encoder (e)
, _last_frame (0)
{
- _da = decoder_factory (_fs_a, o, j, _log);
- _db = decoder_factory (_fs_b, o, j, _log);
+ _da = decoder_factory (_film_a, o, j);
+ _db = decoder_factory (_film_b, o, j);
_da->Video.connect (sigc::bind (sigc::mem_fun (*this, &ABTranscoder::process_video), 0));
_db->Video.connect (sigc::bind (sigc::mem_fun (*this, &ABTranscoder::process_video), 1));
bool const a = _da->pass ();
bool const b = _db->pass ();
- if (_job) {
- _job->set_progress (float (_last_frame) / _fs_a->dcp_length());
- }
-
if (a && b) {
break;
}
*/
/** @file src/ab_transcoder.h
- * @brief A transcoder which uses one FilmState for the left half of the screen, and a different one
+ * @brief A transcoder which uses one Film for the left half of the screen, and a different one
* for the right half (to facilitate A/B comparisons of settings)
*/
class Job;
class Encoder;
class Decoder;
-class FilmState;
class Options;
class Image;
class Log;
class Subtitle;
+class Film;
/** @class ABTranscoder
- * @brief A transcoder which uses one FilmState for the left half of the screen, and a different one
+ * @brief A transcoder which uses one Film for the left half of the screen, and a different one
* for the right half (to facilitate A/B comparisons of settings)
*/
class ABTranscoder
{
public:
ABTranscoder (
- boost::shared_ptr<const FilmState> a,
- boost::shared_ptr<const FilmState> b,
+ boost::shared_ptr<Film> a,
+ boost::shared_ptr<Film> b,
boost::shared_ptr<const Options> o,
Job* j,
- Log* l,
boost::shared_ptr<Encoder> e
);
private:
void process_video (boost::shared_ptr<Image>, int, boost::shared_ptr<Subtitle>, int);
- boost::shared_ptr<const FilmState> _fs_a;
- boost::shared_ptr<const FilmState> _fs_b;
+ boost::shared_ptr<Film> _film_a;
+ boost::shared_ptr<Film> _film_b;
boost::shared_ptr<const Options> _opt;
Job* _job;
- Log* _log;
boost::shared_ptr<Encoder> _encoder;
boost::shared_ptr<Decoder> _da;
boost::shared_ptr<Decoder> _db;
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
#include "check_hashes_job.h"
-#include "film_state.h"
#include "options.h"
#include "log.h"
#include "job_manager.h"
#include "ab_transcode_job.h"
#include "transcode_job.h"
+#include "film.h"
using namespace std;
using namespace boost;
-CheckHashesJob::CheckHashesJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
- : Job (s, l, req)
+CheckHashesJob::CheckHashesJob (shared_ptr<Film> f, shared_ptr<const Options> o, shared_ptr<Job> req)
+ : Job (f, req)
, _opt (o)
, _bad (0)
{
string
CheckHashesJob::name () const
{
- return String::compose ("Check hashes of %1", _fs->name());
+ return String::compose ("Check hashes of %1", _film->name());
}
void
{
_bad = 0;
- int const N = _fs->dcp_length ();
+ int const N = _film->dcp_length ();
for (int i = 0; i < N; ++i) {
string const j2k_file = _opt->frame_out_path (i, false);
string const hash_file = j2k_file + ".md5";
if (!filesystem::exists (j2k_file)) {
- _log->log (String::compose ("Frame %1 has a missing J2K file.", i));
+ _film->log()->log (String::compose ("Frame %1 has a missing J2K file.", i));
filesystem::remove (hash_file);
++_bad;
} else if (!filesystem::exists (hash_file)) {
- _log->log (String::compose ("Frame %1 has a missing hash file.", i));
+ _film->log()->log (String::compose ("Frame %1 has a missing hash file.", i));
filesystem::remove (j2k_file);
++_bad;
} else {
string hash;
ref >> hash;
if (hash != md5_digest (j2k_file)) {
- _log->log (String::compose ("Frame %1 has wrong hash; deleting.", i));
+ _film->log()->log (String::compose ("Frame %1 has wrong hash; deleting.", i));
filesystem::remove (j2k_file);
filesystem::remove (hash_file);
++_bad;
}
}
- set_progress (float (i) / _fs->length());
+ set_progress (float (i) / _film->length());
}
if (_bad) {
shared_ptr<Job> tc;
- if (_fs->dcp_ab()) {
- tc.reset (new ABTranscodeJob (_fs, _opt, _log, shared_from_this()));
+ if (_film->dcp_ab()) {
+ tc.reset (new ABTranscodeJob (_film, _opt, shared_from_this()));
} else {
- tc.reset (new TranscodeJob (_fs, _opt, _log, shared_from_this()));
+ tc.reset (new TranscodeJob (_film, _opt, shared_from_this()));
}
JobManager::instance()->add_after (shared_from_this(), tc);
- JobManager::instance()->add_after (tc, shared_ptr<Job> (new CheckHashesJob (_fs, _opt, _log, tc)));
+ JobManager::instance()->add_after (tc, shared_ptr<Job> (new CheckHashesJob (_film, _opt, tc)));
}
set_progress (1);
class CheckHashesJob : public Job
{
public:
- CheckHashesJob (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l, boost::shared_ptr<Job> req);
+ CheckHashesJob (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, boost::shared_ptr<Job> req);
std::string name () const;
void run ();
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include "copy_from_dvd_job.h"
-#include "film_state.h"
#include "dvd.h"
#include "cross.h"
+#include "film.h"
using namespace std;
using namespace boost;
-/** @param fs FilmState for the film to write DVD data into.
- * @param l Log that we can write to.
+/** @param f Film to write DVD data into.
*/
-CopyFromDVDJob::CopyFromDVDJob (shared_ptr<const FilmState> fs, Log* l, shared_ptr<Job> req)
- : Job (fs, l, req)
+CopyFromDVDJob::CopyFromDVDJob (shared_ptr<Film> f, shared_ptr<Job> req)
+ : Job (f, req)
{
}
CopyFromDVDJob::run ()
{
/* Remove any old DVD rips */
- filesystem::remove_all (_fs->dir ("dvd"));
+ filesystem::remove_all (_film->dir ("dvd"));
string const dvd = find_dvd ();
if (dvd.empty ()) {
}
stringstream c;
- c << "vobcopy -n " << longest_title << " -l -o \"" << _fs->dir ("dvd") << "\" 2>&1";
+ c << "vobcopy -n " << longest_title << " -l -o \"" << _film->dir ("dvd") << "\" 2>&1";
FILE* f = popen (c.str().c_str(), "r");
if (f == 0) {
class CopyFromDVDJob : public Job
{
public:
- CopyFromDVDJob (boost::shared_ptr<const FilmState>, Log *, boost::shared_ptr<Job> req);
+ CopyFromDVDJob (boost::shared_ptr<Film>, boost::shared_ptr<Job> req);
std::string name () const;
void run ();
*/
+#ifndef DVDOMATIC_DCP_CONTENT_TYPE_H
+#define DVDOMATIC_DCP_CONTENT_TYPE_H
+
/** @file src/content_type.h
* @brief A description of the type of content for a DCP (e.g. feature, trailer etc.)
*/
static std::vector<DCPContentType const *> _dcp_content_types;
};
+#endif
#include "dcp_video_frame.h"
#include "lut.h"
#include "config.h"
-#include "film_state.h"
#include "options.h"
#include "exceptions.h"
#include "server.h"
#include "film.h"
#include "format.h"
#include "job.h"
-#include "film_state.h"
#include "options.h"
#include "exceptions.h"
#include "image.h"
using namespace std;
using namespace boost;
-/** @param s FilmState of the Film.
+/** @param f Film.
* @param o Options.
* @param j Job that we are running within, or 0
- * @param l Log to use.
* @param minimal true to do the bare minimum of work; just run through the content. Useful for acquiring
* accurate frame counts as quickly as possible. This generates no video or audio output.
* @param ignore_length Ignore the content's claimed length when computing progress.
*/
-Decoder::Decoder (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Job* j, Log* l, bool minimal, bool ignore_length)
- : _fs (s)
+Decoder::Decoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal, bool ignore_length)
+ : _film (f)
, _opt (o)
, _job (j)
- , _log (l)
, _minimal (minimal)
, _ignore_length (ignore_length)
, _video_frame (0)
, _delay_in_bytes (0)
, _audio_frames_processed (0)
{
- if (_opt->decode_video_frequency != 0 && _fs->length() == 0) {
+ if (_opt->decode_video_frequency != 0 && _film->length() == 0) {
throw DecodeError ("cannot do a partial decode if length == 0");
}
}
void
Decoder::process_begin ()
{
- _delay_in_bytes = _fs->audio_delay() * _fs->audio_sample_rate() * _fs->audio_channels() * bytes_per_audio_sample() / 1000;
+ _delay_in_bytes = _film->audio_delay() * _film->audio_sample_rate() * _film->audio_channels() * bytes_per_audio_sample() / 1000;
delete _delay_line;
_delay_line = new DelayLine (_delay_in_bytes);
if (_delay_in_bytes < 0) {
uint8_t remainder[-_delay_in_bytes];
_delay_line->get_remaining (remainder);
- _audio_frames_processed += _delay_in_bytes / (_fs->audio_channels() * bytes_per_audio_sample());
+ _audio_frames_processed += _delay_in_bytes / (_film->audio_channels() * bytes_per_audio_sample());
emit_audio (remainder, -_delay_in_bytes);
}
in to get it to the right length.
*/
- int64_t const video_length_in_audio_frames = ((int64_t) _fs->dcp_length() * _fs->audio_sample_rate() / _fs->frames_per_second());
+ int64_t const video_length_in_audio_frames = ((int64_t) _film->dcp_length() * _film->audio_sample_rate() / _film->frames_per_second());
int64_t const audio_short_by_frames = video_length_in_audio_frames - _audio_frames_processed;
_log->log (
String::compose ("DCP length is %1 (%2 audio frames); %3 frames of audio processed.",
- _fs->dcp_length(),
+ _film->dcp_length(),
video_length_in_audio_frames,
_audio_frames_processed)
);
if (audio_short_by_frames >= 0 && _opt->decode_audio) {
- _log->log (String::compose ("DCP length is %1; %2 frames of audio processed.", _fs->dcp_length(), _audio_frames_processed));
+ _log->log (String::compose ("DCP length is %1; %2 frames of audio processed.", _film->dcp_length(), _audio_frames_processed));
_log->log (String::compose ("Adding %1 frames of silence to the end.", audio_short_by_frames));
/* XXX: this is slightly questionable; does memset () give silence with all
sample formats?
*/
- int64_t bytes = audio_short_by_frames * _fs->audio_channels() * bytes_per_audio_sample();
+ int64_t bytes = audio_short_by_frames * _film->audio_channels() * bytes_per_audio_sample();
- int64_t const silence_size = 16 * 1024 * _fs->audio_channels() * bytes_per_audio_sample();
+ int64_t const silence_size = 16 * 1024 * _film->audio_channels() * bytes_per_audio_sample();
uint8_t silence[silence_size];
memset (silence, 0, silence_size);
while (pass () == false) {
if (_job && !_ignore_length) {
- _job->set_progress (float (_video_frame) / _fs->dcp_length());
+ _job->set_progress (float (_video_frame) / _film->dcp_length());
}
}
_have_setup_video_filters = true;
}
- if (!_ignore_length && _video_frame >= _fs->dcp_length()) {
+ if (!_ignore_length && _video_frame >= _film->dcp_length()) {
return true;
}
}
/** Called by subclasses to tell the world that some audio data is ready
- * @param data Audio data, in FilmState::audio_sample_format.
+ * @param data Audio data, in Film::audio_sample_format.
* @param size Number of bytes of data.
*/
void
{
/* Deinterleave and convert to float */
- assert ((size % (bytes_per_audio_sample() * _fs->audio_channels())) == 0);
+ assert ((size % (bytes_per_audio_sample() * _film->audio_channels())) == 0);
int const total_samples = size / bytes_per_audio_sample();
- int const frames = total_samples / _fs->audio_channels();
- shared_ptr<AudioBuffers> audio (new AudioBuffers (_fs->audio_channels(), frames));
+ int const frames = total_samples / _film->audio_channels();
+ shared_ptr<AudioBuffers> audio (new AudioBuffers (_film->audio_channels(), frames));
switch (audio_sample_format()) {
case AV_SAMPLE_FMT_S16:
audio->data(channel)[sample] = float(*p++) / (1 << 15);
++channel;
- if (channel == _fs->audio_channels()) {
+ if (channel == _film->audio_channels()) {
channel = 0;
++sample;
}
audio->data(channel)[sample] = float(*p++) / (1 << 31);
++channel;
- if (channel == _fs->audio_channels()) {
+ if (channel == _film->audio_channels()) {
channel = 0;
++sample;
}
case AV_SAMPLE_FMT_FLTP:
{
float* p = reinterpret_cast<float*> (data);
- for (int i = 0; i < _fs->audio_channels(); ++i) {
+ for (int i = 0; i < _film->audio_channels(); ++i) {
memcpy (audio->data(i), p, frames * sizeof(float));
p += frames;
}
}
/* Maybe apply gain */
- if (_fs->audio_gain() != 0) {
- float const linear_gain = pow (10, _fs->audio_gain() / 20);
- for (int i = 0; i < _fs->audio_channels(); ++i) {
+ if (_film->audio_gain() != 0) {
+ float const linear_gain = pow (10, _film->audio_gain() / 20);
+ for (int i = 0; i < _film->audio_channels(); ++i) {
for (int j = 0; j < frames; ++j) {
audio->data(i)[j] *= linear_gain;
}
return;
}
- /* Use FilmState::length here as our one may be wrong */
+ /* Use Film::length here as our one may be wrong */
int gap = 0;
if (_opt->decode_video_frequency != 0) {
- gap = _fs->length() / _opt->decode_video_frequency;
+ gap = _film->length() / _opt->decode_video_frequency;
}
if (_opt->decode_video_frequency != 0 && gap != 0 && (_video_frame % gap) != 0) {
}
shared_ptr<Subtitle> sub;
- if (_timed_subtitle && _timed_subtitle->displayed_at (double (last_video_frame()) / _fs->frames_per_second())) {
+ if (_timed_subtitle && _timed_subtitle->displayed_at (double (last_video_frame()) / _film->frames_per_second())) {
sub = _timed_subtitle->subtitle ();
}
Size size_after_crop;
if (_opt->apply_crop) {
- size_after_crop = _fs->cropped_size (native_size ());
- fs << crop_string (Position (_fs->crop().left, _fs->crop().top), size_after_crop);
+ size_after_crop = _film->cropped_size (native_size ());
+ fs << crop_string (Position (_film->crop().left, _film->crop().top), size_after_crop);
} else {
size_after_crop = native_size ();
fs << crop_string (Position (0, 0), size_after_crop);
}
- string filters = Filter::ffmpeg_strings (_fs->filters()).first;
+ string filters = Filter::ffmpeg_strings (_film->filters()).first;
if (!filters.empty ()) {
filters += ",";
}
if (_timed_subtitle && _opt->apply_crop) {
Position const p = _timed_subtitle->subtitle()->position ();
- _timed_subtitle->subtitle()->set_position (Position (p.x - _fs->crop().left, p.y - _fs->crop().top));
+ _timed_subtitle->subtitle()->set_position (Position (p.x - _film->crop().left, p.y - _film->crop().top));
}
}
#include "stream.h"
class Job;
-class FilmState;
class Options;
class Image;
class Log;
class DelayLine;
class TimedSubtitle;
class Subtitle;
+class Film;
/** @class Decoder.
* @brief Parent class for decoders of content.
class Decoder
{
public:
- Decoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Job *, Log *, bool, bool);
+ Decoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool, bool);
virtual ~Decoder ();
/* Methods to query our input video */
int bytes_per_audio_sample () const;
- /** our FilmState */
- boost::shared_ptr<const FilmState> _fs;
+ /** our Film */
+ boost::shared_ptr<Film> _film;
/** our options */
boost::shared_ptr<const Options> _opt;
/** associated Job, or 0 */
#include "ffmpeg_decoder.h"
#include "tiff_decoder.h"
#include "imagemagick_decoder.h"
-#include "film_state.h"
+#include "film.h"
using namespace std;
using namespace boost;
shared_ptr<Decoder>
decoder_factory (
- shared_ptr<const FilmState> fs, shared_ptr<const Options> o, Job* j, Log* l, bool minimal = false, bool ignore_length = false
+ shared_ptr<Film> f, shared_ptr<const Options> o, Job* j, bool minimal = false, bool ignore_length = false
)
{
- if (filesystem::is_directory (fs->content_path ())) {
+ if (filesystem::is_directory (f->content_path ())) {
/* Assume a directory contains TIFFs */
- return shared_ptr<Decoder> (new TIFFDecoder (fs, o, j, l, minimal, ignore_length));
+ return shared_ptr<Decoder> (new TIFFDecoder (f, o, j, minimal, ignore_length));
}
- if (fs->content_type() == STILL) {
+ if (f->content_type() == STILL) {
/* Always ignore length of decodes of stills, since the decoder finishes very quickly
and it's the encoder that takes the time.
*/
- return shared_ptr<Decoder> (new ImageMagickDecoder (fs, o, j, l, minimal, true));
+ return shared_ptr<Decoder> (new ImageMagickDecoder (f, o, j, minimal, true));
}
- return shared_ptr<Decoder> (new FFmpegDecoder (fs, o, j, l, minimal, ignore_length));
+ return shared_ptr<Decoder> (new FFmpegDecoder (f, o, j, minimal, ignore_length));
}
*/
class Decoder;
-class FilmState;
+class Film;
class Options;
class Job;
class Log;
extern boost::shared_ptr<Decoder> decoder_factory (
- boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Job *, Log *, bool minimal = false, bool ignore_length = false
+ boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool minimal = false, bool ignore_length = false
);
int const Encoder::_history_size = 25;
-/** @param s FilmState of the film that we are encoding.
+/** @param f Film that we are encoding.
* @param o Options.
- * @param l Log.
*/
-Encoder::Encoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
- : _fs (s)
+Encoder::Encoder (shared_ptr<const Film> f, shared_ptr<const Options> o)
+ : _film (f)
, _opt (o)
- , _log (l)
, _just_skipped (false)
, _last_frame (0)
{
#include <libavutil/samplefmt.h>
}
-class FilmState;
class Options;
class Image;
-class Log;
class Subtitle;
class AudioBuffers;
+class Film;
/** @class Encoder
* @brief Parent class for classes which can encode video and audio frames.
class Encoder
{
public:
- Encoder (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l);
+ Encoder (boost::shared_ptr<const Film> f, boost::shared_ptr<const Options> o);
/** Called to indicate that a processing run is about to begin */
virtual void process_begin (int64_t audio_channel_layout) = 0;
void frame_done (int n);
void frame_skipped ();
- /** FilmState of the film that we are encoding */
- boost::shared_ptr<const FilmState> _fs;
+ /** Film that we are encoding */
+ boost::shared_ptr<const Film> _film;
/** Options */
boost::shared_ptr<const Options> _opt;
- /** Log */
- Log* _log;
/** Mutex for _time_history, _just_skipped and _last_frame */
mutable boost::mutex _history_mutex;
#include <boost/filesystem.hpp>
#include "j2k_wav_encoder.h"
#include "j2k_still_encoder.h"
-#include "film_state.h"
+#include "film.h"
using namespace std;
using namespace boost;
shared_ptr<Encoder>
-encoder_factory (shared_ptr<const FilmState> fs, shared_ptr<const Options> o, Log* l)
+encoder_factory (shared_ptr<const Film> f, shared_ptr<const Options> o)
{
- if (!filesystem::is_directory (fs->content_path()) && fs->content_type() == STILL) {
- return shared_ptr<Encoder> (new J2KStillEncoder (fs, o, l));
+ if (!filesystem::is_directory (f->content_path()) && f->content_type() == STILL) {
+ return shared_ptr<Encoder> (new J2KStillEncoder (f, o));
}
- return shared_ptr<Encoder> (new J2KWAVEncoder (fs, o, l));
+ return shared_ptr<Encoder> (new J2KWAVEncoder (f, o));
}
*/
class Encoder;
-class FilmState;
class Options;
class Job;
class Log;
+class Film;
-extern boost::shared_ptr<Encoder> encoder_factory (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Log *);
+extern boost::shared_ptr<Encoder> encoder_factory (boost::shared_ptr<const Film>, boost::shared_ptr<const Options>);
#include "examine_content_job.h"
#include "options.h"
-#include "film_state.h"
#include "decoder_factory.h"
#include "decoder.h"
#include "imagemagick_encoder.h"
#include "transcoder.h"
#include "log.h"
+#include "film.h"
using namespace std;
using namespace boost;
-ExamineContentJob::ExamineContentJob (shared_ptr<const FilmState> fs, Log* l, shared_ptr<Job> req)
- : Job (fs, l, req)
+ExamineContentJob::ExamineContentJob (shared_ptr<Film> f, shared_ptr<Job> req)
+ : Job (f, req)
{
}
string
ExamineContentJob::name () const
{
- if (_fs->name().empty ()) {
+ if (_film->name().empty ()) {
return "Examine content";
}
- return String::compose ("Examine content of %1", _fs->name());
+ return String::compose ("Examine content of %1", _film->name());
}
void
ExamineContentJob::run ()
{
- shared_ptr<FilmState> fs = _fs->state_copy ();
-
/* Decode the content to get an accurate length */
shared_ptr<Options> o (new Options ("", "", ""));
descend (0.5);
- _decoder = decoder_factory (fs, o, this, _log, true, true);
+ _decoder = decoder_factory (_film, o, this, true, true);
_decoder->go ();
- fs->set_length (_decoder->last_video_frame ());
+ _film->set_length (_decoder->last_video_frame ());
- _log->log (String::compose ("Video length is %1 frames", _decoder->last_video_frame()));
+ _film->log()->log (String::compose ("Video length is %1 frames", _decoder->last_video_frame()));
ascend ();
descend (0.5);
try {
- o.reset (new Options (fs->dir ("thumbs"), ".png", ""));
- o->out_size = fs->size ();
+ o.reset (new Options (_film->dir ("thumbs"), ".png", ""));
+ o->out_size = _film->size ();
o->apply_crop = false;
o->decode_audio = false;
o->decode_video_frequency = 128;
o->decode_subtitles = true;
- shared_ptr<ImageMagickEncoder> e (new ImageMagickEncoder (fs, o, _log));
- Transcoder w (fs, o, this, _log, e);
+ shared_ptr<ImageMagickEncoder> e (new ImageMagickEncoder (_film, o));
+ Transcoder w (_film, o, this, e);
w.go ();
} catch (std::exception& e) {
class ExamineContentJob : public Job
{
public:
- ExamineContentJob (boost::shared_ptr<const FilmState>, Log *, boost::shared_ptr<Job> req);
+ ExamineContentJob (boost::shared_ptr<Film>, boost::shared_ptr<Job> req);
~ExamineContentJob ();
std::string name () const;
#include "transcoder.h"
#include "job.h"
#include "filter.h"
-#include "film_state.h"
#include "options.h"
#include "exceptions.h"
#include "image.h"
using namespace std;
using namespace boost;
-FFmpegDecoder::FFmpegDecoder (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Job* j, Log* l, bool minimal, bool ignore_length)
- : Decoder (s, o, j, l, minimal, ignore_length)
+FFmpegDecoder::FFmpegDecoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal, bool ignore_length)
+ : Decoder (f, o, j, minimal, ignore_length)
, _format_context (0)
, _video_stream (-1)
, _audio_stream (-1)
av_register_all ();
- if ((r = avformat_open_input (&_format_context, _fs->content_path().c_str(), 0, 0)) != 0) {
- throw OpenFileError (_fs->content_path ());
+ if ((r = avformat_open_input (&_format_context, _film->content_path().c_str(), 0, 0)) != 0) {
+ throw OpenFileError (_film->content_path ());
}
if (avformat_find_stream_info (_format_context, 0) < 0) {
/* Now override audio and subtitle streams with those from the Film, if it has any */
- if (_fs->audio_stream_index() != -1) {
- _audio_stream = _fs->audio_stream().id();
+ if (_film->audio_stream_index() != -1) {
+ _audio_stream = _film->audio_stream().id();
}
- if (_fs->subtitle_stream_index() != -1) {
- _subtitle_stream = _fs->subtitle_stream().id ();
+ if (_film->subtitle_stream_index() != -1) {
+ _subtitle_stream = _film->subtitle_stream().id ();
}
if (_video_stream < 0) {
0, _audio_codec_context->channels, _frame->nb_samples, audio_sample_format (), 1
);
- assert (_audio_codec_context->channels == _fs->audio_channels());
+ assert (_audio_codec_context->channels == _film->audio_channels());
process_audio (_frame->data[0], data_size);
}
}
0, _audio_codec_context->channels, _frame->nb_samples, audio_sample_format (), 1
);
- assert (_audio_codec_context->channels == _fs->audio_channels());
+ assert (_audio_codec_context->channels == _film->audio_channels());
process_audio (_frame->data[0], data_size);
}
struct AVCodec;
struct AVStream;
class Job;
-class FilmState;
class Options;
class Image;
class Log;
class FFmpegDecoder : public Decoder
{
public:
- FFmpegDecoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Job *, Log *, bool, bool);
+ FFmpegDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool, bool);
~FFmpegDecoder ();
/* Methods to query our input video */
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/date_time.hpp>
#include "film.h"
#include "format.h"
#include "imagemagick_encoder.h"
#include "scp_dcp_job.h"
#include "copy_from_dvd_job.h"
#include "make_dcp_job.h"
-#include "film_state.h"
#include "log.h"
#include "options.h"
#include "exceptions.h"
*/
Film::Film (string d, bool must_exist)
+ : _use_dci_name (false)
+ , _dcp_content_type (0)
+ , _format (0)
+ , _scaler (Scaler::from_id ("bicubic"))
+ , _dcp_frames (0)
+ , _dcp_trim_action (CUT)
+ , _dcp_ab (false)
+ , _audio_stream (-1)
+ , _audio_gain (0)
+ , _audio_delay (0)
+ , _still_duration (10)
+ , _subtitle_stream (-1)
+ , _with_subtitles (false)
+ , _subtitle_offset (0)
+ , _subtitle_scale (1)
+ , _length (0)
+ , _audio_sample_rate (0)
+ , _has_subtitles (false)
+ , _frames_per_second (0)
+ , _dirty (false)
{
/* Make state.directory a complete path without ..s (where possible)
(Code swiped from Adam Bowen on stackoverflow)
_log = new FileLog (file ("log"));
}
+Film::Film (Film const & o)
+ : _log (0)
+ , _directory (o._directory)
+ , _name (o._name)
+ , _use_dci_name (o._use_dci_name)
+ , _content (o._content)
+ , _dcp_content_type (o._dcp_content_type)
+ , _format (o._format)
+ , _crop (o._crop)
+ , _filters (o._filters)
+ , _scaler (o._scaler)
+ , _dcp_frames (o._dcp_frames)
+ , _dcp_trim_action (o._dcp_trim_action)
+ , _dcp_ab (o._dcp_ab)
+ , _audio_stream (o._audio_stream)
+ , _audio_gain (o._audio_gain)
+ , _audio_delay (o._audio_delay)
+ , _still_duration (o._still_duration)
+ , _subtitle_stream (o._subtitle_stream)
+ , _with_subtitles (o._with_subtitles)
+ , _subtitle_offset (o._subtitle_offset)
+ , _subtitle_scale (o._subtitle_scale)
+ , _audio_language (o._audio_language)
+ , _subtitle_language (o._subtitle_language)
+ , _territory (o._territory)
+ , _rating (o._rating)
+ , _studio (o._studio)
+ , _facility (o._facility)
+ , _package_type (o._package_type)
+ , _thumbs (o._thumbs)
+ , _size (o._size)
+ , _length (o._length)
+ , _audio_sample_rate (o._audio_sample_rate)
+ , _content_digest (o._content_digest)
+ , _has_subtitles (o._has_subtitles)
+ , _audio_streams (o._audio_streams)
+ , _subtitle_streams (o._subtitle_streams)
+ , _frames_per_second (o._frames_per_second)
+ , _dirty (o._dirty)
+{
+
+}
+
Film::~Film ()
{
delete _log;
throw MissingSettingError ("name");
}
- shared_ptr<const FilmState> fs = state_copy ();
shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs")));
o->out_size = format()->dcp_size ();
if (dcp_frames() == 0) {
if (transcode) {
if (dcp_ab()) {
- r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (fs, o, log(), shared_ptr<Job> ())));
+ r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
} else {
- r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (fs, o, log(), shared_ptr<Job> ())));
+ r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
}
}
- r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (fs, o, log(), r)));
- JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (fs, o, log(), r)));
+ r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
+ JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
}
void
/* This call will recreate the directory */
dir ("thumbs");
- _examine_content_job.reset (new ExamineContentJob (state_copy (), log(), shared_ptr<Job> ()));
+ _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
_examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_post_gui));
JobManager::instance()->add (_examine_content_job);
}
void
Film::send_dcp_to_tms ()
{
- shared_ptr<Job> j (new SCPDCPJob (state_copy (), log(), shared_ptr<Job> ()));
+ shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
JobManager::instance()->add (j);
}
void
Film::copy_from_dvd ()
{
- shared_ptr<Job> j (new CopyFromDVDJob (state_copy (), log(), shared_ptr<Job> ()));
+ shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
j->Finished.connect (sigc::mem_fun (*this, &Film::copy_from_dvd_post_gui));
JobManager::instance()->add (j);
}
return sub;
}
+/** Write state to our `metadata' file */
+void
+Film::write_metadata () const
+{
+ filesystem::create_directories (directory());
+
+ string const m = file ("metadata");
+ ofstream f (m.c_str ());
+ if (!f.good ()) {
+ throw CreateFileError (m);
+ }
+
+ /* User stuff */
+ f << "name " << _name << "\n";
+ f << "use_dci_name " << _use_dci_name << "\n";
+ f << "content " << _content << "\n";
+ if (_dcp_content_type) {
+ f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
+ }
+ if (_format) {
+ f << "format " << _format->as_metadata () << "\n";
+ }
+ f << "left_crop " << _crop.left << "\n";
+ f << "right_crop " << _crop.right << "\n";
+ f << "top_crop " << _crop.top << "\n";
+ f << "bottom_crop " << _crop.bottom << "\n";
+ for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
+ f << "filter " << (*i)->id () << "\n";
+ }
+ f << "scaler " << _scaler->id () << "\n";
+ f << "dcp_frames " << _dcp_frames << "\n";
+
+ f << "dcp_trim_action ";
+ switch (_dcp_trim_action) {
+ case CUT:
+ f << "cut\n";
+ break;
+ case BLACK_OUT:
+ f << "black_out\n";
+ break;
+ }
+
+ f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
+ f << "selected_audio_stream " << _audio_stream << "\n";
+ f << "audio_gain " << _audio_gain << "\n";
+ f << "audio_delay " << _audio_delay << "\n";
+ f << "still_duration " << _still_duration << "\n";
+ f << "selected_subtitle_stream " << _subtitle_stream << "\n";
+ f << "with_subtitles " << _with_subtitles << "\n";
+ f << "subtitle_offset " << _subtitle_offset << "\n";
+ f << "subtitle_scale " << _subtitle_scale << "\n";
+ f << "audio_language " << _audio_language << "\n";
+ f << "subtitle_language " << _subtitle_language << "\n";
+ f << "territory " << _territory << "\n";
+ f << "rating " << _rating << "\n";
+ f << "studio " << _studio << "\n";
+ f << "facility " << _facility << "\n";
+ f << "package_type " << _package_type << "\n";
+
+ /* Cached stuff; this is information about our content; we could
+ look it up each time, but that's slow.
+ */
+ for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
+ f << "thumb " << *i << "\n";
+ }
+ f << "width " << _size.width << "\n";
+ f << "height " << _size.height << "\n";
+ f << "length " << _length << "\n";
+ f << "audio_sample_rate " << _audio_sample_rate << "\n";
+ f << "content_digest " << _content_digest << "\n";
+ f << "has_subtitles " << _has_subtitles << "\n";
+
+ for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
+ f << "audio_stream " << i->to_string () << "\n";
+ }
+
+ for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
+ f << "subtitle_stream " << i->to_string () << "\n";
+ }
+
+ f << "frames_per_second " << _frames_per_second << "\n";
+
+ _dirty = false;
+}
+
+/** Read state from our metadata file */
+void
+Film::read_metadata ()
+{
+ ifstream f (file("metadata").c_str());
+ multimap<string, string> kv = read_key_value (f);
+ for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
+ string const k = i->first;
+ string const v = i->second;
+
+ /* User-specified stuff */
+ if (k == "name") {
+ _name = v;
+ } else if (k == "use_dci_name") {
+ _use_dci_name = (v == "1");
+ } else if (k == "content") {
+ _content = v;
+ } else if (k == "dcp_content_type") {
+ _dcp_content_type = DCPContentType::from_pretty_name (v);
+ } else if (k == "format") {
+ _format = Format::from_metadata (v);
+ } else if (k == "left_crop") {
+ _crop.left = atoi (v.c_str ());
+ } else if (k == "right_crop") {
+ _crop.right = atoi (v.c_str ());
+ } else if (k == "top_crop") {
+ _crop.top = atoi (v.c_str ());
+ } else if (k == "bottom_crop") {
+ _crop.bottom = atoi (v.c_str ());
+ } else if (k == "filter") {
+ _filters.push_back (Filter::from_id (v));
+ } else if (k == "scaler") {
+ _scaler = Scaler::from_id (v);
+ } else if (k == "dcp_frames") {
+ _dcp_frames = atoi (v.c_str ());
+ } else if (k == "dcp_trim_action") {
+ if (v == "cut") {
+ _dcp_trim_action = CUT;
+ } else if (v == "black_out") {
+ _dcp_trim_action = BLACK_OUT;
+ }
+ } else if (k == "dcp_ab") {
+ _dcp_ab = (v == "1");
+ } else if (k == "selected_audio_stream") {
+ _audio_stream = atoi (v.c_str ());
+ } else if (k == "audio_gain") {
+ _audio_gain = atof (v.c_str ());
+ } else if (k == "audio_delay") {
+ _audio_delay = atoi (v.c_str ());
+ } else if (k == "still_duration") {
+ _still_duration = atoi (v.c_str ());
+ } else if (k == "selected_subtitle_stream") {
+ _subtitle_stream = atoi (v.c_str ());
+ } else if (k == "with_subtitles") {
+ _with_subtitles = (v == "1");
+ } else if (k == "subtitle_offset") {
+ _subtitle_offset = atoi (v.c_str ());
+ } else if (k == "subtitle_scale") {
+ _subtitle_scale = atof (v.c_str ());
+ } else if (k == "audio_language") {
+ _audio_language = v;
+ } else if (k == "subtitle_language") {
+ _subtitle_language = v;
+ } else if (k == "territory") {
+ _territory = v;
+ } else if (k == "rating") {
+ _rating = v;
+ } else if (k == "studio") {
+ _studio = v;
+ } else if (k == "facility") {
+ _facility = v;
+ } else if (k == "package_type") {
+ _package_type = v;
+ }
+
+ /* Cached stuff */
+ if (k == "thumb") {
+ int const n = atoi (v.c_str ());
+ /* Only add it to the list if it still exists */
+ if (filesystem::exists (thumb_file_for_frame (n))) {
+ _thumbs.push_back (n);
+ }
+ } else if (k == "width") {
+ _size.width = atoi (v.c_str ());
+ } else if (k == "height") {
+ _size.height = atoi (v.c_str ());
+ } else if (k == "length") {
+ _length = atof (v.c_str ());
+ } else if (k == "audio_sample_rate") {
+ _audio_sample_rate = atoi (v.c_str ());
+ } else if (k == "content_digest") {
+ _content_digest = v;
+ } else if (k == "has_subtitles") {
+ _has_subtitles = (v == "1");
+ } else if (k == "audio_stream") {
+ _audio_streams.push_back (AudioStream (v));
+ } else if (k == "subtitle_stream") {
+ _subtitle_streams.push_back (SubtitleStream (v));
+ } else if (k == "frames_per_second") {
+ _frames_per_second = atof (v.c_str ());
+ }
+ }
+
+ _dirty = false;
+}
+
+/** @param n A thumb index.
+ * @return The path to the thumb's image file.
+ */
+string
+Film::thumb_file (int n) const
+{
+ return thumb_file_for_frame (thumb_frame (n));
+}
+
+/** @param n A frame index within the Film.
+ * @return The path to the thumb's image file for this frame;
+ * we assume that it exists.
+ */
+string
+Film::thumb_file_for_frame (int n) const
+{
+ return thumb_base_for_frame(n) + ".png";
+}
+
+string
+Film::thumb_base (int n) const
+{
+ return thumb_base_for_frame (thumb_frame (n));
+}
+
+string
+Film::thumb_base_for_frame (int n) const
+{
+ stringstream s;
+ s.width (8);
+ s << setfill('0') << n;
+
+ filesystem::path p;
+ p /= dir ("thumbs");
+ p /= s.str ();
+
+ return p.string ();
+}
+
+
+/** @param n A thumb index.
+ * @return The frame within the Film that it is for.
+ */
+int
+Film::thumb_frame (int n) const
+{
+ assert (n < int (_thumbs.size ()));
+ return _thumbs[n];
+}
+
+Size
+Film::cropped_size (Size s) const
+{
+ s.width -= _crop.left + _crop.right;
+ s.height -= _crop.top + _crop.bottom;
+ return s;
+}
+
+/** Given a directory name, return its full path within the Film's directory.
+ * The directory (and its parents) will be created if they do not exist.
+ */
+string
+Film::dir (string d) const
+{
+ filesystem::path p;
+ p /= _directory;
+ p /= d;
+ filesystem::create_directories (p);
+ return p.string ();
+}
+
+/** Given a file or directory name, return its full path within the Film's directory */
+string
+Film::file (string f) const
+{
+ filesystem::path p;
+ p /= _directory;
+ p /= f;
+ return p.string ();
+}
+
+/** @return full path of the content (actual video) file
+ * of the Film.
+ */
+string
+Film::content_path () const
+{
+ if (filesystem::path(_content).has_root_directory ()) {
+ return _content;
+ }
+
+ return file (_content);
+}
+
+ContentType
+Film::content_type () const
+{
+#if BOOST_FILESYSTEM_VERSION == 3
+ string ext = filesystem::path(_content).extension().string();
+#else
+ string ext = filesystem::path(_content).extension();
+#endif
+
+ transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
+
+ if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
+ return STILL;
+ }
+
+ return VIDEO;
+}
+
+/** @return The sampling rate that we will resample the audio to */
+int
+Film::target_audio_sample_rate () const
+{
+ /* Resample to a DCI-approved sample rate */
+ double t = dcp_audio_sample_rate (_audio_sample_rate);
+
+ /* Compensate for the fact that video will be rounded to the
+ nearest integer number of frames per second.
+ */
+ if (rint (_frames_per_second) != _frames_per_second) {
+ t *= _frames_per_second / rint (_frames_per_second);
+ }
+
+ return rint (t);
+}
+
+int
+Film::dcp_length () const
+{
+ if (_dcp_frames) {
+ return _dcp_frames;
+ }
+
+ return _length;
+}
+
+/** @return a DCI-compliant name for a DCP of this film */
+string
+Film::dci_name () const
+{
+ stringstream d;
+
+ string fixed_name = to_upper_copy (_name);
+ for (size_t i = 0; i < fixed_name.length(); ++i) {
+ if (fixed_name[i] == ' ') {
+ fixed_name[i] = '-';
+ }
+ }
+
+ /* Spec is that the name part should be maximum 14 characters, as I understand it */
+ if (fixed_name.length() > 14) {
+ fixed_name = fixed_name.substr (0, 14);
+ }
+
+ d << fixed_name << "_";
+
+ if (_dcp_content_type) {
+ d << _dcp_content_type->dci_name() << "_";
+ }
+
+ if (_format) {
+ d << _format->dci_name() << "_";
+ }
+
+ if (!_audio_language.empty ()) {
+ d << _audio_language;
+ if (!_subtitle_language.empty() && _with_subtitles) {
+ d << "-" << _subtitle_language;
+ } else {
+ d << "-XX";
+ }
+
+ d << "_";
+ }
+
+ if (!_territory.empty ()) {
+ d << _territory;
+ if (!_rating.empty ()) {
+ d << "-" << _rating;
+ }
+ d << "_";
+ }
+
+ switch (_audio_streams[_audio_stream].channels()) {
+ case 1:
+ d << "10_";
+ break;
+ case 2:
+ d << "20_";
+ break;
+ case 6:
+ d << "51_";
+ break;
+ case 8:
+ d << "71_";
+ break;
+ }
+
+ d << "2K_";
+
+ if (!_studio.empty ()) {
+ d << _studio << "_";
+ }
+
+ gregorian::date today = gregorian::day_clock::local_day ();
+ d << gregorian::to_iso_string (today) << "_";
+
+ if (!_facility.empty ()) {
+ d << _facility << "_";
+ }
+
+ if (!_package_type.empty ()) {
+ d << _package_type;
+ }
+
+ return d.str ();
+}
+
+/** @return name to give the DCP */
+string
+Film::dcp_name () const
+{
+ if (_use_dci_name) {
+ return dci_name ();
+ }
+
+ return _name;
+}
+
+
+void
+Film::set_directory (string d)
+{
+ _directory = d;
+ _dirty = true;
+}
+
+void
+Film::set_name (string n)
+{
+ _name = n;
+ signal_changed (NAME);
+}
+
+void
+Film::set_use_dci_name (bool u)
+{
+ _use_dci_name = u;
+ signal_changed (USE_DCI_NAME);
+}
+
void
Film::set_content (string c)
{
- FilmState::set_content (c);
- examine_content ();
+ string check = _directory;
+
+#if BOOST_FILESYSTEM_VERSION == 3
+ filesystem::path slash ("/");
+ string platform_slash = slash.make_preferred().string ();
+#else
+#ifdef DVDOMATIC_WINDOWS
+ string platform_slash = "\\";
+#else
+ string platform_slash = "/";
+#endif
+#endif
+
+ if (!ends_with (check, platform_slash)) {
+ check += platform_slash;
+ }
+
+ if (filesystem::path(c).has_root_directory () && starts_with (c, check)) {
+ c = c.substr (_directory.length() + 1);
+ }
+
+ if (c == _content) {
+ return;
+ }
+
+ /* Create a temporary decoder so that we can get information
+ about the content.
+ */
+
+ _content = c;
+
+ shared_ptr<Options> o (new Options ("", "", ""));
+ o->out_size = Size (1024, 1024);
+
+ shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
+
+ set_size (d->native_size ());
+ set_frames_per_second (d->frames_per_second ());
+ set_audio_sample_rate (d->audio_sample_rate ());
+ set_has_subtitles (d->has_subtitles ());
+ set_audio_streams (d->audio_streams ());
+ set_subtitle_streams (d->subtitle_streams ());
+ set_audio_stream (audio_streams().empty() ? -1 : 0);
+ set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
+
+ signal_changed (CONTENT);
+
+ set_content_digest (md5_digest (content_path ()));
+}
+
+void
+Film::set_dcp_content_type (DCPContentType const * t)
+{
+ _dcp_content_type = t;
+ signal_changed (DCP_CONTENT_TYPE);
+}
+
+void
+Film::set_format (Format const * f)
+{
+ _format = f;
+ signal_changed (FORMAT);
+}
+
+void
+Film::set_crop (Crop c)
+{
+ _crop = c;
+ signal_changed (CROP);
+}
+
+void
+Film::set_left_crop (int c)
+{
+ if (_crop.left == c) {
+ return;
+ }
+
+ _crop.left = c;
+ signal_changed (CROP);
+}
+
+void
+Film::set_right_crop (int c)
+{
+ if (_crop.right == c) {
+ return;
+ }
+
+ _crop.right = c;
+ signal_changed (CROP);
+}
+
+void
+Film::set_top_crop (int c)
+{
+ if (_crop.top == c) {
+ return;
+ }
+
+ _crop.top = c;
+ signal_changed (CROP);
+}
+
+void
+Film::set_bottom_crop (int c)
+{
+ if (_crop.bottom == c) {
+ return;
+ }
+
+ _crop.bottom = c;
+ signal_changed (CROP);
+}
+
+void
+Film::set_filters (vector<Filter const *> f)
+{
+ _filters = f;
+ signal_changed (FILTERS);
+}
+
+void
+Film::set_scaler (Scaler const * s)
+{
+ _scaler = s;
+ signal_changed (SCALER);
+}
+
+void
+Film::set_dcp_frames (int f)
+{
+ _dcp_frames = f;
+ signal_changed (DCP_FRAMES);
+}
+
+void
+Film::set_dcp_trim_action (TrimAction a)
+{
+ _dcp_trim_action = a;
+ signal_changed (DCP_TRIM_ACTION);
+}
+
+void
+Film::set_dcp_ab (bool a)
+{
+ _dcp_ab = a;
+ signal_changed (DCP_AB);
+}
+
+void
+Film::set_audio_stream (int s)
+{
+ _audio_stream = s;
+ signal_changed (AUDIO_STREAM);
+}
+
+void
+Film::set_audio_gain (float g)
+{
+ _audio_gain = g;
+ signal_changed (AUDIO_GAIN);
+}
+
+void
+Film::set_audio_delay (int d)
+{
+ _audio_delay = d;
+ signal_changed (AUDIO_DELAY);
+}
+
+void
+Film::set_still_duration (int d)
+{
+ _still_duration = d;
+ signal_changed (STILL_DURATION);
+}
+
+void
+Film::set_subtitle_stream (int s)
+{
+ _subtitle_stream = s;
+ signal_changed (SUBTITLE_STREAM);
+}
+
+void
+Film::set_with_subtitles (bool w)
+{
+ _with_subtitles = w;
+ signal_changed (WITH_SUBTITLES);
+}
+
+void
+Film::set_subtitle_offset (int o)
+{
+ _subtitle_offset = o;
+ signal_changed (SUBTITLE_OFFSET);
+}
+
+void
+Film::set_subtitle_scale (float s)
+{
+ _subtitle_scale = s;
+ signal_changed (SUBTITLE_SCALE);
+}
+
+void
+Film::set_audio_language (string l)
+{
+ _audio_language = l;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_subtitle_language (string l)
+{
+ _subtitle_language = l;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_territory (string t)
+{
+ _territory = t;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_rating (string r)
+{
+ _rating = r;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_studio (string s)
+{
+ _studio = s;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_facility (string f)
+{
+ _facility = f;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_package_type (string p)
+{
+ _package_type = p;
+ signal_changed (DCI_METADATA);
+}
+
+void
+Film::set_thumbs (vector<int> t)
+{
+ _thumbs = t;
+ signal_changed (THUMBS);
+}
+
+void
+Film::set_size (Size s)
+{
+ _size = s;
+ signal_changed (SIZE);
+}
+
+void
+Film::set_length (int l)
+{
+ _length = l;
+ signal_changed (LENGTH);
+}
+
+void
+Film::set_audio_sample_rate (int r)
+{
+ _audio_sample_rate = r;
+ signal_changed (AUDIO_SAMPLE_RATE);
+}
+
+void
+Film::set_content_digest (string d)
+{
+ _content_digest = d;
+ _dirty = true;
+}
+
+void
+Film::set_has_subtitles (bool s)
+{
+ _has_subtitles = s;
+ signal_changed (HAS_SUBTITLES);
+}
+
+void
+Film::set_audio_streams (vector<AudioStream> s)
+{
+ _audio_streams = s;
+ _dirty = true;
+}
+
+void
+Film::set_subtitle_streams (vector<SubtitleStream> s)
+{
+ _subtitle_streams = s;
+ _dirty = true;
+}
+
+void
+Film::set_frames_per_second (float f)
+{
+ _frames_per_second = f;
+ signal_changed (FRAMES_PER_SECOND);
+}
+
+void
+Film::signal_changed (Property p)
+{
+ _dirty = true;
+ Changed (p);
+}
+
+int
+Film::audio_channels () const
+{
+ if (_audio_stream == -1) {
+ return 0;
+ }
+
+ return _audio_streams[_audio_stream].channels ();
}
#include <libavcodec/avcodec.h>
}
#include "dcp_content_type.h"
-#include "film_state.h"
+#include "util.h"
+#include "stream.h"
+#include "trim_action.h"
class Format;
class Job;
* A representation of a piece of video (with sound), including naming,
* the source content file, and how it should be presented in a DCP.
*/
-class Film : public FilmState
+class Film : public boost::enable_shared_from_this<Film>
{
public:
Film (std::string d, bool must_exist = true);
+ Film (Film const &);
~Film ();
std::string j2k_dir () const;
int encoded_frames () const;
- void set_content (std::string);
+ std::string file (std::string f) const;
+ std::string dir (std::string d) const;
-private:
+
+
+ std::string content_path () const;
+ ContentType content_type () const;
+
+ bool content_is_dvd () const;
+
+ std::string thumb_file (int) const;
+ std::string thumb_base (int) const;
+ int thumb_frame (int) const;
+
+ int target_audio_sample_rate () const;
+
+ void write_metadata () const;
+ void read_metadata ();
+
+ Size cropped_size (Size) const;
+ int dcp_length () const;
+ std::string dci_name () const;
+ std::string dcp_name () const;
+
+ bool dirty () const {
+ return _dirty;
+ }
+
+ int audio_channels () const;
+
+ enum Property {
+ NONE,
+ NAME,
+ USE_DCI_NAME,
+ CONTENT,
+ DCP_CONTENT_TYPE,
+ FORMAT,
+ CROP,
+ FILTERS,
+ SCALER,
+ DCP_FRAMES,
+ DCP_TRIM_ACTION,
+ DCP_AB,
+ AUDIO_STREAM,
+ AUDIO_GAIN,
+ AUDIO_DELAY,
+ STILL_DURATION,
+ SUBTITLE_STREAM,
+ WITH_SUBTITLES,
+ SUBTITLE_OFFSET,
+ SUBTITLE_SCALE,
+ DCI_METADATA,
+ THUMBS,
+ SIZE,
+ LENGTH,
+ AUDIO_SAMPLE_RATE,
+ HAS_SUBTITLES,
+ AUDIO_STREAMS,
+ SUBTITLE_STREAMS,
+ FRAMES_PER_SECOND,
+ };
+
+
+ /* GET */
+
+ std::string directory () const {
+ return _directory;
+ }
+
+ std::string name () const {
+ return _name;
+ }
+
+ bool use_dci_name () const {
+ return _use_dci_name;
+ }
+
+ std::string content () const {
+ return _content;
+ }
+
+ DCPContentType const * dcp_content_type () const {
+ return _dcp_content_type;
+ }
+
+ Format const * format () const {
+ return _format;
+ }
+
+ Crop crop () const {
+ return _crop;
+ }
+
+ std::vector<Filter const *> filters () const {
+ return _filters;
+ }
+
+ Scaler const * scaler () const {
+ return _scaler;
+ }
+
+ int dcp_frames () const {
+ return _dcp_frames;
+ }
+
+ TrimAction dcp_trim_action () const {
+ return _dcp_trim_action;
+ }
+
+ bool dcp_ab () const {
+ return _dcp_ab;
+ }
+
+ int audio_stream_index () const {
+ return _audio_stream;
+ }
+
+ AudioStream audio_stream () const {
+ assert (_audio_stream < int (_audio_streams.size()));
+ return _audio_streams[_audio_stream];
+ }
+
+ float audio_gain () const {
+ return _audio_gain;
+ }
+
+ int audio_delay () const {
+ return _audio_delay;
+ }
+
+ int still_duration () const {
+ return _still_duration;
+ }
+
+ int subtitle_stream_index () const {
+ return _subtitle_stream;
+ }
+
+ SubtitleStream subtitle_stream () const {
+ assert (_subtitle_stream < int (_subtitle_streams.size()));
+ return _subtitle_streams[_subtitle_stream];
+ }
+
+ bool with_subtitles () const {
+ return _with_subtitles;
+ }
+
+ int subtitle_offset () const {
+ return _subtitle_offset;
+ }
+
+ float subtitle_scale () const {
+ return _subtitle_scale;
+ }
+
+ std::string audio_language () const {
+ return _audio_language;
+ }
+
+ std::string subtitle_language () const {
+ return _subtitle_language;
+ }
+
+ std::string territory () const {
+ return _territory;
+ }
+
+ std::string rating () const {
+ return _rating;
+ }
+
+ std::string studio () const {
+ return _studio;
+ }
+
+ std::string facility () const {
+ return _facility;
+ }
+
+ std::string package_type () const {
+ return _package_type;
+ }
+
+ std::vector<int> thumbs () const {
+ return _thumbs;
+ }
+
+ Size size () const {
+ return _size;
+ }
+
+ int length () const {
+ return _length;
+ }
+
+ int audio_sample_rate () const {
+ return _audio_sample_rate;
+ }
+
+ std::string content_digest () const {
+ return _content_digest;
+ }
+
+ bool has_subtitles () const {
+ return _has_subtitles;
+ }
+
+ std::vector<AudioStream> audio_streams () const {
+ return _audio_streams;
+ }
+
+ std::vector<SubtitleStream> subtitle_streams () const {
+ return _subtitle_streams;
+ }
+
+ float frames_per_second () const {
+ return _frames_per_second;
+ }
+
+
+ /* SET */
+
+ void set_directory (std::string);
+ void set_name (std::string);
+ void set_use_dci_name (bool);
+ virtual void set_content (std::string);
+ void set_dcp_content_type (DCPContentType const *);
+ void set_format (Format const *);
+ void set_crop (Crop);
+ void set_left_crop (int);
+ void set_right_crop (int);
+ void set_top_crop (int);
+ void set_bottom_crop (int);
+ void set_filters (std::vector<Filter const *>);
+ void set_scaler (Scaler const *);
+ void set_dcp_frames (int);
+ void set_dcp_trim_action (TrimAction);
+ void set_dcp_ab (bool);
+ void set_audio_stream (int);
+ void set_audio_gain (float);
+ void set_audio_delay (int);
+ void set_still_duration (int);
+ void set_subtitle_stream (int);
+ void set_with_subtitles (bool);
+ void set_subtitle_offset (int);
+ void set_subtitle_scale (float);
+ void set_audio_language (std::string);
+ void set_subtitle_language (std::string);
+ void set_territory (std::string);
+ void set_rating (std::string);
+ void set_studio (std::string);
+ void set_facility (std::string);
+ void set_package_type (std::string);
+ void set_thumbs (std::vector<int>);
+ void set_size (Size);
+ void set_length (int);
+ void set_audio_sample_rate (int);
+ void set_content_digest (std::string);
+ void set_has_subtitles (bool);
+ void set_audio_streams (std::vector<AudioStream>);
+ void set_subtitle_streams (std::vector<SubtitleStream>);
+ void set_frames_per_second (float);
+
+ /** Emitted when some property has changed */
+ mutable sigc::signal1<void, Property> Changed;
+
+private:
/** Log to write to */
Log* _log;
/** Any running ExamineContentJob, or 0 */
boost::shared_ptr<ExamineContentJob> _examine_content_job;
+
+ std::string thumb_file_for_frame (int) const;
+ std::string thumb_base_for_frame (int) const;
+ void signal_changed (Property);
+
+ /** Complete path to directory containing the film metadata;
+ * must not be relative.
+ */
+ std::string _directory;
+ /** Name for DVD-o-matic */
+ std::string _name;
+ /** True if a auto-generated DCI-compliant name should be used for our DCP */
+ bool _use_dci_name;
+ /** File or directory containing content; may be relative to our directory
+ * or an absolute path.
+ */
+ std::string _content;
+ /** The type of content that this Film represents (feature, trailer etc.) */
+ DCPContentType const * _dcp_content_type;
+ /** The format to present this Film in (flat, scope, etc.) */
+ Format const * _format;
+ /** The crop to apply to the source */
+ Crop _crop;
+ /** Video filters that should be used when generating DCPs */
+ std::vector<Filter const *> _filters;
+ /** Scaler algorithm to use */
+ Scaler const * _scaler;
+ /** Number of frames to put in the DCP, or 0 for all */
+ int _dcp_frames;
+ /** What to do with audio when trimming DCPs */
+ TrimAction _dcp_trim_action;
+ /** true to create an A/B comparison DCP, where the left half of the image
+ is the video without any filters or post-processing, and the right half
+ has the specified filters and post-processing.
+ */
+ bool _dcp_ab;
+ /** An index into our _audio_streams vector for the stream to use for audio, or -1 if there is none */
+ int _audio_stream;
+ /** Gain to apply to audio in dB */
+ float _audio_gain;
+ /** Delay to apply to audio (positive moves audio later) in milliseconds */
+ int _audio_delay;
+ /** Duration to make still-sourced films (in seconds) */
+ int _still_duration;
+ /** An index into our _subtitle_streams vector for the stream to use for subtitles, or -1 if there is none */
+ int _subtitle_stream;
+ /** True if subtitles should be shown for this film */
+ bool _with_subtitles;
+ /** y offset for placing subtitles, in source pixels; +ve is further down
+ the frame, -ve is further up.
+ */
+ int _subtitle_offset;
+ /** scale factor to apply to subtitles */
+ float _subtitle_scale;
+
+ /* DCI naming stuff */
+ std::string _audio_language;
+ std::string _subtitle_language;
+ std::string _territory;
+ std::string _rating;
+ std::string _studio;
+ std::string _facility;
+ std::string _package_type;
+
+ /* Data which are cached to speed things up */
+
+ /** Vector of frame indices for each of our `thumbnails' */
+ std::vector<int> _thumbs;
+ /** Size, in pixels, of the source (ignoring cropping) */
+ Size _size;
+ /** Length of the source in frames */
+ int _length;
+ /** Sample rate of the source audio, in Hz */
+ int _audio_sample_rate;
+ /** MD5 digest of our content file */
+ std::string _content_digest;
+ /** true if the source has subtitles */
+ bool _has_subtitles;
+ /** the audio streams that the source has */
+ std::vector<AudioStream> _audio_streams;
+ /** the subtitle streams that the source has */
+ std::vector<SubtitleStream> _subtitle_streams;
+ /** Frames per second of the source */
+ float _frames_per_second;
+
+ mutable bool _dirty;
+
+ friend class paths_test;
};
#endif
+++ /dev/null
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/film_state.cc
- * @brief The state of a Film. This is separate from Film so that
- * state can easily be copied and kept around for reference
- * by long-running jobs. This avoids the jobs getting confused
- * by the user changing Film settings during their run.
- */
-
-#include <fstream>
-#include <string>
-#include <iomanip>
-#include <sstream>
-#include <boost/filesystem.hpp>
-#include <boost/date_time.hpp>
-#include <boost/algorithm/string.hpp>
-#include "film_state.h"
-#include "scaler.h"
-#include "filter.h"
-#include "format.h"
-#include "dcp_content_type.h"
-#include "util.h"
-#include "exceptions.h"
-#include "options.h"
-#include "decoder.h"
-#include "decoder_factory.h"
-
-using namespace std;
-using namespace boost;
-
-/** Write state to our `metadata' file */
-void
-FilmState::write_metadata () const
-{
- filesystem::create_directories (directory());
-
- string const m = file ("metadata");
- ofstream f (m.c_str ());
- if (!f.good ()) {
- throw CreateFileError (m);
- }
-
- /* User stuff */
- f << "name " << _name << "\n";
- f << "use_dci_name " << _use_dci_name << "\n";
- f << "content " << _content << "\n";
- if (_dcp_content_type) {
- f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
- }
- if (_format) {
- f << "format " << _format->as_metadata () << "\n";
- }
- f << "left_crop " << _crop.left << "\n";
- f << "right_crop " << _crop.right << "\n";
- f << "top_crop " << _crop.top << "\n";
- f << "bottom_crop " << _crop.bottom << "\n";
- for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
- f << "filter " << (*i)->id () << "\n";
- }
- f << "scaler " << _scaler->id () << "\n";
- f << "dcp_frames " << _dcp_frames << "\n";
-
- f << "dcp_trim_action ";
- switch (_dcp_trim_action) {
- case CUT:
- f << "cut\n";
- break;
- case BLACK_OUT:
- f << "black_out\n";
- break;
- }
-
- f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
- f << "selected_audio_stream " << _audio_stream << "\n";
- f << "audio_gain " << _audio_gain << "\n";
- f << "audio_delay " << _audio_delay << "\n";
- f << "still_duration " << _still_duration << "\n";
- f << "selected_subtitle_stream " << _subtitle_stream << "\n";
- f << "with_subtitles " << _with_subtitles << "\n";
- f << "subtitle_offset " << _subtitle_offset << "\n";
- f << "subtitle_scale " << _subtitle_scale << "\n";
- f << "audio_language " << _audio_language << "\n";
- f << "subtitle_language " << _subtitle_language << "\n";
- f << "territory " << _territory << "\n";
- f << "rating " << _rating << "\n";
- f << "studio " << _studio << "\n";
- f << "facility " << _facility << "\n";
- f << "package_type " << _package_type << "\n";
-
- /* Cached stuff; this is information about our content; we could
- look it up each time, but that's slow.
- */
- for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
- f << "thumb " << *i << "\n";
- }
- f << "width " << _size.width << "\n";
- f << "height " << _size.height << "\n";
- f << "length " << _length << "\n";
- f << "audio_sample_rate " << _audio_sample_rate << "\n";
- f << "content_digest " << _content_digest << "\n";
- f << "has_subtitles " << _has_subtitles << "\n";
-
- for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
- f << "audio_stream " << i->to_string () << "\n";
- }
-
- for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
- f << "subtitle_stream " << i->to_string () << "\n";
- }
-
- f << "frames_per_second " << _frames_per_second << "\n";
-
- _dirty = false;
-}
-
-/** Read state from our metadata file */
-void
-FilmState::read_metadata ()
-{
- ifstream f (file("metadata").c_str());
- multimap<string, string> kv = read_key_value (f);
- for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
- string const k = i->first;
- string const v = i->second;
-
- /* User-specified stuff */
- if (k == "name") {
- _name = v;
- } else if (k == "use_dci_name") {
- _use_dci_name = (v == "1");
- } else if (k == "content") {
- _content = v;
- } else if (k == "dcp_content_type") {
- _dcp_content_type = DCPContentType::from_pretty_name (v);
- } else if (k == "format") {
- _format = Format::from_metadata (v);
- } else if (k == "left_crop") {
- _crop.left = atoi (v.c_str ());
- } else if (k == "right_crop") {
- _crop.right = atoi (v.c_str ());
- } else if (k == "top_crop") {
- _crop.top = atoi (v.c_str ());
- } else if (k == "bottom_crop") {
- _crop.bottom = atoi (v.c_str ());
- } else if (k == "filter") {
- _filters.push_back (Filter::from_id (v));
- } else if (k == "scaler") {
- _scaler = Scaler::from_id (v);
- } else if (k == "dcp_frames") {
- _dcp_frames = atoi (v.c_str ());
- } else if (k == "dcp_trim_action") {
- if (v == "cut") {
- _dcp_trim_action = CUT;
- } else if (v == "black_out") {
- _dcp_trim_action = BLACK_OUT;
- }
- } else if (k == "dcp_ab") {
- _dcp_ab = (v == "1");
- } else if (k == "selected_audio_stream") {
- _audio_stream = atoi (v.c_str ());
- } else if (k == "audio_gain") {
- _audio_gain = atof (v.c_str ());
- } else if (k == "audio_delay") {
- _audio_delay = atoi (v.c_str ());
- } else if (k == "still_duration") {
- _still_duration = atoi (v.c_str ());
- } else if (k == "selected_subtitle_stream") {
- _subtitle_stream = atoi (v.c_str ());
- } else if (k == "with_subtitles") {
- _with_subtitles = (v == "1");
- } else if (k == "subtitle_offset") {
- _subtitle_offset = atoi (v.c_str ());
- } else if (k == "subtitle_scale") {
- _subtitle_scale = atof (v.c_str ());
- } else if (k == "audio_language") {
- _audio_language = v;
- } else if (k == "subtitle_language") {
- _subtitle_language = v;
- } else if (k == "territory") {
- _territory = v;
- } else if (k == "rating") {
- _rating = v;
- } else if (k == "studio") {
- _studio = v;
- } else if (k == "facility") {
- _facility = v;
- } else if (k == "package_type") {
- _package_type = v;
- }
-
- /* Cached stuff */
- if (k == "thumb") {
- int const n = atoi (v.c_str ());
- /* Only add it to the list if it still exists */
- if (filesystem::exists (thumb_file_for_frame (n))) {
- _thumbs.push_back (n);
- }
- } else if (k == "width") {
- _size.width = atoi (v.c_str ());
- } else if (k == "height") {
- _size.height = atoi (v.c_str ());
- } else if (k == "length") {
- _length = atof (v.c_str ());
- } else if (k == "audio_sample_rate") {
- _audio_sample_rate = atoi (v.c_str ());
- } else if (k == "content_digest") {
- _content_digest = v;
- } else if (k == "has_subtitles") {
- _has_subtitles = (v == "1");
- } else if (k == "audio_stream") {
- _audio_streams.push_back (AudioStream (v));
- } else if (k == "subtitle_stream") {
- _subtitle_streams.push_back (SubtitleStream (v));
- } else if (k == "frames_per_second") {
- _frames_per_second = atof (v.c_str ());
- }
- }
-
- _dirty = false;
-}
-
-/** @param n A thumb index.
- * @return The path to the thumb's image file.
- */
-string
-FilmState::thumb_file (int n) const
-{
- return thumb_file_for_frame (thumb_frame (n));
-}
-
-/** @param n A frame index within the Film.
- * @return The path to the thumb's image file for this frame;
- * we assume that it exists.
- */
-string
-FilmState::thumb_file_for_frame (int n) const
-{
- return thumb_base_for_frame(n) + ".png";
-}
-
-string
-FilmState::thumb_base (int n) const
-{
- return thumb_base_for_frame (thumb_frame (n));
-}
-
-string
-FilmState::thumb_base_for_frame (int n) const
-{
- stringstream s;
- s.width (8);
- s << setfill('0') << n;
-
- filesystem::path p;
- p /= dir ("thumbs");
- p /= s.str ();
-
- return p.string ();
-}
-
-
-/** @param n A thumb index.
- * @return The frame within the Film that it is for.
- */
-int
-FilmState::thumb_frame (int n) const
-{
- assert (n < int (_thumbs.size ()));
- return _thumbs[n];
-}
-
-Size
-FilmState::cropped_size (Size s) const
-{
- s.width -= _crop.left + _crop.right;
- s.height -= _crop.top + _crop.bottom;
- return s;
-}
-
-/** Given a directory name, return its full path within the Film's directory.
- * The directory (and its parents) will be created if they do not exist.
- */
-string
-FilmState::dir (string d) const
-{
- filesystem::path p;
- p /= _directory;
- p /= d;
- filesystem::create_directories (p);
- return p.string ();
-}
-
-/** Given a file or directory name, return its full path within the Film's directory */
-string
-FilmState::file (string f) const
-{
- filesystem::path p;
- p /= _directory;
- p /= f;
- return p.string ();
-}
-
-/** @return full path of the content (actual video) file
- * of the Film.
- */
-string
-FilmState::content_path () const
-{
- if (filesystem::path(_content).has_root_directory ()) {
- return _content;
- }
-
- return file (_content);
-}
-
-ContentType
-FilmState::content_type () const
-{
-#if BOOST_FILESYSTEM_VERSION == 3
- string ext = filesystem::path(_content).extension().string();
-#else
- string ext = filesystem::path(_content).extension();
-#endif
-
- transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-
- if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
- return STILL;
- }
-
- return VIDEO;
-}
-
-/** @return The sampling rate that we will resample the audio to */
-int
-FilmState::target_audio_sample_rate () const
-{
- /* Resample to a DCI-approved sample rate */
- double t = dcp_audio_sample_rate (_audio_sample_rate);
-
- /* Compensate for the fact that video will be rounded to the
- nearest integer number of frames per second.
- */
- if (rint (_frames_per_second) != _frames_per_second) {
- t *= _frames_per_second / rint (_frames_per_second);
- }
-
- return rint (t);
-}
-
-int
-FilmState::dcp_length () const
-{
- if (_dcp_frames) {
- return _dcp_frames;
- }
-
- return _length;
-}
-
-/** @return a DCI-compliant name for a DCP of this film */
-string
-FilmState::dci_name () const
-{
- stringstream d;
-
- string fixed_name = to_upper_copy (_name);
- for (size_t i = 0; i < fixed_name.length(); ++i) {
- if (fixed_name[i] == ' ') {
- fixed_name[i] = '-';
- }
- }
-
- /* Spec is that the name part should be maximum 14 characters, as I understand it */
- if (fixed_name.length() > 14) {
- fixed_name = fixed_name.substr (0, 14);
- }
-
- d << fixed_name << "_";
-
- if (_dcp_content_type) {
- d << _dcp_content_type->dci_name() << "_";
- }
-
- if (_format) {
- d << _format->dci_name() << "_";
- }
-
- if (!_audio_language.empty ()) {
- d << _audio_language;
- if (!_subtitle_language.empty() && _with_subtitles) {
- d << "-" << _subtitle_language;
- } else {
- d << "-XX";
- }
-
- d << "_";
- }
-
- if (!_territory.empty ()) {
- d << _territory;
- if (!_rating.empty ()) {
- d << "-" << _rating;
- }
- d << "_";
- }
-
- switch (_audio_streams[_audio_stream].channels()) {
- case 1:
- d << "10_";
- break;
- case 2:
- d << "20_";
- break;
- case 6:
- d << "51_";
- break;
- case 8:
- d << "71_";
- break;
- }
-
- d << "2K_";
-
- if (!_studio.empty ()) {
- d << _studio << "_";
- }
-
- gregorian::date today = gregorian::day_clock::local_day ();
- d << gregorian::to_iso_string (today) << "_";
-
- if (!_facility.empty ()) {
- d << _facility << "_";
- }
-
- if (!_package_type.empty ()) {
- d << _package_type;
- }
-
- return d.str ();
-}
-
-/** @return name to give the DCP */
-string
-FilmState::dcp_name () const
-{
- if (_use_dci_name) {
- return dci_name ();
- }
-
- return _name;
-}
-
-
-void
-FilmState::set_directory (string d)
-{
- _directory = d;
- _dirty = true;
-}
-
-void
-FilmState::set_name (string n)
-{
- _name = n;
- signal_changed (NAME);
-}
-
-void
-FilmState::set_use_dci_name (bool u)
-{
- _use_dci_name = u;
- signal_changed (USE_DCI_NAME);
-}
-
-void
-FilmState::set_content (string c)
-{
- string check = _directory;
-
-#if BOOST_FILESYSTEM_VERSION == 3
- filesystem::path slash ("/");
- string platform_slash = slash.make_preferred().string ();
-#else
-#ifdef DVDOMATIC_WINDOWS
- string platform_slash = "\\";
-#else
- string platform_slash = "/";
-#endif
-#endif
-
- if (!ends_with (check, platform_slash)) {
- check += platform_slash;
- }
-
- if (filesystem::path(c).has_root_directory () && starts_with (c, check)) {
- c = c.substr (_directory.length() + 1);
- }
-
- if (c == _content) {
- return;
- }
-
- /* Create a temporary decoder so that we can get information
- about the content.
- */
-
- shared_ptr<FilmState> s = state_copy ();
- s->_content = c;
- shared_ptr<Options> o (new Options ("", "", ""));
- o->out_size = Size (1024, 1024);
-
- shared_ptr<Decoder> d = decoder_factory (s, o, 0, 0);
-
- set_size (d->native_size ());
- set_frames_per_second (d->frames_per_second ());
- set_audio_sample_rate (d->audio_sample_rate ());
- set_has_subtitles (d->has_subtitles ());
- set_audio_streams (d->audio_streams ());
- set_subtitle_streams (d->subtitle_streams ());
- set_audio_stream (audio_streams().empty() ? -1 : 0);
- set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
-
- _content = c;
- signal_changed (CONTENT);
-
- set_content_digest (md5_digest (content_path ()));
-}
-
-void
-FilmState::set_dcp_content_type (DCPContentType const * t)
-{
- _dcp_content_type = t;
- signal_changed (DCP_CONTENT_TYPE);
-}
-
-void
-FilmState::set_format (Format const * f)
-{
- _format = f;
- signal_changed (FORMAT);
-}
-
-void
-FilmState::set_crop (Crop c)
-{
- _crop = c;
- signal_changed (CROP);
-}
-
-void
-FilmState::set_left_crop (int c)
-{
- if (_crop.left == c) {
- return;
- }
-
- _crop.left = c;
- signal_changed (CROP);
-}
-
-void
-FilmState::set_right_crop (int c)
-{
- if (_crop.right == c) {
- return;
- }
-
- _crop.right = c;
- signal_changed (CROP);
-}
-
-void
-FilmState::set_top_crop (int c)
-{
- if (_crop.top == c) {
- return;
- }
-
- _crop.top = c;
- signal_changed (CROP);
-}
-
-void
-FilmState::set_bottom_crop (int c)
-{
- if (_crop.bottom == c) {
- return;
- }
-
- _crop.bottom = c;
- signal_changed (CROP);
-}
-
-void
-FilmState::set_filters (vector<Filter const *> f)
-{
- _filters = f;
- signal_changed (FILTERS);
-}
-
-void
-FilmState::set_scaler (Scaler const * s)
-{
- _scaler = s;
- signal_changed (SCALER);
-}
-
-void
-FilmState::set_dcp_frames (int f)
-{
- _dcp_frames = f;
- signal_changed (DCP_FRAMES);
-}
-
-void
-FilmState::set_dcp_trim_action (TrimAction a)
-{
- _dcp_trim_action = a;
- signal_changed (DCP_TRIM_ACTION);
-}
-
-void
-FilmState::set_dcp_ab (bool a)
-{
- _dcp_ab = a;
- signal_changed (DCP_AB);
-}
-
-void
-FilmState::set_audio_stream (int s)
-{
- _audio_stream = s;
- signal_changed (AUDIO_STREAM);
-}
-
-void
-FilmState::set_audio_gain (float g)
-{
- _audio_gain = g;
- signal_changed (AUDIO_GAIN);
-}
-
-void
-FilmState::set_audio_delay (int d)
-{
- _audio_delay = d;
- signal_changed (AUDIO_DELAY);
-}
-
-void
-FilmState::set_still_duration (int d)
-{
- _still_duration = d;
- signal_changed (STILL_DURATION);
-}
-
-void
-FilmState::set_subtitle_stream (int s)
-{
- _subtitle_stream = s;
- signal_changed (SUBTITLE_STREAM);
-}
-
-void
-FilmState::set_with_subtitles (bool w)
-{
- _with_subtitles = w;
- signal_changed (WITH_SUBTITLES);
-}
-
-void
-FilmState::set_subtitle_offset (int o)
-{
- _subtitle_offset = o;
- signal_changed (SUBTITLE_OFFSET);
-}
-
-void
-FilmState::set_subtitle_scale (float s)
-{
- _subtitle_scale = s;
- signal_changed (SUBTITLE_SCALE);
-}
-
-void
-FilmState::set_audio_language (string l)
-{
- _audio_language = l;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_subtitle_language (string l)
-{
- _subtitle_language = l;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_territory (string t)
-{
- _territory = t;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_rating (string r)
-{
- _rating = r;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_studio (string s)
-{
- _studio = s;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_facility (string f)
-{
- _facility = f;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_package_type (string p)
-{
- _package_type = p;
- signal_changed (DCI_METADATA);
-}
-
-void
-FilmState::set_thumbs (vector<int> t)
-{
- _thumbs = t;
- signal_changed (THUMBS);
-}
-
-void
-FilmState::set_size (Size s)
-{
- _size = s;
- signal_changed (SIZE);
-}
-
-void
-FilmState::set_length (int l)
-{
- _length = l;
- signal_changed (LENGTH);
-}
-
-void
-FilmState::set_audio_sample_rate (int r)
-{
- _audio_sample_rate = r;
- signal_changed (AUDIO_SAMPLE_RATE);
-}
-
-void
-FilmState::set_content_digest (string d)
-{
- _content_digest = d;
- _dirty = true;
-}
-
-void
-FilmState::set_has_subtitles (bool s)
-{
- _has_subtitles = s;
- signal_changed (HAS_SUBTITLES);
-}
-
-void
-FilmState::set_audio_streams (vector<AudioStream> s)
-{
- _audio_streams = s;
- _dirty = true;
-}
-
-void
-FilmState::set_subtitle_streams (vector<SubtitleStream> s)
-{
- _subtitle_streams = s;
- _dirty = true;
-}
-
-void
-FilmState::set_frames_per_second (float f)
-{
- _frames_per_second = f;
- signal_changed (FRAMES_PER_SECOND);
-}
-
-void
-FilmState::signal_changed (Property p)
-{
- _dirty = true;
- Changed (p);
-}
-
-shared_ptr<FilmState>
-FilmState::state_copy () const
-{
- return shared_ptr<FilmState> (new FilmState (*this));
-}
-
-int
-FilmState::audio_channels () const
-{
- if (_audio_stream == -1) {
- return 0;
- }
-
- return _audio_streams[_audio_stream].channels ();
-}
+++ /dev/null
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/film_state.h
- * @brief The state of a Film. This is separate from Film so that
- * state can easily be copied and kept around for reference
- * by long-running jobs. This avoids the jobs getting confused
- * by the user changing Film settings during their run.
- */
-
-#ifndef DVDOMATIC_FILM_STATE_H
-#define DVDOMATIC_FILM_STATE_H
-
-#include <sigc++/signal.h>
-extern "C" {
-#include <libavcodec/avcodec.h>
-#include <libswscale/swscale.h>
-}
-#include "scaler.h"
-#include "util.h"
-#include "trim_action.h"
-#include "stream.h"
-
-class Format;
-class DCPContentType;
-class Filter;
-
-/** @class FilmState
- * @brief The state of a Film.
- *
- * This is separate from Film so that state can easily be copied and
- * kept around for reference by long-running jobs. This avoids the
- * jobs getting confused by the user changing Film settings during
- * their run.
- */
-
-class FilmState
-{
-public:
- FilmState ()
- : _use_dci_name (false)
- , _dcp_content_type (0)
- , _format (0)
- , _scaler (Scaler::from_id ("bicubic"))
- , _dcp_frames (0)
- , _dcp_trim_action (CUT)
- , _dcp_ab (false)
- , _audio_stream (-1)
- , _audio_gain (0)
- , _audio_delay (0)
- , _still_duration (10)
- , _subtitle_stream (-1)
- , _with_subtitles (false)
- , _subtitle_offset (0)
- , _subtitle_scale (1)
- , _length (0)
- , _audio_sample_rate (0)
- , _has_subtitles (false)
- , _frames_per_second (0)
- , _dirty (false)
- {}
-
- FilmState (FilmState const & o)
- : _directory (o._directory)
- , _name (o._name)
- , _use_dci_name (o._use_dci_name)
- , _content (o._content)
- , _dcp_content_type (o._dcp_content_type)
- , _format (o._format)
- , _crop (o._crop)
- , _filters (o._filters)
- , _scaler (o._scaler)
- , _dcp_frames (o._dcp_frames)
- , _dcp_trim_action (o._dcp_trim_action)
- , _dcp_ab (o._dcp_ab)
- , _audio_stream (o._audio_stream)
- , _audio_gain (o._audio_gain)
- , _audio_delay (o._audio_delay)
- , _still_duration (o._still_duration)
- , _subtitle_stream (o._subtitle_stream)
- , _with_subtitles (o._with_subtitles)
- , _subtitle_offset (o._subtitle_offset)
- , _subtitle_scale (o._subtitle_scale)
- , _audio_language (o._audio_language)
- , _subtitle_language (o._subtitle_language)
- , _territory (o._territory)
- , _rating (o._rating)
- , _studio (o._studio)
- , _facility (o._facility)
- , _package_type (o._package_type)
- , _thumbs (o._thumbs)
- , _size (o._size)
- , _length (o._length)
- , _audio_sample_rate (o._audio_sample_rate)
- , _content_digest (o._content_digest)
- , _has_subtitles (o._has_subtitles)
- , _audio_streams (o._audio_streams)
- , _subtitle_streams (o._subtitle_streams)
- , _frames_per_second (o._frames_per_second)
- , _dirty (o._dirty)
- {}
-
- virtual ~FilmState () {}
-
- std::string file (std::string f) const;
- std::string dir (std::string d) const;
-
- std::string content_path () const;
- ContentType content_type () const;
-
- bool content_is_dvd () const;
-
- std::string thumb_file (int) const;
- std::string thumb_base (int) const;
- int thumb_frame (int) const;
-
- int target_audio_sample_rate () const;
-
- void write_metadata () const;
- void read_metadata ();
-
- Size cropped_size (Size) const;
- int dcp_length () const;
- std::string dci_name () const;
-
- std::string dcp_name () const;
-
- boost::shared_ptr<FilmState> state_copy () const;
-
- bool dirty () const {
- return _dirty;
- }
-
- int audio_channels () const;
-
- enum Property {
- NONE,
- NAME,
- USE_DCI_NAME,
- CONTENT,
- DCP_CONTENT_TYPE,
- FORMAT,
- CROP,
- FILTERS,
- SCALER,
- DCP_FRAMES,
- DCP_TRIM_ACTION,
- DCP_AB,
- AUDIO_STREAM,
- AUDIO_GAIN,
- AUDIO_DELAY,
- STILL_DURATION,
- SUBTITLE_STREAM,
- WITH_SUBTITLES,
- SUBTITLE_OFFSET,
- SUBTITLE_SCALE,
- DCI_METADATA,
- THUMBS,
- SIZE,
- LENGTH,
- AUDIO_SAMPLE_RATE,
- HAS_SUBTITLES,
- AUDIO_STREAMS,
- SUBTITLE_STREAMS,
- FRAMES_PER_SECOND,
- };
-
-
- /* GET */
-
- std::string directory () const {
- return _directory;
- }
-
- std::string name () const {
- return _name;
- }
-
- bool use_dci_name () const {
- return _use_dci_name;
- }
-
- std::string content () const {
- return _content;
- }
-
- DCPContentType const * dcp_content_type () const {
- return _dcp_content_type;
- }
-
- Format const * format () const {
- return _format;
- }
-
- Crop crop () const {
- return _crop;
- }
-
- std::vector<Filter const *> filters () const {
- return _filters;
- }
-
- Scaler const * scaler () const {
- return _scaler;
- }
-
- int dcp_frames () const {
- return _dcp_frames;
- }
-
- TrimAction dcp_trim_action () const {
- return _dcp_trim_action;
- }
-
- bool dcp_ab () const {
- return _dcp_ab;
- }
-
- int audio_stream_index () const {
- return _audio_stream;
- }
-
- AudioStream audio_stream () const {
- assert (_audio_stream < int (_audio_streams.size()));
- return _audio_streams[_audio_stream];
- }
-
- float audio_gain () const {
- return _audio_gain;
- }
-
- int audio_delay () const {
- return _audio_delay;
- }
-
- int still_duration () const {
- return _still_duration;
- }
-
- int subtitle_stream_index () const {
- return _subtitle_stream;
- }
-
- SubtitleStream subtitle_stream () const {
- assert (_subtitle_stream < int (_subtitle_streams.size()));
- return _subtitle_streams[_subtitle_stream];
- }
-
- bool with_subtitles () const {
- return _with_subtitles;
- }
-
- int subtitle_offset () const {
- return _subtitle_offset;
- }
-
- float subtitle_scale () const {
- return _subtitle_scale;
- }
-
- std::string audio_language () const {
- return _audio_language;
- }
-
- std::string subtitle_language () const {
- return _subtitle_language;
- }
-
- std::string territory () const {
- return _territory;
- }
-
- std::string rating () const {
- return _rating;
- }
-
- std::string studio () const {
- return _studio;
- }
-
- std::string facility () const {
- return _facility;
- }
-
- std::string package_type () const {
- return _package_type;
- }
-
- std::vector<int> thumbs () const {
- return _thumbs;
- }
-
- Size size () const {
- return _size;
- }
-
- int length () const {
- return _length;
- }
-
- int audio_sample_rate () const {
- return _audio_sample_rate;
- }
-
- std::string content_digest () const {
- return _content_digest;
- }
-
- bool has_subtitles () const {
- return _has_subtitles;
- }
-
- std::vector<AudioStream> audio_streams () const {
- return _audio_streams;
- }
-
- std::vector<SubtitleStream> subtitle_streams () const {
- return _subtitle_streams;
- }
-
- float frames_per_second () const {
- return _frames_per_second;
- }
-
-
- /* SET */
-
- void set_directory (std::string);
- void set_name (std::string);
- void set_use_dci_name (bool);
- virtual void set_content (std::string);
- void set_dcp_content_type (DCPContentType const *);
- void set_format (Format const *);
- void set_crop (Crop);
- void set_left_crop (int);
- void set_right_crop (int);
- void set_top_crop (int);
- void set_bottom_crop (int);
- void set_filters (std::vector<Filter const *>);
- void set_scaler (Scaler const *);
- void set_dcp_frames (int);
- void set_dcp_trim_action (TrimAction);
- void set_dcp_ab (bool);
- void set_audio_stream (int);
- void set_audio_gain (float);
- void set_audio_delay (int);
- void set_still_duration (int);
- void set_subtitle_stream (int);
- void set_with_subtitles (bool);
- void set_subtitle_offset (int);
- void set_subtitle_scale (float);
- void set_audio_language (std::string);
- void set_subtitle_language (std::string);
- void set_territory (std::string);
- void set_rating (std::string);
- void set_studio (std::string);
- void set_facility (std::string);
- void set_package_type (std::string);
- void set_thumbs (std::vector<int>);
- void set_size (Size);
- void set_length (int);
- void set_audio_channels (int);
- void set_audio_sample_rate (int);
- void set_content_digest (std::string);
- void set_has_subtitles (bool);
- void set_audio_streams (std::vector<AudioStream>);
- void set_subtitle_streams (std::vector<SubtitleStream>);
- void set_frames_per_second (float);
-
- /** Emitted when some property has changed */
- mutable sigc::signal1<void, Property> Changed;
-
-private:
-
- std::string thumb_file_for_frame (int) const;
- std::string thumb_base_for_frame (int) const;
- void signal_changed (Property);
-
- /** Complete path to directory containing the film metadata;
- * must not be relative.
- */
- std::string _directory;
- /** Name for DVD-o-matic */
- std::string _name;
- /** True if a auto-generated DCI-compliant name should be used for our DCP */
- bool _use_dci_name;
- /** File or directory containing content; may be relative to our directory
- * or an absolute path.
- */
- std::string _content;
- /** The type of content that this Film represents (feature, trailer etc.) */
- DCPContentType const * _dcp_content_type;
- /** The format to present this Film in (flat, scope, etc.) */
- Format const * _format;
- /** The crop to apply to the source */
- Crop _crop;
- /** Video filters that should be used when generating DCPs */
- std::vector<Filter const *> _filters;
- /** Scaler algorithm to use */
- Scaler const * _scaler;
- /** Number of frames to put in the DCP, or 0 for all */
- int _dcp_frames;
- /** What to do with audio when trimming DCPs */
- TrimAction _dcp_trim_action;
- /** true to create an A/B comparison DCP, where the left half of the image
- is the video without any filters or post-processing, and the right half
- has the specified filters and post-processing.
- */
- bool _dcp_ab;
- /** An index into our _audio_streams vector for the stream to use for audio, or -1 if there is none */
- int _audio_stream;
- /** Gain to apply to audio in dB */
- float _audio_gain;
- /** Delay to apply to audio (positive moves audio later) in milliseconds */
- int _audio_delay;
- /** Duration to make still-sourced films (in seconds) */
- int _still_duration;
- /** An index into our _subtitle_streams vector for the stream to use for subtitles, or -1 if there is none */
- int _subtitle_stream;
- /** True if subtitles should be shown for this film */
- bool _with_subtitles;
- /** y offset for placing subtitles, in source pixels; +ve is further down
- the frame, -ve is further up.
- */
- int _subtitle_offset;
- /** scale factor to apply to subtitles */
- float _subtitle_scale;
-
- /* DCI naming stuff */
- std::string _audio_language;
- std::string _subtitle_language;
- std::string _territory;
- std::string _rating;
- std::string _studio;
- std::string _facility;
- std::string _package_type;
-
- /* Data which are cached to speed things up */
-
- /** Vector of frame indices for each of our `thumbnails' */
- std::vector<int> _thumbs;
- /** Size, in pixels, of the source (ignoring cropping) */
- Size _size;
- /** Length of the source in frames */
- int _length;
- /** Sample rate of the source audio, in Hz */
- int _audio_sample_rate;
- /** MD5 digest of our content file */
- std::string _content_digest;
- /** true if the source has subtitles */
- bool _has_subtitles;
- /** the audio streams that the source has */
- std::vector<AudioStream> _audio_streams;
- /** the subtitle streams that the source has */
- std::vector<SubtitleStream> _subtitle_streams;
- /** Frames per second of the source */
- float _frames_per_second;
-
- mutable bool _dirty;
-
- friend class paths_test;
-};
-
-#endif
#include <iostream>
#include <Magick++/Image.h>
#include "imagemagick_decoder.h"
-#include "film_state.h"
#include "image.h"
+#include "film.h"
using namespace std;
using namespace boost;
ImageMagickDecoder::ImageMagickDecoder (
- boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Job* j, Log* l, bool minimal, bool ignore_length)
- : Decoder (s, o, j, l, minimal, ignore_length)
+ boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal, bool ignore_length)
+ : Decoder (f, o, j, minimal, ignore_length)
, _done (false)
{
- _magick_image = new Magick::Image (_fs->content_path ());
+ _magick_image = new Magick::Image (_film->content_path ());
}
Size
class ImageMagickDecoder : public Decoder
{
public:
- ImageMagickDecoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Job *, Log *, bool, bool);
+ ImageMagickDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool, bool);
float frames_per_second () const {
return static_frames_per_second ();
#include <Magick++/Image.h>
#include "imagemagick_encoder.h"
#include "film.h"
-#include "film_state.h"
#include "options.h"
#include "exceptions.h"
#include "image.h"
using namespace std;
using namespace boost;
-/** @param s FilmState of the film that we are encoding.
+/** @param f Film that we are encoding.
* @param o Options.
- * @param l Log.
*/
-ImageMagickEncoder::ImageMagickEncoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
- : Encoder (s, o, l)
+ImageMagickEncoder::ImageMagickEncoder (shared_ptr<const Film> f, shared_ptr<const Options> o)
+ : Encoder (f, o)
{
}
void
ImageMagickEncoder::process_video (shared_ptr<Image> image, int frame, shared_ptr<Subtitle> sub)
{
- shared_ptr<Image> scaled = image->scale_and_convert_to_rgb (_opt->out_size, _opt->padding, _fs->scaler());
+ shared_ptr<Image> scaled = image->scale_and_convert_to_rgb (_opt->out_size, _opt->padding, _film->scaler());
shared_ptr<Image> compact (new CompactImage (scaled));
string tmp_file = _opt->frame_out_path (frame, true);
filesystem::rename (tmp_file, _opt->frame_out_path (frame, false));
if (sub) {
- float const x_scale = float (_opt->out_size.width) / _fs->size().width;
- float const y_scale = float (_opt->out_size.height) / _fs->size().height;
+ float const x_scale = float (_opt->out_size.width) / _film->size().width;
+ float const y_scale = float (_opt->out_size.height) / _film->size().height;
string tmp_metadata_file = _opt->frame_out_path (frame, false, ".sub");
ofstream metadata (tmp_metadata_file.c_str ());
Size new_size = sub->image()->size ();
new_size.width *= x_scale;
new_size.height *= y_scale;
- shared_ptr<Image> scaled = sub->image()->scale (new_size, _fs->scaler());
+ shared_ptr<Image> scaled = sub->image()->scale (new_size, _film->scaler());
shared_ptr<Image> compact (new CompactImage (scaled));
string tmp_sub_file = _opt->frame_out_path (frame, true, ".sub.png");
class ImageMagickEncoder : public Encoder
{
public:
- ImageMagickEncoder (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l);
+ ImageMagickEncoder (boost::shared_ptr<const Film> f, boost::shared_ptr<const Options> o);
void process_begin (int64_t audio_channel_layout) {}
void process_video (boost::shared_ptr<Image>, int, boost::shared_ptr<Subtitle>);
#include <openjpeg.h>
#include "j2k_still_encoder.h"
#include "config.h"
-#include "film_state.h"
#include "options.h"
#include "exceptions.h"
#include "dcp_video_frame.h"
#include "filter.h"
#include "log.h"
#include "imagemagick_decoder.h"
+#include "film.h"
using namespace std;
using namespace boost;
-J2KStillEncoder::J2KStillEncoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
- : Encoder (s, o, l)
+J2KStillEncoder::J2KStillEncoder (shared_ptr<const Film> f, shared_ptr<const Options> o)
+ : Encoder (f, o)
{
}
void
J2KStillEncoder::process_video (shared_ptr<Image> yuv, int frame, shared_ptr<Subtitle> sub)
{
- pair<string, string> const s = Filter::ffmpeg_strings (_fs->filters());
+ pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
DCPVideoFrame* f = new DCPVideoFrame (
- yuv, sub, _opt->out_size, _opt->padding, _fs->subtitle_offset(), _fs->subtitle_scale(), _fs->scaler(), 0, _fs->frames_per_second(), s.second,
+ yuv, sub, _opt->out_size, _opt->padding, _film->subtitle_offset(), _film->subtitle_scale(), _film->scaler(), 0, _film->frames_per_second(), s.second,
Config::instance()->colour_lut_index(), Config::instance()->j2k_bandwidth(),
- _log
+ _film->log()
);
if (!boost::filesystem::exists (_opt->frame_out_path (0, false))) {
}
string const real = _opt->frame_out_path (0, false);
- for (int i = 1; i < (_fs->still_duration() * ImageMagickDecoder::static_frames_per_second()); ++i) {
+ for (int i = 1; i < (_film->still_duration() * ImageMagickDecoder::static_frames_per_second()); ++i) {
if (!boost::filesystem::exists (_opt->frame_out_path (i, false))) {
string const link = _opt->frame_out_path (i, false);
#ifdef DVDOMATIC_POSIX
class J2KStillEncoder : public Encoder
{
public:
- J2KStillEncoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Log *);
+ J2KStillEncoder (boost::shared_ptr<const Film>, boost::shared_ptr<const Options>);
void process_begin (int64_t audio_channel_layout) {}
void process_video (boost::shared_ptr<Image>, int, boost::shared_ptr<Subtitle>);
#include <openjpeg.h>
#include "j2k_wav_encoder.h"
#include "config.h"
-#include "film_state.h"
#include "options.h"
#include "exceptions.h"
#include "dcp_video_frame.h"
#include "filter.h"
#include "log.h"
#include "cross.h"
+#include "film.h"
using namespace std;
using namespace boost;
-J2KWAVEncoder::J2KWAVEncoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
- : Encoder (s, o, l)
+J2KWAVEncoder::J2KWAVEncoder (shared_ptr<const Film> f, shared_ptr<const Options> o)
+ : Encoder (f, o)
#ifdef HAVE_SWRESAMPLE
, _swr_context (0)
#endif
/* Create sound output files with .tmp suffixes; we will rename
them if and when we complete.
*/
- for (int i = 0; i < _fs->audio_channels(); ++i) {
+ for (int i = 0; i < _film->audio_channels(); ++i) {
SF_INFO sf_info;
- sf_info.samplerate = dcp_audio_sample_rate (_fs->audio_sample_rate());
+ sf_info.samplerate = dcp_audio_sample_rate (_film->audio_sample_rate());
/* We write mono files */
sf_info.channels = 1;
sf_info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_24;
/* Only do the processing if we don't already have a file for this frame */
if (!boost::filesystem::exists (_opt->frame_out_path (frame, false))) {
- pair<string, string> const s = Filter::ffmpeg_strings (_fs->filters());
+ pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
TIMING ("adding to queue of %1", _queue.size ());
_queue.push_back (boost::shared_ptr<DCPVideoFrame> (
new DCPVideoFrame (
- yuv, sub, _opt->out_size, _opt->padding, _fs->subtitle_offset(), _fs->subtitle_scale(),
- _fs->scaler(), frame, _fs->frames_per_second(), s.second,
+ yuv, sub, _opt->out_size, _opt->padding, _film->subtitle_offset(), _film->subtitle_scale(),
+ _film->scaler(), frame, _film->frames_per_second(), s.second,
Config::instance()->colour_lut_index (), Config::instance()->j2k_bandwidth (),
- _log
+ _film->log()
)
));
TIMING ("encoder thread %1 wakes with queue of %2", boost::this_thread::get_id(), _queue.size());
boost::shared_ptr<DCPVideoFrame> vf = _queue.front ();
- _log->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame()));
+ _film->log()->log (String::compose ("Encoder thread %1 pops frame %2 from queue", boost::this_thread::get_id(), vf->frame()));
_queue.pop_front ();
lock.unlock ();
encoded = vf->encode_remotely (server);
if (remote_backoff > 0) {
- _log->log (String::compose ("%1 was lost, but now she is found; removing backoff", server->host_name ()));
+ _film->log()->log (String::compose ("%1 was lost, but now she is found; removing backoff", server->host_name ()));
}
/* This job succeeded, so remove any backoff */
/* back off more */
remote_backoff += 10;
}
- _log->log (
+ _film->log()->log (
String::compose (
"Remote encode of %1 on %2 failed (%3); thread sleeping for %4s",
vf->frame(), server->host_name(), e.what(), remote_backoff)
encoded = vf->encode_locally ();
TIMING ("encoder thread %1 finishes local encode of %2", boost::this_thread::get_id(), vf->frame());
} catch (std::exception& e) {
- _log->log (String::compose ("Local encode failed (%1)", e.what ()));
+ _film->log()->log (String::compose ("Local encode failed (%1)", e.what ()));
}
}
frame_done (vf->frame ());
} else {
lock.lock ();
- _log->log (String::compose ("Encoder thread %1 pushes frame %2 back onto queue after failure", boost::this_thread::get_id(), vf->frame()));
+ _film->log()->log (
+ String::compose ("Encoder thread %1 pushes frame %2 back onto queue after failure", boost::this_thread::get_id(), vf->frame())
+ );
_queue.push_front (vf);
lock.unlock ();
}
void
J2KWAVEncoder::process_begin (int64_t audio_channel_layout)
{
- if (_fs->audio_sample_rate() != _fs->target_audio_sample_rate()) {
+ if (_film->audio_sample_rate() != _film->target_audio_sample_rate()) {
#ifdef HAVE_SWRESAMPLE
stringstream s;
- s << "Will resample audio from " << _fs->audio_sample_rate() << " to " << _fs->target_audio_sample_rate();
- _log->log (s.str ());
+ s << "Will resample audio from " << _film->audio_sample_rate() << " to " << _film->target_audio_sample_rate();
+ _film->log()->log (s.str ());
/* We will be using planar float data when we call the resampler */
_swr_context = swr_alloc_set_opts (
0,
audio_channel_layout,
AV_SAMPLE_FMT_FLTP,
- _fs->target_audio_sample_rate(),
+ _film->target_audio_sample_rate(),
audio_channel_layout,
AV_SAMPLE_FMT_FLTP,
- _fs->audio_sample_rate(),
+ _film->audio_sample_rate(),
0, 0
);
{
boost::mutex::scoped_lock lock (_worker_mutex);
- _log->log ("Clearing queue of " + lexical_cast<string> (_queue.size ()));
+ _film->log()->log ("Clearing queue of " + lexical_cast<string> (_queue.size ()));
/* Keep waking workers until the queue is empty */
while (!_queue.empty ()) {
- _log->log ("Waking with " + lexical_cast<string> (_queue.size ()));
+ _film->log()->log ("Waking with " + lexical_cast<string> (_queue.size ()));
_worker_condition.notify_all ();
_worker_condition.wait (lock);
}
terminate_worker_threads ();
- _log->log ("Mopping up " + lexical_cast<string> (_queue.size()));
+ _film->log()->log ("Mopping up " + lexical_cast<string> (_queue.size()));
/* The following sequence of events can occur in the above code:
1. a remote worker takes the last image off the queue
*/
for (list<shared_ptr<DCPVideoFrame> >::iterator i = _queue.begin(); i != _queue.end(); ++i) {
- _log->log (String::compose ("Encode left-over frame %1", (*i)->frame ()));
+ _film->log()->log (String::compose ("Encode left-over frame %1", (*i)->frame ()));
try {
shared_ptr<EncodedData> e = (*i)->encode_locally ();
e->write (_opt, (*i)->frame ());
frame_done ((*i)->frame ());
} catch (std::exception& e) {
- _log->log (String::compose ("Local encode failed (%1)", e.what ()));
+ _film->log()->log (String::compose ("Local encode failed (%1)", e.what ()));
}
}
#if HAVE_SWRESAMPLE
if (_swr_context) {
- shared_ptr<AudioBuffers> out (new AudioBuffers (_fs->audio_channels(), 256));
+ shared_ptr<AudioBuffers> out (new AudioBuffers (_film->audio_channels(), 256));
while (1) {
int const frames = swr_convert (_swr_context, (uint8_t **) out->data(), 256, 0, 0);
}
#endif
- int const dcp_sr = dcp_audio_sample_rate (_fs->audio_sample_rate ());
+ int const dcp_sr = dcp_audio_sample_rate (_film->audio_sample_rate ());
int64_t const extra_audio_frames = dcp_sr - (_audio_frames_written % dcp_sr);
- shared_ptr<AudioBuffers> silence (new AudioBuffers (_fs->audio_channels(), extra_audio_frames));
+ shared_ptr<AudioBuffers> silence (new AudioBuffers (_film->audio_channels(), extra_audio_frames));
silence->make_silent ();
write_audio (silence);
close_sound_files ();
/* Rename .wav.tmp files to .wav */
- for (int i = 0; i < _fs->audio_channels(); ++i) {
+ for (int i = 0; i < _film->audio_channels(); ++i) {
if (boost::filesystem::exists (_opt->multichannel_audio_out_path (i, false))) {
boost::filesystem::remove (_opt->multichannel_audio_out_path (i, false));
}
if (_swr_context) {
/* Compute the resampled frames count and add 32 for luck */
- int const max_resampled_frames = ceil (audio->frames() * _fs->target_audio_sample_rate() / _fs->audio_sample_rate()) + 32;
+ int const max_resampled_frames = ceil (audio->frames() * _film->target_audio_sample_rate() / _film->audio_sample_rate()) + 32;
- resampled.reset (new AudioBuffers (_fs->audio_channels(), max_resampled_frames));
+ resampled.reset (new AudioBuffers (_film->audio_channels(), max_resampled_frames));
/* Resample audio */
int const resampled_frames = swr_convert (
void
J2KWAVEncoder::write_audio (shared_ptr<const AudioBuffers> audio)
{
- for (int i = 0; i < _fs->audio_channels(); ++i) {
+ for (int i = 0; i < _film->audio_channels(); ++i) {
sf_write_float (_sound_files[i], audio->data(i), audio->frames());
}
class J2KWAVEncoder : public Encoder
{
public:
- J2KWAVEncoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Log *);
+ J2KWAVEncoder (boost::shared_ptr<const Film>, boost::shared_ptr<const Options>);
~J2KWAVEncoder ();
void process_begin (int64_t audio_channel_layout);
using namespace std;
using namespace boost;
-/** @param s FilmState for the film that we are operating on.
- * @param l A log that we can write to.
+/** @param s Film that we are operating on.
*/
-Job::Job (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
- : _fs (s)
- , _log (l)
+Job::Job (shared_ptr<Film> f, shared_ptr<Job> req)
+ : _film (f)
, _required (req)
, _state (NEW)
, _start_time (0)
, _progress_unknown (false)
, _ran_for (0)
{
- assert (_log);
-
descend (1);
}
#include <boost/enable_shared_from_this.hpp>
#include <sigc++/sigc++.h>
-class Log;
-class FilmState;
+class Film;
class Options;
/** @class Job
class Job : public boost::enable_shared_from_this<Job>
{
public:
- Job (boost::shared_ptr<const FilmState> s, Log* l, boost::shared_ptr<Job> req);
+ Job (boost::shared_ptr<Film> s, boost::shared_ptr<Job> req);
/** @return user-readable name of this job */
virtual std::string name () const = 0;
void set_state (State);
void set_error (std::string e);
- /** FilmState for this job */
- boost::shared_ptr<const FilmState> _fs;
- /** a log that this job can write to */
- Log* _log;
+ /** Film for this job */
+ boost::shared_ptr<Film> _film;
private:
#include <libavutil/pixdesc.h>
}
#include "make_dcp_job.h"
-#include "film_state.h"
#include "dcp_content_type.h"
#include "exceptions.h"
#include "options.h"
#include "imagemagick_decoder.h"
+#include "film.h"
using namespace std;
using namespace boost;
-/** @param s FilmState of the Film we are making the DCP for.
+/** @param f Film we are making the DCP for.
* @param o Options.
- * @param l Log.
*/
-MakeDCPJob::MakeDCPJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
- : Job (s, l, req)
+MakeDCPJob::MakeDCPJob (shared_ptr<Film> f, shared_ptr<const Options> o, shared_ptr<Job> req)
+ : Job (f, req)
, _opt (o)
{
string
MakeDCPJob::name () const
{
- return String::compose ("Make DCP for %1", _fs->name());
+ return String::compose ("Make DCP for %1", _film->name());
}
string
void
MakeDCPJob::run ()
{
- string const dcp_path = _fs->dir (_fs->dcp_name());
+ string const dcp_path = _film->dir (_film->dcp_name());
/* Remove any old DCP */
filesystem::remove_all (dcp_path);
int frames = 0;
- switch (_fs->content_type ()) {
+ switch (_film->content_type ()) {
case VIDEO:
- frames = _fs->dcp_length ();
+ frames = _film->dcp_length ();
break;
case STILL:
- frames = _fs->still_duration() * ImageMagickDecoder::static_frames_per_second ();
+ frames = _film->still_duration() * ImageMagickDecoder::static_frames_per_second ();
break;
}
- libdcp::DCP dcp (_fs->dir (_fs->dcp_name()));
+ libdcp::DCP dcp (_film->dir (_film->dcp_name()));
dcp.Progress.connect (sigc::mem_fun (*this, &MakeDCPJob::dcp_progress));
shared_ptr<libdcp::CPL> cpl (
- new libdcp::CPL (_fs->dir (_fs->dcp_name()), _fs->dcp_name(), _fs->dcp_content_type()->libdcp_kind (), frames, rint (_fs->frames_per_second()))
+ new libdcp::CPL (_film->dir (_film->dcp_name()), _film->dcp_name(), _film->dcp_content_type()->libdcp_kind (), frames, rint (_film->frames_per_second()))
);
dcp.add_cpl (cpl);
shared_ptr<libdcp::MonoPictureAsset> pa (
new libdcp::MonoPictureAsset (
sigc::mem_fun (*this, &MakeDCPJob::j2c_path),
- _fs->dir (_fs->dcp_name()),
+ _film->dir (_film->dcp_name()),
"video.mxf",
&dcp.Progress,
- rint (_fs->frames_per_second()),
+ rint (_film->frames_per_second()),
frames,
_opt->out_size.width,
_opt->out_size.height
shared_ptr<libdcp::SoundAsset> sa;
- if (_fs->audio_channels() > 0) {
+ if (_film->audio_channels() > 0) {
descend (0.1);
sa.reset (
new libdcp::SoundAsset (
sigc::mem_fun (*this, &MakeDCPJob::wav_path),
- _fs->dir (_fs->dcp_name()),
+ _film->dir (_film->dcp_name()),
"audio.mxf",
&dcp.Progress,
- rint (_fs->frames_per_second()),
+ rint (_film->frames_per_second()),
frames,
- _fs->audio_channels()
+ _film->audio_channels()
)
);
ascend ();
class MakeDCPJob : public Job
{
public:
- MakeDCPJob (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Log *, boost::shared_ptr<Job> req);
+ MakeDCPJob (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, boost::shared_ptr<Job> req);
std::string name () const;
void run ();
#include <boost/thread.hpp>
#include <boost/algorithm/string.hpp>
#include "player.h"
-#include "film_state.h"
#include "filter.h"
#include "screen.h"
#include "exceptions.h"
#include "player_manager.h"
#include "player.h"
-#include "film_state.h"
#include "screen.h"
using namespace std;
}
void
-PlayerManager::setup (shared_ptr<const FilmState> fs, shared_ptr<const Screen> sc)
+PlayerManager::setup (shared_ptr<const Film> f, shared_ptr<const Screen> sc)
{
boost::mutex::scoped_lock lm (_players_mutex);
_players.clear ();
- _players.push_back (shared_ptr<Player> (new Player (fs, sc, Player::SPLIT_NONE)));
+ _players.push_back (shared_ptr<Player> (new Player (f, sc, Player::SPLIT_NONE)));
}
void
-PlayerManager::setup (shared_ptr<const FilmState> fs_a, shared_ptr<const FilmState> fs_b, shared_ptr<const Screen> sc)
+PlayerManager::setup (shared_ptr<const Film> fs_a, shared_ptr<const Film> fs_b, shared_ptr<const Screen> sc)
{
boost::mutex::scoped_lock lm (_players_mutex);
#include <fcntl.h>
#include <boost/filesystem.hpp>
#include <libssh/libssh.h>
+#include "compose.hpp"
#include "scp_dcp_job.h"
#include "exceptions.h"
#include "config.h"
#include "log.h"
-#include "film_state.h"
+#include "film.h"
using namespace std;
using namespace boost;
};
-SCPDCPJob::SCPDCPJob (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
- : Job (s, l, req)
+SCPDCPJob::SCPDCPJob (shared_ptr<Film> f, shared_ptr<Job> req)
+ : Job (f, req)
, _status ("Waiting")
{
void
SCPDCPJob::run ()
{
- _log->log ("SCP DCP job starting");
+ _film->log()->log ("SCP DCP job starting");
SSHSession ss;
throw NetworkError (String::compose ("Could not start SCP session (%1)", ssh_get_error (ss.session)));
}
- r = ssh_scp_push_directory (sc.scp, _fs->dcp_name().c_str(), S_IRWXU);
+ r = ssh_scp_push_directory (sc.scp, _film->dcp_name().c_str(), S_IRWXU);
if (r != SSH_OK) {
- throw NetworkError (String::compose ("Could not create remote directory %1 (%2)", _fs->dcp_name(), ssh_get_error (ss.session)));
+ throw NetworkError (String::compose ("Could not create remote directory %1 (%2)", _film->dcp_name(), ssh_get_error (ss.session)));
}
- string const dcp_dir = _fs->dir (_fs->dcp_name());
+ string const dcp_dir = _film->dir (_film->dcp_name());
boost::uintmax_t bytes_to_transfer = 0;
for (filesystem::directory_iterator i = filesystem::directory_iterator (dcp_dir); i != filesystem::directory_iterator(); ++i) {
class SCPDCPJob : public Job
{
public:
- SCPDCPJob (boost::shared_ptr<const FilmState>, Log *, boost::shared_ptr<Job> req);
+ SCPDCPJob (boost::shared_ptr<Film>, boost::shared_ptr<Job> req);
std::string name () const;
void run ();
#include "subtitle.h"
#include "image.h"
#include "exceptions.h"
-#include "film_state.h"
using namespace std;
using namespace boost;
}
#include "util.h"
#include "tiff_decoder.h"
-#include "film_state.h"
#include "exceptions.h"
#include "image.h"
#include "options.h"
+#include "film.h"
using namespace std;
using namespace boost;
-/** @param fs FilmState of our Film.
+/** @param f Our Film.
* @param o Options.
* @param j Job that we are associated with, or 0.
- * @param l Log that we can write to.
* @param minimal true to do the bare minimum of work; just run through the content. Useful for acquiring
* accurate frame counts as quickly as possible. This generates no video or audio output.
* @param ignore_length Ignore the content's claimed length when computing progress.
*/
-TIFFDecoder::TIFFDecoder (boost::shared_ptr<const FilmState> fs, boost::shared_ptr<const Options> o, Job* j, Log* l, bool minimal, bool ignore_length)
- : Decoder (fs, o, j, l, minimal, ignore_length)
+TIFFDecoder::TIFFDecoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, bool minimal, bool ignore_length)
+ : Decoder (f, o, j, minimal, ignore_length)
{
- string const dir = _fs->content_path ();
+ string const dir = _film->content_path ();
if (!filesystem::is_directory (dir)) {
throw DecodeError ("TIFF content must be in a directory");
TIFFDecoder::file_path (string f) const
{
stringstream s;
- s << _fs->content_path() << "/" << f;
- return _fs->file (s.str ());
+ s << _film->content_path() << "/" << f;
+ return _film->file (s.str ());
}
PixelFormat
int
TIFFDecoder::time_base_numerator () const
{
- return rint (_fs->frames_per_second());
+ return rint (_film->frames_per_second());
}
class FilmState;
class Options;
class Image;
-class Log;
/** @class TIFFDecoder.
* @brief A decoder which reads a numbered set of TIFF files, one per frame.
class TIFFDecoder : public Decoder
{
public:
- TIFFDecoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Job *, Log *, bool, bool);
+ TIFFDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool, bool);
/* Methods to query our input video */
float frames_per_second () const;
#include "film.h"
#include "format.h"
#include "transcoder.h"
-#include "film_state.h"
#include "log.h"
#include "encoder_factory.h"
using namespace std;
using namespace boost;
-/** @param s FilmState to use.
+/** @param s Film to use.
* @param o Options.
- * @param l A log that we can write to.
*/
-TranscodeJob::TranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
- : Job (s, l, req)
+TranscodeJob::TranscodeJob (shared_ptr<Film> f, shared_ptr<const Options> o, shared_ptr<Job> req)
+ : Job (f, req)
, _opt (o)
{
string
TranscodeJob::name () const
{
- return String::compose ("Transcode %1", _fs->name());
+ return String::compose ("Transcode %1", _film->name());
}
void
{
try {
- _log->log ("Transcode job starting");
+ _film->log()->log ("Transcode job starting");
- _encoder = encoder_factory (_fs, _opt, _log);
- Transcoder w (_fs, _opt, this, _log, _encoder);
+ _encoder = encoder_factory (_film, _opt);
+ Transcoder w (_film, _opt, this, _encoder);
w.go ();
set_progress (1);
set_state (FINISHED_OK);
- _log->log ("Transcode job completed successfully");
+ _film->log()->log ("Transcode job completed successfully");
} catch (std::exception& e) {
set_progress (1);
set_state (FINISHED_ERROR);
- _log->log (String::compose ("Transcode job failed (%1)", e.what()));
+ _film->log()->log (String::compose ("Transcode job failed (%1)", e.what()));
throw;
}
return 0;
}
- return ((_fs->dcp_length() - _encoder->last_frame()) / fps);
+ return ((_film->dcp_length() - _encoder->last_frame()) / fps);
}
class TranscodeJob : public Job
{
public:
- TranscodeJob (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l, boost::shared_ptr<Job> req);
+ TranscodeJob (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, boost::shared_ptr<Job> req);
std::string name () const;
void run ();
*/
/** @file src/transcoder.cc
- * @brief A class which takes a FilmState and some Options, then uses those to transcode a Film.
+ * @brief A class which takes a Film and some Options, then uses those to transcode the film.
*
* A decoder is selected according to the content type, and the encoder can be specified
* as a parameter to the constructor.
using namespace boost;
/** Construct a transcoder using a Decoder that we create and a supplied Encoder.
- * @param s FilmState of Film that we are transcoding.
+ * @param f Film that we are transcoding.
* @param o Options.
* @param j Job that we are running under, or 0.
- * @param l Log that we can write to.
* @param e Encoder to use.
*/
-Transcoder::Transcoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Job* j, Log* l, shared_ptr<Encoder> e)
+Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j, shared_ptr<Encoder> e)
: _job (j)
, _encoder (e)
- , _decoder (decoder_factory (s, o, j, l))
+ , _decoder (decoder_factory (f, o, j))
{
assert (_encoder);
class Transcoder
{
public:
- Transcoder (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Job* j, Log* l, boost::shared_ptr<Encoder> e);
+ Transcoder (boost::shared_ptr<Film> f, boost::shared_ptr<const Options> o, Job* j, boost::shared_ptr<Encoder> e);
void go ();
#include "dcp_content_type.h"
#include "filter.h"
#include "screen.h"
-#include "film_state.h"
#include "sound_processor.h"
#ifndef DVDOMATIC_DISABLE_PLAYER
#include "player_manager.h"
#include "compose.hpp"
#ifdef DVDOMATIC_DEBUG
-#define TIMING(...) _log->microsecond_log (String::compose (__VA_ARGS__), Log::TIMING);
+#define TIMING(...) _film->log()->microsecond_log (String::compose (__VA_ARGS__), Log::TIMING);
#else
#define TIMING(...)
#endif
ffmpeg_compatibility.cc
ffmpeg_decoder.cc
film.cc
- film_state.cc
filter.cc
format.cc
image.cc
#include "gain_calculator_dialog.h"
#include "sound_processor.h"
#include "dci_name_dialog.h"
+#include "scaler.h"
using namespace std;
using namespace boost;
/** @param f Film to edit */
FilmEditor::FilmEditor (Film* f, wxWindow* parent)
: wxPanel (parent)
- , _ignore_changes (FilmState::NONE)
+ , _ignore_changes (Film::NONE)
, _film (f)
{
_sizer = new wxFlexGridSizer (2, 4, 4);
return;
}
- _ignore_changes = FilmState::CROP;
+ _ignore_changes = Film::CROP;
_film->set_left_crop (_left_crop->GetValue ());
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
/** Called when the right crop widget has been changed */
return;
}
- _ignore_changes = FilmState::CROP;
+ _ignore_changes = Film::CROP;
_film->set_right_crop (_right_crop->GetValue ());
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
/** Called when the top crop widget has been changed */
return;
}
- _ignore_changes = FilmState::CROP;
+ _ignore_changes = Film::CROP;
_film->set_top_crop (_top_crop->GetValue ());
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
/** Called when the bottom crop value has been changed */
return;
}
- _ignore_changes = FilmState::CROP;
+ _ignore_changes = Film::CROP;
_film->set_bottom_crop (_bottom_crop->GetValue ());
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
/** Called when the content filename has been changed */
return;
}
- _ignore_changes = FilmState::CONTENT;
+ _ignore_changes = Film::CONTENT;
try {
_film->set_content (wx_to_std (_content->GetPath ()));
error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
}
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
setup_visibility ();
setup_formats ();
return;
}
- _ignore_changes = FilmState::DCP_AB;
+ _ignore_changes = Film::DCP_AB;
_film->set_dcp_ab (_dcp_ab->GetValue ());
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
/** Called when the name widget has been changed */
return;
}
- _ignore_changes = FilmState::NAME;
+ _ignore_changes = Film::NAME;
_film->set_name (string (_name->GetValue().mb_str()));
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
}
return;
}
- _ignore_changes = FilmState::SUBTITLE_OFFSET;
+ _ignore_changes = Film::SUBTITLE_OFFSET;
_film->set_subtitle_offset (_subtitle_offset->GetValue ());
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
void
return;
}
- _ignore_changes = FilmState::SUBTITLE_OFFSET;
+ _ignore_changes = Film::SUBTITLE_OFFSET;
_film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
}
* @param p Property of the Film that has changed.
*/
void
-FilmEditor::film_changed (FilmState::Property p)
+FilmEditor::film_changed (Film::Property p)
{
ensure_ui_thread ();
stringstream s;
switch (p) {
- case FilmState::NONE:
+ case Film::NONE:
break;
- case FilmState::CONTENT:
+ case Film::CONTENT:
_content->SetPath (std_to_wx (_film->content ()));
setup_visibility ();
setup_formats ();
setup_subtitle_button ();
setup_streams ();
break;
- case FilmState::HAS_SUBTITLES:
+ case Film::HAS_SUBTITLES:
setup_subtitle_button ();
setup_streams ();
break;
- case FilmState::AUDIO_STREAMS:
- case FilmState::SUBTITLE_STREAMS:
+ case Film::AUDIO_STREAMS:
+ case Film::SUBTITLE_STREAMS:
setup_streams ();
break;
- case FilmState::FORMAT:
+ case Film::FORMAT:
{
int n = 0;
vector<Format const *>::iterator i = _formats.begin ();
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
break;
}
- case FilmState::CROP:
+ case Film::CROP:
_left_crop->SetValue (_film->crop().left);
_right_crop->SetValue (_film->crop().right);
_top_crop->SetValue (_film->crop().top);
_bottom_crop->SetValue (_film->crop().bottom);
break;
- case FilmState::FILTERS:
+ case Film::FILTERS:
{
pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
if (p.first.empty () && p.second.empty ()) {
_sizer->Layout ();
break;
}
- case FilmState::NAME:
+ case Film::NAME:
_name->ChangeValue (std_to_wx (_film->name ()));
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
break;
- case FilmState::FRAMES_PER_SECOND:
+ case Film::FRAMES_PER_SECOND:
s << fixed << setprecision(2) << _film->frames_per_second();
_frames_per_second->SetLabel (std_to_wx (s.str ()));
break;
- case FilmState::AUDIO_SAMPLE_RATE:
+ case Film::AUDIO_SAMPLE_RATE:
setup_audio_details ();
break;
- case FilmState::SIZE:
+ case Film::SIZE:
if (_film->size().width == 0 && _film->size().height == 0) {
_original_size->SetLabel (wxT (""));
} else {
_original_size->SetLabel (std_to_wx (s.str ()));
}
break;
- case FilmState::LENGTH:
+ case Film::LENGTH:
if (_film->frames_per_second() > 0 && _film->length() > 0) {
s << _film->length() << " frames; " << seconds_to_hms (_film->length() / _film->frames_per_second());
} else if (_film->length() > 0) {
}
_length->SetLabel (std_to_wx (s.str ()));
break;
- case FilmState::DCP_CONTENT_TYPE:
+ case Film::DCP_CONTENT_TYPE:
_dcp_content_type->SetSelection (DCPContentType::as_index (_film->dcp_content_type ()));
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
break;
- case FilmState::THUMBS:
+ case Film::THUMBS:
break;
- case FilmState::DCP_FRAMES:
+ case Film::DCP_FRAMES:
if (_film->dcp_frames() == 0) {
_dcp_range->SetLabel (wxT ("Whole film"));
} else {
}
_sizer->Layout ();
break;
- case FilmState::DCP_TRIM_ACTION:
+ case Film::DCP_TRIM_ACTION:
break;
- case FilmState::DCP_AB:
+ case Film::DCP_AB:
_dcp_ab->SetValue (_film->dcp_ab ());
break;
- case FilmState::SCALER:
+ case Film::SCALER:
_scaler->SetSelection (Scaler::as_index (_film->scaler ()));
break;
- case FilmState::AUDIO_GAIN:
+ case Film::AUDIO_GAIN:
_audio_gain->SetValue (_film->audio_gain ());
break;
- case FilmState::AUDIO_DELAY:
+ case Film::AUDIO_DELAY:
_audio_delay->SetValue (_film->audio_delay ());
break;
- case FilmState::STILL_DURATION:
+ case Film::STILL_DURATION:
_still_duration->SetValue (_film->still_duration ());
break;
- case FilmState::WITH_SUBTITLES:
+ case Film::WITH_SUBTITLES:
_with_subtitles->SetValue (_film->with_subtitles ());
_subtitle_scale->Enable (_film->with_subtitles ());
_subtitle_offset->Enable (_film->with_subtitles ());
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
break;
- case FilmState::SUBTITLE_OFFSET:
+ case Film::SUBTITLE_OFFSET:
_subtitle_offset->SetValue (_film->subtitle_offset ());
break;
- case FilmState::SUBTITLE_SCALE:
+ case Film::SUBTITLE_SCALE:
_subtitle_scale->SetValue (_film->subtitle_scale() * 100);
break;
- case FilmState::USE_DCI_NAME:
+ case Film::USE_DCI_NAME:
_use_dci_name->SetValue (_film->use_dci_name ());
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
break;
- case FilmState::DCI_METADATA:
+ case Film::DCI_METADATA:
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
break;
- case FilmState::AUDIO_STREAM:
+ case Film::AUDIO_STREAM:
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
_audio_stream->SetSelection (_film->audio_stream_index ());
setup_audio_details ();
break;
- case FilmState::SUBTITLE_STREAM:
+ case Film::SUBTITLE_STREAM:
_subtitle_stream->SetSelection (_film->subtitle_stream_index ());
break;
}
return;
}
- _ignore_changes = FilmState::FORMAT;
+ _ignore_changes = Film::FORMAT;
int const n = _format->GetSelection ();
if (n >= 0) {
assert (n < int (_formats.size()));
_film->set_format (_formats[n]);
}
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
}
return;
}
- _ignore_changes = FilmState::DCP_CONTENT_TYPE;
+ _ignore_changes = Film::DCP_CONTENT_TYPE;
int const n = _dcp_content_type->GetSelection ();
if (n >= 0) {
_film->set_dcp_content_type (DCPContentType::from_index (n));
}
- _ignore_changes = FilmState::NONE;
+ _ignore_changes = Film::NONE;
_dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
}
FileChanged ("");
}
- film_changed (FilmState::NAME);
- film_changed (FilmState::CONTENT);
- film_changed (FilmState::DCP_CONTENT_TYPE);
- film_changed (FilmState::FORMAT);
- film_changed (FilmState::CROP);
- film_changed (FilmState::FILTERS);
- film_changed (FilmState::DCP_FRAMES);
- film_changed (FilmState::DCP_TRIM_ACTION);
- film_changed (FilmState::DCP_AB);
- film_changed (FilmState::SIZE);
- film_changed (FilmState::LENGTH);
- film_changed (FilmState::FRAMES_PER_SECOND);
- film_changed (FilmState::AUDIO_SAMPLE_RATE);
- film_changed (FilmState::SCALER);
- film_changed (FilmState::AUDIO_GAIN);
- film_changed (FilmState::AUDIO_DELAY);
- film_changed (FilmState::STILL_DURATION);
- film_changed (FilmState::WITH_SUBTITLES);
- film_changed (FilmState::SUBTITLE_OFFSET);
- film_changed (FilmState::SUBTITLE_SCALE);
- film_changed (FilmState::USE_DCI_NAME);
- film_changed (FilmState::DCI_METADATA);
+ film_changed (Film::NAME);
+ film_changed (Film::CONTENT);
+ film_changed (Film::DCP_CONTENT_TYPE);
+ film_changed (Film::FORMAT);
+ film_changed (Film::CROP);
+ film_changed (Film::FILTERS);
+ film_changed (Film::DCP_FRAMES);
+ film_changed (Film::DCP_TRIM_ACTION);
+ film_changed (Film::DCP_AB);
+ film_changed (Film::SIZE);
+ film_changed (Film::LENGTH);
+ film_changed (Film::FRAMES_PER_SECOND);
+ film_changed (Film::AUDIO_SAMPLE_RATE);
+ film_changed (Film::SCALER);
+ film_changed (Film::AUDIO_GAIN);
+ film_changed (Film::AUDIO_DELAY);
+ film_changed (Film::STILL_DURATION);
+ film_changed (Film::WITH_SUBTITLES);
+ film_changed (Film::SUBTITLE_OFFSET);
+ film_changed (Film::SUBTITLE_SCALE);
+ film_changed (Film::USE_DCI_NAME);
+ film_changed (Film::DCI_METADATA);
}
/** Updates the sensitivity of lots of widgets to a given value.
void subtitle_stream_changed (wxCommandEvent &);
/* Handle changes to the model */
- void film_changed (FilmState::Property);
+ void film_changed (Film::Property);
/* Button clicks */
void edit_filters_clicked (wxCommandEvent &);
wxControl* video_control (wxControl *);
wxControl* still_control (wxControl *);
- FilmState::Property _ignore_changes;
+ Film::Property _ignore_changes;
/** The film we are editing */
Film* _film;
case PlayerManager::QUIESCENT:
_last_play_fs = _film->state_copy ();
if (_ab.get_active ()) {
- shared_ptr<FilmState> fs_a = _film->state_copy ();
+ shared_ptr<Film> fs_a = _film->state_copy ();
fs_a->filters.clear ();
/* This is somewhat arbitrary, but hey ho */
fs_a->scaler = Scaler::from_id ("bicubic");
#include "lib/format.h"
#include "lib/util.h"
#include "lib/job_manager.h"
-#include "lib/film_state.h"
#include "lib/options.h"
#include "lib/subtitle.h"
#include "film_viewer.h"
}
void
-FilmViewer::film_changed (FilmState::Property p)
+FilmViewer::film_changed (Film::Property p)
{
ensure_ui_thread ();
switch (p) {
- case FilmState::THUMBS:
+ case Film::THUMBS:
if (_film && _film->thumbs().size() > 1) {
_slider->SetRange (0, _film->thumbs().size() - 1);
} else {
_slider->SetValue (0);
set_thumbnail (0);
break;
- case FilmState::CONTENT:
+ case Film::CONTENT:
setup_visibility ();
break;
- case FilmState::CROP:
- case FilmState::FORMAT:
- case FilmState::WITH_SUBTITLES:
- case FilmState::SUBTITLE_OFFSET:
- case FilmState::SUBTITLE_SCALE:
+ case Film::CROP:
+ case Film::FORMAT:
+ case Film::WITH_SUBTITLES:
+ case Film::SUBTITLE_OFFSET:
+ case Film::SUBTITLE_SCALE:
_thumb_panel->recompose ();
break;
default:
private:
void slider_changed (wxCommandEvent &);
void set_thumbnail (int);
- void film_changed (FilmState::Property);
+ void film_changed (Film::Property);
Film* _film;
wxBoxSizer* _sizer;
#include "cross.h"
#include "job.h"
#include "subtitle.h"
+#include "scaler.h"
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE dvdomatic_test
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE (paths_test)
{
- FilmState s;
- s.set_directory ("build/test/a/b/c/d/e");
+ Film f ("build/test/film4", false);
+ f.set_directory ("build/test/a/b/c/d/e");
vector<int> thumbs;
thumbs.push_back (42);
- s.set_thumbs (thumbs);
- BOOST_CHECK_EQUAL (s.thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.png");
+ f.set_thumbs (thumbs);
+ BOOST_CHECK_EQUAL (f.thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.png");
- s._content = "/foo/bar/baz";
- BOOST_CHECK_EQUAL (s.content_path(), "/foo/bar/baz");
- s._content = "foo/bar/baz";
- BOOST_CHECK_EQUAL (s.content_path(), "build/test/a/b/c/d/e/foo/bar/baz");
+ f._content = "/foo/bar/baz";
+ BOOST_CHECK_EQUAL (f.content_path(), "/foo/bar/baz");
+ f._content = "foo/bar/baz";
+ BOOST_CHECK_EQUAL (f.content_path(), "build/test/a/b/c/d/e/foo/bar/baz");
}
void
BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
{
- FilmState fs;
- fs.set_frames_per_second (24);
+ Film f ("build/test/test_film5", false);
+ f.set_frames_per_second (24);
- fs.set_audio_sample_rate (48000);
- BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 48000);
+ f.set_audio_sample_rate (48000);
+ BOOST_CHECK_EQUAL (f.target_audio_sample_rate(), 48000);
- fs.set_audio_sample_rate (44100);
- BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 48000);
+ f.set_audio_sample_rate (44100);
+ BOOST_CHECK_EQUAL (f.target_audio_sample_rate(), 48000);
- fs.set_audio_sample_rate (80000);
- BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 96000);
+ f.set_audio_sample_rate (80000);
+ BOOST_CHECK_EQUAL (f.target_audio_sample_rate(), 96000);
- fs.set_frames_per_second (23.976);
- fs.set_audio_sample_rate (48000);
- BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 47952);
+ f.set_frames_per_second (23.976);
+ f.set_audio_sample_rate (48000);
+ BOOST_CHECK_EQUAL (f.target_audio_sample_rate(), 47952);
- fs.set_frames_per_second (29.97);
- fs.set_audio_sample_rate (48000);
- BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 47952);
+ f.set_frames_per_second (29.97);
+ f.set_audio_sample_rate (48000);
+ BOOST_CHECK_EQUAL (f.target_audio_sample_rate(), 47952);
}
class TestJob : public Job
{
public:
- TestJob (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
- : Job (s, l, req)
+ TestJob (shared_ptr<Film> f, shared_ptr<Job> req)
+ : Job (f, req)
{
}
BOOST_AUTO_TEST_CASE (job_manager_test)
{
- shared_ptr<const FilmState> s;
- FileLog log ("build/test/job_manager_test.log");
+ shared_ptr<Film> f;
/* Single job, no dependency */
- shared_ptr<TestJob> a (new TestJob (s, &log, shared_ptr<Job> ()));
+ shared_ptr<TestJob> a (new TestJob (f, shared_ptr<Job> ()));
JobManager::instance()->add (a);
dvdomatic_sleep (1);
BOOST_CHECK_EQUAL (a->finished_ok(), true);
/* Two jobs, dependency */
- a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
- shared_ptr<TestJob> b (new TestJob (s, &log, a));
+ a.reset (new TestJob (f, shared_ptr<Job> ()));
+ shared_ptr<TestJob> b (new TestJob (f, a));
JobManager::instance()->add (a);
JobManager::instance()->add (b);
BOOST_CHECK_EQUAL (b->finished_ok(), true);
/* Two jobs, dependency, first fails */
- a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
- b.reset (new TestJob (s, &log, a));
+ a.reset (new TestJob (f, shared_ptr<Job> ()));
+ b.reset (new TestJob (f, a));
JobManager::instance()->add (a);
JobManager::instance()->add (b);