Merge master.
[dcpomatic.git] / src / lib / film.cc
index 4b3f6a8dd1afe508f90cfde344faf3d3a94ca77c..cc80f5bc2d8be73bf40f60b99a136a963f0f582e 100644 (file)
@@ -85,8 +85,10 @@ using dcp::Signer;
  * AudioMapping XML changed.
  * 6 -> 7
  * Subtitle offset changed to subtitle y offset, and subtitle x offset added.
+ * 7 -> 8
+ * Use <Scale> tag in <VideoContent> rather than <Ratio>.
  */
-int const Film::current_state_version = 7;
+int const Film::current_state_version = 8;
 
 /** Construct a Film object in a given directory.
  *
@@ -230,11 +232,9 @@ Film::filename_safe_name () const
 }
 
 boost::filesystem::path
-Film::audio_analysis_path (shared_ptr<const AudioContent> c) const
+Film::audio_analysis_dir () const
 {
-       boost::filesystem::path p = dir ("analysis");
-       p /= c->digest();
-       return p;
+       return dir ("analysis");
 }
 
 /** Add suitable Jobs to the JobManager to create a DCP for this Film */
@@ -381,8 +381,10 @@ Film::write_metadata () const
        _dirty = false;
 }
 
-/** Read state from our metadata file */
-void
+/** Read state from our metadata file.
+ *  @return Notes about things that the user should know about, or empty.
+ */
+list<string>
 Film::read_metadata ()
 {
        LocaleGuard lg;
@@ -395,6 +397,9 @@ Film::read_metadata ()
        f.read_file (file ("metadata.xml"));
 
        _state_version = f.number_child<int> ("Version");
+       if (_state_version > current_state_version) {
+               throw StringError (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version.  Sorry!"));
+       }
        
        _name = f.string_child ("Name");
        _use_dci_name = f.bool_child ("UseDCIName");
@@ -427,9 +432,13 @@ Film::read_metadata ()
        _three_d = f.bool_child ("ThreeD");
        _interop = f.bool_child ("Interop");
        _key = dcp::Key (f.string_child ("Key"));
-       _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version);
+
+       list<string> notes;
+       /* This method is the only one that can return notes (so far) */
+       _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
        _dirty = false;
+       return notes;
 }
 
 /** Given a directory name, return its full path within the Film's directory.
@@ -873,7 +882,7 @@ Film::has_subtitles () const
        return _playlist->has_subtitles ();
 }
 
-VideoFrame
+int
 Film::best_video_frame_rate () const
 {
        return _playlist->best_dcp_frame_rate ();
@@ -903,31 +912,7 @@ Film::playlist_changed ()
        signal_changed (CONTENT);
 }      
 
-AudioFrame
-Film::time_to_audio_frames (DCPTime t) const
-{
-       return divide_with_round (t * audio_frame_rate (), TIME_HZ);
-}
-
-VideoFrame
-Film::time_to_video_frames (DCPTime t) const
-{
-       return divide_with_round (t * video_frame_rate (), TIME_HZ);
-}
-
-DCPTime
-Film::audio_frames_to_time (AudioFrame f) const
-{
-       return divide_with_round (f * TIME_HZ, audio_frame_rate ());
-}
-
-DCPTime
-Film::video_frames_to_time (VideoFrame f) const
-{
-       return divide_with_round (f * TIME_HZ, video_frame_rate ());
-}
-
-AudioFrame
+int
 Film::audio_frame_rate () const
 {
        /* XXX */
@@ -942,6 +927,7 @@ Film::set_sequence_video (bool s)
        signal_changed (SEQUENCE_VIDEO);
 }
 
+/** @return Size of the largest possible image in whatever resolution we are using */
 dcp::Size
 Film::full_frame () const
 {
@@ -956,6 +942,13 @@ Film::full_frame () const
        return dcp::Size ();
 }
 
+/** @return Size of the frame */
+dcp::Size
+Film::frame_size () const
+{
+       return fit_ratio_within (container()->ratio(), full_frame ());
+}
+
 dcp::KDM
 Film::make_kdm (
        shared_ptr<dcp::Certificate> target,
@@ -1006,7 +999,7 @@ Film::make_kdms (
 uint64_t
 Film::required_disk_space () const
 {
-       return uint64_t (j2k_bandwidth() / 8) * length() / TIME_HZ;
+       return uint64_t (j2k_bandwidth() / 8) * length().seconds();
 }
 
 /** This method checks the disk that the Film is on and tries to decide whether or not