Merge branch 'master' into content-rework-take5
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index 5bff1cecc0768eecdb0f44d5c9c022b0828b16fd..577dbd14d084ba6fe8a19db0c8870935a7d7d9dd 100644 (file)
 #include "i18n.h"
 
 using std::string;
+using std::stringstream;
 using std::vector;
 using std::list;
+using std::cout;
 using boost::shared_ptr;
 using boost::lexical_cast;
 
@@ -72,7 +74,6 @@ FFmpegContent::FFmpegContent (FFmpegContent const & o)
        : Content (o)
        , VideoContent (o)
        , AudioContent (o)
-       , boost::enable_shared_from_this<FFmpegContent> (o)
        , _subtitle_streams (o._subtitle_streams)
        , _subtitle_stream (o._subtitle_stream)
        , _audio_streams (o._audio_streams)
@@ -110,12 +111,10 @@ FFmpegContent::as_xml (xmlpp::Node* node) const
 void
 FFmpegContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
 {
-       job->descend (0.5);
-       Content::examine (film, job, quick);
-       job->ascend ();
-
        job->set_progress_unknown ();
 
+       Content::examine (film, job, quick);
+
        shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), true, false, false, true));
 
        ContentVideoFrame video_length = 0;
@@ -149,17 +148,33 @@ FFmpegContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
 
         take_from_video_decoder (decoder);
 
-        Changed (VideoContentProperty::VIDEO_LENGTH);
-        Changed (FFmpegContentProperty::SUBTITLE_STREAMS);
-        Changed (FFmpegContentProperty::SUBTITLE_STREAM);
-        Changed (FFmpegContentProperty::AUDIO_STREAMS);
-        Changed (FFmpegContentProperty::AUDIO_STREAM);
+        signal_changed (VideoContentProperty::VIDEO_LENGTH);
+        signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
+        signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
+        signal_changed (FFmpegContentProperty::AUDIO_STREAMS);
+        signal_changed (FFmpegContentProperty::AUDIO_STREAM);
+        signal_changed (AudioContentProperty::AUDIO_CHANNELS);
 }
 
 string
 FFmpegContent::summary () const
 {
-       return String::compose (_("Movie: %1"), file().filename ());
+       return String::compose (_("Movie: %1"), file().filename().string());
+}
+
+string
+FFmpegContent::information () const
+{
+       if (video_length() == 0 || video_frame_rate() == 0) {
+               return "";
+       }
+       
+       stringstream s;
+       
+       s << String::compose (_("%1 frames; %2 frames per second"), video_length(), video_frame_rate()) << "\n";
+       s << VideoContent::information ();
+
+       return s.str ();
 }
 
 void
@@ -170,7 +185,7 @@ FFmpegContent::set_subtitle_stream (FFmpegSubtitleStream s)
                 _subtitle_stream = s;
         }
 
-        Changed (FFmpegContentProperty::SUBTITLE_STREAM);
+        signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
 }
 
 void
@@ -181,7 +196,7 @@ FFmpegContent::set_audio_stream (FFmpegAudioStream s)
                 _audio_stream = s;
         }
 
-        Changed (FFmpegContentProperty::AUDIO_STREAM);
+        signal_changed (FFmpegContentProperty::AUDIO_STREAM);
 }
 
 ContentAudioFrame
@@ -201,7 +216,7 @@ FFmpegContent::audio_channels () const
                 return 0;
         }
 
-        return _audio_stream->channels ();
+        return _audio_stream->channels;
 }
 
 int
@@ -214,16 +229,6 @@ FFmpegContent::audio_frame_rate () const
         return _audio_stream->frame_rate;
 }
 
-int64_t
-FFmpegContent::audio_channel_layout () const
-{
-        if (!_audio_stream) {
-                return 0;
-        }
-
-        return _audio_stream->channel_layout;
-}
-       
 bool
 operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b)
 {
@@ -241,7 +246,7 @@ FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node)
        name = node->string_child ("Name");
        id = node->number_child<int> ("Id");
        frame_rate = node->number_child<int> ("FrameRate");
-       channel_layout = node->number_child<int64_t> ("ChannelLayout");
+       channels = node->number_child<int64_t> ("Channels");
 }
 
 void
@@ -250,7 +255,7 @@ FFmpegAudioStream::as_xml (xmlpp::Node* root) const
        root->add_child("Name")->add_child_text (name);
        root->add_child("Id")->add_child_text (lexical_cast<string> (id));
        root->add_child("FrameRate")->add_child_text (lexical_cast<string> (frame_rate));
-       root->add_child("ChannelLayout")->add_child_text (lexical_cast<string> (channel_layout));
+       root->add_child("Channels")->add_child_text (lexical_cast<string> (channels));
 }
 
 /** Construct a SubtitleStream from a value returned from to_string().