UI tweaks for still image DCPs with audio.
[dcpomatic.git] / src / lib / film.cc
index 4cfe7de0abce543e9b7c71e9743c422bf8542338..9da15a73baf31ffc36f27bbfa05f87e61ad4310a 100644 (file)
@@ -678,6 +678,10 @@ Film::target_audio_sample_rate () const
 boost::optional<SourceFrame>
 Film::dcp_length () const
 {
+       if (content_type() == STILL) {
+               return _still_duration * frames_per_second();
+       }
+       
        if (!length()) {
                return boost::optional<SourceFrame> ();
        }
@@ -857,10 +861,12 @@ Film::set_content (string c)
                set_size (d.video->native_size ());
                set_frames_per_second (d.video->frames_per_second ());
                set_subtitle_streams (d.video->subtitle_streams ());
-               set_content_audio_streams (d.audio->audio_streams ());
+               if (d.audio) {
+                       set_content_audio_streams (d.audio->audio_streams ());
+               }
 
                /* Start off with the first audio and subtitle streams */
-               if (!d.audio->audio_streams().empty()) {
+               if (d.audio && !d.audio->audio_streams().empty()) {
                        set_content_audio_stream (d.audio->audio_streams().front());
                }
                
@@ -875,8 +881,6 @@ Film::set_content (string c)
                
                signal_changed (CONTENT);
                
-               set_content_digest (md5_digest (content_path ()));
-
                examine_content ();
 
        } catch (...) {
@@ -886,6 +890,21 @@ Film::set_content (string c)
                throw;
 
        }
+
+       /* Default format */
+       switch (content_type()) {
+       case STILL:
+               set_format (Format::from_id ("var-185"));
+               break;
+       case VIDEO:
+               set_format (Format::from_id ("185"));
+               break;
+       }
+
+       /* Still image DCPs must use external audio */
+       if (content_type() == STILL) {
+               set_use_content_audio (false);
+       }
 }
 
 void