Hand-apply d849d411cff28ef5453085791d0b4d7cd73bd070 from master; replace all assert...
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index d2bb329db346bc3ca34988f95a8425a3727dcded..740efdc299fadc9131692581b91004b5a4b1dc9e 100644 (file)
@@ -34,13 +34,13 @@ extern "C" {
 #include "log.h"
 #include "exceptions.h"
 #include "frame_rate_change.h"
+#include "safe_stringstream.h"
 
 #include "i18n.h"
 
 #define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
 
 using std::string;
-using std::stringstream;
 using std::vector;
 using std::list;
 using std::cout;
@@ -106,11 +106,11 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> f, vector<boost::shared_ptr
        , SubtitleContent (f, c)
 {
        shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
-       assert (ref);
+       DCPOMATIC_ASSERT (ref);
 
        for (size_t i = 0; i < c.size(); ++i) {
                shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]);
-               if (fc->subtitle_use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
+               if (fc->use_subtitles() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
 
@@ -163,17 +163,17 @@ FFmpegContent::as_xml (xmlpp::Node* node) const
 }
 
 void
-FFmpegContent::examine (shared_ptr<Job> job)
+FFmpegContent::examine (shared_ptr<Job> job, bool calculate_digest)
 {
        job->set_progress_unknown ();
 
-       Content::examine (job);
+       Content::examine (job, calculate_digest);
 
        shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this ()));
        take_from_video_examiner (examiner);
 
        shared_ptr<const Film> film = _film.lock ();
-       assert (film);
+       DCPOMATIC_ASSERT (film);
 
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -235,7 +235,7 @@ FFmpegContent::information () const
                return "";
        }
        
-       stringstream s;
+       SafeStringStream s;
        
        s << String::compose (_("%1 frames; %2 frames per second"), video_length_after_3d_combine().frames (video_frame_rate()), video_frame_rate()) << "\n";
        s << VideoContent::information ();
@@ -284,7 +284,7 @@ FFmpegContent::audio_channels () const
                return 0;
        }
 
-       return _audio_stream->channels;
+       return _audio_stream->channels ();
 }
 
 int
@@ -296,7 +296,7 @@ FFmpegContent::audio_frame_rate () const
                return 0;
        }
 
-       return _audio_stream->frame_rate;
+       return _audio_stream->frame_rate ();
 }
 
 bool
@@ -315,7 +315,7 @@ DCPTime
 FFmpegContent::full_length () const
 {
        shared_ptr<const Film> film = _film.lock ();
-       assert (film);
+       DCPOMATIC_ASSERT (film);
        return DCPTime (video_length_after_3d_combine(), FrameRateChange (video_frame_rate (), film->video_frame_rate ()));
 }
 
@@ -328,7 +328,7 @@ FFmpegContent::audio_mapping () const
                return AudioMapping ();
        }
 
-       return _audio_stream->mapping;
+       return _audio_stream->mapping ();
 }
 
 void
@@ -345,14 +345,14 @@ FFmpegContent::set_filters (vector<Filter const *> const & filters)
 void
 FFmpegContent::set_audio_mapping (AudioMapping m)
 {
-       audio_stream()->mapping = m;
+       audio_stream()->set_mapping (m);
        AudioContent::set_audio_mapping (m);
 }
 
 string
 FFmpegContent::identifier () const
 {
-       stringstream s;
+       SafeStringStream s;
 
        s << VideoContent::identifier();
 
@@ -382,7 +382,7 @@ FFmpegContent::audio_analysis_path () const
        */
 
        boost::filesystem::path p = film->audio_analysis_dir ();
-       string name = digest ();
+       string name = digest().get_value_or ("X");
        if (audio_stream ()) {
                name += "_" + audio_stream()->identifier ();
        }
@@ -409,3 +409,9 @@ FFmpegContent::subtitles_during (ContentTimePeriod period, bool starting) const
 
        return d;
 }
+
+bool
+FFmpegContent::has_subtitles () const
+{
+       return !subtitle_streams().empty ();
+}