Make video view type configurable.
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index fcadc91165ab12179b9e1987467fd912115d97fa..69d74321514729208eaeea371185a924b52f80fe 100644 (file)
@@ -45,8 +45,6 @@ extern "C" {
 
 #include "i18n.h"
 
-#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL);
-
 using std::string;
 using std::vector;
 using std::list;
@@ -58,6 +56,7 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 using dcp::raw_convert;
+using namespace dcpomatic;
 
 int const FFmpegContentProperty::SUBTITLE_STREAMS = 100;
 int const FFmpegContentProperty::SUBTITLE_STREAM = 101;
@@ -309,7 +308,7 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
 
                        AudioStreamPtr as = audio->streams().front();
                        AudioMapping m = as->mapping ();
-                       film->make_audio_mapping_default (m, first_path);
+                       m.make_default (film ? film->audio_processor() : 0, first_path);
                        as->set_mapping (m);
                }
 
@@ -407,14 +406,34 @@ FFmpegContent::full_length (shared_ptr<const Film> film) const
                return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
        }
 
+       if (audio) {
+               DCPTime longest;
+               BOOST_FOREACH (AudioStreamPtr i, audio->streams()) {
+                       longest = max (longest, DCPTime::from_frames(llrint(i->length() / frc.speed_up), i->frame_rate()));
+               }
+               return longest;
+       }
+
+       /* XXX: subtitle content? */
+
+       return DCPTime();
+}
+
+DCPTime
+FFmpegContent::approximate_length () const
+{
+       if (video) {
+               return DCPTime::from_frames (video->length_after_3d_combine(), 24);
+       }
+
        DCPOMATIC_ASSERT (audio);
 
-       DCPTime longest;
+       Frame longest = 0;
        BOOST_FOREACH (AudioStreamPtr i, audio->streams ()) {
-               longest = max (longest, DCPTime::from_frames (llrint (i->length() / frc.speed_up), i->frame_rate()));
+               longest = max (longest, Frame(llrint(i->length())));
        }
 
-       return longest;
+       return DCPTime::from_frames (longest, 24);
 }
 
 void
@@ -492,7 +511,7 @@ FFmpegContent::set_default_colour_conversion ()
 void
 FFmpegContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p) const
 {
-       Content::add_properties (p);
+       Content::add_properties (film, p);
 
        if (video) {
                video->add_properties (p);