Use make_shared<>.
[dcpomatic.git] / src / lib / ffmpeg_examiner.cc
index f03b744a160a3a13170d32f164b1d19aa6046d7f..2e48810b1ed87779a9bd6e5f53d1df5931cc4a89 100644 (file)
@@ -32,6 +32,7 @@ extern "C" {
 #include "util.h"
 #include "safe_stringstream.h"
 #include <boost/foreach.hpp>
+#include <boost/make_shared.hpp>
 #include <iostream>
 
 #include "i18n.h"
@@ -40,6 +41,7 @@ using std::string;
 using std::cout;
 using std::max;
 using boost::shared_ptr;
+using boost::make_shared;
 using boost::optional;
 
 /** @param job job that the examiner is operating in, or 0 */
@@ -63,11 +65,14 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
                        }
 
                        DCPOMATIC_ASSERT (_format_context->duration != AV_NOPTS_VALUE);
+                       DCPOMATIC_ASSERT (s->codec->codec);
+                       DCPOMATIC_ASSERT (s->codec->codec->name);
 
                        _audio_streams.push_back (
                                shared_ptr<FFmpegAudioStream> (
                                        new FFmpegAudioStream (
-                                               audio_stream_name (s),
+                                               stream_name (s),
+                                               s->codec->codec->name,
                                                s->id,
                                                s->codec->sample_rate,
                                                (double (_format_context->duration) / AV_TIME_BASE) * s->codec->sample_rate,
@@ -77,7 +82,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
                                );
 
                } else if (s->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
-                       _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (subtitle_stream_name (s), s->id)));
+                       _subtitle_streams.push_back (boost::make_shared<FFmpegSubtitleStream> (subtitle_stream_name (s), s->id));
                }
        }
 
@@ -92,8 +97,10 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
        if (job) {
                if (_need_video_length) {
                        job->sub (_("Finding length and subtitles"));
-               } else {
+               } else if (!_subtitle_streams.empty()) {
                        job->sub (_("Finding subtitles"));
+               } else {
+                       job->sub (_("Finding length"));
                }
        }
 
@@ -343,22 +350,6 @@ FFmpegExaminer::sample_aspect_ratio () const
        return double (sar.num) / sar.den;
 }
 
-string
-FFmpegExaminer::audio_stream_name (AVStream* s) const
-{
-       SafeStringStream n;
-
-       n << stream_name (s);
-
-       if (!n.str().empty()) {
-               n << "; ";
-       }
-
-       n << s->codec->channels << " channels";
-
-       return n.str ();
-}
-
 string
 FFmpegExaminer::subtitle_stream_name (AVStream* s) const
 {