Add assert.
[dcpomatic.git] / src / lib / string_text_file.cc
index b8ca27e160ca989ad283768f963a1bdf974546db..869a2c96a832cf1044caff7e19463b674230aaa6 100644 (file)
@@ -28,6 +28,7 @@
 #include <sub/ssa_reader.h>
 #include <sub/stl_binary_reader.h>
 #include <sub/subrip_reader.h>
+#include <sub/web_vtt_reader.h>
 #include <unicode/ucsdet.h>
 #include <unicode/ucnv.h>
 #include <iostream>
@@ -105,6 +106,8 @@ StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content)
                        reader.reset(new sub::SubripReader(utf8.get()));
                } else if (ext == ".ssa" || ext == ".ass") {
                        reader.reset(new sub::SSAReader(utf8.get()));
+               } else if (ext == ".vtt") {
+                       reader.reset(new sub::WebVTTReader(utf8.get()));
                }
        }
 
@@ -118,7 +121,7 @@ optional<ContentTime>
 StringTextFile::first () const
 {
        if (_subtitles.empty()) {
-               return optional<ContentTime>();
+               return {};
        }
 
        return ContentTime::from_seconds(_subtitles[0].from.all_as_seconds());
@@ -128,7 +131,7 @@ ContentTime
 StringTextFile::length () const
 {
        if (_subtitles.empty ()) {
-               return ContentTime ();
+               return {};
        }
 
        return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ());