diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-07-04 16:34:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-07-04 16:34:13 +0100 |
| commit | 1555c48eda3def5f7ece413a47f0c7ff94dd70dd (patch) | |
| tree | b76430372b6807f9d3341a1c70bb64e41472182c /src/lib | |
| parent | 9655db97eae5a6137a45ad809dbf42528dc74408 (diff) | |
Make XML subtitle work at the very minimal level.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcpomatic_time.cc | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 6 | ||||
| -rw-r--r-- | src/lib/film.h | 1 | ||||
| -rw-r--r-- | src/lib/image_subtitle.h | 7 | ||||
| -rw-r--r-- | src/lib/player_subtitles.h | 8 | ||||
| -rw-r--r-- | src/lib/transcoder.cc | 1 | ||||
| -rw-r--r-- | src/lib/writer.cc | 21 | ||||
| -rw-r--r-- | src/lib/writer.h | 4 |
8 files changed, 49 insertions, 1 deletions
diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index fa6271354..812c756ec 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -59,5 +59,5 @@ ContentTimePeriod::overlaps (ContentTimePeriod const & other) const bool ContentTimePeriod::contains (ContentTime const & other) const { - return (from >= other && to < other); + return (from <= other && other < to); } diff --git a/src/lib/film.cc b/src/lib/film.cc index 4f4dc3187..85dc5b168 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -230,6 +230,12 @@ Film::audio_mxf_filename () const return filename_safe_name() + "_audio.mxf"; } +boost::filesystem::path +Film::subtitle_xml_filename () const +{ + return filename_safe_name() + "_subtitle.xml"; +} + string Film::filename_safe_name () const { diff --git a/src/lib/film.h b/src/lib/film.h index 83505cc6d..6c3f78895 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -70,6 +70,7 @@ public: boost::filesystem::path video_mxf_filename () const; boost::filesystem::path audio_mxf_filename () const; + boost::filesystem::path subtitle_xml_filename () const; void send_dcp_to_tms (); void make_dcp (); diff --git a/src/lib/image_subtitle.h b/src/lib/image_subtitle.h index 6a4f902e6..b25943ae1 100644 --- a/src/lib/image_subtitle.h +++ b/src/lib/image_subtitle.h @@ -17,6 +17,11 @@ */ +#ifndef DCPOMATIC_IMAGE_SUBTITLE_H +#define DCPOMATIC_IMAGE_SUBTITLE_H + +#include "rect.h" + class Image; class ImageSubtitle @@ -37,3 +42,5 @@ public: */ dcpomatic::Rect<double> rectangle; }; + +#endif diff --git a/src/lib/player_subtitles.h b/src/lib/player_subtitles.h index 62b77c077..46994ea3b 100644 --- a/src/lib/player_subtitles.h +++ b/src/lib/player_subtitles.h @@ -17,6 +17,12 @@ */ +#ifndef DCPOMATIC_PLAYER_SUBTITLES_H +#define DCPOMATIC_PLAYER_SUBTITLES_H + +#include <dcp/subtitle_string.h> +#include "image_subtitle.h" + class PlayerSubtitles { public: @@ -32,3 +38,5 @@ public: std::list<ImageSubtitle> image; std::list<dcp::SubtitleString> text; }; + +#endif diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index df5f0221e..843524cce 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -68,6 +68,7 @@ Transcoder::go () _encoder->enqueue (*i); } _writer->write (_player->get_audio (t, frame, true)); + _writer->write (_player->get_subtitles (t, frame, true)); } _finishing = true; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 04eac854c..b1dbca0e0 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -27,6 +27,7 @@ #include <dcp/reel_mono_picture_asset.h> #include <dcp/reel_stereo_picture_asset.h> #include <dcp/reel_sound_asset.h> +#include <dcp/reel_subtitle_asset.h> #include <dcp/dcp.h> #include <dcp/cpl.h> #include "writer.h" @@ -452,6 +453,12 @@ Writer::finish () reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (_sound_mxf, 0))); dcp.add (_sound_mxf); } + + if (_subtitle_content) { + _subtitle_content->write_xml (_film->dir (_film->dcp_name ()) / _film->subtitle_xml_filename ()); + reel->add (shared_ptr<dcp::ReelSubtitleAsset> (new dcp::ReelSubtitleAsset (_subtitle_content, 0))); + dcp.add (_subtitle_content); + } cpl->add (reel); @@ -571,6 +578,20 @@ Writer::can_fake_write (int frame) const return (frame != 0 && frame < _first_nonexistant_frame); } +void +Writer::write (PlayerSubtitles subs) +{ + if (!_subtitle_content) { + _subtitle_content.reset ( + new dcp::SubtitleContent (dcp::Fraction (_film->video_frame_rate(), 1), _film->name(), _film->isdcf_metadata().subtitle_language) + ); + } + + for (list<dcp::SubtitleString>::const_iterator i = subs.text.begin(); i != subs.text.end(); ++i) { + _subtitle_content->add (*i); + } +} + bool operator< (QueueItem const & a, QueueItem const & b) { diff --git a/src/lib/writer.h b/src/lib/writer.h index 2ddf70380..66fe98ec7 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -25,8 +25,10 @@ #include <boost/shared_ptr.hpp> #include <boost/thread.hpp> #include <boost/thread/condition.hpp> +#include <dcp/subtitle_content.h> #include "exceptions.h" #include "types.h" +#include "player_subtitles.h" class Film; class EncodedData; @@ -91,6 +93,7 @@ public: void write (boost::shared_ptr<const EncodedData>, int, Eyes); void fake_write (int, Eyes); void write (boost::shared_ptr<const AudioBuffers>); + void write (PlayerSubtitles); void repeat (int f, Eyes); void finish (); @@ -145,4 +148,5 @@ private: boost::shared_ptr<dcp::PictureMXFWriter> _picture_mxf_writer; boost::shared_ptr<dcp::SoundMXF> _sound_mxf; boost::shared_ptr<dcp::SoundMXFWriter> _sound_mxf_writer; + boost::shared_ptr<dcp::SubtitleContent> _subtitle_content; }; |
