X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fwriter.cc;h=c31ae2a91661f5e42b5403f28220bc0a1e8c4936;hp=3ab1cc5b9e014aa08ce9519acd0f9d983c32dc05;hb=ad1ef39eda58b3a919ea3b7084401a0439409ec6;hpb=df17bbd25da69fc38eb2dcd8b4a2531cf0bab0bc diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 3ab1cc5b9..c31ae2a91 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -23,6 +23,7 @@ #include "film.h" #include "ratio.h" #include "log.h" +#include "dcpomatic_log.h" #include "dcp_video.h" #include "dcp_content_type.h" #include "audio_mapping.h" @@ -44,14 +45,6 @@ #include "i18n.h" -#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); -#define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, LogEntry::TYPE_GENERAL); -#define LOG_DEBUG_ENCODE(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_DEBUG_ENCODE); -#define LOG_TIMING(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_TIMING); -#define LOG_WARNING_NC(...) _film->log()->log (__VA_ARGS__, LogEntry::TYPE_WARNING); -#define LOG_WARNING(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_WARNING); -#define LOG_ERROR(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR); - /* OS X strikes again */ #undef set_key @@ -63,9 +56,11 @@ using std::cout; using std::map; using std::min; using std::max; +using std::vector; using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; +using boost::optional; using dcp::Data; Writer::Writer (shared_ptr film, weak_ptr j) @@ -95,8 +90,9 @@ Writer::Writer (shared_ptr film, weak_ptr j) and captions arrive to the Writer in sequence. This is not so for video. */ _audio_reel = _reels.begin (); - for (int i = 0; i < CAPTION_COUNT; ++i) { - _caption_reel[i] = _reels.begin (); + _subtitle_reel = _reels.begin (); + BOOST_FOREACH (DCPTextTrack i, _film->closed_caption_tracks()) { + _caption_reels[i] = _reels.begin (); } /* Check that the signer is OK if we need one */ @@ -435,7 +431,7 @@ try DCPOMATIC_ASSERT (i != _queue.rend()); ++_pushed_to_disk; /* For the log message below */ - int const awaiting = _reels[_queue.front().reel].last_written_video_frame(); + int const awaiting = _reels[_queue.front().reel].last_written_video_frame() + 1; lock.unlock (); /* i is valid here, even though we don't hold a lock on the mutex, @@ -664,17 +660,32 @@ Writer::can_fake_write (Frame frame) const return (frame != 0 && frame < reel.first_nonexistant_frame()); } +/** @param track Closed caption track if type == TEXT_CLOSED_CAPTION */ void -Writer::write (PlayerText text, TextType type, DCPTimePeriod period) +Writer::write (PlayerText text, TextType type, optional track, DCPTimePeriod period) { - while (_caption_reel[type]->period().to <= period.from) { - ++_caption_reel[type]; - DCPOMATIC_ASSERT (_caption_reel[type] != _reels.end()); + vector::iterator* reel = 0; + + switch (type) { + case TEXT_OPEN_SUBTITLE: + reel = &_subtitle_reel; + break; + case TEXT_CLOSED_CAPTION: + DCPOMATIC_ASSERT (track); + DCPOMATIC_ASSERT (_caption_reels.find(*track) != _caption_reels.end()); + reel = &_caption_reels[*track]; + break; + default: + DCPOMATIC_ASSERT (false); } - DCPOMATIC_ASSERT (_caption_reel[type] != _reels.end()); + DCPOMATIC_ASSERT (*reel != _reels.end()); + while ((*reel)->period().to <= period.from) { + ++(*reel); + DCPOMATIC_ASSERT (*reel != _reels.end()); + } - _caption_reel[type]->write (text, type, period); + (*reel)->write (text, type, track, period); } void