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>
32 #include <libxml++/libxml++.h>
33 #include <libcxml/cxml.h>
39 #include "job_manager.h"
40 #include "ab_transcode_job.h"
41 #include "transcode_job.h"
42 #include "scp_dcp_job.h"
44 #include "exceptions.h"
45 #include "examine_content_job.h"
49 #include "ui_signaller.h"
50 #include "analyse_audio_job.h"
53 #include "ffmpeg_content.h"
54 #include "imagemagick_content.h"
55 #include "sndfile_content.h"
56 #include "dcp_content_type.h"
61 using std::stringstream;
74 using boost::shared_ptr;
75 using boost::lexical_cast;
76 using boost::to_upper_copy;
77 using boost::ends_with;
78 using boost::starts_with;
79 using boost::optional;
82 int const Film::state_version = 4;
84 /** Construct a Film object in a given directory, reading any metadata
85 * file that exists in that directory. An exception will be thrown if
86 * must_exist is true and the specified directory does not exist.
88 * @param d Film directory.
89 * @param must_exist true to throw an exception if does not exist.
92 Film::Film (string d, bool must_exist)
93 : _playlist (new Playlist)
94 , _use_dci_name (true)
95 , _trust_content_headers (true)
96 , _dcp_content_type (Config::instance()->default_dcp_content_type ())
97 , _format (Config::instance()->default_format ())
98 , _scaler (Scaler::from_id ("bicubic"))
105 , _with_subtitles (false)
106 , _subtitle_offset (0)
107 , _subtitle_scale (1)
109 , _j2k_bandwidth (200000000)
110 , _dci_metadata (Config::instance()->default_dci_metadata ())
111 , _dcp_frame_rate (0)
114 set_dci_date_today ();
116 _playlist->Changed.connect (bind (&Film::playlist_changed, this));
117 _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
119 /* Make state.directory a complete path without ..s (where possible)
120 (Code swiped from Adam Bowen on stackoverflow)
123 boost::filesystem::path p (boost::filesystem::system_complete (d));
124 boost::filesystem::path result;
125 for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
127 if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
130 result = result.parent_path ();
132 } else if (*i != ".") {
137 set_directory (result.string ());
139 if (!boost::filesystem::exists (directory())) {
141 throw OpenFileError (directory());
143 boost::filesystem::create_directory (directory());
153 _log.reset (new FileLog (file ("log")));
156 Film::Film (Film const & o)
157 : boost::enable_shared_from_this<Film> (o)
158 /* note: the copied film shares the original's log */
160 , _playlist (new Playlist (o._playlist))
161 , _directory (o._directory)
163 , _use_dci_name (o._use_dci_name)
164 , _trust_content_headers (o._trust_content_headers)
165 , _dcp_content_type (o._dcp_content_type)
166 , _format (o._format)
168 , _filters (o._filters)
169 , _scaler (o._scaler)
170 , _trim_start (o._trim_start)
171 , _trim_end (o._trim_end)
172 , _trim_type (o._trim_type)
174 , _audio_gain (o._audio_gain)
175 , _audio_delay (o._audio_delay)
176 , _with_subtitles (o._with_subtitles)
177 , _subtitle_offset (o._subtitle_offset)
178 , _subtitle_scale (o._subtitle_scale)
179 , _colour_lut (o._colour_lut)
180 , _j2k_bandwidth (o._j2k_bandwidth)
181 , _dci_metadata (o._dci_metadata)
182 , _dcp_frame_rate (o._dcp_frame_rate)
183 , _dci_date (o._dci_date)
186 _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
190 Film::video_state_identifier () const
195 pair<string, string> f = Filter::ffmpeg_strings (filters());
199 << "_" << _playlist->video_digest()
200 << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
201 << "_" << _dcp_frame_rate
202 << "_" << f.first << "_" << f.second
203 << "_" << scaler()->id()
204 << "_" << j2k_bandwidth()
205 << "_" << boost::lexical_cast<int> (colour_lut());
208 pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
209 s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
215 /** @return The path to the directory to write video frame info files to */
217 Film::info_dir () const
219 boost::filesystem::path p;
221 p /= video_state_identifier ();
222 return dir (p.string());
226 Film::internal_video_mxf_dir () const
228 boost::filesystem::path p;
229 return dir ("video");
233 Film::internal_video_mxf_filename () const
235 return video_state_identifier() + ".mxf";
239 Film::dcp_video_mxf_filename () const
241 return filename_safe_name() + "_video.mxf";
245 Film::dcp_audio_mxf_filename () const
247 return filename_safe_name() + "_audio.mxf";
251 Film::filename_safe_name () const
253 string const n = name ();
255 for (size_t i = 0; i < n.length(); ++i) {
256 if (isalnum (n[i])) {
267 Film::audio_analysis_path () const
269 boost::filesystem::path p;
271 p /= _playlist->audio_digest();
272 return file (p.string ());
275 /** Add suitable Jobs to the JobManager to create a DCP for this Film */
279 set_dci_date_today ();
281 if (dcp_name().find ("/") != string::npos) {
282 throw BadSettingError (_("name"), _("cannot contain slashes"));
285 log()->log (String::compose ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()));
289 gethostname (buffer, sizeof (buffer));
290 log()->log (String::compose ("Starting to make DCP on %1", buffer));
293 // log()->log (String::compose ("Content is %1; type %2", content_path(), (content_type() == STILL ? _("still") : _("video"))));
295 // log()->log (String::compose ("Content length %1", length().get()));
297 // log()->log (String::compose ("Content digest %1", content_digest()));
298 // log()->log (String::compose ("Content at %1 fps, DCP at %2 fps", source_frame_rate(), dcp_frame_rate()));
299 log()->log (String::compose ("%1 threads", Config::instance()->num_local_encoding_threads()));
300 log()->log (String::compose ("J2K bandwidth %1", j2k_bandwidth()));
301 #ifdef DCPOMATIC_DEBUG
302 log()->log ("DCP-o-matic built in debug mode.");
304 log()->log ("DCP-o-matic built in optimised mode.");
307 log()->log ("libdcp built in debug mode.");
309 log()->log ("libdcp built in optimised mode.");
311 pair<string, int> const c = cpu_info ();
312 log()->log (String::compose ("CPU: %1, %2 processors", c.first, c.second));
315 throw MissingSettingError (_("format"));
318 if (_playlist->content().empty ()) {
319 throw MissingSettingError (_("content"));
322 if (dcp_content_type() == 0) {
323 throw MissingSettingError (_("content type"));
326 if (name().empty()) {
327 throw MissingSettingError (_("name"));
333 r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this())));
335 r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this())));
339 /** Start a job to analyse the audio in our Playlist */
341 Film::analyse_audio ()
343 if (_analyse_audio_job) {
347 _analyse_audio_job.reset (new AnalyseAudioJob (shared_from_this()));
348 _analyse_audio_job->Finished.connect (bind (&Film::analyse_audio_finished, this));
349 JobManager::instance()->add (_analyse_audio_job);
352 /** Start a job to examine a piece of content */
354 Film::examine_content (shared_ptr<Content> c)
356 shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c, trust_content_headers ()));
357 JobManager::instance()->add (j);
361 Film::analyse_audio_finished ()
365 if (_analyse_audio_job->finished_ok ()) {
366 AudioAnalysisSucceeded ();
369 _analyse_audio_job.reset ();
372 /** Start a job to send our DCP to the configured TMS */
374 Film::send_dcp_to_tms ()
376 shared_ptr<Job> j (new SCPDCPJob (shared_from_this()));
377 JobManager::instance()->add (j);
380 /** Count the number of frames that have been encoded for this film.
381 * @return frame count.
384 Film::encoded_frames () const
391 for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (info_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
393 boost::this_thread::interruption_point ();
399 /** Write state to our `metadata' file */
401 Film::write_metadata () const
403 boost::mutex::scoped_lock lm (_state_mutex);
406 boost::filesystem::create_directories (directory());
409 xmlpp::Element* root = doc.create_root_node ("Metadata");
411 root->add_child("Version")->add_child_text (boost::lexical_cast<string> (state_version));
412 root->add_child("Name")->add_child_text (_name);
413 root->add_child("UseDCIName")->add_child_text (_use_dci_name ? "1" : "0");
414 root->add_child("TrustContentHeaders")->add_child_text (_trust_content_headers ? "1" : "0");
416 if (_dcp_content_type) {
417 root->add_child("DCPContentType")->add_child_text (_dcp_content_type->dci_name ());
421 root->add_child("Format")->add_child_text (_format->id ());
424 switch (_trim_type) {
426 root->add_child("TrimType")->add_child_text ("CPL");
429 root->add_child("TrimType")->add_child_text ("Encode");
432 root->add_child("LeftCrop")->add_child_text (boost::lexical_cast<string> (_crop.left));
433 root->add_child("RightCrop")->add_child_text (boost::lexical_cast<string> (_crop.right));
434 root->add_child("TopCrop")->add_child_text (boost::lexical_cast<string> (_crop.top));
435 root->add_child("BottomCrop")->add_child_text (boost::lexical_cast<string> (_crop.bottom));
437 for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
438 root->add_child("Filter")->add_child_text ((*i)->id ());
441 root->add_child("Scaler")->add_child_text (_scaler->id ());
442 root->add_child("TrimStart")->add_child_text (boost::lexical_cast<string> (_trim_start));
443 root->add_child("TrimEnd")->add_child_text (boost::lexical_cast<string> (_trim_end));
444 root->add_child("AB")->add_child_text (_ab ? "1" : "0");
445 root->add_child("AudioGain")->add_child_text (boost::lexical_cast<string> (_audio_gain));
446 root->add_child("AudioDelay")->add_child_text (boost::lexical_cast<string> (_audio_delay));
447 root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0");
448 root->add_child("SubtitleOffset")->add_child_text (boost::lexical_cast<string> (_subtitle_offset));
449 root->add_child("SubtitleScale")->add_child_text (boost::lexical_cast<string> (_subtitle_scale));
450 root->add_child("ColourLUT")->add_child_text (boost::lexical_cast<string> (_colour_lut));
451 root->add_child("J2KBandwidth")->add_child_text (boost::lexical_cast<string> (_j2k_bandwidth));
452 _dci_metadata.as_xml (root->add_child ("DCIMetadata"));
453 root->add_child("DCPFrameRate")->add_child_text (boost::lexical_cast<string> (_dcp_frame_rate));
454 root->add_child("DCIDate")->add_child_text (boost::gregorian::to_iso_string (_dci_date));
455 _audio_mapping.as_xml (root->add_child("AudioMapping"));
456 _playlist->as_xml (root->add_child ("Playlist"));
458 doc.write_to_file_formatted (file ("metadata.xml"));
463 /** Read state from our metadata file */
465 Film::read_metadata ()
467 boost::mutex::scoped_lock lm (_state_mutex);
470 if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file ("metadata.xml"))) {
471 throw StringError (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version. You will need to create a new Film, re-add your content and set it up again. Sorry!"));
474 cxml::File f (file ("metadata.xml"), "Metadata");
476 _name = f.string_child ("Name");
477 _use_dci_name = f.bool_child ("UseDCIName");
478 _trust_content_headers = f.bool_child ("TrustContentHeaders");
481 optional<string> c = f.optional_string_child ("DCPContentType");
483 _dcp_content_type = DCPContentType::from_dci_name (c.get ());
488 optional<string> c = f.optional_string_child ("Format");
490 _format = Format::from_id (c.get ());
495 optional<string> c = f.optional_string_child ("TrimType");
496 if (!c || c.get() == "CPL") {
498 } else if (c && c.get() == "Encode") {
503 _crop.left = f.number_child<int> ("LeftCrop");
504 _crop.right = f.number_child<int> ("RightCrop");
505 _crop.top = f.number_child<int> ("TopCrop");
506 _crop.bottom = f.number_child<int> ("BottomCrop");
509 list<shared_ptr<cxml::Node> > c = f.node_children ("Filter");
510 for (list<shared_ptr<cxml::Node> >::iterator i = c.begin(); i != c.end(); ++i) {
511 _filters.push_back (Filter::from_id ((*i)->content ()));
515 _scaler = Scaler::from_id (f.string_child ("Scaler"));
516 _trim_start = f.number_child<int> ("TrimStart");
517 _trim_end = f.number_child<int> ("TrimEnd");
518 _ab = f.bool_child ("AB");
519 _audio_gain = f.number_child<float> ("AudioGain");
520 _audio_delay = f.number_child<int> ("AudioDelay");
521 _with_subtitles = f.bool_child ("WithSubtitles");
522 _subtitle_offset = f.number_child<float> ("SubtitleOffset");
523 _subtitle_scale = f.number_child<float> ("SubtitleScale");
524 _colour_lut = f.number_child<int> ("ColourLUT");
525 _j2k_bandwidth = f.number_child<int> ("J2KBandwidth");
526 _dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
527 _dcp_frame_rate = f.number_child<int> ("DCPFrameRate");
528 _dci_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
530 _playlist->set_from_xml (f.node_child ("Playlist"));
531 _audio_mapping.set_from_xml (_playlist->content(), f.node_child ("AudioMapping"));
537 Film::cropped_size (libdcp::Size s) const
539 boost::mutex::scoped_lock lm (_state_mutex);
540 s.width -= _crop.left + _crop.right;
541 s.height -= _crop.top + _crop.bottom;
545 /** Given a directory name, return its full path within the Film's directory.
546 * The directory (and its parents) will be created if they do not exist.
549 Film::dir (string d) const
551 boost::mutex::scoped_lock lm (_directory_mutex);
553 boost::filesystem::path p;
557 boost::filesystem::create_directories (p);
562 /** Given a file or directory name, return its full path within the Film's directory.
563 * _directory_mutex must not be locked on entry.
564 * Any required parent directories will be created.
567 Film::file (string f) const
569 boost::mutex::scoped_lock lm (_directory_mutex);
571 boost::filesystem::path p;
575 boost::filesystem::create_directories (p.parent_path ());
580 /** @return The sampling rate that we will resample the audio to */
582 Film::target_audio_sample_rate () const
588 /* Resample to a DCI-approved sample rate */
589 double t = dcp_audio_sample_rate (audio_frame_rate());
591 FrameRateConversion frc (video_frame_rate(), dcp_frame_rate());
593 /* Compensate if the DCP is being run at a different frame rate
594 to the source; that is, if the video is run such that it will
595 look different in the DCP compared to the source (slower or faster).
596 skip/repeat doesn't come into effect here.
599 if (frc.change_speed) {
600 t *= video_frame_rate() * frc.factor() / dcp_frame_rate();
606 /** @return a DCI-compliant name for a DCP of this film */
608 Film::dci_name (bool if_created_now) const
612 string fixed_name = to_upper_copy (name());
613 for (size_t i = 0; i < fixed_name.length(); ++i) {
614 if (fixed_name[i] == ' ') {
619 /* Spec is that the name part should be maximum 14 characters, as I understand it */
620 if (fixed_name.length() > 14) {
621 fixed_name = fixed_name.substr (0, 14);
626 if (dcp_content_type()) {
627 d << "_" << dcp_content_type()->dci_name();
631 d << "_" << format()->dci_name();
634 DCIMetadata const dm = dci_metadata ();
636 if (!dm.audio_language.empty ()) {
637 d << "_" << dm.audio_language;
638 if (!dm.subtitle_language.empty()) {
639 d << "-" << dm.subtitle_language;
645 if (!dm.territory.empty ()) {
646 d << "_" << dm.territory;
647 if (!dm.rating.empty ()) {
648 d << "-" << dm.rating;
652 switch (audio_channels ()) {
669 if (!dm.studio.empty ()) {
670 d << "_" << dm.studio;
673 if (if_created_now) {
674 d << "_" << boost::gregorian::to_iso_string (boost::gregorian::day_clock::local_day ());
676 d << "_" << boost::gregorian::to_iso_string (_dci_date);
679 if (!dm.facility.empty ()) {
680 d << "_" << dm.facility;
683 if (!dm.package_type.empty ()) {
684 d << "_" << dm.package_type;
690 /** @return name to give the DCP */
692 Film::dcp_name (bool if_created_now) const
694 if (use_dci_name()) {
695 return dci_name (if_created_now);
703 Film::set_directory (string d)
705 boost::mutex::scoped_lock lm (_state_mutex);
711 Film::set_name (string n)
714 boost::mutex::scoped_lock lm (_state_mutex);
717 signal_changed (NAME);
721 Film::set_use_dci_name (bool u)
724 boost::mutex::scoped_lock lm (_state_mutex);
727 signal_changed (USE_DCI_NAME);
731 Film::set_trust_content_headers (bool t)
734 boost::mutex::scoped_lock lm (_state_mutex);
735 _trust_content_headers = t;
738 signal_changed (TRUST_CONTENT_HEADERS);
741 ContentList content = _playlist->content ();
742 if (!_trust_content_headers && !content.empty()) {
743 /* We just said that we don't trust the content's header */
744 for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
745 examine_content (*i);
751 Film::set_dcp_content_type (DCPContentType const * t)
754 boost::mutex::scoped_lock lm (_state_mutex);
755 _dcp_content_type = t;
757 signal_changed (DCP_CONTENT_TYPE);
761 Film::set_format (Format const * f)
764 boost::mutex::scoped_lock lm (_state_mutex);
767 signal_changed (FORMAT);
771 Film::set_crop (Crop c)
774 boost::mutex::scoped_lock lm (_state_mutex);
777 signal_changed (CROP);
781 Film::set_left_crop (int c)
784 boost::mutex::scoped_lock lm (_state_mutex);
786 if (_crop.left == c) {
792 signal_changed (CROP);
796 Film::set_right_crop (int c)
799 boost::mutex::scoped_lock lm (_state_mutex);
800 if (_crop.right == c) {
806 signal_changed (CROP);
810 Film::set_top_crop (int c)
813 boost::mutex::scoped_lock lm (_state_mutex);
814 if (_crop.top == c) {
820 signal_changed (CROP);
824 Film::set_bottom_crop (int c)
827 boost::mutex::scoped_lock lm (_state_mutex);
828 if (_crop.bottom == c) {
834 signal_changed (CROP);
838 Film::set_filters (vector<Filter const *> f)
841 boost::mutex::scoped_lock lm (_state_mutex);
844 signal_changed (FILTERS);
848 Film::set_scaler (Scaler const * s)
851 boost::mutex::scoped_lock lm (_state_mutex);
854 signal_changed (SCALER);
858 Film::set_trim_start (int t)
861 boost::mutex::scoped_lock lm (_state_mutex);
864 signal_changed (TRIM_START);
868 Film::set_trim_end (int t)
871 boost::mutex::scoped_lock lm (_state_mutex);
874 signal_changed (TRIM_END);
878 Film::set_trim_type (TrimType t)
881 boost::mutex::scoped_lock lm (_state_mutex);
884 signal_changed (TRIM_TYPE);
888 Film::set_ab (bool a)
891 boost::mutex::scoped_lock lm (_state_mutex);
898 Film::set_audio_gain (float g)
901 boost::mutex::scoped_lock lm (_state_mutex);
904 signal_changed (AUDIO_GAIN);
908 Film::set_audio_delay (int d)
911 boost::mutex::scoped_lock lm (_state_mutex);
914 signal_changed (AUDIO_DELAY);
918 Film::set_with_subtitles (bool w)
921 boost::mutex::scoped_lock lm (_state_mutex);
924 signal_changed (WITH_SUBTITLES);
928 Film::set_subtitle_offset (int o)
931 boost::mutex::scoped_lock lm (_state_mutex);
932 _subtitle_offset = o;
934 signal_changed (SUBTITLE_OFFSET);
938 Film::set_subtitle_scale (float s)
941 boost::mutex::scoped_lock lm (_state_mutex);
944 signal_changed (SUBTITLE_SCALE);
948 Film::set_colour_lut (int i)
951 boost::mutex::scoped_lock lm (_state_mutex);
954 signal_changed (COLOUR_LUT);
958 Film::set_j2k_bandwidth (int b)
961 boost::mutex::scoped_lock lm (_state_mutex);
964 signal_changed (J2K_BANDWIDTH);
968 Film::set_dci_metadata (DCIMetadata m)
971 boost::mutex::scoped_lock lm (_state_mutex);
974 signal_changed (DCI_METADATA);
979 Film::set_dcp_frame_rate (int f)
982 boost::mutex::scoped_lock lm (_state_mutex);
985 signal_changed (DCP_FRAME_RATE);
989 Film::signal_changed (Property p)
992 boost::mutex::scoped_lock lm (_state_mutex);
998 set_dcp_frame_rate (best_dcp_frame_rate (video_frame_rate ()));
999 set_audio_mapping (_playlist->default_audio_mapping ());
1006 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
1011 Film::set_dci_date_today ()
1013 _dci_date = boost::gregorian::day_clock::local_day ();
1017 Film::info_path (int f) const
1019 boost::filesystem::path p;
1024 s << setfill('0') << f << ".md5";
1028 /* info_dir() will already have added any initial bit of the path,
1029 so don't call file() on this.
1035 Film::j2c_path (int f, bool t) const
1037 boost::filesystem::path p;
1039 p /= video_state_identifier ();
1043 s << setfill('0') << f << ".j2c";
1050 return file (p.string ());
1053 /** Make an educated guess as to whether we have a complete DCP
1055 * @return true if we do.
1059 Film::have_dcp () const
1062 libdcp::DCP dcp (dir (dcp_name()));
1072 Film::player () const
1074 boost::mutex::scoped_lock lm (_state_mutex);
1075 return shared_ptr<Player> (new Player (shared_from_this (), _playlist));
1079 Film::content () const
1081 return _playlist->content ();
1085 Film::add_content (shared_ptr<Content> c)
1088 examine_content (c);
1092 Film::remove_content (shared_ptr<Content> c)
1094 _playlist->remove (c);
1098 Film::move_content_earlier (shared_ptr<Content> c)
1100 _playlist->move_earlier (c);
1104 Film::move_content_later (shared_ptr<Content> c)
1106 _playlist->move_later (c);
1110 Film::audio_length () const
1112 return _playlist->audio_length ();
1116 Film::audio_channels () const
1118 return _playlist->audio_channels ();
1122 Film::audio_frame_rate () const
1124 return _playlist->audio_frame_rate ();
1128 Film::has_audio () const
1130 return _playlist->has_audio ();
1134 Film::video_frame_rate () const
1136 return _playlist->video_frame_rate ();
1140 Film::video_size () const
1142 return _playlist->video_size ();
1146 Film::video_length () const
1148 return _playlist->video_length ();
1152 Film::content_length () const
1154 return _playlist->content_length ();
1157 vector<FFmpegSubtitleStream>
1158 Film::ffmpeg_subtitle_streams () const
1160 shared_ptr<FFmpegContent> f = _playlist->ffmpeg ();
1162 return f->subtitle_streams ();
1165 return vector<FFmpegSubtitleStream> ();
1168 boost::optional<FFmpegSubtitleStream>
1169 Film::ffmpeg_subtitle_stream () const
1171 shared_ptr<FFmpegContent> f = _playlist->ffmpeg ();
1173 return f->subtitle_stream ();
1179 vector<FFmpegAudioStream>
1180 Film::ffmpeg_audio_streams () const
1182 shared_ptr<FFmpegContent> f = _playlist->ffmpeg ();
1184 return f->audio_streams ();
1187 return vector<FFmpegAudioStream> ();
1190 boost::optional<FFmpegAudioStream>
1191 Film::ffmpeg_audio_stream () const
1193 shared_ptr<FFmpegContent> f = _playlist->ffmpeg ();
1195 return f->audio_stream ();
1202 Film::set_ffmpeg_subtitle_stream (FFmpegSubtitleStream s)
1204 shared_ptr<FFmpegContent> f = _playlist->ffmpeg ();
1206 f->set_subtitle_stream (s);
1211 Film::set_ffmpeg_audio_stream (FFmpegAudioStream s)
1213 shared_ptr<FFmpegContent> f = _playlist->ffmpeg ();
1215 f->set_audio_stream (s);
1220 Film::set_audio_mapping (AudioMapping m)
1223 boost::mutex::scoped_lock lm (_state_mutex);
1227 signal_changed (AUDIO_MAPPING);
1231 Film::playlist_content_changed (boost::weak_ptr<Content> c, int p)
1233 if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
1234 set_dcp_frame_rate (best_dcp_frame_rate (video_frame_rate ()));
1235 } else if (p == AudioContentProperty::AUDIO_CHANNELS) {
1236 set_audio_mapping (_playlist->default_audio_mapping ());
1240 ui_signaller->emit (boost::bind (boost::ref (ContentChanged), c, p));
1245 Film::playlist_changed ()
1247 signal_changed (CONTENT);
1253 return _playlist->loop ();
1257 Film::set_loop (int c)
1259 _playlist->set_loop (c);