summaryrefslogtreecommitdiff
path: root/src/lib/reel_writer.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-08-06 23:57:22 +0200
committerCarl Hetherington <cth@carlh.net>2024-09-03 17:02:24 +0200
commitf3ab77e34a41ad4d8f5156e9d6598314975b9565 (patch)
tree638c81f1b1e71ee138afd4d58ef404e7b3c7f523 /src/lib/reel_writer.cc
parente65d17fa04c411295496968f6ecee9b3a6c21fae (diff)
Adapt to some libdcp class renaming to allow open captions/closed subtitles.
Diffstat (limited to 'src/lib/reel_writer.cc')
-rw-r--r--src/lib/reel_writer.cc53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc
index d8aff1162..5210466b2 100644
--- a/src/lib/reel_writer.cc
+++ b/src/lib/reel_writer.cc
@@ -41,24 +41,22 @@
#include <dcp/cpl.h>
#include <dcp/dcp.h>
#include <dcp/filesystem.h>
-#include <dcp/interop_subtitle_asset.h>
+#include <dcp/interop_text_asset.h>
#include <dcp/mono_j2k_picture_asset.h>
#include <dcp/raw_convert.h>
#include <dcp/reel.h>
#include <dcp/reel_atmos_asset.h>
-#include <dcp/reel_interop_closed_caption_asset.h>
-#include <dcp/reel_interop_subtitle_asset.h>
+#include <dcp/reel_interop_text_asset.h>
#include <dcp/reel_markers_asset.h>
#include <dcp/reel_mono_picture_asset.h>
-#include <dcp/reel_smpte_closed_caption_asset.h>
-#include <dcp/reel_smpte_subtitle_asset.h>
+#include <dcp/reel_smpte_text_asset.h>
#include <dcp/reel_sound_asset.h>
#include <dcp/reel_stereo_picture_asset.h>
-#include <dcp/smpte_subtitle_asset.h>
+#include <dcp/smpte_text_asset.h>
#include <dcp/sound_asset.h>
#include <dcp/sound_asset_writer.h>
#include <dcp/stereo_j2k_picture_asset.h>
-#include <dcp/subtitle_image.h>
+#include <dcp/text_image.h>
#include "i18n.h"
@@ -416,12 +414,13 @@ ReelWriter::finish (boost::filesystem::path output_dcp)
/** Try to make a ReelAsset for a subtitles or closed captions in a given period in the DCP.
- * A SubtitleAsset can be provided, or we will use one from @ref refs if not.
+ * A TextAsset can be provided, or we will use one from @ref refs if not.
*/
template <class Interop, class SMPTE, class Result>
shared_ptr<Result>
maybe_add_text (
- shared_ptr<dcp::SubtitleAsset> asset,
+ shared_ptr<dcp::TextAsset> asset,
+ dcp::TextType type,
int64_t picture_duration,
shared_ptr<dcp::Reel> reel,
int reel_index,
@@ -439,17 +438,18 @@ maybe_add_text (
shared_ptr<Result> reel_asset;
if (asset) {
- if (auto interop = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(asset)) {
+ if (auto interop = dynamic_pointer_cast<dcp::InteropTextAsset>(asset)) {
auto directory = output_dcp / interop->id ();
dcp::filesystem::create_directories(directory);
interop->write (directory / subtitle_asset_filename(asset, reel_index, reel_count, content_summary, ".xml"));
reel_asset = make_shared<Interop> (
+ type,
interop,
dcp::Fraction(film->video_frame_rate(), 1),
picture_duration,
0
);
- } else if (auto smpte = dynamic_pointer_cast<dcp::SMPTESubtitleAsset>(asset)) {
+ } else if (auto smpte = dynamic_pointer_cast<dcp::SMPTETextAsset>(asset)) {
/* All our assets should be the same length; use the picture asset length here
as a reference to set the subtitle one. We'll use the duration rather than
the intrinsic duration; we don't care if the picture asset has been trimmed, we're
@@ -460,6 +460,7 @@ maybe_add_text (
output_dcp / subtitle_asset_filename(asset, reel_index, reel_count, content_summary, ".mxf")
);
reel_asset = make_shared<SMPTE> (
+ type,
smpte,
dcp::Fraction(film->video_frame_rate(), 1),
picture_duration,
@@ -602,14 +603,15 @@ ReelWriter::create_reel_text (
set<DCPTextTrack> ensure_closed_captions
) const
{
- auto subtitle = maybe_add_text<dcp::ReelInteropSubtitleAsset, dcp::ReelSMPTESubtitleAsset, dcp::ReelSubtitleAsset> (
- _subtitle_asset, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only
+ auto subtitle = maybe_add_text<dcp::ReelInteropTextAsset, dcp::ReelSMPTETextAsset, dcp::ReelTextAsset> (
+ _subtitle_asset, dcp::TextType::OPEN_SUBTITLE, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only
);
if (!subtitle && ensure_subtitles) {
/* We had no subtitle asset, but we've been asked to make sure there is one */
- subtitle = maybe_add_text<dcp::ReelInteropSubtitleAsset, dcp::ReelSMPTESubtitleAsset, dcp::ReelSubtitleAsset> (
+ subtitle = maybe_add_text<dcp::ReelInteropTextAsset, dcp::ReelSMPTETextAsset, dcp::ReelTextAsset>(
empty_text_asset(TextType::OPEN_SUBTITLE, optional<DCPTextTrack>(), true),
+ dcp::TextType::OPEN_SUBTITLE,
duration,
reel,
_reel_index,
@@ -631,8 +633,8 @@ ReelWriter::create_reel_text (
}
for (auto const& i: _closed_caption_assets) {
- auto a = maybe_add_text<dcp::ReelInteropClosedCaptionAsset, dcp::ReelSMPTEClosedCaptionAsset, dcp::ReelClosedCaptionAsset> (
- i.second, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only
+ auto a = maybe_add_text<dcp::ReelInteropTextAsset, dcp::ReelSMPTETextAsset, dcp::ReelTextAsset>(
+ i.second, dcp::TextType::CLOSED_CAPTION, duration, reel, _reel_index, _reel_count, _content_summary, refs, film(), _period, output_dcp, _text_only
);
DCPOMATIC_ASSERT (a);
a->set_annotation_text (i.first.name);
@@ -645,8 +647,9 @@ ReelWriter::create_reel_text (
/* Make empty tracks for anything we've been asked to ensure but that we haven't added */
for (auto i: ensure_closed_captions) {
- auto a = maybe_add_text<dcp::ReelInteropClosedCaptionAsset, dcp::ReelSMPTEClosedCaptionAsset, dcp::ReelClosedCaptionAsset> (
+ auto a = maybe_add_text<dcp::ReelInteropTextAsset, dcp::ReelSMPTETextAsset, dcp::ReelTextAsset>(
empty_text_asset(TextType::CLOSED_CAPTION, i, true),
+ dcp::TextType::CLOSED_CAPTION,
duration,
reel,
_reel_index,
@@ -791,15 +794,15 @@ ReelWriter::write (shared_ptr<const AudioBuffers> audio)
}
-shared_ptr<dcp::SubtitleAsset>
+shared_ptr<dcp::TextAsset>
ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track, bool with_dummy) const
{
- shared_ptr<dcp::SubtitleAsset> asset;
+ shared_ptr<dcp::TextAsset> asset;
optional<string> font;
auto lang = film()->subtitle_languages();
if (film()->interop()) {
- auto s = make_shared<dcp::InteropSubtitleAsset>();
+ auto s = make_shared<dcp::InteropTextAsset>();
s->set_movie_title (film()->name());
if (type == TextType::OPEN_SUBTITLE) {
s->set_language (lang.first ? lang.first->to_string() : "Unknown");
@@ -809,7 +812,7 @@ ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track, bool
s->set_reel_number (raw_convert<string> (_reel_index + 1));
asset = s;
} else {
- auto s = make_shared<dcp::SMPTESubtitleAsset>();
+ auto s = make_shared<dcp::SMPTETextAsset>();
s->set_content_title_text (film()->name());
s->set_metadata (mxf_metadata());
if (type == TextType::OPEN_SUBTITLE && lang.first) {
@@ -829,7 +832,7 @@ ReelWriter::empty_text_asset (TextType type, optional<DCPTextTrack> track, bool
if (with_dummy) {
asset->add(
- std::make_shared<dcp::SubtitleString>(
+ std::make_shared<dcp::TextString>(
font,
false,
false,
@@ -897,7 +900,7 @@ ReelWriter::convert_vertical_position(StringText const& subtitle, dcp::SubtitleS
void
ReelWriter::write(PlayerText subs, TextType type, optional<DCPTextTrack> track, DCPTimePeriod period, FontIdMap const& fonts, shared_ptr<dcpomatic::Font> chosen_interop_font)
{
- shared_ptr<dcp::SubtitleAsset> asset;
+ shared_ptr<dcp::TextAsset> asset;
switch (type) {
case TextType::OPEN_SUBTITLE:
@@ -934,7 +937,7 @@ ReelWriter::write(PlayerText subs, TextType type, optional<DCPTextTrack> track,
i.set_in (dcp::Time(period.from.seconds() - _period.from.seconds(), tcr));
i.set_out (dcp::Time(period.to.seconds() - _period.from.seconds(), tcr));
i.set_v_position(convert_vertical_position(i, film()->interop() ? dcp::SubtitleStandard::INTEROP : dcp::SubtitleStandard::SMPTE_2014));
- auto sub = make_shared<dcp::SubtitleString>(i);
+ auto sub = make_shared<dcp::TextString>(i);
/* i.font is a shared_ptr<Font> which uniquely identifies the font we want,
* though if we are Interop we can only have one font, so we'll use the chosen
* one instead.
@@ -951,7 +954,7 @@ ReelWriter::write(PlayerText subs, TextType type, optional<DCPTextTrack> track,
for (auto i: subs.bitmap) {
asset->add (
- make_shared<dcp::SubtitleImage>(
+ make_shared<dcp::TextImage>(
image_as_png(i.image),
dcp::Time(period.from.seconds() - _period.from.seconds(), tcr),
dcp::Time(period.to.seconds() - _period.from.seconds(), tcr),