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;
67 using boost::shared_ptr;
68 using boost::lexical_cast;
69 using boost::to_upper_copy;
70 using boost::ends_with;
71 using boost::starts_with;
73 /** Construct a Film object in a given directory, reading any metadata
74 * file that exists in that directory. An exception will be thrown if
75 * must_exist is true and the specified directory does not exist.
77 * @param d Film directory.
78 * @param must_exist true to throw an exception if does not exist.
81 Film::Film (string d, bool must_exist)
82 : _use_dci_name (false)
83 , _dcp_content_type (0)
85 , _scaler (Scaler::from_id ("bicubic"))
92 , _still_duration (10)
93 , _subtitle_stream (-1)
94 , _with_subtitles (false)
95 , _subtitle_offset (0)
97 , _audio_sample_rate (0)
98 , _has_subtitles (false)
99 , _frames_per_second (0)
102 /* Make state.directory a complete path without ..s (where possible)
103 (Code swiped from Adam Bowen on stackoverflow)
106 boost::filesystem::path p (boost::filesystem::system_complete (d));
107 boost::filesystem::path result;
108 for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
110 if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
113 result = result.parent_path ();
115 } else if (*i != ".") {
120 set_directory (result.string ());
122 if (!boost::filesystem::exists (directory())) {
124 throw OpenFileError (directory());
126 boost::filesystem::create_directory (directory());
132 _log = new FileLog (file ("log"));
133 set_dci_date_today ();
136 Film::Film (Film const & o)
138 , _directory (o._directory)
140 , _use_dci_name (o._use_dci_name)
141 , _content (o._content)
142 , _dcp_content_type (o._dcp_content_type)
143 , _format (o._format)
145 , _filters (o._filters)
146 , _scaler (o._scaler)
147 , _dcp_trim_start (o._dcp_trim_start)
148 , _dcp_trim_end (o._dcp_trim_end)
149 , _dcp_ab (o._dcp_ab)
150 , _audio_stream (o._audio_stream)
151 , _audio_gain (o._audio_gain)
152 , _audio_delay (o._audio_delay)
153 , _still_duration (o._still_duration)
154 , _subtitle_stream (o._subtitle_stream)
155 , _with_subtitles (o._with_subtitles)
156 , _subtitle_offset (o._subtitle_offset)
157 , _subtitle_scale (o._subtitle_scale)
158 , _audio_language (o._audio_language)
159 , _subtitle_language (o._subtitle_language)
160 , _territory (o._territory)
161 , _rating (o._rating)
162 , _studio (o._studio)
163 , _facility (o._facility)
164 , _package_type (o._package_type)
165 , _thumbs (o._thumbs)
167 , _length (o._length)
168 , _audio_sample_rate (o._audio_sample_rate)
169 , _content_digest (o._content_digest)
170 , _has_subtitles (o._has_subtitles)
171 , _audio_streams (o._audio_streams)
172 , _subtitle_streams (o._subtitle_streams)
173 , _frames_per_second (o._frames_per_second)
184 /** @return The path to the directory to write JPEG2000 files to */
186 Film::j2k_dir () const
190 boost::filesystem::path p;
195 pair<string, string> f = Filter::ffmpeg_strings (filters());
197 /* Write stuff to specify the filter / post-processing settings that are in use,
198 so that we don't get confused about J2K files generated using different
203 << "_" << content_digest()
204 << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
205 << "_" << f.first << "_" << f.second
206 << "_" << scaler()->id();
210 /* Similarly for the A/B case */
213 pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
214 s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
218 return dir (p.string());
221 /** Add suitable Jobs to the JobManager to create a DCP for this Film.
222 * @param true to transcode, false to use the WAV and J2K files that are already there.
225 Film::make_dcp (bool transcode)
227 set_dci_date_today ();
229 if (dcp_name().find ("/") != string::npos) {
230 throw BadSettingError ("name", "cannot contain slashes");
233 log()->log (String::compose ("DVD-o-matic %1 git %2 using %3", dvdomatic_version, dvdomatic_git_commit, dependency_version_summary()));
237 gethostname (buffer, sizeof (buffer));
238 log()->log (String::compose ("Starting to make DCP on %1", buffer));
242 throw MissingSettingError ("format");
245 if (content().empty ()) {
246 throw MissingSettingError ("content");
249 if (dcp_content_type() == 0) {
250 throw MissingSettingError ("content type");
253 if (name().empty()) {
254 throw MissingSettingError ("name");
257 shared_ptr<Options> o (new Options (j2k_dir(), ".j2c", dir ("wavs")));
258 o->out_size = format()->dcp_size ();
259 o->padding = format()->dcp_padding (shared_from_this ());
260 o->ratio = format()->ratio_as_float (shared_from_this ());
262 o->video_decode_range = make_pair (dcp_trim_start(), dcp_trim_start() + dcp_length().get());
263 o->audio_decode_range = make_pair (
264 video_frames_to_audio_frames (o->video_decode_range.get().first, audio_sample_rate(), frames_per_second()),
265 video_frames_to_audio_frames (o->video_decode_range.get().second, audio_sample_rate(), frames_per_second())
269 o->decode_subtitles = with_subtitles ();
270 o->decode_video_skip = dcp_frame_rate (frames_per_second()).skip;
276 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
278 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), o, shared_ptr<Job> ())));
282 r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (shared_from_this(), o, r)));
283 JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r)));
286 /** Start a job to examine our content file */
288 Film::examine_content ()
290 if (_examine_content_job) {
294 set_thumbs (vector<SourceFrame> ());
295 boost::filesystem::remove_all (dir ("thumbs"));
297 /* This call will recreate the directory */
300 _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ()));
301 _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this));
302 JobManager::instance()->add (_examine_content_job);
306 Film::examine_content_finished ()
308 _examine_content_job.reset ();
311 /** @return full paths to any audio files that this Film has */
313 Film::audio_files () const
316 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) {
317 f.push_back (i->path().string ());
323 /** Start a job to send our DCP to the configured TMS */
325 Film::send_dcp_to_tms ()
327 shared_ptr<Job> j (new SCPDCPJob (shared_from_this(), shared_ptr<Job> ()));
328 JobManager::instance()->add (j);
332 Film::copy_from_dvd ()
334 shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ()));
335 JobManager::instance()->add (j);
338 /** Count the number of frames that have been encoded for this film.
339 * @return frame count.
342 Film::encoded_frames () const
349 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
351 boost::this_thread::interruption_point ();
357 /** Return the filename of a subtitle image if one exists for a given thumb index.
358 * @param Thumbnail index.
359 * @return Position of the image within the source frame, and the image filename, if one exists.
360 * Otherwise the filename will be empty.
362 pair<Position, string>
363 Film::thumb_subtitle (int n) const
365 string sub_file = thumb_base(n) + ".sub";
366 if (!boost::filesystem::exists (sub_file)) {
367 return pair<Position, string> ();
370 pair<Position, string> sub;
372 ifstream f (sub_file.c_str ());
373 multimap<string, string> kv = read_key_value (f);
374 for (map<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
375 if (i->first == "x") {
376 sub.first.x = lexical_cast<int> (i->second);
377 } else if (i->first == "y") {
378 sub.first.y = lexical_cast<int> (i->second);
379 sub.second = String::compose ("%1.sub.png", thumb_base(n));
386 /** Write state to our `metadata' file */
388 Film::write_metadata () const
390 boost::mutex::scoped_lock lm (_state_mutex);
392 boost::filesystem::create_directories (directory());
394 string const m = file ("metadata");
395 ofstream f (m.c_str ());
397 throw CreateFileError (m);
401 f << "name " << _name << "\n";
402 f << "use_dci_name " << _use_dci_name << "\n";
403 f << "content " << _content << "\n";
404 if (_dcp_content_type) {
405 f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
408 f << "format " << _format->as_metadata () << "\n";
410 f << "left_crop " << _crop.left << "\n";
411 f << "right_crop " << _crop.right << "\n";
412 f << "top_crop " << _crop.top << "\n";
413 f << "bottom_crop " << _crop.bottom << "\n";
414 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
415 f << "filter " << (*i)->id () << "\n";
417 f << "scaler " << _scaler->id () << "\n";
418 f << "dcp_trim_start " << _dcp_trim_start << "\n";
419 f << "dcp_trim_end " << _dcp_trim_end << "\n";
420 f << "dcp_ab " << (_dcp_ab ? "1" : "0") << "\n";
421 f << "selected_audio_stream " << _audio_stream << "\n";
422 f << "audio_gain " << _audio_gain << "\n";
423 f << "audio_delay " << _audio_delay << "\n";
424 f << "still_duration " << _still_duration << "\n";
425 f << "selected_subtitle_stream " << _subtitle_stream << "\n";
426 f << "with_subtitles " << _with_subtitles << "\n";
427 f << "subtitle_offset " << _subtitle_offset << "\n";
428 f << "subtitle_scale " << _subtitle_scale << "\n";
429 f << "audio_language " << _audio_language << "\n";
430 f << "subtitle_language " << _subtitle_language << "\n";
431 f << "territory " << _territory << "\n";
432 f << "rating " << _rating << "\n";
433 f << "studio " << _studio << "\n";
434 f << "facility " << _facility << "\n";
435 f << "package_type " << _package_type << "\n";
437 /* Cached stuff; this is information about our content; we could
438 look it up each time, but that's slow.
440 for (vector<SourceFrame>::const_iterator i = _thumbs.begin(); i != _thumbs.end(); ++i) {
441 f << "thumb " << *i << "\n";
443 f << "width " << _size.width << "\n";
444 f << "height " << _size.height << "\n";
445 f << "length " << _length.get_value_or(0) << "\n";
446 f << "audio_sample_rate " << _audio_sample_rate << "\n";
447 f << "content_digest " << _content_digest << "\n";
448 f << "has_subtitles " << _has_subtitles << "\n";
450 for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
451 f << "audio_stream " << i->to_string () << "\n";
454 for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
455 f << "subtitle_stream " << i->to_string () << "\n";
458 f << "frames_per_second " << _frames_per_second << "\n";
463 /** Read state from our metadata file */
465 Film::read_metadata ()
467 boost::mutex::scoped_lock lm (_state_mutex);
469 ifstream f (file ("metadata").c_str());
470 multimap<string, string> kv = read_key_value (f);
471 for (multimap<string, string>::const_iterator i = kv.begin(); i != kv.end(); ++i) {
472 string const k = i->first;
473 string const v = i->second;
475 /* User-specified stuff */
478 } else if (k == "use_dci_name") {
479 _use_dci_name = (v == "1");
480 } else if (k == "content") {
482 } else if (k == "dcp_content_type") {
483 _dcp_content_type = DCPContentType::from_pretty_name (v);
484 } else if (k == "format") {
485 _format = Format::from_metadata (v);
486 } else if (k == "left_crop") {
487 _crop.left = atoi (v.c_str ());
488 } else if (k == "right_crop") {
489 _crop.right = atoi (v.c_str ());
490 } else if (k == "top_crop") {
491 _crop.top = atoi (v.c_str ());
492 } else if (k == "bottom_crop") {
493 _crop.bottom = atoi (v.c_str ());
494 } else if (k == "filter") {
495 _filters.push_back (Filter::from_id (v));
496 } else if (k == "scaler") {
497 _scaler = Scaler::from_id (v);
498 } else if (k == "dcp_trim_start") {
499 _dcp_trim_start = atoi (v.c_str ());
500 } else if (k == "dcp_trim_end") {
501 _dcp_trim_end = atoi (v.c_str ());
502 } else if (k == "dcp_ab") {
503 _dcp_ab = (v == "1");
504 } else if (k == "selected_audio_stream") {
505 _audio_stream = atoi (v.c_str ());
506 } else if (k == "audio_gain") {
507 _audio_gain = atof (v.c_str ());
508 } else if (k == "audio_delay") {
509 _audio_delay = atoi (v.c_str ());
510 } else if (k == "still_duration") {
511 _still_duration = atoi (v.c_str ());
512 } else if (k == "selected_subtitle_stream") {
513 _subtitle_stream = atoi (v.c_str ());
514 } else if (k == "with_subtitles") {
515 _with_subtitles = (v == "1");
516 } else if (k == "subtitle_offset") {
517 _subtitle_offset = atoi (v.c_str ());
518 } else if (k == "subtitle_scale") {
519 _subtitle_scale = atof (v.c_str ());
520 } else if (k == "audio_language") {
522 } else if (k == "subtitle_language") {
523 _subtitle_language = v;
524 } else if (k == "territory") {
526 } else if (k == "rating") {
528 } else if (k == "studio") {
530 } else if (k == "facility") {
532 } else if (k == "package_type") {
538 int const n = atoi (v.c_str ());
539 /* Only add it to the list if it still exists */
540 if (boost::filesystem::exists (thumb_file_for_frame (n))) {
541 _thumbs.push_back (n);
543 } else if (k == "width") {
544 _size.width = atoi (v.c_str ());
545 } else if (k == "height") {
546 _size.height = atoi (v.c_str ());
547 } else if (k == "length") {
548 int const vv = atoi (v.c_str ());
552 } else if (k == "audio_sample_rate") {
553 _audio_sample_rate = atoi (v.c_str ());
554 } else if (k == "content_digest") {
556 } else if (k == "has_subtitles") {
557 _has_subtitles = (v == "1");
558 } else if (k == "audio_stream") {
559 _audio_streams.push_back (AudioStream (v));
560 } else if (k == "subtitle_stream") {
561 _subtitle_streams.push_back (SubtitleStream (v));
562 } else if (k == "frames_per_second") {
563 _frames_per_second = atof (v.c_str ());
570 /** @param n A thumb index.
571 * @return The path to the thumb's image file.
574 Film::thumb_file (int n) const
576 return thumb_file_for_frame (thumb_frame (n));
579 /** @param n A frame index within the Film's source.
580 * @return The path to the thumb's image file for this frame;
581 * we assume that it exists.
584 Film::thumb_file_for_frame (SourceFrame n) const
586 return thumb_base_for_frame(n) + ".png";
589 /** @param n Thumb index.
590 * Must not be called with the _state_mutex locked.
593 Film::thumb_base (int n) const
595 return thumb_base_for_frame (thumb_frame (n));
599 Film::thumb_base_for_frame (SourceFrame n) const
603 s << setfill('0') << n;
605 boost::filesystem::path p;
612 /** @param n A thumb index.
613 * @return The frame within the Film's source that it is for.
615 * Must not be called with the _state_mutex locked.
618 Film::thumb_frame (int n) const
620 boost::mutex::scoped_lock lm (_state_mutex);
621 assert (n < int (_thumbs.size ()));
626 Film::cropped_size (Size s) const
628 boost::mutex::scoped_lock lm (_state_mutex);
629 s.width -= _crop.left + _crop.right;
630 s.height -= _crop.top + _crop.bottom;
634 /** Given a directory name, return its full path within the Film's directory.
635 * The directory (and its parents) will be created if they do not exist.
638 Film::dir (string d) const
640 boost::mutex::scoped_lock lm (_directory_mutex);
641 boost::filesystem::path p;
644 boost::filesystem::create_directories (p);
648 /** Given a file or directory name, return its full path within the Film's directory.
649 * _directory_mutex must not be locked on entry.
652 Film::file (string f) const
654 boost::mutex::scoped_lock lm (_directory_mutex);
655 boost::filesystem::path p;
661 /** @return full path of the content (actual video) file
665 Film::content_path () const
667 boost::mutex::scoped_lock lm (_state_mutex);
668 if (boost::filesystem::path(_content).has_root_directory ()) {
672 return file (_content);
676 Film::content_type () const
678 #if BOOST_FILESYSTEM_VERSION == 3
679 string ext = boost::filesystem::path(_content).extension().string();
681 string ext = boost::filesystem::path(_content).extension();
684 transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
686 if (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") {
693 /** @return The sampling rate that we will resample the audio to */
695 Film::target_audio_sample_rate () const
697 /* Resample to a DCI-approved sample rate */
698 double t = dcp_audio_sample_rate (audio_sample_rate());
700 DCPFrameRate dfr = dcp_frame_rate (frames_per_second ());
702 /* Compensate for the fact that video will be rounded to the
703 nearest integer number of frames per second.
706 t *= _frames_per_second * dfr.skip / dfr.frames_per_second;
712 boost::optional<SourceFrame>
713 Film::dcp_length () const
716 return boost::optional<SourceFrame> ();
719 return length().get() - dcp_trim_start() - dcp_trim_end();
722 /** @return a DCI-compliant name for a DCP of this film */
724 Film::dci_name () const
726 boost::mutex::scoped_lock lm (_state_mutex);
730 string fixed_name = to_upper_copy (_name);
731 for (size_t i = 0; i < fixed_name.length(); ++i) {
732 if (fixed_name[i] == ' ') {
737 /* Spec is that the name part should be maximum 14 characters, as I understand it */
738 if (fixed_name.length() > 14) {
739 fixed_name = fixed_name.substr (0, 14);
742 d << fixed_name << "_";
744 if (_dcp_content_type) {
745 d << _dcp_content_type->dci_name() << "_";
749 d << _format->dci_name() << "_";
752 if (!_audio_language.empty ()) {
753 d << _audio_language;
754 if (!_subtitle_language.empty() && _with_subtitles) {
755 d << "-" << _subtitle_language;
763 if (!_territory.empty ()) {
765 if (!_rating.empty ()) {
771 if (_audio_stream != -1) {
772 switch (_audio_streams[_audio_stream].channels()) {
790 if (!_studio.empty ()) {
794 d << boost::gregorian::to_iso_string (_dci_date) << "_";
796 if (!_facility.empty ()) {
797 d << _facility << "_";
800 if (!_package_type.empty ()) {
807 /** @return name to give the DCP */
809 Film::dcp_name () const
811 if (use_dci_name()) {
820 Film::set_directory (string d)
822 boost::mutex::scoped_lock lm (_state_mutex);
828 Film::set_name (string n)
831 boost::mutex::scoped_lock lm (_state_mutex);
834 signal_changed (NAME);
838 Film::set_use_dci_name (bool u)
841 boost::mutex::scoped_lock lm (_state_mutex);
844 signal_changed (USE_DCI_NAME);
848 Film::set_content (string c)
850 string check = directory ();
852 #if BOOST_FILESYSTEM_VERSION == 3
853 boost::filesystem::path slash ("/");
854 string platform_slash = slash.make_preferred().string ();
856 #ifdef DVDOMATIC_WINDOWS
857 string platform_slash = "\\";
859 string platform_slash = "/";
863 if (!ends_with (check, platform_slash)) {
864 check += platform_slash;
867 if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) {
868 c = c.substr (_directory.length() + 1);
874 boost::mutex::scoped_lock lm (_state_mutex);
879 old_content = _content;
883 /* Create a temporary decoder so that we can get information
888 shared_ptr<Options> o (new Options ("", "", ""));
889 o->out_size = Size (1024, 1024);
891 shared_ptr<Decoder> d = decoder_factory (shared_from_this(), o, 0);
893 set_size (d->native_size ());
894 set_frames_per_second (d->frames_per_second ());
895 set_audio_sample_rate (d->audio_sample_rate ());
896 set_has_subtitles (d->has_subtitles ());
897 set_audio_streams (d->audio_streams ());
898 set_subtitle_streams (d->subtitle_streams ());
899 set_audio_stream (audio_streams().empty() ? -1 : 0);
900 set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
903 boost::mutex::scoped_lock lm (_state_mutex);
907 signal_changed (CONTENT);
909 set_content_digest (md5_digest (content_path ()));
915 boost::mutex::scoped_lock lm (_state_mutex);
916 _content = old_content;
923 Film::set_dcp_content_type (DCPContentType const * t)
926 boost::mutex::scoped_lock lm (_state_mutex);
927 _dcp_content_type = t;
929 signal_changed (DCP_CONTENT_TYPE);
933 Film::set_format (Format const * f)
936 boost::mutex::scoped_lock lm (_state_mutex);
939 signal_changed (FORMAT);
943 Film::set_crop (Crop c)
946 boost::mutex::scoped_lock lm (_state_mutex);
949 signal_changed (CROP);
953 Film::set_left_crop (int c)
956 boost::mutex::scoped_lock lm (_state_mutex);
958 if (_crop.left == c) {
964 signal_changed (CROP);
968 Film::set_right_crop (int c)
971 boost::mutex::scoped_lock lm (_state_mutex);
972 if (_crop.right == c) {
978 signal_changed (CROP);
982 Film::set_top_crop (int c)
985 boost::mutex::scoped_lock lm (_state_mutex);
986 if (_crop.top == c) {
992 signal_changed (CROP);
996 Film::set_bottom_crop (int c)
999 boost::mutex::scoped_lock lm (_state_mutex);
1000 if (_crop.bottom == c) {
1006 signal_changed (CROP);
1010 Film::set_filters (vector<Filter const *> f)
1013 boost::mutex::scoped_lock lm (_state_mutex);
1016 signal_changed (FILTERS);
1020 Film::set_scaler (Scaler const * s)
1023 boost::mutex::scoped_lock lm (_state_mutex);
1026 signal_changed (SCALER);
1030 Film::set_dcp_trim_start (int t)
1033 boost::mutex::scoped_lock lm (_state_mutex);
1034 _dcp_trim_start = t;
1036 signal_changed (DCP_TRIM_START);
1040 Film::set_dcp_trim_end (int t)
1043 boost::mutex::scoped_lock lm (_state_mutex);
1046 signal_changed (DCP_TRIM_END);
1050 Film::set_dcp_ab (bool a)
1053 boost::mutex::scoped_lock lm (_state_mutex);
1056 signal_changed (DCP_AB);
1060 Film::set_audio_stream (int s)
1063 boost::mutex::scoped_lock lm (_state_mutex);
1066 signal_changed (AUDIO_STREAM);
1070 Film::set_audio_gain (float g)
1073 boost::mutex::scoped_lock lm (_state_mutex);
1076 signal_changed (AUDIO_GAIN);
1080 Film::set_audio_delay (int d)
1083 boost::mutex::scoped_lock lm (_state_mutex);
1086 signal_changed (AUDIO_DELAY);
1090 Film::set_still_duration (int d)
1093 boost::mutex::scoped_lock lm (_state_mutex);
1094 _still_duration = d;
1096 signal_changed (STILL_DURATION);
1100 Film::set_subtitle_stream (int s)
1103 boost::mutex::scoped_lock lm (_state_mutex);
1104 _subtitle_stream = s;
1106 signal_changed (SUBTITLE_STREAM);
1110 Film::set_with_subtitles (bool w)
1113 boost::mutex::scoped_lock lm (_state_mutex);
1114 _with_subtitles = w;
1116 signal_changed (WITH_SUBTITLES);
1120 Film::set_subtitle_offset (int o)
1123 boost::mutex::scoped_lock lm (_state_mutex);
1124 _subtitle_offset = o;
1126 signal_changed (SUBTITLE_OFFSET);
1130 Film::set_subtitle_scale (float s)
1133 boost::mutex::scoped_lock lm (_state_mutex);
1134 _subtitle_scale = s;
1136 signal_changed (SUBTITLE_SCALE);
1140 Film::set_audio_language (string l)
1143 boost::mutex::scoped_lock lm (_state_mutex);
1144 _audio_language = l;
1146 signal_changed (DCI_METADATA);
1150 Film::set_subtitle_language (string l)
1153 boost::mutex::scoped_lock lm (_state_mutex);
1154 _subtitle_language = l;
1156 signal_changed (DCI_METADATA);
1160 Film::set_territory (string t)
1163 boost::mutex::scoped_lock lm (_state_mutex);
1166 signal_changed (DCI_METADATA);
1170 Film::set_rating (string r)
1173 boost::mutex::scoped_lock lm (_state_mutex);
1176 signal_changed (DCI_METADATA);
1180 Film::set_studio (string s)
1183 boost::mutex::scoped_lock lm (_state_mutex);
1186 signal_changed (DCI_METADATA);
1190 Film::set_facility (string f)
1193 boost::mutex::scoped_lock lm (_state_mutex);
1196 signal_changed (DCI_METADATA);
1200 Film::set_package_type (string p)
1203 boost::mutex::scoped_lock lm (_state_mutex);
1206 signal_changed (DCI_METADATA);
1210 Film::set_thumbs (vector<SourceFrame> t)
1213 boost::mutex::scoped_lock lm (_state_mutex);
1216 signal_changed (THUMBS);
1220 Film::set_size (Size s)
1223 boost::mutex::scoped_lock lm (_state_mutex);
1226 signal_changed (SIZE);
1230 Film::set_length (SourceFrame l)
1233 boost::mutex::scoped_lock lm (_state_mutex);
1236 signal_changed (LENGTH);
1240 Film::unset_length ()
1243 boost::mutex::scoped_lock lm (_state_mutex);
1244 _length = boost::none;
1246 signal_changed (LENGTH);
1250 Film::set_audio_sample_rate (int r)
1253 boost::mutex::scoped_lock lm (_state_mutex);
1254 _audio_sample_rate = r;
1256 signal_changed (AUDIO_SAMPLE_RATE);
1260 Film::set_content_digest (string d)
1263 boost::mutex::scoped_lock lm (_state_mutex);
1264 _content_digest = d;
1270 Film::set_has_subtitles (bool s)
1273 boost::mutex::scoped_lock lm (_state_mutex);
1276 signal_changed (HAS_SUBTITLES);
1280 Film::set_audio_streams (vector<AudioStream> s)
1283 boost::mutex::scoped_lock lm (_state_mutex);
1290 Film::set_subtitle_streams (vector<SubtitleStream> s)
1293 boost::mutex::scoped_lock lm (_state_mutex);
1294 _subtitle_streams = s;
1300 Film::set_frames_per_second (float f)
1303 boost::mutex::scoped_lock lm (_state_mutex);
1304 _frames_per_second = f;
1306 signal_changed (FRAMES_PER_SECOND);
1310 Film::signal_changed (Property p)
1313 boost::mutex::scoped_lock lm (_state_mutex);
1318 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1323 Film::audio_channels () const
1325 boost::mutex::scoped_lock lm (_state_mutex);
1326 if (_audio_stream == -1) {
1330 return _audio_streams[_audio_stream].channels ();
1334 Film::set_dci_date_today ()
1336 _dci_date = boost::gregorian::day_clock::local_day ();