static VerifyAssetResult
verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelFileAsset> reel_file_asset, function<void (float)> progress)
{
+ /* When reading the DCP the hash will have been set to the one from the PKL/CPL.
+ * We want to calculate the hash of the actual file contents here, so that we
+ * can check it. unset_hash() means that this calculation will happen on the
+ * call to hash().
+ */
+ reel_file_asset->asset_ref()->unset_hash();
auto const actual_hash = reel_file_asset->asset_ref()->hash(progress);
auto pkls = dcp->pkls();
}
-/** Check the timing of the individual subtitles and make sure there are no empty <Text> nodes */
+/** Check the timing of the individual subtitles and make sure there are no empty <Text> nodes etc. */
static
void
verify_text_details (
+ dcp::Standard standard,
vector<shared_ptr<Reel>> reels,
int edit_rate,
vector<VerificationNote>& notes,
std::function<bool (shared_ptr<Reel>)> check,
std::function<optional<string> (shared_ptr<Reel>)> xml,
- std::function<int64_t (shared_ptr<Reel>)> duration
+ std::function<int64_t (shared_ptr<Reel>)> duration,
+ std::function<std::string (shared_ptr<Reel>)> id
)
{
/* end of last subtitle (in editable units) */
auto empty_text = false;
/* current reel start time (in editable units) */
int64_t reel_offset = 0;
-
- std::function<void (cxml::ConstNodePtr, optional<int>, optional<Time>, int, bool)> parse;
- parse = [&parse, &last_out, &too_short, &too_close, &too_early, &empty_text, &reel_offset](cxml::ConstNodePtr node, optional<int> tcr, optional<Time> start_time, int er, bool first_reel) {
+ optional<string> missing_load_font_id;
+
+ std::function<void (cxml::ConstNodePtr, optional<int>, optional<Time>, int, bool, bool&, vector<string>&)> parse;
+
+ parse = [&parse, &last_out, &too_short, &too_close, &too_early, &empty_text, &reel_offset, &missing_load_font_id](
+ cxml::ConstNodePtr node,
+ optional<int> tcr,
+ optional<Time> start_time,
+ int er,
+ bool first_reel,
+ bool& has_text,
+ vector<string>& font_ids
+ ) {
if (node->name() == "Subtitle") {
Time in (node->string_attribute("TimeIn"), tcr);
if (start_time) {
if (!node_has_content(node)) {
empty_text = true;
}
+ has_text = true;
+ } else if (node->name() == "LoadFont") {
+ if (auto const id = node->optional_string_attribute("Id")) {
+ font_ids.push_back(*id);
+ } else if (auto const id = node->optional_string_attribute("ID")) {
+ font_ids.push_back(*id);
+ }
+ } else if (node->name() == "Font") {
+ if (auto const font_id = node->optional_string_attribute("Id")) {
+ if (std::find_if(font_ids.begin(), font_ids.end(), [font_id](string const& id) { return id == font_id; }) == font_ids.end()) {
+ missing_load_font_id = font_id;
+ }
+ }
}
-
for (auto i: node->node_children()) {
- parse(i, tcr, start_time, er, first_reel);
+ parse(i, tcr, start_time, er, first_reel, has_text, font_ids);
}
};
shared_ptr<cxml::Document> doc;
optional<int> tcr;
optional<Time> start_time;
- try {
+ switch (standard) {
+ case dcp::Standard::INTEROP:
+ doc = make_shared<cxml::Document>("DCSubtitle");
+ doc->read_string (*reel_xml);
+ break;
+ case dcp::Standard::SMPTE:
doc = make_shared<cxml::Document>("SubtitleReel");
doc->read_string (*reel_xml);
tcr = doc->number_child<int>("TimeCodeRate");
- auto start_time_string = doc->optional_string_child("StartTime");
- if (start_time_string) {
+ if (auto start_time_string = doc->optional_string_child("StartTime")) {
start_time = Time(*start_time_string, tcr);
}
- } catch (...) {
- doc = make_shared<cxml::Document>("DCSubtitle");
- doc->read_string (*reel_xml);
+ break;
}
- parse (doc, tcr, start_time, edit_rate, i == 0);
+ bool has_text = false;
+ vector<string> font_ids;
+ parse(doc, tcr, start_time, edit_rate, i == 0, has_text, font_ids);
auto end = reel_offset + duration(reels[i]);
if (last_out && *last_out > end) {
reel_overlap = true;
}
reel_offset = end;
+
+ if (standard == dcp::Standard::SMPTE && has_text && font_ids.empty()) {
+ notes.push_back(dcp::VerificationNote(dcp::VerificationNote::Type::ERROR, VerificationNote::Code::MISSING_LOAD_FONT).set_id(id(reels[i])));
+ }
}
if (last_out && *last_out > reel_offset) {
VerificationNote::Type::WARNING, VerificationNote::Code::EMPTY_TEXT
});
}
+
+ if (missing_load_font_id) {
+ notes.push_back(dcp::VerificationNote(VerificationNote::Type::ERROR, VerificationNote::Code::MISSING_LOAD_FONT_FOR_FONT).set_id(*missing_load_font_id));
+ }
}
static
void
-verify_text_details (vector<shared_ptr<Reel>> reels, vector<VerificationNote>& notes)
+verify_text_details(dcp::Standard standard, vector<shared_ptr<Reel>> reels, vector<VerificationNote>& notes)
{
if (reels.empty()) {
return;
}
if (reels[0]->main_subtitle()) {
- verify_text_details (reels, reels[0]->main_subtitle()->edit_rate().numerator, notes,
+ verify_text_details(standard, reels, reels[0]->main_subtitle()->edit_rate().numerator, notes,
[](shared_ptr<Reel> reel) {
return static_cast<bool>(reel->main_subtitle());
},
[](shared_ptr<Reel> reel) {
- auto interop = dynamic_pointer_cast<ReelInteropSubtitleAsset>(reel->main_subtitle());
- if (interop) {
- return interop->asset()->raw_xml();
- }
- auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(reel->main_subtitle());
- DCP_ASSERT (smpte);
- return smpte->asset()->raw_xml();
+ return reel->main_subtitle()->asset()->raw_xml();
},
[](shared_ptr<Reel> reel) {
return reel->main_subtitle()->actual_duration();
+ },
+ [](shared_ptr<Reel> reel) {
+ return reel->main_subtitle()->id();
}
);
}
for (auto i = 0U; i < reels[0]->closed_captions().size(); ++i) {
- verify_text_details (reels, reels[0]->closed_captions()[i]->edit_rate().numerator, notes,
+ verify_text_details(standard, reels, reels[0]->closed_captions()[i]->edit_rate().numerator, notes,
[i](shared_ptr<Reel> reel) {
return i < reel->closed_captions().size();
},
},
[i](shared_ptr<Reel> reel) {
return reel->closed_captions()[i]->actual_duration();
+ },
+ [i](shared_ptr<Reel> reel) {
+ return reel->closed_captions()[i]->id();
}
);
}
}
}
}
+
}
if (reel->main_sound() && reel->main_sound()->asset_ref().resolved()) {
}
}
+ for (auto version: cpl->content_versions()) {
+ if (version.label_text.empty()) {
+ notes.push_back(
+ dcp::VerificationNote(VerificationNote::Type::WARNING, VerificationNote::Code::EMPTY_CONTENT_VERSION_LABEL_TEXT, cpl->file().get()).set_id(cpl->id())
+ );
+ break;
+ }
+ }
+
if (dcp->standard() == Standard::SMPTE) {
if (!cpl->annotation_text()) {
notes.push_back({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISSING_CPL_ANNOTATION_TEXT, cpl->id(), cpl->file().get()});
);
}
- verify_text_details(cpl->reels(), notes);
+ verify_text_details(dcp->standard().get_value_or(dcp::Standard::SMPTE), cpl->reels(), notes);
if (dcp->standard() == Standard::SMPTE) {
if (auto msc = cpl->main_sound_configuration()) {
);
case VerificationNote::Code::INCORRECT_SUBTITLE_NAMESPACE_COUNT:
return String::compose("The XML in the subtitle asset %1 has more than one namespace declaration.", note.note().get());
+ case VerificationNote::Code::MISSING_LOAD_FONT_FOR_FONT:
+ return String::compose("A subtitle or closed caption refers to a font with ID %1 that does not have a corresponding <LoadFont> node", note.id().get());
+ case VerificationNote::Code::MISSING_LOAD_FONT:
+ return String::compose("The SMPTE subtitle asset %1 has <Text> nodes but no <LoadFont> node", note.id().get());
+ case VerificationNote::Code::MISMATCHED_ASSET_MAP_ID:
+ return String::compose("The asset with ID %1 in the asset map actually has an id of %2", note.id().get(), note.other_id().get());
+ case VerificationNote::Code::EMPTY_CONTENT_VERSION_LABEL_TEXT:
+ return String::compose("The <LabelText> in a <ContentVersion> in CPL %1 is empty", note.id().get());
}
return "";