shared_ptr<dcp::SubtitleAsset> asset,
int64_t picture_duration,
shared_ptr<dcp::Reel> reel,
+ int reel_index,
+ int reel_count,
+ optional<string> content_summary,
list<ReferencedReelAsset> const & refs,
vector<FontData> const & fonts,
dcp::ArrayData default_font,
if (auto interop = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(asset)) {
auto directory = output_dcp / interop->id ();
boost::filesystem::create_directories (directory);
- interop->write (directory / ("sub_" + interop->id() + ".xml"));
+ interop->write (directory / subtitle_asset_filename(asset, reel_index, reel_count, content_summary));
reel_asset = make_shared<Interop> (
interop,
dcp::Fraction(film->video_frame_rate(), 1),
*/
smpte->set_intrinsic_duration(picture_duration);
smpte->write (
- output_dcp / ("sub_" + asset->id() + ".mxf")
+ output_dcp / subtitle_asset_filename(asset, reel_index, reel_count, content_summary)
);
reel_asset = make_shared<SMPTE> (
smpte,
) const
{
auto subtitle = maybe_add_text<dcp::ReelInteropSubtitleAsset, dcp::ReelSMPTESubtitleAsset, dcp::ReelSubtitleAsset> (
- _subtitle_asset, duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
+ _subtitle_asset, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
);
if (subtitle) {
empty_text_asset(TextType::OPEN_SUBTITLE, optional<DCPTextTrack>(), true),
duration,
reel,
+ _reel_index,
+ _reel_count,
+ _content_summary,
refs,
fonts,
_default_font,
for (auto const& i: _closed_caption_assets) {
auto a = maybe_add_text<dcp::ReelInteropClosedCaptionAsset, dcp::ReelSMPTEClosedCaptionAsset, dcp::ReelClosedCaptionAsset> (
- i.second, duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
+ i.second, duration, reel, _reel_index, _reel_count, _content_summary, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
);
DCPOMATIC_ASSERT (a);
a->set_annotation_text (i.first.name);
/* 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> (
- empty_text_asset(TextType::CLOSED_CAPTION, i, true), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only
+ empty_text_asset(TextType::CLOSED_CAPTION, i, true),
+ duration,
+ reel,
+ _reel_index,
+ _reel_count,
+ _content_summary,
+ refs,
+ fonts,
+ _default_font,
+ film(),
+ _period,
+ output_dcp,
+ _text_only
);
DCPOMATIC_ASSERT (a);
a->set_annotation_text (i.name);
namespace dcp {
class PictureAsset;
class SoundAsset;
+ class SubtitleAsset;
}
/** The maximum number of audio channels that we can have in a DCP */
extern std::map<std::string, std::string> split_get_request (std::string url);
extern std::string video_asset_filename (std::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
extern std::string audio_asset_filename (std::shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
+extern std::string subtitle_asset_filename (std::shared_ptr<dcp::SubtitleAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
extern std::string atmos_asset_filename (std::shared_ptr<dcp::AtmosAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
extern float relaxed_string_to_float (std::string);
extern std::string careful_string_filter (std::string);
#include "test.h"
#include "lib/config.h"
-#include "lib/film.h"
-#include "lib/ffmpeg_content.h"
+#include "lib/content_factory.h"
#include "lib/dcp_content_type.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/film.h"
#include "lib/video_content.h"
#ifdef DCPOMATIC_WINDOWS
#include <boost/locale.hpp>
#include <boost/regex.hpp>
-using std::string;
-using std::shared_ptr;
using std::make_shared;
+using std::shared_ptr;
+using std::string;
class Keep
BOOST_CHECK (got[i] == 2);
}
}
+
+
+BOOST_AUTO_TEST_CASE (subtitle_file_naming)
+{
+ Keep keep;
+
+ Config::instance()->set_dcp_asset_filename_format(dcp::NameFormat("%t ostrabagalous %c"));
+
+ auto content = content_factory("test/data/15s.srt");
+ auto film = new_test_film2("subtitle_file_naming", { content.front() });
+ film->set_interop(false);
+
+ make_and_verify_dcp (
+ film,
+ {
+ dcp::VerificationNote::Code::MISSING_CPL_METADATA,
+ dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+ dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+ });
+
+ int got = 0;
+
+ for (auto i: boost::filesystem::directory_iterator(film->file(film->dcp_name()))) {
+ if (boost::regex_match(i.path().filename().string(), boost::regex("sub_ostrabagalous_15s.*\\.mxf"))) {
+ ++got;
+ }
+ }
+
+ BOOST_CHECK_EQUAL(got, 1);
+}
+