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 ();
280 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
282 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
286 r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
287 JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
290 /** Start a job to examine our content file */
292 Film::examine_content ()
294 if (_examine_content_job) {
298 set_thumbs (vector<int> ());
299 boost::filesystem::remove_all (dir ("thumbs"));
301 /* This call will recreate the directory */
304 _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
305 _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
306 JobManager::instance()->add (_examine_content_job);
310 Film::examine_content_finished ()
312 _examine_content_job.reset ();
315 /** @return full paths to any audio files that this Film has */
317 Film::audio_files () const
320 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) {
321 f.push_back (i->path().string ());
327 /** Start a job to send our DCP to the configured TMS */
329 Film::send_dcp_to_tms ()
331 shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
332 JobManager::instance()->add (j);
336 Film::copy_from_dvd ()
338 shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
339 JobManager::instance()->add (j);
342 /** Count the number of frames that have been encoded for this film.
343 * @return frame count.
346 Film::encoded_frames () const
353 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
355 boost::this_thread::interruption_point ();
361 /** Return the filename of a subtitle image if one exists for a given thumb index.
362 * @param Thumbnail index.
363 * @return Position of the image within the source frame, and the image filename, if one exists.
364 * Otherwise the filename will be empty.
366 pair<Position, string>
367 Film::thumb_subtitle (int n) const
369 string sub_file = thumb_base(n) + ".sub";
370 if (!boost::filesystem::exists (sub_file)) {
371 return pair<Position, string> ();
374 pair<Position, string> sub;
376 ifstream f (sub_file.c_str ());
377 multimap<string, string> kv = read_key_value (f);
378 for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
379 if (i->first == "x") {
380 sub.first.x = lexical_cast<int> (i->second);
381 } else if (i->first == "y") {
382 sub.first.y = lexical_cast<int> (i->second);
383 sub.second = String::compose ("%1.sub.png", thumb_base(n));
390 /** Write state to our `metadata' file */
392 Film::write_metadata () const
394 boost::mutex::scoped_lock lm (_state_mutex);
396 boost::filesystem::create_directories (directory());
398 string const m = file ("metadata");
399 ofstream f (m.c_str ());
401 throw CreateFileError (m);
405 f << "name " << _name << "\n";
406 f << "use_dci_name " << _use_dci_name << "\n";
407 f << "content " << _content << "\n";
408 if (_dcp_content_type) {
409 f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
412 f << "format " << _format->as_metadata () << "\n";
414 f << "left_crop " << _crop.left << "\n";
415 f << "right_crop " << _crop.right << "\n";
416 f << "top_crop " << _crop.top << "\n";
417 f << "bottom_crop " << _crop.bottom << "\n";
418 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
419 f << "filter " << (*i)->id () << "\n";
421 f << "scaler " << _scaler->id () << "\n";
422 f << "dcp_frames " << _dcp_frames.get_value_or(0) << "\n";
424 f << "dcp_trim_action ";
425 switch (_dcp_trim_action) {
434 f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
435 f << "selected_audio_stream " << _audio_stream << "\n";
436 f << "audio_gain " << _audio_gain << "\n";
437 f << "audio_delay " << _audio_delay << "\n";
438 f << "still_duration " << _still_duration << "\n";
439 f << "selected_subtitle_stream " << _subtitle_stream << "\n";
440 f << "with_subtitles " << _with_subtitles << "\n";
441 f << "subtitle_offset " << _subtitle_offset << "\n";
442 f << "subtitle_scale " << _subtitle_scale << "\n";
443 f << "audio_language " << _audio_language << "\n";
444 f << "subtitle_language " << _subtitle_language << "\n";
445 f << "territory " << _territory << "\n";
446 f << "rating " << _rating << "\n";
447 f << "studio " << _studio << "\n";
448 f << "facility " << _facility << "\n";
449 f << "package_type " << _package_type << "\n";
451 /* Cached stuff; this is information about our content; we could
452 look it up each time, but that's slow.
454 for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
455 f << "thumb " << *i << "\n";
457 f << "width " << _size.width << "\n";
458 f << "height " << _size.height << "\n";
459 f << "length " << _length.get_value_or(0) << "\n";
460 f << "audio_sample_rate " << _audio_sample_rate << "\n";
461 f << "content_digest " << _content_digest << "\n";
462 f << "has_subtitles " << _has_subtitles << "\n";
464 for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
465 f << "audio_stream " << i->to_string () << "\n";
468 for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
469 f << "subtitle_stream " << i->to_string () << "\n";
472 f << "frames_per_second " << _frames_per_second << "\n";
477 /** Read state from our metadata file */
479 Film::read_metadata ()
481 boost::mutex::scoped_lock lm (_state_mutex);
483 ifstream f (file ("metadata").c_str());
484 multimap<string, string> kv = read_key_value (f);
485 for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
486 string const k = i->first;
487 string const v = i->second;
489 /* User-specified stuff */
492 } else if (k == "use_dci_name") {
493 _use_dci_name = (v == "1");
494 } else if (k == "content") {
496 } else if (k == "dcp_content_type") {
497 _dcp_content_type = DCPContentType::from_pretty_name (v);
498 } else if (k == "format") {
499 _format = Format::from_metadata (v);
500 } else if (k == "left_crop") {
501 _crop.left = atoi (v.c_str ());
502 } else if (k == "right_crop") {
503 _crop.right = atoi (v.c_str ());
504 } else if (k == "top_crop") {
505 _crop.top = atoi (v.c_str ());
506 } else if (k == "bottom_crop") {
507 _crop.bottom = atoi (v.c_str ());
508 } else if (k == "filter") {
509 _filters.push_back (Filter::from_id (v));
510 } else if (k == "scaler") {
511 _scaler = Scaler::from_id (v);
512 } else if (k == "dcp_frames") {
513 int const vv = atoi (v.c_str ());
517 } else if (k == "dcp_trim_action") {
519 _dcp_trim_action = CUT;
520 } else if (v == "black_out") {
521 _dcp_trim_action = BLACK_OUT;
523 } else if (k == "dcp_ab") {
524 _dcp_ab = (v == "1");
525 } else if (k == "selected_audio_stream") {
526 _audio_stream = atoi (v.c_str ());
527 } else if (k == "audio_gain") {
528 _audio_gain = atof (v.c_str ());
529 } else if (k == "audio_delay") {
530 _audio_delay = atoi (v.c_str ());
531 } else if (k == "still_duration") {
532 _still_duration = atoi (v.c_str ());
533 } else if (k == "selected_subtitle_stream") {
534 _subtitle_stream = atoi (v.c_str ());
535 } else if (k == "with_subtitles") {
536 _with_subtitles = (v == "1");
537 } else if (k == "subtitle_offset") {
538 _subtitle_offset = atoi (v.c_str ());
539 } else if (k == "subtitle_scale") {
540 _subtitle_scale = atof (v.c_str ());
541 } else if (k == "audio_language") {
543 } else if (k == "subtitle_language") {
544 _subtitle_language = v;
545 } else if (k == "territory") {
547 } else if (k == "rating") {
549 } else if (k == "studio") {
551 } else if (k == "facility") {
553 } else if (k == "package_type") {
559 int const n = atoi (v.c_str ());
560 /* Only add it to the list if it still exists */
561 if (boost::filesystem::exists (thumb_file_for_frame (n))) {
562 _thumbs.push_back (n);
564 } else if (k == "width") {
565 _size.width = atoi (v.c_str ());
566 } else if (k == "height") {
567 _size.height = atoi (v.c_str ());
568 } else if (k == "length") {
569 int const vv = atoi (v.c_str ());
573 } else if (k == "audio_sample_rate") {
574 _audio_sample_rate = atoi (v.c_str ());
575 } else if (k == "content_digest") {
577 } else if (k == "has_subtitles") {
578 _has_subtitles = (v == "1");
579 } else if (k == "audio_stream") {
580 _audio_streams.push_back (AudioStream (v));
581 } else if (k == "subtitle_stream") {
582 _subtitle_streams.push_back (SubtitleStream (v));
583 } else if (k == "frames_per_second") {
584 _frames_per_second = atof (v.c_str ());
591 /** @param n A thumb index.
592 * @return The path to the thumb's image file.
595 Film::thumb_file (int n) const
597 return thumb_file_for_frame (thumb_frame (n));
600 /** @param n A frame index within the Film.
601 * @return The path to the thumb's image file for this frame;
602 * we assume that it exists.
605 Film::thumb_file_for_frame (int n) const
607 return thumb_base_for_frame(n) + ".png";
611 Film::thumb_base (int n) const
613 return thumb_base_for_frame (thumb_frame (n));
617 Film::thumb_base_for_frame (int n) const
619 boost::mutex::scoped_lock lm (_state_mutex);
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.
636 Film::thumb_frame (int n) const
638 boost::mutex::scoped_lock lm (_state_mutex);
639 assert (n < int (_thumbs.size ()));
644 Film::cropped_size (Size s) const
646 boost::mutex::scoped_lock lm (_state_mutex);
647 s.width -= _crop.left + _crop.right;
648 s.height -= _crop.top + _crop.bottom;
652 /** Given a directory name, return its full path within the Film's directory.
653 * The directory (and its parents) will be created if they do not exist.
656 Film::dir (string d) const
658 boost::mutex::scoped_lock lm (_directory_mutex);
659 boost::filesystem::path p;
662 boost::filesystem::create_directories (p);
666 /** Given a file or directory name, return its full path within the Film's directory.
667 * _directory_mutex must not be locked on entry.
670 Film::file (string f) const
672 boost::mutex::scoped_lock lm (_directory_mutex);
673 boost::filesystem::path p;
679 /** @return full path of the content (actual video) file
683 Film::content_path () const
685 boost::mutex::scoped_lock lm (_state_mutex);
686 if (boost::filesystem::path(_content).has_root_directory ()) {
690 return file (_content);
694 Film::content_type () const
696 #if BOOST_FILESYSTEM_VERSION == 3
697 string ext = boost::filesystem::path(_content).extension().string();
699 string ext = boost::filesystem::path(_content).extension();
702 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
704 if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
711 /** @return The sampling rate that we will resample the audio to */
713 Film::target_audio_sample_rate () const
715 /* Resample to a DCI-approved sample rate */
716 double t = dcp_audio_sample_rate (audio_sample_rate());
718 /* Compensate for the fact that video will be rounded to the
719 nearest integer number of frames per second.
721 if (rint (frames_per_second()) != frames_per_second()) {
722 t *= _frames_per_second / rint (frames_per_second());
729 Film::dcp_length () const
732 return boost::optional<int> ();
736 return min (dcp_frames().get(), length().get());
742 /** @return a DCI-compliant name for a DCP of this film */
744 Film::dci_name () const
746 boost::mutex::scoped_lock lm (_state_mutex);
750 string fixed_name = to_upper_copy (_name);
751 for (size_t i = 0; i < fixed_name.length(); ++i) {
752 if (fixed_name[i] == ' ') {
757 /* Spec is that the name part should be maximum 14 characters, as I understand it */
758 if (fixed_name.length() > 14) {
759 fixed_name = fixed_name.substr (0, 14);
762 d << fixed_name << "_";
764 if (_dcp_content_type) {
765 d << _dcp_content_type->dci_name() << "_";
769 d << _format->dci_name() << "_";
772 if (!_audio_language.empty ()) {
773 d << _audio_language;
774 if (!_subtitle_language.empty() && _with_subtitles) {
775 d << "-" << _subtitle_language;
783 if (!_territory.empty ()) {
785 if (!_rating.empty ()) {
791 switch (_audio_streams[_audio_stream].channels()) {
808 if (!_studio.empty ()) {
812 d << boost::gregorian::to_iso_string (_dci_date) << "_";
814 if (!_facility.empty ()) {
815 d << _facility << "_";
818 if (!_package_type.empty ()) {
825 /** @return name to give the DCP */
827 Film::dcp_name () const
829 if (use_dci_name()) {
838 Film::set_directory (string d)
840 boost::mutex::scoped_lock lm (_state_mutex);
846 Film::set_name (string n)
849 boost::mutex::scoped_lock lm (_state_mutex);
852 signal_changed (NAME);
856 Film::set_use_dci_name (bool u)
859 boost::mutex::scoped_lock lm (_state_mutex);
862 signal_changed (USE_DCI_NAME);
866 Film::set_content (string c)
868 string check = directory ();
870 #if BOOST_FILESYSTEM_VERSION == 3
871 boost::filesystem::path slash ("/");
872 string platform_slash = slash.make_preferred().string ();
874 #ifdef DVDOMATIC_WINDOWS
875 string platform_slash = "\\";
877 string platform_slash = "/";
881 if (!ends_with (check, platform_slash)) {
882 check += platform_slash;
885 if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) {
886 c = c.substr (_directory.length() + 1);
892 boost::mutex::scoped_lock lm (_state_mutex);
897 old_content = _content;
901 /* Create a temporary decoder so that we can get information
906 shared_ptr<Options> o (new Options ("", "", ""));
907 o->out_size = Size (1024, 1024);
909 shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
911 set_size (d->native_size ());
912 set_frames_per_second (d->frames_per_second ());
913 set_audio_sample_rate (d->audio_sample_rate ());
914 set_has_subtitles (d->has_subtitles ());
915 set_audio_streams (d->audio_streams ());
916 set_subtitle_streams (d->subtitle_streams ());
917 set_audio_stream (audio_streams().empty() ? -1 : 0);
918 set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
921 boost::mutex::scoped_lock lm (_state_mutex);
925 signal_changed (CONTENT);
927 set_content_digest (md5_digest (content_path ()));
933 boost::mutex::scoped_lock lm (_state_mutex);
934 _content = old_content;
941 Film::set_dcp_content_type (DCPContentType const * t)
944 boost::mutex::scoped_lock lm (_state_mutex);
945 _dcp_content_type = t;
947 signal_changed (DCP_CONTENT_TYPE);
951 Film::set_format (Format const * f)
954 boost::mutex::scoped_lock lm (_state_mutex);
957 signal_changed (FORMAT);
961 Film::set_crop (Crop c)
964 boost::mutex::scoped_lock lm (_state_mutex);
967 signal_changed (CROP);
971 Film::set_left_crop (int c)
974 boost::mutex::scoped_lock lm (_state_mutex);
976 if (_crop.left == c) {
982 signal_changed (CROP);
986 Film::set_right_crop (int c)
989 boost::mutex::scoped_lock lm (_state_mutex);
990 if (_crop.right == c) {
996 signal_changed (CROP);
1000 Film::set_top_crop (int c)
1003 boost::mutex::scoped_lock lm (_state_mutex);
1004 if (_crop.top == c) {
1010 signal_changed (CROP);
1014 Film::set_bottom_crop (int c)
1017 boost::mutex::scoped_lock lm (_state_mutex);
1018 if (_crop.bottom == c) {
1024 signal_changed (CROP);
1028 Film::set_filters (vector<Filter const *> f)
1031 boost::mutex::scoped_lock lm (_state_mutex);
1034 signal_changed (FILTERS);
1038 Film::set_scaler (Scaler const * s)
1041 boost::mutex::scoped_lock lm (_state_mutex);
1044 signal_changed (SCALER);
1048 Film::set_dcp_frames (int f)
1051 boost::mutex::scoped_lock lm (_state_mutex);
1054 signal_changed (DCP_FRAMES);
1058 Film::unset_dcp_frames ()
1061 boost::mutex::scoped_lock lm (_state_mutex);
1062 _dcp_frames = boost::none;
1064 signal_changed (DCP_FRAMES);
1068 Film::set_dcp_trim_action (TrimAction a)
1071 boost::mutex::scoped_lock lm (_state_mutex);
1072 _dcp_trim_action = a;
1074 signal_changed (DCP_TRIM_ACTION);
1078 Film::set_dcp_ab (bool a)
1081 boost::mutex::scoped_lock lm (_state_mutex);
1084 signal_changed (DCP_AB);
1088 Film::set_audio_stream (int s)
1091 boost::mutex::scoped_lock lm (_state_mutex);
1094 signal_changed (AUDIO_STREAM);
1098 Film::set_audio_gain (float g)
1101 boost::mutex::scoped_lock lm (_state_mutex);
1104 signal_changed (AUDIO_GAIN);
1108 Film::set_audio_delay (int d)
1111 boost::mutex::scoped_lock lm (_state_mutex);
1114 signal_changed (AUDIO_DELAY);
1118 Film::set_still_duration (int d)
1121 boost::mutex::scoped_lock lm (_state_mutex);
1122 _still_duration = d;
1124 signal_changed (STILL_DURATION);
1128 Film::set_subtitle_stream (int s)
1131 boost::mutex::scoped_lock lm (_state_mutex);
1132 _subtitle_stream = s;
1134 signal_changed (SUBTITLE_STREAM);
1138 Film::set_with_subtitles (bool w)
1141 boost::mutex::scoped_lock lm (_state_mutex);
1142 _with_subtitles = w;
1144 signal_changed (WITH_SUBTITLES);
1148 Film::set_subtitle_offset (int o)
1151 boost::mutex::scoped_lock lm (_state_mutex);
1152 _subtitle_offset = o;
1154 signal_changed (SUBTITLE_OFFSET);
1158 Film::set_subtitle_scale (float s)
1161 boost::mutex::scoped_lock lm (_state_mutex);
1162 _subtitle_scale = s;
1164 signal_changed (SUBTITLE_SCALE);
1168 Film::set_audio_language (string l)
1171 boost::mutex::scoped_lock lm (_state_mutex);
1172 _audio_language = l;
1174 signal_changed (DCI_METADATA);
1178 Film::set_subtitle_language (string l)
1181 boost::mutex::scoped_lock lm (_state_mutex);
1182 _subtitle_language = l;
1184 signal_changed (DCI_METADATA);
1188 Film::set_territory (string t)
1191 boost::mutex::scoped_lock lm (_state_mutex);
1194 signal_changed (DCI_METADATA);
1198 Film::set_rating (string r)
1201 boost::mutex::scoped_lock lm (_state_mutex);
1204 signal_changed (DCI_METADATA);
1208 Film::set_studio (string s)
1211 boost::mutex::scoped_lock lm (_state_mutex);
1214 signal_changed (DCI_METADATA);
1218 Film::set_facility (string f)
1221 boost::mutex::scoped_lock lm (_state_mutex);
1224 signal_changed (DCI_METADATA);
1228 Film::set_package_type (string p)
1231 boost::mutex::scoped_lock lm (_state_mutex);
1234 signal_changed (DCI_METADATA);
1238 Film::set_thumbs (vector<int> t)
1241 boost::mutex::scoped_lock lm (_state_mutex);
1244 signal_changed (THUMBS);
1248 Film::set_size (Size s)
1251 boost::mutex::scoped_lock lm (_state_mutex);
1254 signal_changed (SIZE);
1258 Film::set_length (int l)
1261 boost::mutex::scoped_lock lm (_state_mutex);
1264 signal_changed (LENGTH);
1268 Film::unset_length ()
1271 boost::mutex::scoped_lock lm (_state_mutex);
1272 _length = boost::none;
1274 signal_changed (LENGTH);
1278 Film::set_audio_sample_rate (int r)
1281 boost::mutex::scoped_lock lm (_state_mutex);
1282 _audio_sample_rate = r;
1284 signal_changed (AUDIO_SAMPLE_RATE);
1288 Film::set_content_digest (string d)
1291 boost::mutex::scoped_lock lm (_state_mutex);
1292 _content_digest = d;
1298 Film::set_has_subtitles (bool s)
1301 boost::mutex::scoped_lock lm (_state_mutex);
1304 signal_changed (HAS_SUBTITLES);
1308 Film::set_audio_streams (vector<AudioStream> s)
1311 boost::mutex::scoped_lock lm (_state_mutex);
1318 Film::set_subtitle_streams (vector<SubtitleStream> s)
1321 boost::mutex::scoped_lock lm (_state_mutex);
1322 _subtitle_streams = s;
1328 Film::set_frames_per_second (float f)
1331 boost::mutex::scoped_lock lm (_state_mutex);
1332 _frames_per_second = f;
1334 signal_changed (FRAMES_PER_SECOND);
1338 Film::signal_changed (Property p)
1341 boost::mutex::scoped_lock lm (_state_mutex);
1346 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1351 Film::audio_channels () const
1353 boost::mutex::scoped_lock lm (_state_mutex);
1354 if (_audio_stream == -1) {
1358 return _audio_streams[_audio_stream].channels ();
1362 Film::set_dci_date_today ()
1364 _dci_date = boost::gregorian::day_clock::local_day ();