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"))
89 , _still_duration (10)
90 , _subtitle_stream (-1)
91 , _with_subtitles (false)
92 , _subtitle_offset (0)
94 , _audio_sample_rate (0)
95 , _has_subtitles (false)
96 , _frames_per_second (0)
99 /* Make state.directory a complete path without ..s (where possible)
100 (Code swiped from Adam Bowen on stackoverflow)
103 boost::filesystem::path p (boost::filesystem::system_complete (d));
104 boost::filesystem::path result;
105 for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
107 if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
110 result = result.parent_path ();
112 } else if (*i != ".") {
117 set_directory (result.string ());
119 if (!boost::filesystem::exists (directory())) {
121 throw OpenFileError (directory());
123 boost::filesystem::create_directory (directory());
129 _log = new FileLog (file ("log"));
130 set_dci_date_today ();
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_ab (o._dcp_ab)
146 , _audio_stream (o._audio_stream)
147 , _audio_gain (o._audio_gain)
148 , _audio_delay (o._audio_delay)
149 , _still_duration (o._still_duration)
150 , _subtitle_stream (o._subtitle_stream)
151 , _with_subtitles (o._with_subtitles)
152 , _subtitle_offset (o._subtitle_offset)
153 , _subtitle_scale (o._subtitle_scale)
154 , _audio_language (o._audio_language)
155 , _subtitle_language (o._subtitle_language)
156 , _territory (o._territory)
157 , _rating (o._rating)
158 , _studio (o._studio)
159 , _facility (o._facility)
160 , _package_type (o._package_type)
161 , _thumbs (o._thumbs)
163 , _length (o._length)
164 , _audio_sample_rate (o._audio_sample_rate)
165 , _content_digest (o._content_digest)
166 , _has_subtitles (o._has_subtitles)
167 , _audio_streams (o._audio_streams)
168 , _subtitle_streams (o._subtitle_streams)
169 , _frames_per_second (o._frames_per_second)
180 /** @return The path to the directory to write JPEG2000 files to */
182 Film::j2k_dir () const
186 boost::filesystem::path p;
191 pair<string, string> f = Filter::ffmpeg_strings (filters());
193 /* Write stuff to specify the filter / post-processing settings that are in use,
194 so that we don't get confused about J2K files generated using different
199 << "_" << content_digest()
200 << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
201 << "_" << f.first << "_" << f.second
202 << "_" << scaler()->id();
206 /* Similarly for the A/B case */
209 pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
210 s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
214 return dir (p.string());
217 /** Add suitable Jobs to the JobManager to create a DCP for this Film.
218 * @param true to transcode, false to use the WAV and J2K files that are already there.
221 Film::make_dcp (bool transcode)
223 set_dci_date_today ();
225 if (dcp_name().find ("/") != string::npos) {
226 throw BadSettingError ("name", "cannot contain slashes");
229 log()->log (String::compose ("DVD-o-matic %1 git %2 using %3", dvdomatic_version, dvdomatic_git_commit, dependency_version_summary()));
233 gethostname (buffer, sizeof (buffer));
234 log()->log (String::compose ("Starting to make DCP on %1", buffer));
238 throw MissingSettingError ("format");
241 if (content().empty ()) {
242 throw MissingSettingError ("content");
245 if (dcp_content_type() == 0) {
246 throw MissingSettingError ("content type");
249 if (name().empty()) {
250 throw MissingSettingError ("name");
253 shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs")));
254 o->out_size = format()->dcp_size ();
255 o->padding = format()->dcp_padding (shared_from_this ());
256 o->ratio = format()->ratio_as_float (shared_from_this ());
257 o->decode_subtitles = with_subtitles ();
263 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
265 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
269 r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
270 JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
273 /** Start a job to examine our content file */
275 Film::examine_content ()
277 if (_examine_content_job) {
281 set_thumbs (vector<int> ());
282 boost::filesystem::remove_all (dir ("thumbs"));
284 /* This call will recreate the directory */
287 _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
288 _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
289 JobManager::instance()->add (_examine_content_job);
293 Film::examine_content_finished ()
295 _examine_content_job.reset ();
298 /** @return full paths to any audio files that this Film has */
300 Film::audio_files () const
303 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) {
304 f.push_back (i->path().string ());
310 /** Start a job to send our DCP to the configured TMS */
312 Film::send_dcp_to_tms ()
314 shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
315 JobManager::instance()->add (j);
319 Film::copy_from_dvd ()
321 shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
322 JobManager::instance()->add (j);
325 /** Count the number of frames that have been encoded for this film.
326 * @return frame count.
329 Film::encoded_frames () const
336 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
338 boost::this_thread::interruption_point ();
344 /** Return the filename of a subtitle image if one exists for a given thumb index.
345 * @param Thumbnail index.
346 * @return Position of the image within the source frame, and the image filename, if one exists.
347 * Otherwise the filename will be empty.
349 pair<Position, string>
350 Film::thumb_subtitle (int n) const
352 string sub_file = thumb_base(n) + ".sub";
353 if (!boost::filesystem::exists (sub_file)) {
354 return pair<Position, string> ();
357 pair<Position, string> sub;
359 ifstream f (sub_file.c_str ());
360 multimap<string, string> kv = read_key_value (f);
361 for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
362 if (i->first == "x") {
363 sub.first.x = lexical_cast<int> (i->second);
364 } else if (i->first == "y") {
365 sub.first.y = lexical_cast<int> (i->second);
366 sub.second = String::compose ("%1.sub.png", thumb_base(n));
373 /** Write state to our `metadata' file */
375 Film::write_metadata () const
377 boost::mutex::scoped_lock lm (_state_mutex);
379 boost::filesystem::create_directories (directory());
381 string const m = file ("metadata");
382 ofstream f (m.c_str ());
384 throw CreateFileError (m);
388 f << "name " << _name << "\n";
389 f << "use_dci_name " << _use_dci_name << "\n";
390 f << "content " << _content << "\n";
391 if (_dcp_content_type) {
392 f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
395 f << "format " << _format->as_metadata () << "\n";
397 f << "left_crop " << _crop.left << "\n";
398 f << "right_crop " << _crop.right << "\n";
399 f << "top_crop " << _crop.top << "\n";
400 f << "bottom_crop " << _crop.bottom << "\n";
401 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
402 f << "filter " << (*i)->id () << "\n";
404 f << "scaler " << _scaler->id () << "\n";
405 f << "dcp_frames " << _dcp_frames.get_value_or(0) << "\n";
406 f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
407 f << "selected_audio_stream " << _audio_stream << "\n";
408 f << "audio_gain " << _audio_gain << "\n";
409 f << "audio_delay " << _audio_delay << "\n";
410 f << "still_duration " << _still_duration << "\n";
411 f << "selected_subtitle_stream " << _subtitle_stream << "\n";
412 f << "with_subtitles " << _with_subtitles << "\n";
413 f << "subtitle_offset " << _subtitle_offset << "\n";
414 f << "subtitle_scale " << _subtitle_scale << "\n";
415 f << "audio_language " << _audio_language << "\n";
416 f << "subtitle_language " << _subtitle_language << "\n";
417 f << "territory " << _territory << "\n";
418 f << "rating " << _rating << "\n";
419 f << "studio " << _studio << "\n";
420 f << "facility " << _facility << "\n";
421 f << "package_type " << _package_type << "\n";
423 /* Cached stuff; this is information about our content; we could
424 look it up each time, but that's slow.
426 for (vector<int>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
427 f << "thumb " << *i << "\n";
429 f << "width " << _size.width << "\n";
430 f << "height " << _size.height << "\n";
431 f << "length " << _length.get_value_or(0) << "\n";
432 f << "audio_sample_rate " << _audio_sample_rate << "\n";
433 f << "content_digest " << _content_digest << "\n";
434 f << "has_subtitles " << _has_subtitles << "\n";
436 for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
437 f << "audio_stream " << i->to_string () << "\n";
440 for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
441 f << "subtitle_stream " << i->to_string () << "\n";
444 f << "frames_per_second " << _frames_per_second << "\n";
449 /** Read state from our metadata file */
451 Film::read_metadata ()
453 boost::mutex::scoped_lock lm (_state_mutex);
455 ifstream f (file ("metadata").c_str());
456 multimap<string, string> kv = read_key_value (f);
457 for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
458 string const k = i->first;
459 string const v = i->second;
461 /* User-specified stuff */
464 } else if (k == "use_dci_name") {
465 _use_dci_name = (v == "1");
466 } else if (k == "content") {
468 } else if (k == "dcp_content_type") {
469 _dcp_content_type = DCPContentType::from_pretty_name (v);
470 } else if (k == "format") {
471 _format = Format::from_metadata (v);
472 } else if (k == "left_crop") {
473 _crop.left = atoi (v.c_str ());
474 } else if (k == "right_crop") {
475 _crop.right = atoi (v.c_str ());
476 } else if (k == "top_crop") {
477 _crop.top = atoi (v.c_str ());
478 } else if (k == "bottom_crop") {
479 _crop.bottom = atoi (v.c_str ());
480 } else if (k == "filter") {
481 _filters.push_back (Filter::from_id (v));
482 } else if (k == "scaler") {
483 _scaler = Scaler::from_id (v);
484 } else if (k == "dcp_frames") {
485 int const vv = atoi (v.c_str ());
489 } else if (k == "dcp_ab") {
490 _dcp_ab = (v == "1");
491 } else if (k == "selected_audio_stream") {
492 _audio_stream = atoi (v.c_str ());
493 } else if (k == "audio_gain") {
494 _audio_gain = atof (v.c_str ());
495 } else if (k == "audio_delay") {
496 _audio_delay = atoi (v.c_str ());
497 } else if (k == "still_duration") {
498 _still_duration = atoi (v.c_str ());
499 } else if (k == "selected_subtitle_stream") {
500 _subtitle_stream = atoi (v.c_str ());
501 } else if (k == "with_subtitles") {
502 _with_subtitles = (v == "1");
503 } else if (k == "subtitle_offset") {
504 _subtitle_offset = atoi (v.c_str ());
505 } else if (k == "subtitle_scale") {
506 _subtitle_scale = atof (v.c_str ());
507 } else if (k == "audio_language") {
509 } else if (k == "subtitle_language") {
510 _subtitle_language = v;
511 } else if (k == "territory") {
513 } else if (k == "rating") {
515 } else if (k == "studio") {
517 } else if (k == "facility") {
519 } else if (k == "package_type") {
525 int const n = atoi (v.c_str ());
526 /* Only add it to the list if it still exists */
527 if (boost::filesystem::exists (thumb_file_for_frame (n))) {
528 _thumbs.push_back (n);
530 } else if (k == "width") {
531 _size.width = atoi (v.c_str ());
532 } else if (k == "height") {
533 _size.height = atoi (v.c_str ());
534 } else if (k == "length") {
535 int const vv = atoi (v.c_str ());
539 } else if (k == "audio_sample_rate") {
540 _audio_sample_rate = atoi (v.c_str ());
541 } else if (k == "content_digest") {
543 } else if (k == "has_subtitles") {
544 _has_subtitles = (v == "1");
545 } else if (k == "audio_stream") {
546 _audio_streams.push_back (AudioStream (v));
547 } else if (k == "subtitle_stream") {
548 _subtitle_streams.push_back (SubtitleStream (v));
549 } else if (k == "frames_per_second") {
550 _frames_per_second = atof (v.c_str ());
557 /** @param n A thumb index.
558 * @return The path to the thumb's image file.
561 Film::thumb_file (int n) const
563 return thumb_file_for_frame (thumb_frame (n));
566 /** @param n A frame index within the Film.
567 * @return The path to the thumb's image file for this frame;
568 * we assume that it exists.
571 Film::thumb_file_for_frame (int n) const
573 return thumb_base_for_frame(n) + ".png";
576 /** Must not be called with the _state_mutex locked */
578 Film::thumb_base (int n) const
580 return thumb_base_for_frame (thumb_frame (n));
584 Film::thumb_base_for_frame (int n) const
588 s << setfill('0') << n;
590 boost::filesystem::path p;
597 /** @param n A thumb index.
598 * @return The frame within the Film that it is for.
600 * Must not be called with the _state_mutex locked.
603 Film::thumb_frame (int n) const
605 boost::mutex::scoped_lock lm (_state_mutex);
606 assert (n < int (_thumbs.size ()));
611 Film::cropped_size (Size s) const
613 boost::mutex::scoped_lock lm (_state_mutex);
614 s.width -= _crop.left + _crop.right;
615 s.height -= _crop.top + _crop.bottom;
619 /** Given a directory name, return its full path within the Film's directory.
620 * The directory (and its parents) will be created if they do not exist.
623 Film::dir (string d) const
625 boost::mutex::scoped_lock lm (_directory_mutex);
626 boost::filesystem::path p;
629 boost::filesystem::create_directories (p);
633 /** Given a file or directory name, return its full path within the Film's directory.
634 * _directory_mutex must not be locked on entry.
637 Film::file (string f) const
639 boost::mutex::scoped_lock lm (_directory_mutex);
640 boost::filesystem::path p;
646 /** @return full path of the content (actual video) file
650 Film::content_path () const
652 boost::mutex::scoped_lock lm (_state_mutex);
653 if (boost::filesystem::path(_content).has_root_directory ()) {
657 return file (_content);
661 Film::content_type () const
663 #if BOOST_FILESYSTEM_VERSION == 3
664 string ext = boost::filesystem::path(_content).extension().string();
666 string ext = boost::filesystem::path(_content).extension();
669 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
671 if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
678 /** @return The sampling rate that we will resample the audio to */
680 Film::target_audio_sample_rate () const
682 /* Resample to a DCI-approved sample rate */
683 double t = dcp_audio_sample_rate (audio_sample_rate());
685 /* Compensate for the fact that video will be rounded to the
686 nearest integer number of frames per second.
688 if (rint (frames_per_second()) != frames_per_second()) {
689 t *= _frames_per_second / rint (frames_per_second());
696 Film::dcp_length () const
699 return boost::optional<int> ();
703 return min (dcp_frames().get(), length().get());
709 /** @return a DCI-compliant name for a DCP of this film */
711 Film::dci_name () const
713 boost::mutex::scoped_lock lm (_state_mutex);
717 string fixed_name = to_upper_copy (_name);
718 for (size_t i = 0; i < fixed_name.length(); ++i) {
719 if (fixed_name[i] == ' ') {
724 /* Spec is that the name part should be maximum 14 characters, as I understand it */
725 if (fixed_name.length() > 14) {
726 fixed_name = fixed_name.substr (0, 14);
729 d << fixed_name << "_";
731 if (_dcp_content_type) {
732 d << _dcp_content_type->dci_name() << "_";
736 d << _format->dci_name() << "_";
739 if (!_audio_language.empty ()) {
740 d << _audio_language;
741 if (!_subtitle_language.empty() && _with_subtitles) {
742 d << "-" << _subtitle_language;
750 if (!_territory.empty ()) {
752 if (!_rating.empty ()) {
758 switch (_audio_streams[_audio_stream].channels()) {
775 if (!_studio.empty ()) {
779 d << boost::gregorian::to_iso_string (_dci_date) << "_";
781 if (!_facility.empty ()) {
782 d << _facility << "_";
785 if (!_package_type.empty ()) {
792 /** @return name to give the DCP */
794 Film::dcp_name () const
796 if (use_dci_name()) {
805 Film::set_directory (string d)
807 boost::mutex::scoped_lock lm (_state_mutex);
813 Film::set_name (string n)
816 boost::mutex::scoped_lock lm (_state_mutex);
819 signal_changed (NAME);
823 Film::set_use_dci_name (bool u)
826 boost::mutex::scoped_lock lm (_state_mutex);
829 signal_changed (USE_DCI_NAME);
833 Film::set_content (string c)
835 string check = directory ();
837 #if BOOST_FILESYSTEM_VERSION == 3
838 boost::filesystem::path slash ("/");
839 string platform_slash = slash.make_preferred().string ();
841 #ifdef DVDOMATIC_WINDOWS
842 string platform_slash = "\\";
844 string platform_slash = "/";
848 if (!ends_with (check, platform_slash)) {
849 check += platform_slash;
852 if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) {
853 c = c.substr (_directory.length() + 1);
859 boost::mutex::scoped_lock lm (_state_mutex);
864 old_content = _content;
868 /* Create a temporary decoder so that we can get information
873 shared_ptr<Options> o (new Options ("", "", ""));
874 o->out_size = Size (1024, 1024);
876 shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0, 0);
878 set_size (d->native_size ());
879 set_frames_per_second (d->frames_per_second ());
880 set_audio_sample_rate (d->audio_sample_rate ());
881 set_has_subtitles (d->has_subtitles ());
882 set_audio_streams (d->audio_streams ());
883 set_subtitle_streams (d->subtitle_streams ());
884 set_audio_stream (audio_streams().empty() ? -1 : 0);
885 set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
888 boost::mutex::scoped_lock lm (_state_mutex);
892 signal_changed (CONTENT);
894 set_content_digest (md5_digest (content_path ()));
900 boost::mutex::scoped_lock lm (_state_mutex);
901 _content = old_content;
908 Film::set_dcp_content_type (DCPContentType const * t)
911 boost::mutex::scoped_lock lm (_state_mutex);
912 _dcp_content_type = t;
914 signal_changed (DCP_CONTENT_TYPE);
918 Film::set_format (Format const * f)
921 boost::mutex::scoped_lock lm (_state_mutex);
924 signal_changed (FORMAT);
928 Film::set_crop (Crop c)
931 boost::mutex::scoped_lock lm (_state_mutex);
934 signal_changed (CROP);
938 Film::set_left_crop (int c)
941 boost::mutex::scoped_lock lm (_state_mutex);
943 if (_crop.left == c) {
949 signal_changed (CROP);
953 Film::set_right_crop (int c)
956 boost::mutex::scoped_lock lm (_state_mutex);
957 if (_crop.right == c) {
963 signal_changed (CROP);
967 Film::set_top_crop (int c)
970 boost::mutex::scoped_lock lm (_state_mutex);
971 if (_crop.top == c) {
977 signal_changed (CROP);
981 Film::set_bottom_crop (int c)
984 boost::mutex::scoped_lock lm (_state_mutex);
985 if (_crop.bottom == c) {
991 signal_changed (CROP);
995 Film::set_filters (vector<Filter const *> f)
998 boost::mutex::scoped_lock lm (_state_mutex);
1001 signal_changed (FILTERS);
1005 Film::set_scaler (Scaler const * s)
1008 boost::mutex::scoped_lock lm (_state_mutex);
1011 signal_changed (SCALER);
1015 Film::set_dcp_frames (int f)
1018 boost::mutex::scoped_lock lm (_state_mutex);
1021 signal_changed (DCP_FRAMES);
1025 Film::unset_dcp_frames ()
1028 boost::mutex::scoped_lock lm (_state_mutex);
1029 _dcp_frames = boost::none;
1031 signal_changed (DCP_FRAMES);
1035 Film::set_dcp_ab (bool a)
1038 boost::mutex::scoped_lock lm (_state_mutex);
1041 signal_changed (DCP_AB);
1045 Film::set_audio_stream (int s)
1048 boost::mutex::scoped_lock lm (_state_mutex);
1051 signal_changed (AUDIO_STREAM);
1055 Film::set_audio_gain (float g)
1058 boost::mutex::scoped_lock lm (_state_mutex);
1061 signal_changed (AUDIO_GAIN);
1065 Film::set_audio_delay (int d)
1068 boost::mutex::scoped_lock lm (_state_mutex);
1071 signal_changed (AUDIO_DELAY);
1075 Film::set_still_duration (int d)
1078 boost::mutex::scoped_lock lm (_state_mutex);
1079 _still_duration = d;
1081 signal_changed (STILL_DURATION);
1085 Film::set_subtitle_stream (int s)
1088 boost::mutex::scoped_lock lm (_state_mutex);
1089 _subtitle_stream = s;
1091 signal_changed (SUBTITLE_STREAM);
1095 Film::set_with_subtitles (bool w)
1098 boost::mutex::scoped_lock lm (_state_mutex);
1099 _with_subtitles = w;
1101 signal_changed (WITH_SUBTITLES);
1105 Film::set_subtitle_offset (int o)
1108 boost::mutex::scoped_lock lm (_state_mutex);
1109 _subtitle_offset = o;
1111 signal_changed (SUBTITLE_OFFSET);
1115 Film::set_subtitle_scale (float s)
1118 boost::mutex::scoped_lock lm (_state_mutex);
1119 _subtitle_scale = s;
1121 signal_changed (SUBTITLE_SCALE);
1125 Film::set_audio_language (string l)
1128 boost::mutex::scoped_lock lm (_state_mutex);
1129 _audio_language = l;
1131 signal_changed (DCI_METADATA);
1135 Film::set_subtitle_language (string l)
1138 boost::mutex::scoped_lock lm (_state_mutex);
1139 _subtitle_language = l;
1141 signal_changed (DCI_METADATA);
1145 Film::set_territory (string t)
1148 boost::mutex::scoped_lock lm (_state_mutex);
1151 signal_changed (DCI_METADATA);
1155 Film::set_rating (string r)
1158 boost::mutex::scoped_lock lm (_state_mutex);
1161 signal_changed (DCI_METADATA);
1165 Film::set_studio (string s)
1168 boost::mutex::scoped_lock lm (_state_mutex);
1171 signal_changed (DCI_METADATA);
1175 Film::set_facility (string f)
1178 boost::mutex::scoped_lock lm (_state_mutex);
1181 signal_changed (DCI_METADATA);
1185 Film::set_package_type (string p)
1188 boost::mutex::scoped_lock lm (_state_mutex);
1191 signal_changed (DCI_METADATA);
1195 Film::set_thumbs (vector<int> t)
1198 boost::mutex::scoped_lock lm (_state_mutex);
1201 signal_changed (THUMBS);
1205 Film::set_size (Size s)
1208 boost::mutex::scoped_lock lm (_state_mutex);
1211 signal_changed (SIZE);
1215 Film::set_length (int l)
1218 boost::mutex::scoped_lock lm (_state_mutex);
1221 signal_changed (LENGTH);
1225 Film::unset_length ()
1228 boost::mutex::scoped_lock lm (_state_mutex);
1229 _length = boost::none;
1231 signal_changed (LENGTH);
1235 Film::set_audio_sample_rate (int r)
1238 boost::mutex::scoped_lock lm (_state_mutex);
1239 _audio_sample_rate = r;
1241 signal_changed (AUDIO_SAMPLE_RATE);
1245 Film::set_content_digest (string d)
1248 boost::mutex::scoped_lock lm (_state_mutex);
1249 _content_digest = d;
1255 Film::set_has_subtitles (bool s)
1258 boost::mutex::scoped_lock lm (_state_mutex);
1261 signal_changed (HAS_SUBTITLES);
1265 Film::set_audio_streams (vector<AudioStream> s)
1268 boost::mutex::scoped_lock lm (_state_mutex);
1275 Film::set_subtitle_streams (vector<SubtitleStream> s)
1278 boost::mutex::scoped_lock lm (_state_mutex);
1279 _subtitle_streams = s;
1285 Film::set_frames_per_second (float f)
1288 boost::mutex::scoped_lock lm (_state_mutex);
1289 _frames_per_second = f;
1291 signal_changed (FRAMES_PER_SECOND);
1295 Film::signal_changed (Property p)
1298 boost::mutex::scoped_lock lm (_state_mutex);
1303 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1308 Film::audio_channels () const
1310 boost::mutex::scoped_lock lm (_state_mutex);
1311 if (_audio_stream == -1) {
1315 return _audio_streams[_audio_stream].channels ();
1319 Film::set_dci_date_today ()
1321 _dci_date = boost::gregorian::day_clock::local_day ();