2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <boost/filesystem.hpp>
29 #include <boost/algorithm/string.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include <boost/date_time.hpp>
34 #include "imagemagick_encoder.h"
37 #include "transcoder.h"
39 #include "job_manager.h"
40 #include "ab_transcode_job.h"
41 #include "transcode_job.h"
42 #include "scp_dcp_job.h"
43 #include "copy_from_dvd_job.h"
44 #include "make_dcp_job.h"
47 #include "exceptions.h"
48 #include "examine_content_job.h"
50 #include "decoder_factory.h"
52 #include "check_hashes_job.h"
54 #include "ui_signaller.h"
57 using std::stringstream;
66 using boost::shared_ptr;
67 using boost::lexical_cast;
68 using boost::to_upper_copy;
69 using boost::ends_with;
70 using boost::starts_with;
72 /** Construct a Film object in a given directory, reading any metadata
73 * file that exists in that directory. An exception will be thrown if
74 * must_exist is true and the specified directory does not exist.
76 * @param d Film directory.
77 * @param must_exist true to throw an exception if does not exist.
80 Film::Film (string d, bool must_exist)
81 : _use_dci_name (false)
82 , _dcp_content_type (0)
84 , _scaler (Scaler::from_id ("bicubic"))
85 , _dcp_trim_action (CUT)
90 , _still_duration (10)
91 , _subtitle_stream (-1)
92 , _with_subtitles (false)
93 , _subtitle_offset (0)
95 , _audio_sample_rate (0)
96 , _has_subtitles (false)
97 , _frames_per_second (0)
100 /* Make state.directory a complete path without ..s (where possible)
101 (Code swiped from Adam Bowen on stackoverflow)
104 boost::filesystem::path p (boost::filesystem::system_complete (d));
105 boost::filesystem::path result;
106 for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
108 if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
111 result = result.parent_path ();
113 } else if (*i != ".") {
118 set_directory (result.string ());
120 if (!boost::filesystem::exists (directory())) {
122 throw OpenFileError (directory());
124 boost::filesystem::create_directory (directory());
130 _log = new FileLog (file ("log"));
131 set_dci_date_today ();
134 Film::Film (Film const & o)
136 , _directory (o._directory)
138 , _use_dci_name (o._use_dci_name)
139 , _content (o._content)
140 , _dcp_content_type (o._dcp_content_type)
141 , _format (o._format)
143 , _filters (o._filters)
144 , _scaler (o._scaler)
145 , _dcp_frames (o._dcp_frames)
146 , _dcp_trim_action (o._dcp_trim_action)
147 , _dcp_ab (o._dcp_ab)
148 , _audio_stream (o._audio_stream)
149 , _audio_gain (o._audio_gain)
150 , _audio_delay (o._audio_delay)
151 , _still_duration (o._still_duration)
152 , _subtitle_stream (o._subtitle_stream)
153 , _with_subtitles (o._with_subtitles)
154 , _subtitle_offset (o._subtitle_offset)
155 , _subtitle_scale (o._subtitle_scale)
156 , _audio_language (o._audio_language)
157 , _subtitle_language (o._subtitle_language)
158 , _territory (o._territory)
159 , _rating (o._rating)
160 , _studio (o._studio)
161 , _facility (o._facility)
162 , _package_type (o._package_type)
163 , _thumbs (o._thumbs)
165 , _length (o._length)
166 , _audio_sample_rate (o._audio_sample_rate)
167 , _content_digest (o._content_digest)
168 , _has_subtitles (o._has_subtitles)
169 , _audio_streams (o._audio_streams)
170 , _subtitle_streams (o._subtitle_streams)
171 , _frames_per_second (o._frames_per_second)
182 /** @return The path to the directory to write JPEG2000 files to */
184 Film::j2k_dir () const
188 boost::filesystem::path p;
193 pair<string, string> f = Filter::ffmpeg_strings (filters());
195 /* Write stuff to specify the filter / post-processing settings that are in use,
196 so that we don't get confused about J2K files generated using different
201 << "_" << content_digest()
202 << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
203 << "_" << f.first << "_" << f.second
204 << "_" << scaler()->id();
208 /* Similarly for the A/B case */
211 pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
212 s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
216 return dir (p.string());
219 /** Add suitable Jobs to the JobManager to create a DCP for this Film.
220 * @param true to transcode, false to use the WAV and J2K files that are already there.
223 Film::make_dcp (bool transcode)
225 set_dci_date_today ();
227 if (dcp_name().find ("/") != string::npos) {
228 throw BadSettingError ("name", "cannot contain slashes");
231 log()->log (String::compose ("DVD-o-matic %1 git %2 using %3", dvdomatic_version, dvdomatic_git_commit, dependency_version_summary()));
235 gethostname (buffer, sizeof (buffer));
236 log()->log (String::compose ("Starting to make DCP on %1", buffer));
240 throw MissingSettingError ("format");
243 if (content().empty ()) {
244 throw MissingSettingError ("content");
247 if (dcp_content_type() == 0) {
248 throw MissingSettingError ("content type");
251 if (name().empty()) {
252 throw MissingSettingError ("name");
255 shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs")));
256 o->out_size = format()->dcp_size ();
258 /* Decode the whole film, no blacking */
261 switch (dcp_trim_action()) {
263 /* Decode only part of the film, no blacking */
267 /* Decode the whole film, but black some frames out */
268 o->black_after = dcp_frames().get ();
272 o->padding = format()->dcp_padding (shared_from_this ());
273 o->ratio = format()->ratio_as_float (shared_from_this ());
274 o->decode_subtitles = with_subtitles ();
275 o->decode_video_skip = dcp_frame_rate (frames_per_second()).skip;
281 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
283 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
287 r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
288 JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
291 /** Start a job to examine our content file */
293 Film::examine_content ()
295 if (_examine_content_job) {
299 set_thumbs (vector<int> ());
300 boost::filesystem::remove_all (dir ("thumbs"));
302 /* This call will recreate the directory */
305 _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
306 _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
307 JobManager::instance()->add (_examine_content_job);
311 Film::examine_content_finished ()
313 _examine_content_job.reset ();
316 /** @return full paths to any audio files that this Film has */
318 Film::audio_files () const
321 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) {
322 f.push_back (i->path().string ());
328 /** Start a job to send our DCP to the configured TMS */
330 Film::send_dcp_to_tms ()
332 shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
333 JobManager::instance()->add (j);
337 Film::copy_from_dvd ()
339 shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
340 JobManager::instance()->add (j);
343 /** Count the number of frames that have been encoded for this film.
344 * @return frame count.
347 Film::encoded_frames () const
354 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
356 boost::this_thread::interruption_point ();
362 /** Return the filename of a subtitle image if one exists for a given thumb index.
363 * @param Thumbnail index.
364 * @return Position of the image within the source frame, and the image filename, if one exists.
365 * Otherwise the filename will be empty.
367 pair<Position, string>
368 Film::thumb_subtitle (int n) const
370 string sub_file = thumb_base(n) + ".sub";
371 if (!boost::filesystem::exists (sub_file)) {
372 return pair<Position, string> ();
375 pair<Position, string> sub;
377 ifstream f (sub_file.c_str ());
378 multimap<string, string> kv = read_key_value (f);
379 for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
380 if (i->first == "x") {
381 sub.first.x = lexical_cast<int> (i->second);
382 } else if (i->first == "y") {
383 sub.first.y = lexical_cast<int> (i->second);
384 sub.second = String::compose ("%1.sub.png", thumb_base(n));
391 /** Write state to our `metadata' file */
393 Film::write_metadata () const
395 boost::mutex::scoped_lock lm (_state_mutex);
397 boost::filesystem::create_directories (directory());
399 string const m = file ("metadata");
400 ofstream f (m.c_str ());
402 throw CreateFileError (m);
406 f << "name " << _name << "\n";
407 f << "use_dci_name " << _use_dci_name << "\n";
408 f << "content " << _content << "\n";
409 if (_dcp_content_type) {
410 f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
413 f << "format " << _format->as_metadata () << "\n";
415 f << "left_crop " << _crop.left << "\n";
416 f << "right_crop " << _crop.right << "\n";
417 f << "top_crop " << _crop.top << "\n";
418 f << "bottom_crop " << _crop.bottom << "\n";
419 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
420 f << "filter " << (*i)->id () << "\n";
422 f << "scaler " << _scaler->id () << "\n";
423 f << "dcp_frames " << _dcp_frames.get_value_or(0) << "\n";
425 f << "dcp_trim_action ";
426 switch (_dcp_trim_action) {
435 f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
436 f << "selected_audio_stream " << _audio_stream << "\n";
437 f << "audio_gain " << _audio_gain << "\n";
438 f << "audio_delay " << _audio_delay << "\n";
439 f << "still_duration " << _still_duration << "\n";
440 f << "selected_subtitle_stream " << _subtitle_stream << "\n";
441 f << "with_subtitles " << _with_subtitles << "\n";
442 f << "subtitle_offset " << _subtitle_offset << "\n";
443 f << "subtitle_scale " << _subtitle_scale << "\n";
444 f << "audio_language " << _audio_language << "\n";
445 f << "subtitle_language " << _subtitle_language << "\n";
446 f << "territory " << _territory << "\n";
447 f << "rating " << _rating << "\n";
448 f << "studio " << _studio << "\n";
449 f << "facility " << _facility << "\n";
450 f << "package_type " << _package_type << "\n";
452 /* Cached stuff; this is information about our content; we could
453 look it up each time, but that's slow.
455 for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
456 f << "thumb " << *i << "\n";
458 f << "width " << _size.width << "\n";
459 f << "height " << _size.height << "\n";
460 f << "length " << _length.get_value_or(0) << "\n";
461 f << "audio_sample_rate " << _audio_sample_rate << "\n";
462 f << "content_digest " << _content_digest << "\n";
463 f << "has_subtitles " << _has_subtitles << "\n";
465 for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
466 f << "audio_stream " << i->to_string () << "\n";
469 for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
470 f << "subtitle_stream " << i->to_string () << "\n";
473 f << "frames_per_second " << _frames_per_second << "\n";
478 /** Read state from our metadata file */
480 Film::read_metadata ()
482 boost::mutex::scoped_lock lm (_state_mutex);
484 ifstream f (file ("metadata").c_str());
485 multimap<string, string> kv = read_key_value (f);
486 for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
487 string const k = i->first;
488 string const v = i->second;
490 /* User-specified stuff */
493 } else if (k == "use_dci_name") {
494 _use_dci_name = (v == "1");
495 } else if (k == "content") {
497 } else if (k == "dcp_content_type") {
498 _dcp_content_type = DCPContentType::from_pretty_name (v);
499 } else if (k == "format") {
500 _format = Format::from_metadata (v);
501 } else if (k == "left_crop") {
502 _crop.left = atoi (v.c_str ());
503 } else if (k == "right_crop") {
504 _crop.right = atoi (v.c_str ());
505 } else if (k == "top_crop") {
506 _crop.top = atoi (v.c_str ());
507 } else if (k == "bottom_crop") {
508 _crop.bottom = atoi (v.c_str ());
509 } else if (k == "filter") {
510 _filters.push_back (Filter::from_id (v));
511 } else if (k == "scaler") {
512 _scaler = Scaler::from_id (v);
513 } else if (k == "dcp_frames") {
514 int const vv = atoi (v.c_str ());
518 } else if (k == "dcp_trim_action") {
520 _dcp_trim_action = CUT;
521 } else if (v == "black_out") {
522 _dcp_trim_action = BLACK_OUT;
524 } else if (k == "dcp_ab") {
525 _dcp_ab = (v == "1");
526 } else if (k == "selected_audio_stream") {
527 _audio_stream = atoi (v.c_str ());
528 } else if (k == "audio_gain") {
529 _audio_gain = atof (v.c_str ());
530 } else if (k == "audio_delay") {
531 _audio_delay = atoi (v.c_str ());
532 } else if (k == "still_duration") {
533 _still_duration = atoi (v.c_str ());
534 } else if (k == "selected_subtitle_stream") {
535 _subtitle_stream = atoi (v.c_str ());
536 } else if (k == "with_subtitles") {
537 _with_subtitles = (v == "1");
538 } else if (k == "subtitle_offset") {
539 _subtitle_offset = atoi (v.c_str ());
540 } else if (k == "subtitle_scale") {
541 _subtitle_scale = atof (v.c_str ());
542 } else if (k == "audio_language") {
544 } else if (k == "subtitle_language") {
545 _subtitle_language = v;
546 } else if (k == "territory") {
548 } else if (k == "rating") {
550 } else if (k == "studio") {
552 } else if (k == "facility") {
554 } else if (k == "package_type") {
560 int const n = atoi (v.c_str ());
561 /* Only add it to the list if it still exists */
562 if (boost::filesystem::exists (thumb_file_for_frame (n))) {
563 _thumbs.push_back (n);
565 } else if (k == "width") {
566 _size.width = atoi (v.c_str ());
567 } else if (k == "height") {
568 _size.height = atoi (v.c_str ());
569 } else if (k == "length") {
570 int const vv = atoi (v.c_str ());
574 } else if (k == "audio_sample_rate") {
575 _audio_sample_rate = atoi (v.c_str ());
576 } else if (k == "content_digest") {
578 } else if (k == "has_subtitles") {
579 _has_subtitles = (v == "1");
580 } else if (k == "audio_stream") {
581 _audio_streams.push_back (AudioStream (v));
582 } else if (k == "subtitle_stream") {
583 _subtitle_streams.push_back (SubtitleStream (v));
584 } else if (k == "frames_per_second") {
585 _frames_per_second = atof (v.c_str ());
592 /** @param n A thumb index.
593 * @return The path to the thumb's image file.
596 Film::thumb_file (int n) const
598 return thumb_file_for_frame (thumb_frame (n));
601 /** @param n A frame index within the Film.
602 * @return The path to the thumb's image file for this frame;
603 * we assume that it exists.
606 Film::thumb_file_for_frame (int n) const
608 return thumb_base_for_frame(n) + ".png";
611 /** Must not be called with the _state_mutex locked */
613 Film::thumb_base (int n) const
615 return thumb_base_for_frame (thumb_frame (n));
619 Film::thumb_base_for_frame (int n) const
623 s << setfill('0') << n;
625 boost::filesystem::path p;
632 /** @param n A thumb index.
633 * @return The frame within the Film that it is for.
635 * Must not be called with the _state_mutex locked.
638 Film::thumb_frame (int n) const
640 boost::mutex::scoped_lock lm (_state_mutex);
641 assert (n < int (_thumbs.size ()));
646 Film::cropped_size (Size s) const
648 boost::mutex::scoped_lock lm (_state_mutex);
649 s.width -= _crop.left + _crop.right;
650 s.height -= _crop.top + _crop.bottom;
654 /** Given a directory name, return its full path within the Film's directory.
655 * The directory (and its parents) will be created if they do not exist.
658 Film::dir (string d) const
660 boost::mutex::scoped_lock lm (_directory_mutex);
661 boost::filesystem::path p;
664 boost::filesystem::create_directories (p);
668 /** Given a file or directory name, return its full path within the Film's directory.
669 * _directory_mutex must not be locked on entry.
672 Film::file (string f) const
674 boost::mutex::scoped_lock lm (_directory_mutex);
675 boost::filesystem::path p;
681 /** @return full path of the content (actual video) file
685 Film::content_path () const
687 boost::mutex::scoped_lock lm (_state_mutex);
688 if (boost::filesystem::path(_content).has_root_directory ()) {
692 return file (_content);
696 Film::content_type () const
698 #if BOOST_FILESYSTEM_VERSION == 3
699 string ext = boost::filesystem::path(_content).extension().string();
701 string ext = boost::filesystem::path(_content).extension();
704 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
706 if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
713 /** @return The sampling rate that we will resample the audio to */
715 Film::target_audio_sample_rate () const
717 /* Resample to a DCI-approved sample rate */
718 double t = dcp_audio_sample_rate (audio_sample_rate());
720 DCPFrameRate dfr = dcp_frame_rate (frames_per_second ());
722 /* Compensate for the fact that video will be rounded to the
723 nearest integer number of frames per second.
726 t *= _frames_per_second * dfr.skip / dfr.frames_per_second;
733 Film::dcp_length () const
736 return boost::optional<int> ();
740 return min (dcp_frames().get(), length().get());
746 /** @return a DCI-compliant name for a DCP of this film */
748 Film::dci_name () const
750 boost::mutex::scoped_lock lm (_state_mutex);
754 string fixed_name = to_upper_copy (_name);
755 for (size_t i = 0; i < fixed_name.length(); ++i) {
756 if (fixed_name[i] == ' ') {
761 /* Spec is that the name part should be maximum 14 characters, as I understand it */
762 if (fixed_name.length() > 14) {
763 fixed_name = fixed_name.substr (0, 14);
766 d << fixed_name << "_";
768 if (_dcp_content_type) {
769 d << _dcp_content_type->dci_name() << "_";
773 d << _format->dci_name() << "_";
776 if (!_audio_language.empty ()) {
777 d << _audio_language;
778 if (!_subtitle_language.empty() && _with_subtitles) {
779 d << "-" << _subtitle_language;
787 if (!_territory.empty ()) {
789 if (!_rating.empty ()) {
795 switch (_audio_streams[_audio_stream].channels()) {
812 if (!_studio.empty ()) {
816 d << boost::gregorian::to_iso_string (_dci_date) << "_";
818 if (!_facility.empty ()) {
819 d << _facility << "_";
822 if (!_package_type.empty ()) {
829 /** @return name to give the DCP */
831 Film::dcp_name () const
833 if (use_dci_name()) {
842 Film::set_directory (string d)
844 boost::mutex::scoped_lock lm (_state_mutex);
850 Film::set_name (string n)
853 boost::mutex::scoped_lock lm (_state_mutex);
856 signal_changed (NAME);
860 Film::set_use_dci_name (bool u)
863 boost::mutex::scoped_lock lm (_state_mutex);
866 signal_changed (USE_DCI_NAME);
870 Film::set_content (string c)
872 string check = directory ();
874 #if BOOST_FILESYSTEM_VERSION == 3
875 boost::filesystem::path slash ("/");
876 string platform_slash = slash.make_preferred().string ();
878 #ifdef DVDOMATIC_WINDOWS
879 string platform_slash = "\\";
881 string platform_slash = "/";
885 if (!ends_with (check, platform_slash)) {
886 check += platform_slash;
889 if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) {
890 c = c.substr (_directory.length() + 1);
896 boost::mutex::scoped_lock lm (_state_mutex);
901 old_content = _content;
905 /* Create a temporary decoder so that we can get information
910 shared_ptr<Options> o (new Options ("", "", ""));
911 o->out_size = Size (1024, 1024);
913 shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
915 set_size (d->native_size ());
916 set_frames_per_second (d->frames_per_second ());
917 set_audio_sample_rate (d->audio_sample_rate ());
918 set_has_subtitles (d->has_subtitles ());
919 set_audio_streams (d->audio_streams ());
920 set_subtitle_streams (d->subtitle_streams ());
921 set_audio_stream (audio_streams().empty() ? -1 : 0);
922 set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
925 boost::mutex::scoped_lock lm (_state_mutex);
929 signal_changed (CONTENT);
931 set_content_digest (md5_digest (content_path ()));
937 boost::mutex::scoped_lock lm (_state_mutex);
938 _content = old_content;
945 Film::set_dcp_content_type (DCPContentType const * t)
948 boost::mutex::scoped_lock lm (_state_mutex);
949 _dcp_content_type = t;
951 signal_changed (DCP_CONTENT_TYPE);
955 Film::set_format (Format const * f)
958 boost::mutex::scoped_lock lm (_state_mutex);
961 signal_changed (FORMAT);
965 Film::set_crop (Crop c)
968 boost::mutex::scoped_lock lm (_state_mutex);
971 signal_changed (CROP);
975 Film::set_left_crop (int c)
978 boost::mutex::scoped_lock lm (_state_mutex);
980 if (_crop.left == c) {
986 signal_changed (CROP);
990 Film::set_right_crop (int c)
993 boost::mutex::scoped_lock lm (_state_mutex);
994 if (_crop.right == c) {
1000 signal_changed (CROP);
1004 Film::set_top_crop (int c)
1007 boost::mutex::scoped_lock lm (_state_mutex);
1008 if (_crop.top == c) {
1014 signal_changed (CROP);
1018 Film::set_bottom_crop (int c)
1021 boost::mutex::scoped_lock lm (_state_mutex);
1022 if (_crop.bottom == c) {
1028 signal_changed (CROP);
1032 Film::set_filters (vector<Filter const *> f)
1035 boost::mutex::scoped_lock lm (_state_mutex);
1038 signal_changed (FILTERS);
1042 Film::set_scaler (Scaler const * s)
1045 boost::mutex::scoped_lock lm (_state_mutex);
1048 signal_changed (SCALER);
1052 Film::set_dcp_frames (int f)
1055 boost::mutex::scoped_lock lm (_state_mutex);
1058 signal_changed (DCP_FRAMES);
1062 Film::unset_dcp_frames ()
1065 boost::mutex::scoped_lock lm (_state_mutex);
1066 _dcp_frames = boost::none;
1068 signal_changed (DCP_FRAMES);
1072 Film::set_dcp_trim_action (TrimAction a)
1075 boost::mutex::scoped_lock lm (_state_mutex);
1076 _dcp_trim_action = a;
1078 signal_changed (DCP_TRIM_ACTION);
1082 Film::set_dcp_ab (bool a)
1085 boost::mutex::scoped_lock lm (_state_mutex);
1088 signal_changed (DCP_AB);
1092 Film::set_audio_stream (int s)
1095 boost::mutex::scoped_lock lm (_state_mutex);
1098 signal_changed (AUDIO_STREAM);
1102 Film::set_audio_gain (float g)
1105 boost::mutex::scoped_lock lm (_state_mutex);
1108 signal_changed (AUDIO_GAIN);
1112 Film::set_audio_delay (int d)
1115 boost::mutex::scoped_lock lm (_state_mutex);
1118 signal_changed (AUDIO_DELAY);
1122 Film::set_still_duration (int d)
1125 boost::mutex::scoped_lock lm (_state_mutex);
1126 _still_duration = d;
1128 signal_changed (STILL_DURATION);
1132 Film::set_subtitle_stream (int s)
1135 boost::mutex::scoped_lock lm (_state_mutex);
1136 _subtitle_stream = s;
1138 signal_changed (SUBTITLE_STREAM);
1142 Film::set_with_subtitles (bool w)
1145 boost::mutex::scoped_lock lm (_state_mutex);
1146 _with_subtitles = w;
1148 signal_changed (WITH_SUBTITLES);
1152 Film::set_subtitle_offset (int o)
1155 boost::mutex::scoped_lock lm (_state_mutex);
1156 _subtitle_offset = o;
1158 signal_changed (SUBTITLE_OFFSET);
1162 Film::set_subtitle_scale (float s)
1165 boost::mutex::scoped_lock lm (_state_mutex);
1166 _subtitle_scale = s;
1168 signal_changed (SUBTITLE_SCALE);
1172 Film::set_audio_language (string l)
1175 boost::mutex::scoped_lock lm (_state_mutex);
1176 _audio_language = l;
1178 signal_changed (DCI_METADATA);
1182 Film::set_subtitle_language (string l)
1185 boost::mutex::scoped_lock lm (_state_mutex);
1186 _subtitle_language = l;
1188 signal_changed (DCI_METADATA);
1192 Film::set_territory (string t)
1195 boost::mutex::scoped_lock lm (_state_mutex);
1198 signal_changed (DCI_METADATA);
1202 Film::set_rating (string r)
1205 boost::mutex::scoped_lock lm (_state_mutex);
1208 signal_changed (DCI_METADATA);
1212 Film::set_studio (string s)
1215 boost::mutex::scoped_lock lm (_state_mutex);
1218 signal_changed (DCI_METADATA);
1222 Film::set_facility (string f)
1225 boost::mutex::scoped_lock lm (_state_mutex);
1228 signal_changed (DCI_METADATA);
1232 Film::set_package_type (string p)
1235 boost::mutex::scoped_lock lm (_state_mutex);
1238 signal_changed (DCI_METADATA);
1242 Film::set_thumbs (vector<int> t)
1245 boost::mutex::scoped_lock lm (_state_mutex);
1248 signal_changed (THUMBS);
1252 Film::set_size (Size s)
1255 boost::mutex::scoped_lock lm (_state_mutex);
1258 signal_changed (SIZE);
1262 Film::set_length (int l)
1265 boost::mutex::scoped_lock lm (_state_mutex);
1268 signal_changed (LENGTH);
1272 Film::unset_length ()
1275 boost::mutex::scoped_lock lm (_state_mutex);
1276 _length = boost::none;
1278 signal_changed (LENGTH);
1282 Film::set_audio_sample_rate (int r)
1285 boost::mutex::scoped_lock lm (_state_mutex);
1286 _audio_sample_rate = r;
1288 signal_changed (AUDIO_SAMPLE_RATE);
1292 Film::set_content_digest (string d)
1295 boost::mutex::scoped_lock lm (_state_mutex);
1296 _content_digest = d;
1302 Film::set_has_subtitles (bool s)
1305 boost::mutex::scoped_lock lm (_state_mutex);
1308 signal_changed (HAS_SUBTITLES);
1312 Film::set_audio_streams (vector<AudioStream> s)
1315 boost::mutex::scoped_lock lm (_state_mutex);
1322 Film::set_subtitle_streams (vector<SubtitleStream> s)
1325 boost::mutex::scoped_lock lm (_state_mutex);
1326 _subtitle_streams = s;
1332 Film::set_frames_per_second (float f)
1335 boost::mutex::scoped_lock lm (_state_mutex);
1336 _frames_per_second = f;
1338 signal_changed (FRAMES_PER_SECOND);
1342 Film::signal_changed (Property p)
1345 boost::mutex::scoped_lock lm (_state_mutex);
1350 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1355 Film::audio_channels () const
1357 boost::mutex::scoped_lock lm (_state_mutex);
1358 if (_audio_stream == -1) {
1362 return _audio_streams[_audio_stream].channels ();
1366 Film::set_dci_date_today ()
1368 _dci_date = boost::gregorian::day_clock::local_day ();