Merge master.
[dcpomatic.git] / src / lib / film.cc
index 8e93667d5e54ad1ccb7474257e6536ce97a1bd27..67f795a6c739af5e60b8947bfde2e4657ba9f275 100644 (file)
@@ -81,7 +81,12 @@ using boost::optional;
 using libdcp::Size;
 using libdcp::Signer;
 
-int const Film::state_version = 5;
+/* 5 -> 6
+ * AudioMapping XML changed.
+ * 6 -> 7
+ * Subtitle offset changed to subtitle y offset, and subtitle x offset added.
+ */
+int const Film::state_version = 7;
 
 /** Construct a Film object in a given directory.
  *
@@ -262,6 +267,14 @@ Film::make_dcp ()
 #else
        log()->log ("libdcp built in optimised mode.");
 #endif
+
+#ifdef DCPOMATIC_WINDOWS
+       OSVERSIONINFO info;
+       info.dwOSVersionInfoSize = sizeof (info);
+       GetVersionEx (&info);
+       log()->log (String::compose ("Windows version %1.%2.%3 SP %4", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber, info.szCSDVersion));
+#endif 
+       
        log()->log (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency ()));
        list<pair<string, string> > const m = mount_info ();
        for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) {
@@ -854,18 +867,12 @@ Film::has_subtitles () const
        return _playlist->has_subtitles ();
 }
 
-OutputVideoFrame
+VideoFrame
 Film::best_video_frame_rate () const
 {
        return _playlist->best_dcp_frame_rate ();
 }
 
-bool
-Film::content_paths_valid () const
-{
-       return _playlist->content_paths_valid ();
-}
-
 FrameRateChange
 Film::active_frame_rate_change (DCPTime t) const
 {
@@ -890,31 +897,31 @@ Film::playlist_changed ()
        signal_changed (CONTENT);
 }      
 
-OutputAudioFrame
+AudioFrame
 Film::time_to_audio_frames (DCPTime t) const
 {
        return t * audio_frame_rate () / TIME_HZ;
 }
 
-OutputVideoFrame
+VideoFrame
 Film::time_to_video_frames (DCPTime t) const
 {
        return t * video_frame_rate () / TIME_HZ;
 }
 
 DCPTime
-Film::audio_frames_to_time (OutputAudioFrame f) const
+Film::audio_frames_to_time (AudioFrame f) const
 {
        return f * TIME_HZ / audio_frame_rate ();
 }
 
 DCPTime
-Film::video_frames_to_time (OutputVideoFrame f) const
+Film::video_frames_to_time (VideoFrame f) const
 {
        return f * TIME_HZ / video_frame_rate ();
 }
 
-OutputAudioFrame
+AudioFrame
 Film::audio_frame_rate () const
 {
        /* XXX */
@@ -986,3 +993,28 @@ Film::make_kdms (
 
        return kdms;
 }
+
+/** @return The approximate disk space required to encode a DCP of this film with the
+ *  current settings, in bytes.
+ */
+uint64_t
+Film::required_disk_space () const
+{
+       return uint64_t (j2k_bandwidth() / 8) * length() / TIME_HZ;
+}
+
+/** This method checks the disk that the Film is on and tries to decide whether or not
+ *  there will be enough space to make a DCP for it.  If so, true is returned; if not,
+ *  false is returned and required and availabe are filled in with the amount of disk space
+ *  required and available respectively (in Gb).
+ *
+ *  Note: the decision made by this method isn't, of course, 100% reliable.
+ */
+bool
+Film::should_be_enough_disk_space (double& required, double& available) const
+{
+       boost::filesystem::space_info s = boost::filesystem::space (internal_video_mxf_dir ());
+       required = double (required_disk_space ()) / 1073741824.0f;
+       available = double (s.available) / 1073741824.0f;
+       return (available - required) > 1;
+}