Don't crash with bad content (#135).
[dcpomatic.git] / src / lib / film.cc
1 /*
2     Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include <stdexcept>
21 #include <iostream>
22 #include <algorithm>
23 #include <fstream>
24 #include <cstdlib>
25 #include <sstream>
26 #include <iomanip>
27 #include <unistd.h>
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>
34 #include "film.h"
35 #include "job.h"
36 #include "util.h"
37 #include "job_manager.h"
38 #include "transcode_job.h"
39 #include "scp_dcp_job.h"
40 #include "log.h"
41 #include "exceptions.h"
42 #include "examine_content_job.h"
43 #include "scaler.h"
44 #include "config.h"
45 #include "version.h"
46 #include "ui_signaller.h"
47 #include "playlist.h"
48 #include "player.h"
49 #include "dcp_content_type.h"
50 #include "ratio.h"
51 #include "cross.h"
52
53 #include "i18n.h"
54
55 using std::string;
56 using std::stringstream;
57 using std::multimap;
58 using std::pair;
59 using std::map;
60 using std::vector;
61 using std::ifstream;
62 using std::ofstream;
63 using std::setfill;
64 using std::min;
65 using std::make_pair;
66 using std::endl;
67 using std::cout;
68 using std::list;
69 using boost::shared_ptr;
70 using boost::weak_ptr;
71 using boost::lexical_cast;
72 using boost::dynamic_pointer_cast;
73 using boost::to_upper_copy;
74 using boost::ends_with;
75 using boost::starts_with;
76 using boost::optional;
77 using libdcp::Size;
78
79 int const Film::state_version = 4;
80
81 /** Construct a Film object in a given directory.
82  *
83  *  @param d Film directory.
84  */
85
86 Film::Film (string d)
87         : _playlist (new Playlist)
88         , _use_dci_name (true)
89         , _dcp_content_type (Config::instance()->default_dcp_content_type ())
90         , _container (Config::instance()->default_container ())
91         , _resolution (RESOLUTION_2K)
92         , _scaler (Scaler::from_id ("bicubic"))
93         , _with_subtitles (false)
94         , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ())
95         , _dci_metadata (Config::instance()->default_dci_metadata ())
96         , _dcp_video_frame_rate (24)
97         , _dcp_audio_channels (MAX_AUDIO_CHANNELS)
98         , _sequence_video (true)
99         , _dirty (false)
100 {
101         set_dci_date_today ();
102
103         _playlist->Changed.connect (bind (&Film::playlist_changed, this));
104         _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
105         
106         /* Make state.directory a complete path without ..s (where possible)
107            (Code swiped from Adam Bowen on stackoverflow)
108         */
109         
110         boost::filesystem::path p (boost::filesystem::system_complete (d));
111         boost::filesystem::path result;
112         for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
113                 if (*i == "..") {
114                         if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
115                                 result /= *i;
116                         } else {
117                                 result = result.parent_path ();
118                         }
119                 } else if (*i != ".") {
120                         result /= *i;
121                 }
122         }
123
124         set_directory (result.string ());
125         _log.reset (new FileLog ("log"));
126
127         _playlist->set_sequence_video (_sequence_video);
128 }
129
130 string
131 Film::video_identifier () const
132 {
133         assert (container ());
134         LocaleGuard lg;
135
136         stringstream s;
137         s << container()->id()
138           << "_" << resolution_to_string (_resolution)
139           << "_" << _playlist->video_identifier()
140           << "_" << _dcp_video_frame_rate
141           << "_" << scaler()->id()
142           << "_" << j2k_bandwidth();
143
144         return s.str ();
145 }
146           
147 /** @return The path to the directory to write video frame info files to */
148 string
149 Film::info_dir () const
150 {
151         boost::filesystem::path p;
152         p /= "info";
153         p /= video_identifier ();
154         return dir (p.string());
155 }
156
157 string
158 Film::internal_video_mxf_dir () const
159 {
160         return dir ("video");
161 }
162
163 string
164 Film::internal_video_mxf_filename () const
165 {
166         return video_identifier() + ".mxf";
167 }
168
169 string
170 Film::dcp_video_mxf_filename () const
171 {
172         return filename_safe_name() + "_video.mxf";
173 }
174
175 string
176 Film::dcp_audio_mxf_filename () const
177 {
178         return filename_safe_name() + "_audio.mxf";
179 }
180
181 string
182 Film::filename_safe_name () const
183 {
184         string const n = name ();
185         string o;
186         for (size_t i = 0; i < n.length(); ++i) {
187                 if (isalnum (n[i])) {
188                         o += n[i];
189                 } else {
190                         o += "_";
191                 }
192         }
193
194         return o;
195 }
196
197 boost::filesystem::path
198 Film::audio_analysis_path (shared_ptr<const AudioContent> c) const
199 {
200         boost::filesystem::path p = dir ("analysis");
201         p /= c->digest();
202         return p;
203 }
204
205 /** Add suitable Jobs to the JobManager to create a DCP for this Film */
206 void
207 Film::make_dcp ()
208 {
209         set_dci_date_today ();
210         
211         if (dcp_name().find ("/") != string::npos) {
212                 throw BadSettingError (_("name"), _("cannot contain slashes"));
213         }
214         
215         log()->log (String::compose ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()));
216
217         {
218                 char buffer[128];
219                 gethostname (buffer, sizeof (buffer));
220                 log()->log (String::compose ("Starting to make DCP on %1", buffer));
221         }
222         
223 //      log()->log (String::compose ("Content is %1; type %2", content_path(), (content_type() == STILL ? _("still") : _("video"))));
224 //      if (length()) {
225 //              log()->log (String::compose ("Content length %1", length().get()));
226 //      }
227 //      log()->log (String::compose ("Content digest %1", content_digest()));
228 //      log()->log (String::compose ("Content at %1 fps, DCP at %2 fps", source_frame_rate(), dcp_frame_rate()));
229         log()->log (String::compose ("%1 threads", Config::instance()->num_local_encoding_threads()));
230         log()->log (String::compose ("J2K bandwidth %1", j2k_bandwidth()));
231 #ifdef DCPOMATIC_DEBUG
232         log()->log ("DCP-o-matic built in debug mode.");
233 #else
234         log()->log ("DCP-o-matic built in optimised mode.");
235 #endif
236 #ifdef LIBDCP_DEBUG
237         log()->log ("libdcp built in debug mode.");
238 #else
239         log()->log ("libdcp built in optimised mode.");
240 #endif
241         pair<string, int> const c = cpu_info ();
242         log()->log (String::compose ("CPU: %1, %2 processors", c.first, c.second));
243         list<pair<string, string> > const m = mount_info ();
244         for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) {
245                 log()->log (String::compose ("Mount: %1 %2", i->first, i->second));
246         }
247         
248         if (container() == 0) {
249                 throw MissingSettingError (_("container"));
250         }
251
252         if (content().empty()) {
253                 throw StringError (_("You must add some content to the DCP before creating it"));
254         }
255
256         if (dcp_content_type() == 0) {
257                 throw MissingSettingError (_("content type"));
258         }
259
260         if (name().empty()) {
261                 throw MissingSettingError (_("name"));
262         }
263
264         JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this())));
265 }
266
267 /** Start a job to send our DCP to the configured TMS */
268 void
269 Film::send_dcp_to_tms ()
270 {
271         shared_ptr<Job> j (new SCPDCPJob (shared_from_this()));
272         JobManager::instance()->add (j);
273 }
274
275 /** Count the number of frames that have been encoded for this film.
276  *  @return frame count.
277  */
278 int
279 Film::encoded_frames () const
280 {
281         if (container() == 0) {
282                 return 0;
283         }
284
285         int N = 0;
286         for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (info_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
287                 ++N;
288                 boost::this_thread::interruption_point ();
289         }
290
291         return N;
292 }
293
294 /** Write state to our `metadata' file */
295 void
296 Film::write_metadata () const
297 {
298         if (!boost::filesystem::exists (directory())) {
299                 boost::filesystem::create_directory (directory());
300         }
301         
302         boost::mutex::scoped_lock lm (_state_mutex);
303         LocaleGuard lg;
304
305         boost::filesystem::create_directories (directory());
306
307         xmlpp::Document doc;
308         xmlpp::Element* root = doc.create_root_node ("Metadata");
309
310         root->add_child("Version")->add_child_text (lexical_cast<string> (state_version));
311         root->add_child("Name")->add_child_text (_name);
312         root->add_child("UseDCIName")->add_child_text (_use_dci_name ? "1" : "0");
313
314         if (_dcp_content_type) {
315                 root->add_child("DCPContentType")->add_child_text (_dcp_content_type->dci_name ());
316         }
317
318         if (_container) {
319                 root->add_child("Container")->add_child_text (_container->id ());
320         }
321
322         root->add_child("Resolution")->add_child_text (resolution_to_string (_resolution));
323         root->add_child("Scaler")->add_child_text (_scaler->id ());
324         root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0");
325         root->add_child("J2KBandwidth")->add_child_text (lexical_cast<string> (_j2k_bandwidth));
326         _dci_metadata.as_xml (root->add_child ("DCIMetadata"));
327         root->add_child("DCPVideoFrameRate")->add_child_text (lexical_cast<string> (_dcp_video_frame_rate));
328         root->add_child("DCIDate")->add_child_text (boost::gregorian::to_iso_string (_dci_date));
329         root->add_child("DCPAudioChannels")->add_child_text (lexical_cast<string> (_dcp_audio_channels));
330         root->add_child("SequenceVideo")->add_child_text (_sequence_video ? "1" : "0");
331         _playlist->as_xml (root->add_child ("Playlist"));
332
333         doc.write_to_file_formatted (file ("metadata.xml"));
334         
335         _dirty = false;
336 }
337
338 /** Read state from our metadata file */
339 void
340 Film::read_metadata ()
341 {
342         boost::mutex::scoped_lock lm (_state_mutex);
343         LocaleGuard lg;
344
345         if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file ("metadata.xml"))) {
346                 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!"));
347         }
348
349         cxml::File f (file ("metadata.xml"), "Metadata");
350         
351         _name = f.string_child ("Name");
352         _use_dci_name = f.bool_child ("UseDCIName");
353
354         {
355                 optional<string> c = f.optional_string_child ("DCPContentType");
356                 if (c) {
357                         _dcp_content_type = DCPContentType::from_dci_name (c.get ());
358                 }
359         }
360
361         {
362                 optional<string> c = f.optional_string_child ("Container");
363                 if (c) {
364                         _container = Ratio::from_id (c.get ());
365                 }
366         }
367
368         _resolution = string_to_resolution (f.string_child ("Resolution"));
369         _scaler = Scaler::from_id (f.string_child ("Scaler"));
370         _with_subtitles = f.bool_child ("WithSubtitles");
371         _j2k_bandwidth = f.number_child<int> ("J2KBandwidth");
372         _dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
373         _dcp_video_frame_rate = f.number_child<int> ("DCPVideoFrameRate");
374         _dci_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
375         _dcp_audio_channels = f.number_child<int> ("DCPAudioChannels");
376         _sequence_video = f.bool_child ("SequenceVideo");
377
378         _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"));
379
380         _dirty = false;
381 }
382
383 /** Given a directory name, return its full path within the Film's directory.
384  *  The directory (and its parents) will be created if they do not exist.
385  */
386 string
387 Film::dir (string d) const
388 {
389         boost::mutex::scoped_lock lm (_directory_mutex);
390         
391         boost::filesystem::path p;
392         p /= _directory;
393         p /= d;
394         
395         boost::filesystem::create_directories (p);
396         
397         return p.string ();
398 }
399
400 /** Given a file or directory name, return its full path within the Film's directory.
401  *  _directory_mutex must not be locked on entry.
402  *  Any required parent directories will be created.
403  */
404 string
405 Film::file (string f) const
406 {
407         boost::mutex::scoped_lock lm (_directory_mutex);
408
409         boost::filesystem::path p;
410         p /= _directory;
411         p /= f;
412
413         boost::filesystem::create_directories (p.parent_path ());
414         
415         return p.string ();
416 }
417
418 /** @return a DCI-compliant name for a DCP of this film */
419 string
420 Film::dci_name (bool if_created_now) const
421 {
422         stringstream d;
423
424         string fixed_name = to_upper_copy (name());
425         for (size_t i = 0; i < fixed_name.length(); ++i) {
426                 if (fixed_name[i] == ' ') {
427                         fixed_name[i] = '-';
428                 }
429         }
430
431         /* Spec is that the name part should be maximum 14 characters, as I understand it */
432         if (fixed_name.length() > 14) {
433                 fixed_name = fixed_name.substr (0, 14);
434         }
435
436         d << fixed_name;
437
438         if (dcp_content_type()) {
439                 d << "_" << dcp_content_type()->dci_name();
440         }
441
442         if (container()) {
443                 d << "_" << container()->dci_name();
444         }
445
446         DCIMetadata const dm = dci_metadata ();
447
448         if (!dm.audio_language.empty ()) {
449                 d << "_" << dm.audio_language;
450                 if (!dm.subtitle_language.empty() && with_subtitles()) {
451                         d << "-" << dm.subtitle_language;
452                 } else {
453                         d << "-XX";
454                 }
455         }
456
457         if (!dm.territory.empty ()) {
458                 d << "_" << dm.territory;
459                 if (!dm.rating.empty ()) {
460                         d << "-" << dm.rating;
461                 }
462         }
463
464         switch (dcp_audio_channels ()) {
465         case 1:
466                 d << "_10";
467                 break;
468         case 2:
469                 d << "_20";
470                 break;
471         case 3:
472                 d << "_30";
473                 break;
474         case 4:
475                 d << "_40";
476                 break;
477         case 5:
478                 d << "_50";
479                 break;
480         case 6:
481                 d << "_51";
482                 break;
483         }
484
485         d << "_" << resolution_to_string (_resolution);
486
487         if (!dm.studio.empty ()) {
488                 d << "_" << dm.studio;
489         }
490
491         if (if_created_now) {
492                 d << "_" << boost::gregorian::to_iso_string (boost::gregorian::day_clock::local_day ());
493         } else {
494                 d << "_" << boost::gregorian::to_iso_string (_dci_date);
495         }
496
497         if (!dm.facility.empty ()) {
498                 d << "_" << dm.facility;
499         }
500
501         if (!dm.package_type.empty ()) {
502                 d << "_" << dm.package_type;
503         }
504
505         return d.str ();
506 }
507
508 /** @return name to give the DCP */
509 string
510 Film::dcp_name (bool if_created_now) const
511 {
512         if (use_dci_name()) {
513                 return dci_name (if_created_now);
514         }
515
516         return name();
517 }
518
519
520 void
521 Film::set_directory (string d)
522 {
523         boost::mutex::scoped_lock lm (_state_mutex);
524         _directory = d;
525         _dirty = true;
526 }
527
528 void
529 Film::set_name (string n)
530 {
531         {
532                 boost::mutex::scoped_lock lm (_state_mutex);
533                 _name = n;
534         }
535         signal_changed (NAME);
536 }
537
538 void
539 Film::set_use_dci_name (bool u)
540 {
541         {
542                 boost::mutex::scoped_lock lm (_state_mutex);
543                 _use_dci_name = u;
544         }
545         signal_changed (USE_DCI_NAME);
546 }
547
548 void
549 Film::set_dcp_content_type (DCPContentType const * t)
550 {
551         {
552                 boost::mutex::scoped_lock lm (_state_mutex);
553                 _dcp_content_type = t;
554         }
555         signal_changed (DCP_CONTENT_TYPE);
556 }
557
558 void
559 Film::set_container (Ratio const * c)
560 {
561         {
562                 boost::mutex::scoped_lock lm (_state_mutex);
563                 _container = c;
564         }
565         signal_changed (CONTAINER);
566 }
567
568 void
569 Film::set_resolution (Resolution r)
570 {
571         {
572                 boost::mutex::scoped_lock lm (_state_mutex);
573                 _resolution = r;
574         }
575         signal_changed (RESOLUTION);
576 }
577
578 void
579 Film::set_scaler (Scaler const * s)
580 {
581         {
582                 boost::mutex::scoped_lock lm (_state_mutex);
583                 _scaler = s;
584         }
585         signal_changed (SCALER);
586 }
587
588 void
589 Film::set_with_subtitles (bool w)
590 {
591         {
592                 boost::mutex::scoped_lock lm (_state_mutex);
593                 _with_subtitles = w;
594         }
595         signal_changed (WITH_SUBTITLES);
596 }
597
598 void
599 Film::set_j2k_bandwidth (int b)
600 {
601         {
602                 boost::mutex::scoped_lock lm (_state_mutex);
603                 _j2k_bandwidth = b;
604         }
605         signal_changed (J2K_BANDWIDTH);
606 }
607
608 void
609 Film::set_dci_metadata (DCIMetadata m)
610 {
611         {
612                 boost::mutex::scoped_lock lm (_state_mutex);
613                 _dci_metadata = m;
614         }
615         signal_changed (DCI_METADATA);
616 }
617
618 void
619 Film::set_dcp_video_frame_rate (int f)
620 {
621         {
622                 boost::mutex::scoped_lock lm (_state_mutex);
623                 _dcp_video_frame_rate = f;
624         }
625         signal_changed (DCP_VIDEO_FRAME_RATE);
626 }
627
628 void
629 Film::set_dcp_audio_channels (int c)
630 {
631         {
632                 boost::mutex::scoped_lock lm (_state_mutex);
633                 _dcp_audio_channels = c;
634         }
635         signal_changed (DCP_AUDIO_CHANNELS);
636 }
637
638 void
639 Film::signal_changed (Property p)
640 {
641         {
642                 boost::mutex::scoped_lock lm (_state_mutex);
643                 _dirty = true;
644         }
645
646         switch (p) {
647         case Film::CONTENT:
648                 set_dcp_video_frame_rate (_playlist->best_dcp_frame_rate ());
649                 break;
650         case Film::DCP_VIDEO_FRAME_RATE:
651         case Film::SEQUENCE_VIDEO:
652                 _playlist->maybe_sequence_video ();
653                 break;
654         default:
655                 break;
656         }
657
658         if (ui_signaller) {
659                 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
660         }
661 }
662
663 void
664 Film::set_dci_date_today ()
665 {
666         _dci_date = boost::gregorian::day_clock::local_day ();
667 }
668
669 string
670 Film::info_path (int f) const
671 {
672         boost::filesystem::path p;
673         p /= info_dir ();
674
675         stringstream s;
676         s.width (8);
677         s << setfill('0') << f << ".md5";
678
679         p /= s.str();
680
681         /* info_dir() will already have added any initial bit of the path,
682            so don't call file() on this.
683         */
684         return p.string ();
685 }
686
687 string
688 Film::j2c_path (int f, bool t) const
689 {
690         boost::filesystem::path p;
691         p /= "j2c";
692         p /= video_identifier ();
693
694         stringstream s;
695         s.width (8);
696         s << setfill('0') << f << ".j2c";
697
698         if (t) {
699                 s << ".tmp";
700         }
701
702         p /= s.str();
703         return file (p.string ());
704 }
705
706 /** Make an educated guess as to whether we have a complete DCP
707  *  or not.
708  *  @return true if we do.
709  */
710
711 bool
712 Film::have_dcp () const
713 {
714         try {
715                 libdcp::DCP dcp (dir (dcp_name()));
716                 dcp.read ();
717         } catch (...) {
718                 return false;
719         }
720
721         return true;
722 }
723
724 shared_ptr<Player>
725 Film::make_player () const
726 {
727         return shared_ptr<Player> (new Player (shared_from_this (), _playlist));
728 }
729
730 shared_ptr<Playlist>
731 Film::playlist () const
732 {
733         boost::mutex::scoped_lock lm (_state_mutex);
734         return _playlist;
735 }
736
737 ContentList
738 Film::content () const
739 {
740         return _playlist->content ();
741 }
742
743 void
744 Film::examine_and_add_content (shared_ptr<Content> c)
745 {
746         shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
747         j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c)));
748         JobManager::instance()->add (j);
749 }
750
751 void
752 Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c)
753 {
754         shared_ptr<Job> job = j.lock ();
755         if (!job || !job->finished_ok ()) {
756                 return;
757         }
758         
759         shared_ptr<Content> content = c.lock ();
760         if (content) {
761                 add_content (content);
762         }
763 }
764
765 void
766 Film::add_content (shared_ptr<Content> c)
767 {
768         /* Add video content after any existing content */
769         if (dynamic_pointer_cast<VideoContent> (c)) {
770                 c->set_start (_playlist->video_end ());
771         }
772
773         _playlist->add (c);
774 }
775
776 void
777 Film::remove_content (shared_ptr<Content> c)
778 {
779         _playlist->remove (c);
780 }
781
782 Time
783 Film::length () const
784 {
785         return _playlist->length ();
786 }
787
788 bool
789 Film::has_subtitles () const
790 {
791         return _playlist->has_subtitles ();
792 }
793
794 OutputVideoFrame
795 Film::best_dcp_video_frame_rate () const
796 {
797         return _playlist->best_dcp_frame_rate ();
798 }
799
800 void
801 Film::playlist_content_changed (boost::weak_ptr<Content> c, int p)
802 {
803         if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
804                 set_dcp_video_frame_rate (_playlist->best_dcp_frame_rate ());
805         } 
806
807         if (ui_signaller) {
808                 ui_signaller->emit (boost::bind (boost::ref (ContentChanged), c, p));
809         }
810 }
811
812 void
813 Film::playlist_changed ()
814 {
815         signal_changed (CONTENT);
816 }       
817
818 OutputAudioFrame
819 Film::time_to_audio_frames (Time t) const
820 {
821         return t * dcp_audio_frame_rate () / TIME_HZ;
822 }
823
824 OutputVideoFrame
825 Film::time_to_video_frames (Time t) const
826 {
827         return t * dcp_video_frame_rate () / TIME_HZ;
828 }
829
830 Time
831 Film::audio_frames_to_time (OutputAudioFrame f) const
832 {
833         return f * TIME_HZ / dcp_audio_frame_rate ();
834 }
835
836 Time
837 Film::video_frames_to_time (OutputVideoFrame f) const
838 {
839         return f * TIME_HZ / dcp_video_frame_rate ();
840 }
841
842 OutputAudioFrame
843 Film::dcp_audio_frame_rate () const
844 {
845         /* XXX */
846         return 48000;
847 }
848
849 void
850 Film::set_sequence_video (bool s)
851 {
852         {
853                 boost::mutex::scoped_lock lm (_state_mutex);
854                 _sequence_video = s;
855                 _playlist->set_sequence_video (s);
856         }
857         
858         signal_changed (SEQUENCE_VIDEO);
859 }
860
861 libdcp::Size
862 Film::full_frame () const
863 {
864         switch (_resolution) {
865         case RESOLUTION_2K:
866                 return libdcp::Size (2048, 1080);
867         case RESOLUTION_4K:
868                 return libdcp::Size (4096, 2160);
869         }
870
871         assert (false);
872         return libdcp::Size ();
873 }