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"));
133 Film::Film (Film const & o)
135 , _directory (o._directory)
137 , _use_dci_name (o._use_dci_name)
138 , _content (o._content)
139 , _dcp_content_type (o._dcp_content_type)
140 , _format (o._format)
142 , _filters (o._filters)
143 , _scaler (o._scaler)
144 , _dcp_frames (o._dcp_frames)
145 , _dcp_trim_action (o._dcp_trim_action)
146 , _dcp_ab (o._dcp_ab)
147 , _audio_stream (o._audio_stream)
148 , _audio_gain (o._audio_gain)
149 , _audio_delay (o._audio_delay)
150 , _still_duration (o._still_duration)
151 , _subtitle_stream (o._subtitle_stream)
152 , _with_subtitles (o._with_subtitles)
153 , _subtitle_offset (o._subtitle_offset)
154 , _subtitle_scale (o._subtitle_scale)
155 , _audio_language (o._audio_language)
156 , _subtitle_language (o._subtitle_language)
157 , _territory (o._territory)
158 , _rating (o._rating)
159 , _studio (o._studio)
160 , _facility (o._facility)
161 , _package_type (o._package_type)
162 , _thumbs (o._thumbs)
164 , _length (o._length)
165 , _audio_sample_rate (o._audio_sample_rate)
166 , _content_digest (o._content_digest)
167 , _has_subtitles (o._has_subtitles)
168 , _audio_streams (o._audio_streams)
169 , _subtitle_streams (o._subtitle_streams)
170 , _frames_per_second (o._frames_per_second)
181 /** @return The path to the directory to write JPEG2000 files to */
183 Film::j2k_dir () const
187 boost::filesystem::path p;
192 pair<string, string> f = Filter::ffmpeg_strings (filters());
194 /* Write stuff to specify the filter / post-processing settings that are in use,
195 so that we don't get confused about J2K files generated using different
200 << "_" << content_digest()
201 << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
202 << "_" << f.first << "_" << f.second
203 << "_" << scaler()->id();
207 /* Similarly for the A/B case */
210 pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
211 s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
215 return dir (p.string());
218 /** Add suitable Jobs to the JobManager to create a DCP for this Film.
219 * @param true to transcode, false to use the WAV and J2K files that are already there.
222 Film::make_dcp (bool transcode)
224 if (dcp_name().find ("/") != string::npos) {
225 throw BadSettingError ("name", "cannot contain slashes");
228 log()->log (String::compose ("DVD-o-matic %1 git %2 using %3", dvdomatic_version, dvdomatic_git_commit, dependency_version_summary()));
232 gethostname (buffer, sizeof (buffer));
233 log()->log (String::compose ("Starting to make DCP on %1", buffer));
237 throw MissingSettingError ("format");
240 if (content().empty ()) {
241 throw MissingSettingError ("content");
244 if (dcp_content_type() == 0) {
245 throw MissingSettingError ("content type");
248 if (name().empty()) {
249 throw MissingSettingError ("name");
252 shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs")));
253 o->out_size = format()->dcp_size ();
255 /* Decode the whole film, no blacking */
258 switch (dcp_trim_action()) {
260 /* Decode only part of the film, no blacking */
264 /* Decode the whole film, but black some frames out */
265 o->black_after = dcp_frames().get ();
269 o->padding = format()->dcp_padding (shared_from_this ());
270 o->ratio = format()->ratio_as_float (shared_from_this ());
271 o->decode_subtitles = with_subtitles ();
277 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
279 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
283 r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
284 JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
287 /** Start a job to examine our content file */
289 Film::examine_content ()
291 if (_examine_content_job) {
295 set_thumbs (vector<int> ());
296 boost::filesystem::remove_all (dir ("thumbs"));
298 /* This call will recreate the directory */
301 _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
302 _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
303 JobManager::instance()->add (_examine_content_job);
307 Film::examine_content_finished ()
309 _examine_content_job.reset ();
312 /** @return full paths to any audio files that this Film has */
314 Film::audio_files () const
317 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) {
318 f.push_back (i->path().string ());
324 /** Start a job to send our DCP to the configured TMS */
326 Film::send_dcp_to_tms ()
328 shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
329 JobManager::instance()->add (j);
333 Film::copy_from_dvd ()
335 shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
336 JobManager::instance()->add (j);
339 /** Count the number of frames that have been encoded for this film.
340 * @return frame count.
343 Film::encoded_frames () const
350 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
352 boost::this_thread::interruption_point ();
358 /** Return the filename of a subtitle image if one exists for a given thumb index.
359 * @param Thumbnail index.
360 * @return Position of the image within the source frame, and the image filename, if one exists.
361 * Otherwise the filename will be empty.
363 pair<Position, string>
364 Film::thumb_subtitle (int n) const
366 string sub_file = thumb_base(n) + ".sub";
367 if (!boost::filesystem::exists (sub_file)) {
368 return pair<Position, string> ();
371 pair<Position, string> sub;
373 ifstream f (sub_file.c_str ());
374 multimap<string, string> kv = read_key_value (f);
375 for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
376 if (i->first == "x") {
377 sub.first.x = lexical_cast<int> (i->second);
378 } else if (i->first == "y") {
379 sub.first.y = lexical_cast<int> (i->second);
380 sub.second = String::compose ("%1.sub.png", thumb_base(n));
387 /** Write state to our `metadata' file */
389 Film::write_metadata () const
391 std::string const dir = directory ();
393 boost::mutex::scoped_lock lm (_state_mutex);
395 boost::filesystem::create_directories (dir);
397 string const m = file_locked ("metadata");
398 ofstream f (m.c_str ());
400 throw CreateFileError (m);
404 f << "name " << _name << "\n";
405 f << "use_dci_name " << _use_dci_name << "\n";
406 f << "content " << _content << "\n";
407 if (_dcp_content_type) {
408 f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
411 f << "format " << _format->as_metadata () << "\n";
413 f << "left_crop " << _crop.left << "\n";
414 f << "right_crop " << _crop.right << "\n";
415 f << "top_crop " << _crop.top << "\n";
416 f << "bottom_crop " << _crop.bottom << "\n";
417 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
418 f << "filter " << (*i)->id () << "\n";
420 f << "scaler " << _scaler->id () << "\n";
421 f << "dcp_frames " << _dcp_frames.get_value_or(0) << "\n";
423 f << "dcp_trim_action ";
424 switch (_dcp_trim_action) {
433 f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
434 f << "selected_audio_stream " << _audio_stream << "\n";
435 f << "audio_gain " << _audio_gain << "\n";
436 f << "audio_delay " << _audio_delay << "\n";
437 f << "still_duration " << _still_duration << "\n";
438 f << "selected_subtitle_stream " << _subtitle_stream << "\n";
439 f << "with_subtitles " << _with_subtitles << "\n";
440 f << "subtitle_offset " << _subtitle_offset << "\n";
441 f << "subtitle_scale " << _subtitle_scale << "\n";
442 f << "audio_language " << _audio_language << "\n";
443 f << "subtitle_language " << _subtitle_language << "\n";
444 f << "territory " << _territory << "\n";
445 f << "rating " << _rating << "\n";
446 f << "studio " << _studio << "\n";
447 f << "facility " << _facility << "\n";
448 f << "package_type " << _package_type << "\n";
450 /* Cached stuff; this is information about our content; we could
451 look it up each time, but that's slow.
453 for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
454 f << "thumb " << *i << "\n";
456 f << "width " << _size.width << "\n";
457 f << "height " << _size.height << "\n";
458 f << "length " << _length.get_value_or(0) << "\n";
459 f << "audio_sample_rate " << _audio_sample_rate << "\n";
460 f << "content_digest " << _content_digest << "\n";
461 f << "has_subtitles " << _has_subtitles << "\n";
463 for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
464 f << "audio_stream " << i->to_string () << "\n";
467 for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
468 f << "subtitle_stream " << i->to_string () << "\n";
471 f << "frames_per_second " << _frames_per_second << "\n";
476 /** Read state from our metadata file */
478 Film::read_metadata ()
480 boost::mutex::scoped_lock lm (_state_mutex);
482 ifstream f (file_locked("metadata").c_str());
483 multimap<string, string> kv = read_key_value (f);
484 for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
485 string const k = i->first;
486 string const v = i->second;
488 /* User-specified stuff */
491 } else if (k == "use_dci_name") {
492 _use_dci_name = (v == "1");
493 } else if (k == "content") {
495 } else if (k == "dcp_content_type") {
496 _dcp_content_type = DCPContentType::from_pretty_name (v);
497 } else if (k == "format") {
498 _format = Format::from_metadata (v);
499 } else if (k == "left_crop") {
500 _crop.left = atoi (v.c_str ());
501 } else if (k == "right_crop") {
502 _crop.right = atoi (v.c_str ());
503 } else if (k == "top_crop") {
504 _crop.top = atoi (v.c_str ());
505 } else if (k == "bottom_crop") {
506 _crop.bottom = atoi (v.c_str ());
507 } else if (k == "filter") {
508 _filters.push_back (Filter::from_id (v));
509 } else if (k == "scaler") {
510 _scaler = Scaler::from_id (v);
511 } else if (k == "dcp_frames") {
512 int const vv = atoi (v.c_str ());
516 } else if (k == "dcp_trim_action") {
518 _dcp_trim_action = CUT;
519 } else if (v == "black_out") {
520 _dcp_trim_action = BLACK_OUT;
522 } else if (k == "dcp_ab") {
523 _dcp_ab = (v == "1");
524 } else if (k == "selected_audio_stream") {
525 _audio_stream = atoi (v.c_str ());
526 } else if (k == "audio_gain") {
527 _audio_gain = atof (v.c_str ());
528 } else if (k == "audio_delay") {
529 _audio_delay = atoi (v.c_str ());
530 } else if (k == "still_duration") {
531 _still_duration = atoi (v.c_str ());
532 } else if (k == "selected_subtitle_stream") {
533 _subtitle_stream = atoi (v.c_str ());
534 } else if (k == "with_subtitles") {
535 _with_subtitles = (v == "1");
536 } else if (k == "subtitle_offset") {
537 _subtitle_offset = atoi (v.c_str ());
538 } else if (k == "subtitle_scale") {
539 _subtitle_scale = atof (v.c_str ());
540 } else if (k == "audio_language") {
542 } else if (k == "subtitle_language") {
543 _subtitle_language = v;
544 } else if (k == "territory") {
546 } else if (k == "rating") {
548 } else if (k == "studio") {
550 } else if (k == "facility") {
552 } else if (k == "package_type") {
558 int const n = atoi (v.c_str ());
559 /* Only add it to the list if it still exists */
560 if (boost::filesystem::exists (thumb_file_for_frame_locked (n))) {
561 _thumbs.push_back (n);
563 } else if (k == "width") {
564 _size.width = atoi (v.c_str ());
565 } else if (k == "height") {
566 _size.height = atoi (v.c_str ());
567 } else if (k == "length") {
568 int const vv = atoi (v.c_str ());
572 } else if (k == "audio_sample_rate") {
573 _audio_sample_rate = atoi (v.c_str ());
574 } else if (k == "content_digest") {
576 } else if (k == "has_subtitles") {
577 _has_subtitles = (v == "1");
578 } else if (k == "audio_stream") {
579 _audio_streams.push_back (AudioStream (v));
580 } else if (k == "subtitle_stream") {
581 _subtitle_streams.push_back (SubtitleStream (v));
582 } else if (k == "frames_per_second") {
583 _frames_per_second = atof (v.c_str ());
590 /** @param n A thumb index.
591 * @return The path to the thumb's image file.
594 Film::thumb_file (int n) const
596 return thumb_file_for_frame (thumb_frame (n));
599 /** @param n A frame index within the Film.
600 * @return The path to the thumb's image file for this frame;
601 * we assume that it exists.
604 Film::thumb_file_for_frame (int n) const
606 return thumb_base_for_frame(n) + ".png";
610 Film::thumb_file_for_frame_locked (int n) const
612 return thumb_base_for_frame_locked(n) + ".png";
616 Film::thumb_base (int n) const
618 return thumb_base_for_frame (thumb_frame (n));
622 Film::thumb_base_for_frame (int n) const
624 boost::mutex::scoped_lock lm (_state_mutex);
625 return thumb_base_for_frame_locked (n);
629 Film::thumb_base_for_frame_locked (int n) const
633 s << setfill('0') << n;
635 boost::filesystem::path p;
636 p /= dir_locked ("thumbs");
642 /** @param n A thumb index.
643 * @return The frame within the Film that it is for.
646 Film::thumb_frame (int n) const
648 boost::mutex::scoped_lock lm (_state_mutex);
649 assert (n < int (_thumbs.size ()));
654 Film::cropped_size (Size s) const
656 boost::mutex::scoped_lock lm (_state_mutex);
657 s.width -= _crop.left + _crop.right;
658 s.height -= _crop.top + _crop.bottom;
662 /** Given a directory name, return its full path within the Film's directory.
663 * The directory (and its parents) will be created if they do not exist.
666 Film::dir (string d) const
668 boost::mutex::scoped_lock lm (_state_mutex);
669 return dir_locked (d);
673 Film::dir_locked (string d) const
675 boost::filesystem::path p;
678 boost::filesystem::create_directories (p);
682 /** Given a file or directory name, return its full path within the Film's directory */
684 Film::file (string f) const
686 boost::mutex::scoped_lock lm (_state_mutex);
687 return file_locked (f);
691 Film::file_locked (string f) const
693 boost::filesystem::path p;
699 /** @return full path of the content (actual video) file
703 Film::content_path () const
705 boost::mutex::scoped_lock lm (_state_mutex);
706 if (boost::filesystem::path(_content).has_root_directory ()) {
710 return file_locked (_content);
714 Film::content_type () const
716 #if BOOST_FILESYSTEM_VERSION == 3
717 string ext = boost::filesystem::path(_content).extension().string();
719 string ext = boost::filesystem::path(_content).extension();
722 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
724 if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
731 /** @return The sampling rate that we will resample the audio to */
733 Film::target_audio_sample_rate () const
735 /* Resample to a DCI-approved sample rate */
736 double t = dcp_audio_sample_rate (audio_sample_rate());
738 /* Compensate for the fact that video will be rounded to the
739 nearest integer number of frames per second.
741 if (rint (frames_per_second()) != frames_per_second()) {
742 t *= _frames_per_second / rint (frames_per_second());
749 Film::dcp_length () const
752 return boost::optional<int> ();
756 return min (dcp_frames().get(), length().get());
762 /** @return a DCI-compliant name for a DCP of this film */
764 Film::dci_name () const
766 boost::mutex::scoped_lock lm (_state_mutex);
770 string fixed_name = to_upper_copy (_name);
771 for (size_t i = 0; i < fixed_name.length(); ++i) {
772 if (fixed_name[i] == ' ') {
777 /* Spec is that the name part should be maximum 14 characters, as I understand it */
778 if (fixed_name.length() > 14) {
779 fixed_name = fixed_name.substr (0, 14);
782 d << fixed_name << "_";
784 if (_dcp_content_type) {
785 d << _dcp_content_type->dci_name() << "_";
789 d << _format->dci_name() << "_";
792 if (!_audio_language.empty ()) {
793 d << _audio_language;
794 if (!_subtitle_language.empty() && _with_subtitles) {
795 d << "-" << _subtitle_language;
803 if (!_territory.empty ()) {
805 if (!_rating.empty ()) {
811 switch (_audio_streams[_audio_stream].channels()) {
828 if (!_studio.empty ()) {
832 boost::gregorian::date today = boost::gregorian::day_clock::local_day ();
833 d << boost::gregorian::to_iso_string (today) << "_";
835 if (!_facility.empty ()) {
836 d << _facility << "_";
839 if (!_package_type.empty ()) {
846 /** @return name to give the DCP */
848 Film::dcp_name () const
850 if (use_dci_name()) {
859 Film::set_directory (string d)
861 boost::mutex::scoped_lock lm (_state_mutex);
867 Film::set_name (string n)
870 boost::mutex::scoped_lock lm (_state_mutex);
873 signal_changed (NAME);
877 Film::set_use_dci_name (bool u)
880 boost::mutex::scoped_lock lm (_state_mutex);
883 signal_changed (USE_DCI_NAME);
887 Film::set_content (string c)
889 string check = directory ();
891 #if BOOST_FILESYSTEM_VERSION == 3
892 boost::filesystem::path slash ("/");
893 string platform_slash = slash.make_preferred().string ();
895 #ifdef DVDOMATIC_WINDOWS
896 string platform_slash = "\\";
898 string platform_slash = "/";
902 if (!ends_with (check, platform_slash)) {
903 check += platform_slash;
906 if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) {
907 c = c.substr (_directory.length() + 1);
913 boost::mutex::scoped_lock lm (_state_mutex);
918 old_content = _content;
922 /* Create a temporary decoder so that we can get information
927 shared_ptr<Options> o (new Options ("", "", ""));
928 o->out_size = Size (1024, 1024);
930 shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
932 set_size (d->native_size ());
933 set_frames_per_second (d->frames_per_second ());
934 set_audio_sample_rate (d->audio_sample_rate ());
935 set_has_subtitles (d->has_subtitles ());
936 set_audio_streams (d->audio_streams ());
937 set_subtitle_streams (d->subtitle_streams ());
938 set_audio_stream (audio_streams().empty() ? -1 : 0);
939 set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
942 boost::mutex::scoped_lock lm (_state_mutex);
946 signal_changed (CONTENT);
948 set_content_digest (md5_digest (content_path ()));
954 boost::mutex::scoped_lock lm (_state_mutex);
955 _content = old_content;
962 Film::set_dcp_content_type (DCPContentType const * t)
965 boost::mutex::scoped_lock lm (_state_mutex);
966 _dcp_content_type = t;
968 signal_changed (DCP_CONTENT_TYPE);
972 Film::set_format (Format const * f)
975 boost::mutex::scoped_lock lm (_state_mutex);
978 signal_changed (FORMAT);
982 Film::set_crop (Crop c)
985 boost::mutex::scoped_lock lm (_state_mutex);
988 signal_changed (CROP);
992 Film::set_left_crop (int c)
995 boost::mutex::scoped_lock lm (_state_mutex);
997 if (_crop.left == c) {
1003 signal_changed (CROP);
1007 Film::set_right_crop (int c)
1010 boost::mutex::scoped_lock lm (_state_mutex);
1011 if (_crop.right == c) {
1017 signal_changed (CROP);
1021 Film::set_top_crop (int c)
1024 boost::mutex::scoped_lock lm (_state_mutex);
1025 if (_crop.top == c) {
1031 signal_changed (CROP);
1035 Film::set_bottom_crop (int c)
1038 boost::mutex::scoped_lock lm (_state_mutex);
1039 if (_crop.bottom == c) {
1045 signal_changed (CROP);
1049 Film::set_filters (vector<Filter const *> f)
1052 boost::mutex::scoped_lock lm (_state_mutex);
1055 signal_changed (FILTERS);
1059 Film::set_scaler (Scaler const * s)
1062 boost::mutex::scoped_lock lm (_state_mutex);
1065 signal_changed (SCALER);
1069 Film::set_dcp_frames (int f)
1072 boost::mutex::scoped_lock lm (_state_mutex);
1075 signal_changed (DCP_FRAMES);
1079 Film::set_dcp_trim_action (TrimAction a)
1082 boost::mutex::scoped_lock lm (_state_mutex);
1083 _dcp_trim_action = a;
1085 signal_changed (DCP_TRIM_ACTION);
1089 Film::set_dcp_ab (bool a)
1092 boost::mutex::scoped_lock lm (_state_mutex);
1095 signal_changed (DCP_AB);
1099 Film::set_audio_stream (int s)
1102 boost::mutex::scoped_lock lm (_state_mutex);
1105 signal_changed (AUDIO_STREAM);
1109 Film::set_audio_gain (float g)
1112 boost::mutex::scoped_lock lm (_state_mutex);
1115 signal_changed (AUDIO_GAIN);
1119 Film::set_audio_delay (int d)
1122 boost::mutex::scoped_lock lm (_state_mutex);
1125 signal_changed (AUDIO_DELAY);
1129 Film::set_still_duration (int d)
1132 boost::mutex::scoped_lock lm (_state_mutex);
1133 _still_duration = d;
1135 signal_changed (STILL_DURATION);
1139 Film::set_subtitle_stream (int s)
1142 boost::mutex::scoped_lock lm (_state_mutex);
1143 _subtitle_stream = s;
1145 signal_changed (SUBTITLE_STREAM);
1149 Film::set_with_subtitles (bool w)
1152 boost::mutex::scoped_lock lm (_state_mutex);
1153 _with_subtitles = w;
1155 signal_changed (WITH_SUBTITLES);
1159 Film::set_subtitle_offset (int o)
1162 boost::mutex::scoped_lock lm (_state_mutex);
1163 _subtitle_offset = o;
1165 signal_changed (SUBTITLE_OFFSET);
1169 Film::set_subtitle_scale (float s)
1172 boost::mutex::scoped_lock lm (_state_mutex);
1173 _subtitle_scale = s;
1175 signal_changed (SUBTITLE_SCALE);
1179 Film::set_audio_language (string l)
1182 boost::mutex::scoped_lock lm (_state_mutex);
1183 _audio_language = l;
1185 signal_changed (DCI_METADATA);
1189 Film::set_subtitle_language (string l)
1192 boost::mutex::scoped_lock lm (_state_mutex);
1193 _subtitle_language = l;
1195 signal_changed (DCI_METADATA);
1199 Film::set_territory (string t)
1202 boost::mutex::scoped_lock lm (_state_mutex);
1205 signal_changed (DCI_METADATA);
1209 Film::set_rating (string r)
1212 boost::mutex::scoped_lock lm (_state_mutex);
1215 signal_changed (DCI_METADATA);
1219 Film::set_studio (string s)
1222 boost::mutex::scoped_lock lm (_state_mutex);
1225 signal_changed (DCI_METADATA);
1229 Film::set_facility (string f)
1232 boost::mutex::scoped_lock lm (_state_mutex);
1235 signal_changed (DCI_METADATA);
1239 Film::set_package_type (string p)
1242 boost::mutex::scoped_lock lm (_state_mutex);
1245 signal_changed (DCI_METADATA);
1249 Film::set_thumbs (vector<int> t)
1252 boost::mutex::scoped_lock lm (_state_mutex);
1255 signal_changed (THUMBS);
1259 Film::set_size (Size s)
1262 boost::mutex::scoped_lock lm (_state_mutex);
1265 signal_changed (SIZE);
1269 Film::set_length (int l)
1272 boost::mutex::scoped_lock lm (_state_mutex);
1275 signal_changed (LENGTH);
1279 Film::unset_length ()
1282 boost::mutex::scoped_lock lm (_state_mutex);
1283 _length = boost::none;
1285 signal_changed (LENGTH);
1289 Film::set_audio_sample_rate (int r)
1292 boost::mutex::scoped_lock lm (_state_mutex);
1293 _audio_sample_rate = r;
1295 signal_changed (AUDIO_SAMPLE_RATE);
1299 Film::set_content_digest (string d)
1302 boost::mutex::scoped_lock lm (_state_mutex);
1303 _content_digest = d;
1309 Film::set_has_subtitles (bool s)
1312 boost::mutex::scoped_lock lm (_state_mutex);
1315 signal_changed (HAS_SUBTITLES);
1319 Film::set_audio_streams (vector<AudioStream> s)
1322 boost::mutex::scoped_lock lm (_state_mutex);
1329 Film::set_subtitle_streams (vector<SubtitleStream> s)
1332 boost::mutex::scoped_lock lm (_state_mutex);
1333 _subtitle_streams = s;
1339 Film::set_frames_per_second (float f)
1342 boost::mutex::scoped_lock lm (_state_mutex);
1343 _frames_per_second = f;
1345 signal_changed (FRAMES_PER_SECOND);
1349 Film::signal_changed (Property p)
1352 boost::mutex::scoped_lock lm (_state_mutex);
1357 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1362 Film::audio_channels () const
1364 boost::mutex::scoped_lock lm (_state_mutex);
1365 if (_audio_stream == -1) {
1369 return _audio_streams[_audio_stream].channels ();