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"))
91 , _still_duration (10)
92 , _subtitle_stream (-1)
93 , _with_subtitles (false)
94 , _subtitle_offset (0)
96 , _audio_sample_rate (0)
97 , _has_subtitles (false)
98 , _frames_per_second (0)
101 /* Make state.directory a complete path without ..s (where possible)
102 (Code swiped from Adam Bowen on stackoverflow)
105 boost::filesystem::path p (boost::filesystem::system_complete (d));
106 boost::filesystem::path result;
107 for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
109 if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
112 result = result.parent_path ();
114 } else if (*i != ".") {
119 set_directory (result.string ());
121 if (!boost::filesystem::exists (directory())) {
123 throw OpenFileError (directory());
125 boost::filesystem::create_directory (directory());
131 _log = new FileLog (file ("log"));
132 set_dci_date_today ();
135 Film::Film (Film const & o)
137 , _directory (o._directory)
139 , _use_dci_name (o._use_dci_name)
140 , _content (o._content)
141 , _dcp_content_type (o._dcp_content_type)
142 , _format (o._format)
144 , _filters (o._filters)
145 , _scaler (o._scaler)
146 , _dcp_trim_start (o._dcp_trim_start)
147 , _dcp_trim_end (o._dcp_trim_end)
148 , _dcp_ab (o._dcp_ab)
149 , _audio_stream (o._audio_stream)
150 , _audio_gain (o._audio_gain)
151 , _audio_delay (o._audio_delay)
152 , _still_duration (o._still_duration)
153 , _subtitle_stream (o._subtitle_stream)
154 , _with_subtitles (o._with_subtitles)
155 , _subtitle_offset (o._subtitle_offset)
156 , _subtitle_scale (o._subtitle_scale)
157 , _audio_language (o._audio_language)
158 , _subtitle_language (o._subtitle_language)
159 , _territory (o._territory)
160 , _rating (o._rating)
161 , _studio (o._studio)
162 , _facility (o._facility)
163 , _package_type (o._package_type)
164 , _thumbs (o._thumbs)
166 , _length (o._length)
167 , _audio_sample_rate (o._audio_sample_rate)
168 , _content_digest (o._content_digest)
169 , _has_subtitles (o._has_subtitles)
170 , _audio_streams (o._audio_streams)
171 , _subtitle_streams (o._subtitle_streams)
172 , _frames_per_second (o._frames_per_second)
183 /** @return The path to the directory to write JPEG2000 files to */
185 Film::j2k_dir () const
189 boost::filesystem::path p;
194 pair<string, string> f = Filter::ffmpeg_strings (filters());
196 /* Write stuff to specify the filter / post-processing settings that are in use,
197 so that we don't get confused about J2K files generated using different
202 << "_" << content_digest()
203 << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
204 << "_" << f.first << "_" << f.second
205 << "_" << scaler()->id();
209 /* Similarly for the A/B case */
212 pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
213 s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
217 return dir (p.string());
220 /** Add suitable Jobs to the JobManager to create a DCP for this Film.
221 * @param true to transcode, false to use the WAV and J2K files that are already there.
224 Film::make_dcp (bool transcode)
226 set_dci_date_today ();
228 if (dcp_name().find ("/") != string::npos) {
229 throw BadSettingError ("name", "cannot contain slashes");
232 log()->log (String::compose ("DVD-o-matic %1 git %2 using %3", dvdomatic_version, dvdomatic_git_commit, dependency_version_summary()));
236 gethostname (buffer, sizeof (buffer));
237 log()->log (String::compose ("Starting to make DCP on %1", buffer));
241 throw MissingSettingError ("format");
244 if (content().empty ()) {
245 throw MissingSettingError ("content");
248 if (dcp_content_type() == 0) {
249 throw MissingSettingError ("content type");
252 if (name().empty()) {
253 throw MissingSettingError ("name");
256 shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs")));
257 o->out_size = format()->dcp_size ();
258 o->padding = format()->dcp_padding (shared_from_this ());
259 o->ratio = format()->ratio_as_float (shared_from_this ());
260 o->decode_subtitles = with_subtitles ();
261 o->decode_video_skip = dcp_frame_rate (frames_per_second()).skip;
267 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
269 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
273 r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
274 JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
277 /** Start a job to examine our content file */
279 Film::examine_content ()
281 if (_examine_content_job) {
285 set_thumbs (vector<SourceFrame> ());
286 boost::filesystem::remove_all (dir ("thumbs"));
288 /* This call will recreate the directory */
291 _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
292 _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
293 JobManager::instance()->add (_examine_content_job);
297 Film::examine_content_finished ()
299 _examine_content_job.reset ();
302 /** @return full paths to any audio files that this Film has */
304 Film::audio_files () const
307 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) {
308 f.push_back (i->path().string ());
314 /** Start a job to send our DCP to the configured TMS */
316 Film::send_dcp_to_tms ()
318 shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
319 JobManager::instance()->add (j);
323 Film::copy_from_dvd ()
325 shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
326 JobManager::instance()->add (j);
329 /** Count the number of frames that have been encoded for this film.
330 * @return frame count.
333 Film::encoded_frames () const
340 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
342 boost::this_thread::interruption_point ();
348 /** Return the filename of a subtitle image if one exists for a given thumb index.
349 * @param Thumbnail index.
350 * @return Position of the image within the source frame, and the image filename, if one exists.
351 * Otherwise the filename will be empty.
353 pair<Position, string>
354 Film::thumb_subtitle (int n) const
356 string sub_file = thumb_base(n) + ".sub";
357 if (!boost::filesystem::exists (sub_file)) {
358 return pair<Position, string> ();
361 pair<Position, string> sub;
363 ifstream f (sub_file.c_str ());
364 multimap<string, string> kv = read_key_value (f);
365 for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
366 if (i->first == "x") {
367 sub.first.x = lexical_cast<int> (i->second);
368 } else if (i->first == "y") {
369 sub.first.y = lexical_cast<int> (i->second);
370 sub.second = String::compose ("%1.sub.png", thumb_base(n));
377 /** Write state to our `metadata' file */
379 Film::write_metadata () const
381 boost::mutex::scoped_lock lm (_state_mutex);
383 boost::filesystem::create_directories (directory());
385 string const m = file ("metadata");
386 ofstream f (m.c_str ());
388 throw CreateFileError (m);
392 f << "name " << _name << "\n";
393 f << "use_dci_name " << _use_dci_name << "\n";
394 f << "content " << _content << "\n";
395 if (_dcp_content_type) {
396 f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
399 f << "format " << _format->as_metadata () << "\n";
401 f << "left_crop " << _crop.left << "\n";
402 f << "right_crop " << _crop.right << "\n";
403 f << "top_crop " << _crop.top << "\n";
404 f << "bottom_crop " << _crop.bottom << "\n";
405 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
406 f << "filter " << (*i)->id () << "\n";
408 f << "scaler " << _scaler->id () << "\n";
409 f << "dcp_trim_start " << _dcp_trim_start << "\n";
410 f << "dcp_trim_end " << _dcp_trim_end << "\n";
411 f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
412 f << "selected_audio_stream " << _audio_stream << "\n";
413 f << "audio_gain " << _audio_gain << "\n";
414 f << "audio_delay " << _audio_delay << "\n";
415 f << "still_duration " << _still_duration << "\n";
416 f << "selected_subtitle_stream " << _subtitle_stream << "\n";
417 f << "with_subtitles " << _with_subtitles << "\n";
418 f << "subtitle_offset " << _subtitle_offset << "\n";
419 f << "subtitle_scale " << _subtitle_scale << "\n";
420 f << "audio_language " << _audio_language << "\n";
421 f << "subtitle_language " << _subtitle_language << "\n";
422 f << "territory " << _territory << "\n";
423 f << "rating " << _rating << "\n";
424 f << "studio " << _studio << "\n";
425 f << "facility " << _facility << "\n";
426 f << "package_type " << _package_type << "\n";
428 /* Cached stuff; this is information about our content; we could
429 look it up each time, but that's slow.
431 for (vector<SourceFrame>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
432 f << "thumb " << *i << "\n";
434 f << "width " << _size.width << "\n";
435 f << "height " << _size.height << "\n";
436 f << "length " << _length.get_value_or(0) << "\n";
437 f << "audio_sample_rate " << _audio_sample_rate << "\n";
438 f << "content_digest " << _content_digest << "\n";
439 f << "has_subtitles " << _has_subtitles << "\n";
441 for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
442 f << "audio_stream " << i->to_string () << "\n";
445 for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
446 f << "subtitle_stream " << i->to_string () << "\n";
449 f << "frames_per_second " << _frames_per_second << "\n";
454 /** Read state from our metadata file */
456 Film::read_metadata ()
458 boost::mutex::scoped_lock lm (_state_mutex);
460 ifstream f (file ("metadata").c_str());
461 multimap<string, string> kv = read_key_value (f);
462 for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
463 string const k = i->first;
464 string const v = i->second;
466 /* User-specified stuff */
469 } else if (k == "use_dci_name") {
470 _use_dci_name = (v == "1");
471 } else if (k == "content") {
473 } else if (k == "dcp_content_type") {
474 _dcp_content_type = DCPContentType::from_pretty_name (v);
475 } else if (k == "format") {
476 _format = Format::from_metadata (v);
477 } else if (k == "left_crop") {
478 _crop.left = atoi (v.c_str ());
479 } else if (k == "right_crop") {
480 _crop.right = atoi (v.c_str ());
481 } else if (k == "top_crop") {
482 _crop.top = atoi (v.c_str ());
483 } else if (k == "bottom_crop") {
484 _crop.bottom = atoi (v.c_str ());
485 } else if (k == "filter") {
486 _filters.push_back (Filter::from_id (v));
487 } else if (k == "scaler") {
488 _scaler = Scaler::from_id (v);
489 } else if (k == "dcp_trim_start") {
490 _dcp_trim_start = atoi (v.c_str ());
491 } else if (k == "dcp_trim_end") {
492 _dcp_trim_end = atoi (v.c_str ());
493 } else if (k == "dcp_ab") {
494 _dcp_ab = (v == "1");
495 } else if (k == "selected_audio_stream") {
496 _audio_stream = atoi (v.c_str ());
497 } else if (k == "audio_gain") {
498 _audio_gain = atof (v.c_str ());
499 } else if (k == "audio_delay") {
500 _audio_delay = atoi (v.c_str ());
501 } else if (k == "still_duration") {
502 _still_duration = atoi (v.c_str ());
503 } else if (k == "selected_subtitle_stream") {
504 _subtitle_stream = atoi (v.c_str ());
505 } else if (k == "with_subtitles") {
506 _with_subtitles = (v == "1");
507 } else if (k == "subtitle_offset") {
508 _subtitle_offset = atoi (v.c_str ());
509 } else if (k == "subtitle_scale") {
510 _subtitle_scale = atof (v.c_str ());
511 } else if (k == "audio_language") {
513 } else if (k == "subtitle_language") {
514 _subtitle_language = v;
515 } else if (k == "territory") {
517 } else if (k == "rating") {
519 } else if (k == "studio") {
521 } else if (k == "facility") {
523 } else if (k == "package_type") {
529 int const n = atoi (v.c_str ());
530 /* Only add it to the list if it still exists */
531 if (boost::filesystem::exists (thumb_file_for_frame (n))) {
532 _thumbs.push_back (n);
534 } else if (k == "width") {
535 _size.width = atoi (v.c_str ());
536 } else if (k == "height") {
537 _size.height = atoi (v.c_str ());
538 } else if (k == "length") {
539 int const vv = atoi (v.c_str ());
543 } else if (k == "audio_sample_rate") {
544 _audio_sample_rate = atoi (v.c_str ());
545 } else if (k == "content_digest") {
547 } else if (k == "has_subtitles") {
548 _has_subtitles = (v == "1");
549 } else if (k == "audio_stream") {
550 _audio_streams.push_back (AudioStream (v));
551 } else if (k == "subtitle_stream") {
552 _subtitle_streams.push_back (SubtitleStream (v));
553 } else if (k == "frames_per_second") {
554 _frames_per_second = atof (v.c_str ());
561 /** @param n A thumb index.
562 * @return The path to the thumb's image file.
565 Film::thumb_file (int n) const
567 return thumb_file_for_frame (thumb_frame (n));
570 /** @param n A frame index within the Film's source.
571 * @return The path to the thumb's image file for this frame;
572 * we assume that it exists.
575 Film::thumb_file_for_frame (SourceFrame n) const
577 return thumb_base_for_frame(n) + ".png";
580 /** @param n Thumb index.
581 * Must not be called with the _state_mutex locked.
584 Film::thumb_base (int n) const
586 return thumb_base_for_frame (thumb_frame (n));
590 Film::thumb_base_for_frame (SourceFrame n) const
594 s << setfill('0') << n;
596 boost::filesystem::path p;
603 /** @param n A thumb index.
604 * @return The frame within the Film's source that it is for.
606 * Must not be called with the _state_mutex locked.
609 Film::thumb_frame (int n) const
611 boost::mutex::scoped_lock lm (_state_mutex);
612 assert (n < int (_thumbs.size ()));
617 Film::cropped_size (Size s) const
619 boost::mutex::scoped_lock lm (_state_mutex);
620 s.width -= _crop.left + _crop.right;
621 s.height -= _crop.top + _crop.bottom;
625 /** Given a directory name, return its full path within the Film's directory.
626 * The directory (and its parents) will be created if they do not exist.
629 Film::dir (string d) const
631 boost::mutex::scoped_lock lm (_directory_mutex);
632 boost::filesystem::path p;
635 boost::filesystem::create_directories (p);
639 /** Given a file or directory name, return its full path within the Film's directory.
640 * _directory_mutex must not be locked on entry.
643 Film::file (string f) const
645 boost::mutex::scoped_lock lm (_directory_mutex);
646 boost::filesystem::path p;
652 /** @return full path of the content (actual video) file
656 Film::content_path () const
658 boost::mutex::scoped_lock lm (_state_mutex);
659 if (boost::filesystem::path(_content).has_root_directory ()) {
663 return file (_content);
667 Film::content_type () const
669 #if BOOST_FILESYSTEM_VERSION == 3
670 string ext = boost::filesystem::path(_content).extension().string();
672 string ext = boost::filesystem::path(_content).extension();
675 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
677 if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
684 /** @return The sampling rate that we will resample the audio to */
686 Film::target_audio_sample_rate () const
688 /* Resample to a DCI-approved sample rate */
689 double t = dcp_audio_sample_rate (audio_sample_rate());
691 DCPFrameRate dfr = dcp_frame_rate (frames_per_second ());
693 /* Compensate for the fact that video will be rounded to the
694 nearest integer number of frames per second.
697 t *= _frames_per_second * dfr.skip / dfr.frames_per_second;
703 boost::optional<SourceFrame>
704 Film::dcp_length () const
707 return boost::optional<SourceFrame> ();
710 return length().get() - dcp_trim_start() - dcp_trim_end();
713 /** @return a DCI-compliant name for a DCP of this film */
715 Film::dci_name () const
717 boost::mutex::scoped_lock lm (_state_mutex);
721 string fixed_name = to_upper_copy (_name);
722 for (size_t i = 0; i < fixed_name.length(); ++i) {
723 if (fixed_name[i] == ' ') {
728 /* Spec is that the name part should be maximum 14 characters, as I understand it */
729 if (fixed_name.length() > 14) {
730 fixed_name = fixed_name.substr (0, 14);
733 d << fixed_name << "_";
735 if (_dcp_content_type) {
736 d << _dcp_content_type->dci_name() << "_";
740 d << _format->dci_name() << "_";
743 if (!_audio_language.empty ()) {
744 d << _audio_language;
745 if (!_subtitle_language.empty() && _with_subtitles) {
746 d << "-" << _subtitle_language;
754 if (!_territory.empty ()) {
756 if (!_rating.empty ()) {
762 switch (_audio_streams[_audio_stream].channels()) {
779 if (!_studio.empty ()) {
783 d << boost::gregorian::to_iso_string (_dci_date) << "_";
785 if (!_facility.empty ()) {
786 d << _facility << "_";
789 if (!_package_type.empty ()) {
796 /** @return name to give the DCP */
798 Film::dcp_name () const
800 if (use_dci_name()) {
809 Film::set_directory (string d)
811 boost::mutex::scoped_lock lm (_state_mutex);
817 Film::set_name (string n)
820 boost::mutex::scoped_lock lm (_state_mutex);
823 signal_changed (NAME);
827 Film::set_use_dci_name (bool u)
830 boost::mutex::scoped_lock lm (_state_mutex);
833 signal_changed (USE_DCI_NAME);
837 Film::set_content (string c)
839 string check = directory ();
841 #if BOOST_FILESYSTEM_VERSION == 3
842 boost::filesystem::path slash ("/");
843 string platform_slash = slash.make_preferred().string ();
845 #ifdef DVDOMATIC_WINDOWS
846 string platform_slash = "\\";
848 string platform_slash = "/";
852 if (!ends_with (check, platform_slash)) {
853 check += platform_slash;
856 if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) {
857 c = c.substr (_directory.length() + 1);
863 boost::mutex::scoped_lock lm (_state_mutex);
868 old_content = _content;
872 /* Create a temporary decoder so that we can get information
877 shared_ptr<Options> o (new Options ("", "", ""));
878 o->out_size = Size (1024, 1024);
880 shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
882 set_size (d->native_size ());
883 set_frames_per_second (d->frames_per_second ());
884 set_audio_sample_rate (d->audio_sample_rate ());
885 set_has_subtitles (d->has_subtitles ());
886 set_audio_streams (d->audio_streams ());
887 set_subtitle_streams (d->subtitle_streams ());
888 set_audio_stream (audio_streams().empty() ? -1 : 0);
889 set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
892 boost::mutex::scoped_lock lm (_state_mutex);
896 signal_changed (CONTENT);
898 set_content_digest (md5_digest (content_path ()));
904 boost::mutex::scoped_lock lm (_state_mutex);
905 _content = old_content;
912 Film::set_dcp_content_type (DCPContentType const * t)
915 boost::mutex::scoped_lock lm (_state_mutex);
916 _dcp_content_type = t;
918 signal_changed (DCP_CONTENT_TYPE);
922 Film::set_format (Format const * f)
925 boost::mutex::scoped_lock lm (_state_mutex);
928 signal_changed (FORMAT);
932 Film::set_crop (Crop c)
935 boost::mutex::scoped_lock lm (_state_mutex);
938 signal_changed (CROP);
942 Film::set_left_crop (int c)
945 boost::mutex::scoped_lock lm (_state_mutex);
947 if (_crop.left == c) {
953 signal_changed (CROP);
957 Film::set_right_crop (int c)
960 boost::mutex::scoped_lock lm (_state_mutex);
961 if (_crop.right == c) {
967 signal_changed (CROP);
971 Film::set_top_crop (int c)
974 boost::mutex::scoped_lock lm (_state_mutex);
975 if (_crop.top == c) {
981 signal_changed (CROP);
985 Film::set_bottom_crop (int c)
988 boost::mutex::scoped_lock lm (_state_mutex);
989 if (_crop.bottom == c) {
995 signal_changed (CROP);
999 Film::set_filters (vector<Filter const *> f)
1002 boost::mutex::scoped_lock lm (_state_mutex);
1005 signal_changed (FILTERS);
1009 Film::set_scaler (Scaler const * s)
1012 boost::mutex::scoped_lock lm (_state_mutex);
1015 signal_changed (SCALER);
1019 Film::set_dcp_trim_start (int t)
1022 boost::mutex::scoped_lock lm (_state_mutex);
1023 _dcp_trim_start = t;
1025 signal_changed (DCP_TRIM_START);
1029 Film::set_dcp_trim_end (int t)
1032 boost::mutex::scoped_lock lm (_state_mutex);
1035 signal_changed (DCP_TRIM_END);
1039 Film::set_dcp_ab (bool a)
1042 boost::mutex::scoped_lock lm (_state_mutex);
1045 signal_changed (DCP_AB);
1049 Film::set_audio_stream (int s)
1052 boost::mutex::scoped_lock lm (_state_mutex);
1055 signal_changed (AUDIO_STREAM);
1059 Film::set_audio_gain (float g)
1062 boost::mutex::scoped_lock lm (_state_mutex);
1065 signal_changed (AUDIO_GAIN);
1069 Film::set_audio_delay (int d)
1072 boost::mutex::scoped_lock lm (_state_mutex);
1075 signal_changed (AUDIO_DELAY);
1079 Film::set_still_duration (int d)
1082 boost::mutex::scoped_lock lm (_state_mutex);
1083 _still_duration = d;
1085 signal_changed (STILL_DURATION);
1089 Film::set_subtitle_stream (int s)
1092 boost::mutex::scoped_lock lm (_state_mutex);
1093 _subtitle_stream = s;
1095 signal_changed (SUBTITLE_STREAM);
1099 Film::set_with_subtitles (bool w)
1102 boost::mutex::scoped_lock lm (_state_mutex);
1103 _with_subtitles = w;
1105 signal_changed (WITH_SUBTITLES);
1109 Film::set_subtitle_offset (int o)
1112 boost::mutex::scoped_lock lm (_state_mutex);
1113 _subtitle_offset = o;
1115 signal_changed (SUBTITLE_OFFSET);
1119 Film::set_subtitle_scale (float s)
1122 boost::mutex::scoped_lock lm (_state_mutex);
1123 _subtitle_scale = s;
1125 signal_changed (SUBTITLE_SCALE);
1129 Film::set_audio_language (string l)
1132 boost::mutex::scoped_lock lm (_state_mutex);
1133 _audio_language = l;
1135 signal_changed (DCI_METADATA);
1139 Film::set_subtitle_language (string l)
1142 boost::mutex::scoped_lock lm (_state_mutex);
1143 _subtitle_language = l;
1145 signal_changed (DCI_METADATA);
1149 Film::set_territory (string t)
1152 boost::mutex::scoped_lock lm (_state_mutex);
1155 signal_changed (DCI_METADATA);
1159 Film::set_rating (string r)
1162 boost::mutex::scoped_lock lm (_state_mutex);
1165 signal_changed (DCI_METADATA);
1169 Film::set_studio (string s)
1172 boost::mutex::scoped_lock lm (_state_mutex);
1175 signal_changed (DCI_METADATA);
1179 Film::set_facility (string f)
1182 boost::mutex::scoped_lock lm (_state_mutex);
1185 signal_changed (DCI_METADATA);
1189 Film::set_package_type (string p)
1192 boost::mutex::scoped_lock lm (_state_mutex);
1195 signal_changed (DCI_METADATA);
1199 Film::set_thumbs (vector<SourceFrame> t)
1202 boost::mutex::scoped_lock lm (_state_mutex);
1205 signal_changed (THUMBS);
1209 Film::set_size (Size s)
1212 boost::mutex::scoped_lock lm (_state_mutex);
1215 signal_changed (SIZE);
1219 Film::set_length (SourceFrame l)
1222 boost::mutex::scoped_lock lm (_state_mutex);
1225 signal_changed (LENGTH);
1229 Film::unset_length ()
1232 boost::mutex::scoped_lock lm (_state_mutex);
1233 _length = boost::none;
1235 signal_changed (LENGTH);
1239 Film::set_audio_sample_rate (int r)
1242 boost::mutex::scoped_lock lm (_state_mutex);
1243 _audio_sample_rate = r;
1245 signal_changed (AUDIO_SAMPLE_RATE);
1249 Film::set_content_digest (string d)
1252 boost::mutex::scoped_lock lm (_state_mutex);
1253 _content_digest = d;
1259 Film::set_has_subtitles (bool s)
1262 boost::mutex::scoped_lock lm (_state_mutex);
1265 signal_changed (HAS_SUBTITLES);
1269 Film::set_audio_streams (vector<AudioStream> s)
1272 boost::mutex::scoped_lock lm (_state_mutex);
1279 Film::set_subtitle_streams (vector<SubtitleStream> s)
1282 boost::mutex::scoped_lock lm (_state_mutex);
1283 _subtitle_streams = s;
1289 Film::set_frames_per_second (float f)
1292 boost::mutex::scoped_lock lm (_state_mutex);
1293 _frames_per_second = f;
1295 signal_changed (FRAMES_PER_SECOND);
1299 Film::signal_changed (Property p)
1302 boost::mutex::scoped_lock lm (_state_mutex);
1307 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1312 Film::audio_channels () const
1314 boost::mutex::scoped_lock lm (_state_mutex);
1315 if (_audio_stream == -1) {
1319 return _audio_streams[_audio_stream].channels ();
1323 Film::set_dci_date_today ()
1325 _dci_date = boost::gregorian::day_clock::local_day ();