}
+struct State
+{
+ boost::optional<string> subtitle_language;
+ boost::optional<int> audio_channels;
+};
+
+
static void
verify_main_sound_asset (
shared_ptr<const DCP> dcp,
function<void (string, optional<boost::filesystem::path>)> stage,
function<void (float)> progress,
VerificationOptions options,
- vector<VerificationNote>& notes
+ vector<VerificationNote>& notes,
+ State& state
)
{
auto asset = reel_asset->asset();
}
}
+ if (!state.audio_channels) {
+ state.audio_channels = asset->channels();
+ } else if (*state.audio_channels != asset->channels()) {
+ notes.push_back({ VerificationNote::Type::ERROR, VerificationNote::Code::MISMATCHED_SOUND_CHANNEL_COUNTS, file });
+ }
+
stage ("Checking sound asset metadata", file);
if (auto lang = asset->language()) {
}
-struct State
-{
- boost::optional<string> subtitle_language;
-};
-
-
/** Verify stuff that is common to both subtitles and closed captions */
void
verify_smpte_timed_text_asset (
}
if (reel->main_sound() && reel->main_sound()->asset_ref().resolved()) {
- verify_main_sound_asset(dcp, reel->main_sound(), stage, progress, options, notes);
+ verify_main_sound_asset(dcp, reel->main_sound(), stage, progress, options, notes, state);
}
if (reel->main_subtitle()) {
return String::compose("The subtitle asset %1 has no subtitles", note.note().get());
case VerificationNote::Code::INVALID_SUBTITLE_ISSUE_DATE:
return String::compose("<IssueDate> has an invalid value: %1", note.note().get());
+ case VerificationNote::Code::MISMATCHED_SOUND_CHANNEL_COUNTS:
+ return String::compose("The sound assets do not all have the same channel count; the first to differ is %1", note.file()->filename());
}
return "";
});
}
+
+BOOST_AUTO_TEST_CASE(verify_mismatched_sound_channel_counts)
+{
+ boost::filesystem::path const path = "build/test/verify_mismatched_sound_channel_counts";
+
+ dcp::MXFMetadata mxf_meta;
+ mxf_meta.company_name = "OpenDCP";
+ mxf_meta.product_name = "OpenDCP";
+ mxf_meta.product_version = "0.0.25";
+
+ auto constexpr sample_rate = 48000;
+ auto constexpr frames = 240;
+
+ boost::filesystem::remove_all(path);
+ boost::filesystem::create_directories(path);
+ auto dcp = make_shared<dcp::DCP>(path);
+ auto cpl = make_shared<dcp::CPL>("hello", dcp::ContentKind::TRAILER, dcp::Standard::SMPTE);
+ cpl->set_annotation_text("hello");
+ cpl->set_main_sound_configuration(dcp::MainSoundConfiguration("51/L,R"));
+ cpl->set_main_sound_sample_rate(sample_rate);
+ cpl->set_main_picture_stored_area(dcp::Size(1998, 1080));
+ cpl->set_main_picture_active_area(dcp::Size(1998, 1080));
+ cpl->set_version_number(1);
+
+ {
+
+ /* Reel with 2 channels of audio */
+
+ auto mp = simple_picture(path, "1", frames, {});
+ auto ms = simple_sound(path, "1", mxf_meta, "en-US", frames, sample_rate, {}, 2);
+
+ auto reel = make_shared<dcp::Reel>(
+ std::make_shared<dcp::ReelMonoPictureAsset>(mp, 0),
+ std::make_shared<dcp::ReelSoundAsset>(ms, 0)
+ );
+
+ auto markers = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), frames);
+ markers->set(dcp::Marker::FFOC, dcp::Time(0, 0, 0, 1, 24));
+ reel->add(markers);
+
+ cpl->add(reel);
+ }
+
+ {
+ /* Reel with 6 channels of audio */
+
+ auto mp = simple_picture(path, "2", frames, {});
+ auto ms = simple_sound(path, "2", mxf_meta, "en-US", frames, sample_rate, {}, 6);
+
+ auto reel = make_shared<dcp::Reel>(
+ std::make_shared<dcp::ReelMonoPictureAsset>(mp, 0),
+ std::make_shared<dcp::ReelSoundAsset>(ms, 0)
+ );
+
+ auto markers = make_shared<dcp::ReelMarkersAsset>(dcp::Fraction(24, 1), frames);
+ markers->set(dcp::Marker::LFOC, dcp::Time(0, 0, 0, frames - 1, 24));
+ reel->add(markers);
+
+ cpl->add(reel);
+ }
+
+ dcp->add(cpl);
+ dcp->set_annotation_text("hello");
+ dcp->write_xml();
+
+ check_verify_result(
+ { path },
+ {
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_SOUND_CHANNEL_COUNTS, canonical(find_file(path, "audio2")) },
+ });
+}