bool
ContentTimePeriod::contains (ContentTime const & other) const
{
- return (from >= other && to < other);
+ return (from <= other && other < to);
}
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
{
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 ();
*/
+#ifndef DCPOMATIC_IMAGE_SUBTITLE_H
+#define DCPOMATIC_IMAGE_SUBTITLE_H
+
+#include "rect.h"
+
class Image;
class ImageSubtitle
*/
dcpomatic::Rect<double> rectangle;
};
+
+#endif
*/
+#ifndef DCPOMATIC_PLAYER_SUBTITLES_H
+#define DCPOMATIC_PLAYER_SUBTITLES_H
+
+#include <dcp/subtitle_string.h>
+#include "image_subtitle.h"
+
class PlayerSubtitles
{
public:
std::list<ImageSubtitle> image;
std::list<dcp::SubtitleString> text;
};
+
+#endif
_encoder->enqueue (*i);
}
_writer->write (_player->get_audio (t, frame, true));
+ _writer->write (_player->get_subtitles (t, frame, true));
}
_finishing = true;
#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"
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);
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)
{
#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;
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 ();
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;
};
test.cc
threed_test.cc
util_test.cc
+ xml_subtitle_test.cc
"""
obj.target = 'unit-tests'
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file test/burnt_subtitle_test.cc
+ * @brief Test creation of XML DCP subtitles.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include "lib/subrip_content.h"
+#include "lib/film.h"
+#include "lib/ratio.h"
+#include "lib/dcp_content_type.h"
+#include "test.h"
+
+using std::cout;
+using boost::shared_ptr;
+
+/** Build a small DCP with no picture and a single subtitle overlaid onto it */
+BOOST_AUTO_TEST_CASE (xml_subtitle_test)
+{
+ shared_ptr<Film> film = new_test_film ("xml_subtitle_test");
+ film->set_container (Ratio::from_id ("185"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_name ("frobozz");
+ film->set_burn_subtitles (false);
+ shared_ptr<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
+ content->set_subtitle_use (true);
+ film->examine_and_add_content (content);
+ wait_for_jobs ();
+ film->make_dcp ();
+ wait_for_jobs ();
+
+ check_dcp ("test/data/xml_subtitle_test", film->dir (film->dcp_name ()));
+}