diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 8 | ||||
| -rw-r--r-- | src/lib/film.cc | 35 | ||||
| -rw-r--r-- | src/lib/film.h | 3 |
4 files changed, 32 insertions, 18 deletions
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 2c5fcf70e..221a262ef 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -415,6 +415,10 @@ AVStream * FFmpegStream::stream (AVFormatContext const * fc) const { if (_legacy_id) { + if (id >= int (fc->nb_streams)) { + return 0; + } + return fc->streams[id]; } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index c3709166e..587c79495 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -516,15 +516,19 @@ FFmpegDecoder::setup_subtitle () { boost::mutex::scoped_lock lm (_mutex); - if (!_ffmpeg_content->subtitle_stream() || _ffmpeg_content->subtitle_stream()->index (_format_context) >= int (_format_context->nb_streams)) { + if (!_ffmpeg_content->subtitle_stream()) { return; } _subtitle_codec_context = _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; + if (_subtitle_codec_context == 0) { + throw DecodeError (N_("could not find subtitle stream")); + } + _subtitle_codec = avcodec_find_decoder (_subtitle_codec_context->codec_id); if (_subtitle_codec == 0) { - throw DecodeError (_("could not find subtitle decoder")); + throw DecodeError (N_("could not find subtitle decoder")); } if (avcodec_open2 (_subtitle_codec_context, _subtitle_codec, 0) < 0) { diff --git a/src/lib/film.cc b/src/lib/film.cc index f77273001..fb5014b3a 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -93,7 +93,7 @@ int const Film::state_version = 7; * @param dir Film directory. */ -Film::Film (boost::filesystem::path dir) +Film::Film (boost::filesystem::path dir, bool log) : _playlist (new Playlist) , _use_dci_name (true) , _dcp_content_type (Config::instance()->default_dcp_content_type ()) @@ -136,7 +136,11 @@ Film::Film (boost::filesystem::path dir) } set_directory (result); - _log.reset (new FileLog (file ("log"))); + if (log) { + _log.reset (new FileLog (file ("log"))); + } else { + _log.reset (new NullLog); + } _playlist->set_sequence_video (_sequence_video); } @@ -327,20 +331,13 @@ Film::encoded_frames () const return N; } -/** Write state to our `metadata' file */ -void -Film::write_metadata () const +shared_ptr<xmlpp::Document> +Film::metadata () const { - if (!boost::filesystem::exists (directory ())) { - boost::filesystem::create_directory (directory ()); - } - LocaleGuard lg; - boost::filesystem::create_directories (directory ()); - - xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("Metadata"); + shared_ptr<xmlpp::Document> doc (new xmlpp::Document); + xmlpp::Element* root = doc->create_root_node ("Metadata"); root->add_child("Version")->add_child_text (lexical_cast<string> (state_version)); root->add_child("Name")->add_child_text (_name); @@ -370,8 +367,16 @@ Film::write_metadata () const root->add_child("Key")->add_child_text (_key.hex ()); _playlist->as_xml (root->add_child ("Playlist")); - doc.write_to_file_formatted (file("metadata.xml").string ()); - + return doc; +} + +/** Write state to our `metadata' file */ +void +Film::write_metadata () const +{ + boost::filesystem::create_directories (directory ()); + shared_ptr<xmlpp::Document> doc = metadata (); + doc->write_to_file_formatted (file("metadata.xml").string ()); _dirty = false; } diff --git a/src/lib/film.h b/src/lib/film.h index 0a747193e..06d19e67e 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -56,7 +56,7 @@ class Screen; class Film : public boost::enable_shared_from_this<Film>, public boost::noncopyable { public: - Film (boost::filesystem::path); + Film (boost::filesystem::path, bool log = true); boost::filesystem::path info_dir () const; boost::filesystem::path j2c_path (int, Eyes, bool) const; @@ -85,6 +85,7 @@ public: void read_metadata (); void write_metadata () const; + boost::shared_ptr<xmlpp::Document> metadata () const; std::string dci_name (bool if_created_now) const; std::string dcp_name (bool if_created_now = false) const; |
