/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
if (state_version <= 5) {
/* Old-style: on/off mapping */
- list<cxml::NodePtr> const c = node->node_children ("Map");
- for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
- set ((*i)->number_child<int> ("ContentIndex"), static_cast<dcp::Channel> ((*i)->number_child<int> ("DCP")), 1);
+ for (auto i: node->node_children ("Map")) {
+ set (i->number_child<int>("ContentIndex"), static_cast<dcp::Channel>(i->number_child<int>("DCP")), 1);
}
} else {
- list<cxml::NodePtr> const c = node->node_children ("Gain");
- for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
+ for (auto i: node->node_children("Gain")) {
if (state_version < 32) {
set (
- (*i)->number_attribute<int> ("Content"),
- static_cast<dcp::Channel> ((*i)->number_attribute<int> ("DCP")),
- raw_convert<float> ((*i)->content ())
+ i->number_attribute<int>("Content"),
+ static_cast<dcp::Channel>(i->number_attribute<int>("DCP")),
+ raw_convert<float>(i->content())
);
} else {
set (
- (*i)->number_attribute<int> ("Input"),
- (*i)->number_attribute<int> ("Output"),
- raw_convert<float> ((*i)->content ())
+ i->number_attribute<int>("Input"),
+ i->number_attribute<int>("Output"),
+ raw_convert<float>(i->content())
);
}
}
for (int c = 0; c < _input_channels; ++c) {
for (int d = 0; d < _output_channels; ++d) {
- xmlpp::Element* t = node->add_child ("Gain");
+ auto t = node->add_child ("Gain");
t->set_attribute ("Input", raw_convert<string> (c));
t->set_attribute ("Output", raw_convert<string> (d));
t->add_child_text (raw_convert<string> (get (c, d)));
list<int> mapped;
- for (vector<vector<float> >::const_iterator i = _gain.begin(); i != _gain.end(); ++i) {
+ for (auto const& i: _gain) {
for (auto j: dcp::used_audio_channels()) {
- if (abs ((*i)[j]) > minus_96_db) {
+ if (abs(i[j]) > minus_96_db) {
mapped.push_back (j);
}
}
void
AudioMapping::unmap_all ()
{
- for (vector<vector<float> >::iterator i = _gain.begin(); i != _gain.end(); ++i) {
- for (vector<float>::iterator j = i->begin(); j != i->end(); ++j) {
- *j = 0;
+ for (auto& i: _gain) {
+ for (auto& j: i) {
+ j = 0;
}
}
}
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
void
Cinema::read_screens (cxml::ConstNodePtr node)
{
- list<cxml::NodePtr> s = node->node_children ("Screen");
- for (list<cxml::NodePtr>::iterator i = s.begin(); i != s.end(); ++i) {
- add_screen (shared_ptr<Screen> (new Screen (*i)));
+ for (auto i: node->node_children("Screen")) {
+ add_screen (shared_ptr<Screen>(new Screen(i)));
}
}
/*
- Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
using std::string;
using std::cout;
using std::vector;
+using std::make_shared;
using std::shared_ptr;
using boost::optional;
using std::dynamic_pointer_cast;
/* Version 2.x */
- cxml::ConstNodePtr in_node = node->node_child ("InputTransferFunction");
- string in_type = in_node->string_child ("Type");
+ auto in_node = node->node_child ("InputTransferFunction");
+ auto in_type = in_node->string_child ("Type");
if (in_type == "Gamma") {
- _in.reset (new dcp::GammaTransferFunction (in_node->number_child<double> ("Gamma")));
+ _in = make_shared<dcp::GammaTransferFunction>(in_node->number_child<double> ("Gamma"));
} else if (in_type == "ModifiedGamma") {
- _in.reset (new dcp::ModifiedGammaTransferFunction (
- in_node->number_child<double> ("Power"),
- in_node->number_child<double> ("Threshold"),
- in_node->number_child<double> ("A"),
- in_node->number_child<double> ("B")
- ));
+ _in = make_shared<dcp::ModifiedGammaTransferFunction>(
+ in_node->number_child<double>("Power"),
+ in_node->number_child<double>("Threshold"),
+ in_node->number_child<double>("A"),
+ in_node->number_child<double>("B")
+ );
} else if (in_type == "SGamut3") {
- _in.reset (new dcp::SGamut3TransferFunction ());
+ _in = make_shared<dcp::SGamut3TransferFunction>();
}
} else {
_yuv_to_rgb = static_cast<dcp::YUVToRGB> (node->optional_number_child<int>("YUVToRGB").get_value_or (dcp::YUV_TO_RGB_REC601));
- list<cxml::NodePtr> m = node->node_children ("Matrix");
+ auto m = node->node_children ("Matrix");
if (!m.empty ()) {
/* Read in old <Matrix> nodes and convert them to chromaticities */
boost::numeric::ublas::matrix<double> C (3, 3);
- for (list<cxml::NodePtr>::iterator i = m.begin(); i != m.end(); ++i) {
- int const ti = (*i)->number_attribute<int> ("i");
- int const tj = (*i)->number_attribute<int> ("j");
- C(ti, tj) = raw_convert<double> ((*i)->content ());
+ for (auto i: m) {
+ int const ti = i->number_attribute<int>("i");
+ int const tj = i->number_attribute<int>("j");
+ C(ti, tj) = raw_convert<double>(i->content());
}
double const rd = C(0, 0) + C(1, 0) + C(2, 0);
}
}
- optional<double> gamma = node->optional_number_child<double> ("OutputGamma");
+ auto gamma = node->optional_number_child<double>("OutputGamma");
if (gamma) {
- _out.reset (new dcp::GammaTransferFunction (node->number_child<double> ("OutputGamma")));
+ _out = make_shared<dcp::GammaTransferFunction>(node->number_child<double>("OutputGamma"));
} else {
- _out.reset (new dcp::IdentityTransferFunction ());
+ _out = make_shared<dcp::IdentityTransferFunction>();
}
}
void
ColourConversion::as_xml (xmlpp::Node* node) const
{
- xmlpp::Node* in_node = node->add_child ("InputTransferFunction");
+ auto in_node = node->add_child ("InputTransferFunction");
if (dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in)) {
- shared_ptr<const dcp::GammaTransferFunction> tf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in);
+ auto tf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in);
in_node->add_child("Type")->add_child_text ("Gamma");
in_node->add_child("Gamma")->add_child_text (raw_convert<string> (tf->gamma ()));
} else if (dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in)) {
- shared_ptr<const dcp::ModifiedGammaTransferFunction> tf = dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in);
+ auto tf = dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in);
in_node->add_child("Type")->add_child_text ("ModifiedGamma");
in_node->add_child("Power")->add_child_text (raw_convert<string> (tf->power ()));
in_node->add_child("Threshold")->add_child_text (raw_convert<string> (tf->threshold ()));
optional<size_t>
ColourConversion::preset () const
{
- vector<PresetColourConversion> presets = PresetColourConversion::all ();
+ auto presets = PresetColourConversion::all ();
size_t i = 0;
while (i < presets.size() && presets[i].conversion != *this) {
++i;
}
if (i >= presets.size ()) {
- return optional<size_t> ();
+ return {};
}
return i;
digester.add (_adjusted_white.get().y);
}
- shared_ptr<const dcp::GammaTransferFunction> gf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_out);
+ auto gf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_out);
if (gf) {
digester.add (gf->gamma ());
}
/*
- Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
using std::exception;
using std::cerr;
using std::shared_ptr;
+using std::make_shared;
using boost::optional;
using std::dynamic_pointer_cast;
using boost::algorithm::trim;
shared_ptr<dcp::CertificateChain>
Config::create_certificate_chain ()
{
- return shared_ptr<dcp::CertificateChain> (
- new dcp::CertificateChain (
- openssl_path(),
- "dcpomatic.com",
- "dcpomatic.com",
- ".dcpomatic.smpte-430-2.ROOT",
- ".dcpomatic.smpte-430-2.INTERMEDIATE",
- "CS.dcpomatic.smpte-430-2.LEAF"
- )
+ return make_shared<dcp::CertificateChain> (
+ openssl_path(),
+ "dcpomatic.com",
+ "dcpomatic.com",
+ ".dcpomatic.smpte-430-2.ROOT",
+ ".dcpomatic.smpte-430-2.INTERMEDIATE",
+ "CS.dcpomatic.smpte-430-2.LEAF"
);
}
cxml::Document f ("Config");
f.read_file (config_file ());
- optional<int> version = f.optional_number_child<int> ("Version");
+ auto version = f.optional_number_child<int> ("Version");
if (version && *version < _current_version) {
/* Back up the old config before we re-write it in a back-incompatible way */
backup ();
_default_directory = boost::optional<boost::filesystem::path> ();
}
- boost::optional<int> b = f.optional_number_child<int> ("ServerPort");
+ auto b = f.optional_number_child<int> ("ServerPort");
if (!b) {
b = f.optional_number_child<int> ("ServerPortBase");
}
_server_port_base = b.get ();
- boost::optional<bool> u = f.optional_bool_child ("UseAnyServers");
+ auto u = f.optional_bool_child ("UseAnyServers");
_use_any_servers = u.get_value_or (true);
for (auto i: f.node_children("Server")) {
_language = f.optional_string_child ("Language");
- optional<string> c = f.optional_string_child ("DefaultContainer");
+ auto c = f.optional_string_child ("DefaultContainer");
if (c) {
_default_container = Ratio::from_id (c.get ());
}
_dcp_issuer = f.string_child ("DCPIssuer");
}
- optional<bool> up = f.optional_bool_child("UploadAfterMakeDCP");
+ auto up = f.optional_bool_child("UploadAfterMakeDCP");
if (!up) {
up = f.optional_bool_child("DefaultUploadAfterMakeDCP");
}
_player_history.push_back (i->content ());
}
- cxml::NodePtr signer = f.optional_node_child ("Signer");
+ auto signer = f.optional_node_child ("Signer");
if (signer) {
- shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
+ auto c = make_shared<dcp::CertificateChain>();
/* Read the signing certificates and private key in from the config file */
for (auto i: signer->node_children ("Certificate")) {
c->add (dcp::Certificate (i->content ()));
_signer_chain = create_certificate_chain ();
}
- cxml::NodePtr decryption = f.optional_node_child ("Decryption");
+ auto decryption = f.optional_node_child ("Decryption");
if (decryption) {
- shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
+ auto c = make_shared<dcp::CertificateChain>();
for (auto i: decryption->node_children ("Certificate")) {
c->add (dcp::Certificate (i->content ()));
}
of the nags.
*/
for (auto i: f.node_children("Nagged")) {
- int const id = i->number_attribute<int>("Id");
+ auto const id = i->number_attribute<int>("Id");
if (id >= 0 && id < NAG_COUNT) {
_nagged[id] = raw_convert<int>(i->content());
}
}
if (bad) {
- optional<bool> const remake = Bad(*bad);
+ auto const remake = Bad(*bad);
if (remake && *remake) {
switch (*bad) {
case BAD_SIGNER_UTF8_STRINGS:
_gdc_username = f.optional_string_child("GDCUsername");
_gdc_password = f.optional_string_child("GDCPassword");
- optional<string> pm = f.optional_string_child("PlayerMode");
+ auto pm = f.optional_string_child("PlayerMode");
if (pm && *pm == "window") {
_player_mode = PLAYER_MODE_WINDOW;
} else if (pm && *pm == "full") {
}
_image_display = f.optional_number_child<int>("ImageDisplay").get_value_or(0);
- optional<string> vc = f.optional_string_child("VideoViewType");
+ auto vc = f.optional_string_child("VideoViewType");
if (vc && *vc == "opengl") {
_video_view_type = VIDEO_VIEW_OPENGL;
} else if (vc && *vc == "simple") {
Config::write_config () const
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("Config");
+ auto root = doc.create_root_node ("Config");
/* [XML] Version The version number of the configuration file format. */
root->add_child("Version")->add_child_text (raw_convert<string>(_current_version));
/* [XML] Signer Certificate chain and private key to use when signing DCPs and KDMs. Should contain <code><Certificate></code>
tags in order and a <code><PrivateKey></code> tag all containing PEM-encoded certificates or private keys as appropriate.
*/
- xmlpp::Element* signer = root->add_child ("Signer");
+ auto signer = root->add_child ("Signer");
DCPOMATIC_ASSERT (_signer_chain);
for (auto const& i: _signer_chain->unordered()) {
signer->add_child("Certificate")->add_child_text (i.certificate (true));
signer->add_child("PrivateKey")->add_child_text (_signer_chain->key().get ());
/* [XML] Decryption Certificate chain and private key to use when decrypting KDMs */
- xmlpp::Element* decryption = root->add_child ("Decryption");
+ auto decryption = root->add_child ("Decryption");
DCPOMATIC_ASSERT (_decryption_chain);
for (auto const& i: _decryption_chain->unordered()) {
decryption->add_child("Certificate")->add_child_text (i.certificate (true));
}
try {
- string const s = doc.write_to_string_formatted ();
+ auto const s = doc.write_to_string_formatted ();
boost::filesystem::path tmp (string(config_file().string()).append(".tmp"));
- FILE* f = fopen_boost (tmp, "w");
+ auto f = fopen_boost (tmp, "w");
if (!f) {
throw FileError (_("Could not open file for writing"), tmp);
}
template <class T>
void
-write_file (string root_node, string node, string version, list<shared_ptr<T> > things, boost::filesystem::path file)
+write_file (string root_node, string node, string version, list<shared_ptr<T>> things, boost::filesystem::path file)
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node (root_node);
+ auto root = doc.create_root_node (root_node);
root->add_child("Version")->add_child_text(version);
for (auto i: things) {
}
boost::system::error_code ec;
- bool const e = boost::filesystem::exists (*dir, ec);
+ auto const e = boost::filesystem::exists (*dir, ec);
if (ec || !e) {
return a;
}
void
Config::clean_history_internal (vector<boost::filesystem::path>& h)
{
- vector<boost::filesystem::path> old = h;
+ auto old = h;
h.clear ();
for (auto i: old) {
try {
Config::read_cinemas (cxml::Document const & f)
{
_cinemas.clear ();
- list<cxml::NodePtr> cin = f.node_children ("Cinema");
for (auto i: f.node_children("Cinema")) {
/* Slightly grotty two-part construction of Cinema here so that we can use
shared_from_this.
*/
- shared_ptr<Cinema> cinema (new Cinema (i));
+ auto cinema = make_shared<Cinema>(i);
cinema->read_screens (i);
_cinemas.push_back (cinema);
}
Config::read_dkdm_recipients (cxml::Document const & f)
{
_dkdm_recipients.clear ();
- list<cxml::NodePtr> cin = f.node_children ("DKDMRecipient");
for (auto i: f.node_children("DKDMRecipient")) {
_dkdm_recipients.push_back (shared_ptr<DKDMRecipient>(new DKDMRecipient(i)));
}
Config::templates () const
{
if (!boost::filesystem::exists (path ("templates"))) {
- return list<string> ();
+ return {};
}
list<string> n;
- for (boost::filesystem::directory_iterator i (path("templates")); i != boost::filesystem::directory_iterator(); ++i) {
- n.push_back (i->path().filename().string());
+ for (auto const& i: boost::filesystem::directory_iterator(path("templates"))) {
+ n.push_back (i.path().filename().string());
}
return n;
}
Config::config_file ()
{
cxml::Document f ("Config");
- boost::filesystem::path main = path("config.xml", false);
+ auto main = path("config.xml", false);
if (!boost::filesystem::exists (main)) {
/* It doesn't exist, so there can't be any links; just return it */
return main;
/* See if there's a link */
try {
f.read_file (main);
- optional<string> link = f.optional_string_child("Link");
+ auto link = f.optional_string_child("Link");
if (link) {
return *link;
}
bool
Config::have_write_permission () const
{
- FILE* f = fopen_boost (config_file(), "r+");
+ auto f = fopen_boost (config_file(), "r+");
if (!f) {
return false;
}
Config::set_audio_mapping_to_default ()
{
DCPOMATIC_ASSERT (_audio_mapping);
- int const ch = _audio_mapping->output_channels ();
+ auto const ch = _audio_mapping->output_channels ();
_audio_mapping = boost::none;
_audio_mapping = audio_mapping (ch);
changed (AUDIO_MAPPING);
/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
Content::Content (cxml::ConstNodePtr node)
: _change_signals_frequent (false)
{
- list<cxml::NodePtr> path_children = node->node_children ("Path");
- for (auto i: path_children) {
+ for (auto i: node->node_children("Path")) {
_paths.push_back (i->content());
- optional<time_t> const mod = i->optional_number_attribute<time_t>("mtime");
+ auto const mod = i->optional_number_attribute<time_t>("mtime");
if (mod) {
_last_write_times.push_back (*mod);
} else if (boost::filesystem::exists(i->content())) {
Content::calculate_digest () const
{
boost::mutex::scoped_lock lm (_mutex);
- vector<boost::filesystem::path> p = _paths;
+ auto p = _paths;
lm.unlock ();
/* Some content files are very big, so we use a poor man's
job->sub (_("Computing digest"));
}
- string const d = calculate_digest ();
+ auto const d = calculate_digest ();
boost::mutex::scoped_lock lm (_mutex);
_digest = d;
{
/* This is a bit naughty, but I can't think of a compelling reason not to do it ... */
xmlpp::Document doc;
- xmlpp::Node* node = doc.create_root_node ("Content");
+ auto node = doc.create_root_node ("Content");
as_xml (node, true);
/* notes is unused here (we assume) */
string
Content::technical_summary () const
{
- string s = String::compose ("%1 %2 %3", path_summary(), digest(), position().seconds());
+ auto s = String::compose ("%1 %2 %3", path_summary(), digest(), position().seconds());
if (_video_frame_rate) {
s += String::compose(" %1", *_video_frame_rate);
}
DCPTime
Content::length_after_trim (shared_ptr<const Film> film) const
{
- DCPTime length = max(DCPTime(), full_length(film) - DCPTime(trim_start() + trim_end(), film->active_frame_rate_change(position())));
+ auto length = max(DCPTime(), full_length(film) - DCPTime(trim_start() + trim_end(), film->active_frame_rate_change(position())));
if (video) {
length = length.round(film->video_frame_rate());
}
DCPOMATIC_ASSERT (number_of_paths ());
- string s = path(0).filename().string ();
+ auto s = path(0).filename().string();
if (number_of_paths() > 1) {
s += " ...";
}
audio->take_settings_from (c->audio);
}
- list<shared_ptr<TextContent> >::iterator i = text.begin ();
- list<shared_ptr<TextContent> >::const_iterator j = c->text.begin ();
+ auto i = text.begin ();
+ auto j = c->text.begin ();
while (i != text.end() && j != c->text.end()) {
(*i)->take_settings_from (*j);
++i;
/*
- Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
using std::pair;
using std::make_pair;
using std::max;
+using std::make_shared;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using boost::optional;
optional<T>
get_optional_enum (cxml::ConstNodePtr node, string name)
{
- optional<int> const v = node->optional_number_child<int>(name);
+ auto const v = node->optional_number_child<int>(name);
if (!v) {
return optional<T>();
}
audio = AudioContent::from_xml (this, node, version);
text = TextContent::from_xml (this, node, version);
- list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
- for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
- _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i, version)));
- if ((*i)->optional_number_child<int> ("Selected")) {
+ for (auto i: node->node_children("SubtitleStream")) {
+ _subtitle_streams.push_back (make_shared<FFmpegSubtitleStream>(i, version));
+ if (i->optional_number_child<int>("Selected")) {
_subtitle_stream = _subtitle_streams.back ();
}
}
- c = node->node_children ("AudioStream");
- for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
- shared_ptr<FFmpegAudioStream> as (new FFmpegAudioStream (*i, version));
+ for (auto i: node->node_children("AudioStream")) {
+ auto as = make_shared<FFmpegAudioStream>(i, version);
audio->add_stream (as);
- if (version < 11 && !(*i)->optional_node_child ("Selected")) {
+ if (version < 11 && !i->optional_node_child ("Selected")) {
/* This is an old file and this stream is not selected, so un-map it */
as->set_mapping (AudioMapping (as->channels (), MAX_DCP_AUDIO_CHANNELS));
}
}
- c = node->node_children ("Filter");
- for (list<cxml::NodePtr>::iterator i = c.begin(); i != c.end(); ++i) {
- Filter const * f = Filter::from_id ((*i)->content ());
+ for (auto i: node->node_children("Filter")) {
+ Filter const * f = Filter::from_id(i->content());
if (f) {
_filters.push_back (f);
} else {
- notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), (*i)->content()));
+ notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), i->content()));
}
}
- optional<ContentTime::Type> const f = node->optional_number_child<ContentTime::Type> ("FirstVideo");
+ auto const f = node->optional_number_child<ContentTime::Type> ("FirstVideo");
if (f) {
_first_video = ContentTime (f.get ());
}
FFmpegContent::FFmpegContent (vector<shared_ptr<Content> > c)
: Content (c)
{
- vector<shared_ptr<Content> >::const_iterator i = c.begin ();
+ auto i = c.begin ();
bool need_video = false;
bool need_audio = false;
}
if (need_video) {
- video.reset (new VideoContent (this, c));
+ video = make_shared<VideoContent>(this, c);
}
if (need_audio) {
- audio.reset (new AudioContent (this, c));
+ audio = make_shared<AudioContent>(this, c);
}
if (need_text) {
- text.push_back (shared_ptr<TextContent> (new TextContent (this, c)));
+ text.push_back (make_shared<TextContent>(this, c));
}
- shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
+ auto ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
DCPOMATIC_ASSERT (ref);
for (size_t i = 0; i < c.size(); ++i) {
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]);
+ auto fc = dynamic_pointer_cast<FFmpegContent>(c[i]);
if (fc->only_text() && fc->only_text()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
throw JoinError (_("Content to be joined must use the same subtitle stream."));
}
audio->as_xml (node);
for (auto i: audio->streams ()) {
- shared_ptr<FFmpegAudioStream> f = dynamic_pointer_cast<FFmpegAudioStream> (i);
+ auto f = dynamic_pointer_cast<FFmpegAudioStream> (i);
DCPOMATIC_ASSERT (f);
f->as_xml (node->add_child("AudioStream"));
}
boost::mutex::scoped_lock lm (_mutex);
- for (vector<shared_ptr<FFmpegSubtitleStream> >::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
- xmlpp::Node* t = node->add_child("SubtitleStream");
- if (_subtitle_stream && *i == _subtitle_stream) {
+ for (auto i: _subtitle_streams) {
+ auto t = node->add_child("SubtitleStream");
+ if (_subtitle_stream && i == _subtitle_stream) {
t->add_child("Selected")->add_child_text("1");
}
- (*i)->as_xml (t);
+ i->as_xml (t);
}
- for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
- node->add_child("Filter")->add_child_text ((*i)->id ());
+ for (auto i: _filters) {
+ node->add_child("Filter")->add_child_text(i->id());
}
if (_first_video) {
Content::examine (film, job);
- shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this (), job));
+ auto examiner = make_shared<FFmpegExaminer>(shared_from_this (), job);
if (examiner->has_video ()) {
video.reset (new VideoContent (this));
video->take_from_examiner (examiner);
}
- boost::filesystem::path first_path = path (0);
+ auto first_path = path (0);
{
boost::mutex::scoped_lock lm (_mutex);
_bits_per_pixel = examiner->bits_per_pixel ();
if (examiner->rotation()) {
- double rot = *examiner->rotation ();
+ auto rot = *examiner->rotation ();
if (fabs (rot - 180) < 1.0) {
_filters.push_back (Filter::from_id ("vflip"));
_filters.push_back (Filter::from_id ("hflip"));
}
if (!examiner->audio_streams().empty ()) {
- audio.reset (new AudioContent (this));
+ audio = make_shared<AudioContent>(this);
- for (auto i: examiner->audio_streams ()) {
+ for (auto i: examiner->audio_streams()) {
audio->add_stream (i);
}
- AudioStreamPtr as = audio->streams().front();
- AudioMapping m = as->mapping ();
+ auto as = audio->streams().front();
+ auto m = as->mapping ();
m.make_default (film ? film->audio_processor() : 0, first_path);
as->set_mapping (m);
}
_subtitle_streams = examiner->subtitle_streams ();
if (!_subtitle_streams.empty ()) {
text.clear ();
- text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)));
+ text.push_back (make_shared<TextContent>(this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN));
_subtitle_stream = _subtitle_streams.front ();
}
}
ss = _subtitle_stream->technical_summary ();
}
- string filt = Filter::ffmpeg_string (_filters);
+ auto filt = Filter::ffmpeg_string (_filters);
- string s = Content::technical_summary ();
+ auto s = Content::technical_summary ();
if (video) {
s += " - " + video->technical_summary ();
s += "_" + _subtitle_stream->identifier ();
}
- for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
- s += "_" + (*i)->id ();
+ for (auto i: _filters) {
+ s += "_" + i->id();
}
return s;
{
DCPOMATIC_ASSERT (video);
- dcp::Size const s = video->size ();
+ auto const s = video->size ();
boost::mutex::scoped_lock lm (_mutex);
void
FFmpegContent::take_settings_from (shared_ptr<const Content> c)
{
- shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (c);
+ auto fc = dynamic_pointer_cast<const FFmpegContent> (c);
if (!fc) {
return;
}
/*
- Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
using std::cout;
using std::list;
using std::shared_ptr;
+using std::make_shared;
using std::dynamic_pointer_cast;
using boost::optional;
using dcp::raw_convert;
/** @return TextContents from node or <Text> nodes under node (according to version).
* The list could be empty if no TextContents are found.
*/
-list<shared_ptr<TextContent> >
+list<shared_ptr<TextContent>>
TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
{
if (version < 34) {
subtitle streams, so check for that.
*/
if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) {
- return list<shared_ptr<TextContent> >();
+ return {};
}
/* Otherwise we can drop through to the newer logic */
if (version < 37) {
if (!node->optional_number_child<double>("SubtitleXOffset") && !node->optional_number_child<double>("SubtitleOffset")) {
- return list<shared_ptr<TextContent> >();
+ return {};
}
- list<shared_ptr<TextContent> > c;
- c.push_back (shared_ptr<TextContent> (new TextContent (parent, node, version)));
+ list<shared_ptr<TextContent>> c;
+ c.push_back (make_shared<TextContent>(parent, node, version));
return c;
}
if (!node->optional_node_child("Text")) {
- return list<shared_ptr<TextContent> >();
+ return {};
}
- list<shared_ptr<TextContent> > c;
+ list<shared_ptr<TextContent>> c;
for (auto i: node->node_children("Text")) {
- c.push_back (shared_ptr<TextContent> (new TextContent (parent, i, version)));
+ c.push_back (make_shared<TextContent>(parent, i, version));
}
return c;
_effect = dcp::NONE;
}
- optional<string> effect = node->optional_string_child("Effect");
+ auto effect = node->optional_string_child("Effect");
if (effect) {
if (*effect == "none") {
_effect = dcp::NONE;
_x_scale = _y_scale = node->number_child<double> ("SubtitleScale");
}
- optional<int> r = node->optional_number_child<int>("Red");
- optional<int> g = node->optional_number_child<int>("Green");
- optional<int> b = node->optional_number_child<int>("Blue");
+ auto r = node->optional_number_child<int>("Red");
+ auto g = node->optional_number_child<int>("Green");
+ auto b = node->optional_number_child<int>("Blue");
if (r && g && b) {
_colour = dcp::Colour (*r, *g, *b);
}
if (version >= 36) {
- optional<int> er = node->optional_number_child<int>("EffectRed");
- optional<int> eg = node->optional_number_child<int>("EffectGreen");
- optional<int> eb = node->optional_number_child<int>("EffectBlue");
+ auto er = node->optional_number_child<int>("EffectRed");
+ auto eg = node->optional_number_child<int>("EffectGreen");
+ auto eb = node->optional_number_child<int>("EffectBlue");
if (er && eg && eb) {
_effect_colour = dcp::Colour (*er, *eg, *eb);
}
_fade_out = ContentTime (*fo);
}
- list<cxml::NodePtr> fonts = node->node_children ("Font");
- for (list<cxml::NodePtr>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
- _fonts.push_back (shared_ptr<Font> (new Font (*i)));
+ for (auto i: node->node_children ("Font")) {
+ _fonts.push_back (make_shared<Font>(i));
}
connect_to_fonts ();
}
}
- cxml::ConstNodePtr dt = node->optional_node_child("DCPTrack");
+ auto dt = node->optional_node_child("DCPTrack");
if (dt) {
_dcp_track = DCPTextTrack (dt);
}
}
-TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
+TextContent::TextContent (Content* parent, vector<shared_ptr<Content>> c)
: ContentPart (parent)
{
/* This constructor is for join which is only supported for content types
that have a single text, so we can use only_text() here.
*/
- shared_ptr<TextContent> ref = c[0]->only_text();
+ auto ref = c[0]->only_text();
DCPOMATIC_ASSERT (ref);
- list<shared_ptr<Font> > ref_fonts = ref->fonts ();
+ auto ref_fonts = ref->fonts ();
for (size_t i = 1; i < c.size(); ++i) {
throw JoinError (_("Content to be joined must have the same outline width."));
}
- list<shared_ptr<Font> > fonts = c[i]->only_text()->fonts ();
+ auto fonts = c[i]->only_text()->fonts ();
if (fonts.size() != ref_fonts.size()) {
throw JoinError (_("Content to be joined must use the same fonts."));
}
throw JoinError (_("Content to be joined must use the same DCP track."));
}
- list<shared_ptr<Font> >::const_iterator j = ref_fonts.begin ();
- list<shared_ptr<Font> >::const_iterator k = fonts.begin ();
+ auto j = ref_fonts.begin ();
+ auto k = fonts.begin ();
while (j != ref_fonts.end ()) {
if (**j != **k) {
{
boost::mutex::scoped_lock lm (_mutex);
- xmlpp::Element* text = root->add_child ("Text");
+ auto text = root->add_child ("Text");
text->add_child("Use")->add_child_text (_use ? "1" : "0");
text->add_child("Burn")->add_child_text (_burn ? "1" : "0");
}
text->add_child("OutlineWidth")->add_child_text (raw_convert<string> (_outline_width));
- for (list<shared_ptr<Font> >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
- (*i)->as_xml (text->add_child("Font"));
+ for (auto i: _fonts) {
+ i->as_xml (text->add_child("Font"));
}
text->add_child("Type")->add_child_text (text_type_to_string(_type));
string
TextContent::identifier () const
{
- string s = raw_convert<string> (x_scale())
+ auto s = raw_convert<string> (x_scale())
+ "_" + raw_convert<string> (y_scale())
+ "_" + raw_convert<string> (x_offset())
+ "_" + raw_convert<string> (y_offset())
public:
TextContent (Content* parent, TextType type, TextType original_type);
TextContent (Content* parent, std::vector<std::shared_ptr<Content> >);
+ TextContent (Content* parent, cxml::ConstNodePtr, int version);
void as_xml (xmlpp::Node *) const;
std::string identifier () const;
private:
friend struct ffmpeg_pts_offset_test;
- TextContent (Content* parent, cxml::ConstNodePtr, int version);
void font_changed ();
void connect_to_fonts ();