/*
- 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.
*/
+
#include "cross.h"
#include "compose.hpp"
#include "dcpomatic_log.h"
#include "i18n.h"
+
using std::string;
+
Drive::Drive (string xml)
{
cxml::Document doc;
Drive::as_xml () const
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("Drive");
+ auto root = doc.create_root_node ("Drive");
root->add_child("Device")->add_child_text(_device);
for (auto i: _mount_points) {
root->add_child("MountPoint")->add_child_text(i.string());
return String::compose(_("%1 (%2 GB) [%3]"), name, gb, _device);
}
+
string
Drive::log_summary () const
{
DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent> c, bool fast, bool tolerant, shared_ptr<DCPDecoder> old)
: DCP (c, tolerant)
, Decoder (film)
- , _decode_referenced (false)
{
if (c->can_be_played()) {
if (c->video) {
set_decode_referenced (false);
_reel = _reels.begin ();
- _offset = 0;
get_readers ();
}
/*
- Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/dcp_decoder.h
* @brief A decoder of existing DCPs.
*/
+
#include "atmos_metadata.h"
#include "decoder.h"
#include "dcp.h"
#include <dcp/sound_asset_reader.h>
#include <dcp/subtitle_asset.h>
+
namespace dcp {
class Reel;
}
class Log;
struct dcp_subtitle_within_dcp_test;
+
class DCPDecoder : public DCP, public Decoder
{
public:
void set_decode_referenced (bool r);
void set_forced_reduction (boost::optional<int> reduction);
- bool pass ();
- void seek (dcpomatic::ContentTime t, bool accurate);
+ bool pass () override;
+ void seek (dcpomatic::ContentTime t, bool accurate) override;
- std::vector<dcpomatic::FontData> fonts () const;
+ std::vector<dcpomatic::FontData> fonts () const override;
std::string lazy_digest () const {
return _lazy_digest;
}
- dcpomatic::ContentTime position () const;
+ dcpomatic::ContentTime position () const override;
private:
friend struct dcp_subtitle_within_dcp_test;
std::vector<std::shared_ptr<dcp::Reel>>::iterator _reel;
/** Offset of _reel from the start of the content in frames */
- int64_t _offset;
+ int64_t _offset = 0;
/** Reader for current mono picture asset, if applicable */
std::shared_ptr<dcp::MonoPictureAssetReader> _mono_reader;
/** Reader for current stereo picture asset, if applicable */
std::shared_ptr<dcp::AtmosAssetReader> _atmos_reader;
boost::optional<AtmosMetadata> _atmos_metadata;
- bool _decode_referenced;
+ bool _decode_referenced = false;
boost::optional<int> _forced_reduction;
std::string _lazy_digest;
/*
- Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "dcp_subtitle_decoder.h"
#include "dcp_subtitle_content.h"
#include <dcp/interop_subtitle_asset.h>
#include <dcp/load_font_node.h>
#include <iostream>
+
using std::cout;
using std::list;
using std::map;
using std::vector;
using std::shared_ptr;
using std::dynamic_pointer_cast;
+using std::make_shared;
using boost::bind;
using namespace dcpomatic;
+
DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const Film> film, shared_ptr<const DCPSubtitleContent> content)
: Decoder (film)
{
- shared_ptr<dcp::SubtitleAsset> c (load (content->path (0)));
+ auto c = load (content->path(0));
c->fix_empty_font_ids ();
_subtitles = c->subtitles ();
_next = _subtitles.begin ();
if (_next != _subtitles.end()) {
first = content_time_period(*_next).from;
}
- text.push_back (shared_ptr<TextDecoder> (new TextDecoder (this, content->only_text(), first)));
+ text.push_back (make_shared<TextDecoder>(this, content->only_text(), first));
- map<string, dcp::ArrayData> fm = c->font_data();
- for (map<string, dcp::ArrayData>::const_iterator j = fm.begin(); j != fm.end(); ++j) {
- _fonts.push_back (FontData(j->first, j->second));
+ auto fm = c->font_data();
+ for (auto const& i: fm) {
+ _fonts.push_back (FontData(i.first, i.second));
}
/* Add a default font for any LoadFont nodes in our file which we haven't yet found fonts for */
}
}
+
void
DCPSubtitleDecoder::seek (ContentTime time, bool accurate)
{
}
}
+
bool
DCPSubtitleDecoder::pass ()
{
list<dcp::SubtitleString> s;
list<dcp::SubtitleImage> i;
- ContentTimePeriod const p = content_time_period (*_next);
+ auto const p = content_time_period (*_next);
while (_next != _subtitles.end () && content_time_period (*_next) == p) {
auto ns = dynamic_pointer_cast<const dcp::SubtitleString>(*_next);
return false;
}
+
ContentTimePeriod
DCPSubtitleDecoder::content_time_period (shared_ptr<const dcp::Subtitle> s) const
{
/*
- Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "text_decoder.h"
#include "dcp_subtitle.h"
#include "font_data.h"
+
class DCPSubtitleContent;
+
class DCPSubtitleDecoder : public DCPSubtitle, public Decoder
{
public:
/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "dcpomatic_time.h"
#include <inttypes.h>
+
using std::string;
using namespace dcpomatic;
+
template <>
Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
- : _t (llrint (d.get() * f.speed_up))
+ : _t (llrint(d.get() * f.speed_up))
{
}
+
template <>
Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (ContentTime d, FrameRateChange f)
- : _t (llrint (d.get() / f.speed_up))
+ : _t (llrint(d.get() / f.speed_up))
{
}
+
DCPTime
dcpomatic::min (DCPTime a, DCPTime b)
{
return b;
}
+
DCPTime
dcpomatic::max (DCPTime a, DCPTime b)
{
return b;
}
+
ContentTime
dcpomatic::min (ContentTime a, ContentTime b)
{
return b;
}
+
ContentTime
dcpomatic::max (ContentTime a, ContentTime b)
{
return b;
}
+
string
dcpomatic::to_string (ContentTime t)
{
return buffer;
}
+
string
dcpomatic::to_string (DCPTime t)
{
return buffer;
}
+
string
dcpomatic::to_string (DCPTimePeriod p)
{
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "dolby_cp750.h"
#include "i18n.h"
+
using namespace std;
+
DolbyCP750::DolbyCP750 ()
: CinemaSoundProcessor ("dolby_cp750", _("Dolby CP650 or CP750"), 4.0f, 20, 3.33333333333333333)
{
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/lib/dolby_cp750.h
* @brief DolbyCP750 class.
*/
+
#include "cinema_sound_processor.h"
+
class DolbyCP750 : public CinemaSoundProcessor
{
public:
/*
- Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "empty.h"
#include "film.h"
#include "playlist.h"
#include "piece.h"
#include <iostream>
+
using std::cout;
using std::list;
using std::shared_ptr;
using std::dynamic_pointer_cast;
-using boost::function;
+using std::function;
using namespace dcpomatic;
+
Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, function<bool (shared_ptr<const Content>)> part, DCPTime length)
{
list<DCPTimePeriod> full;
for (auto i: playlist->content()) {
if (part(i)) {
- full.push_back (DCPTimePeriod (i->position(), i->end(film)));
+ full.push_back (DCPTimePeriod(i->position(), i->end(film)));
}
}
_periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
- if (!_periods.empty ()) {
+ if (!_periods.empty()) {
_position = _periods.front().from;
}
}
+
void
Empty::set_position (DCPTime position)
{
}
}
+
DCPTimePeriod
Empty::period_at_position () const
{
DCPOMATIC_ASSERT (false);
}
+
bool
Empty::done () const
{
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_EMPTY_H
#define DCPOMATIC_EMPTY_H
+
#include "playlist.h"
#include "dcpomatic_time.h"
#include "content_part.h"
#include <list>
+
struct empty_test1;
struct empty_test2;
struct empty_test3;
struct empty_test_with_overlapping_content;
struct player_subframe_test;
+
class Empty
{
public:
Empty () {}
- Empty (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, boost::function<bool (std::shared_ptr<const Content>)> part, dcpomatic::DCPTime length);
+ Empty (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, std::function<bool (std::shared_ptr<const Content>)> part, dcpomatic::DCPTime length);
dcpomatic::DCPTime position () const {
return _position;
dcpomatic::DCPTime _position;
};
+
#endif
FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmpegContent> c, bool fast)
: FFmpeg (c)
, Decoder (film)
- , _have_current_subtitle (false)
{
if (c->video && c->video->use()) {
video = make_shared<VideoDecoder>(this, c);
public:
FFmpegDecoder (std::shared_ptr<const Film> film, std::shared_ptr<const FFmpegContent>, bool fast);
- bool pass ();
- void seek (dcpomatic::ContentTime time, bool);
+ bool pass () override;
+ void seek (dcpomatic::ContentTime time, bool) override;
private:
friend struct ::ffmpeg_pts_offset_test;
dcpomatic::ContentTime _pts_offset;
boost::optional<dcpomatic::ContentTime> _current_subtitle_to;
/** true if we have a subtitle which has not had emit_stop called for it yet */
- bool _have_current_subtitle;
+ bool _have_current_subtitle = false;
std::shared_ptr<Image> _black_image;
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "font.h"
+
#include "dcpomatic_assert.h"
+#include "font.h"
#include "warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
DCPOMATIC_ENABLE_WARNINGS
+
using std::string;
using namespace dcpomatic;
+
Font::Font (cxml::NodePtr node)
- : _id (node->string_child ("Id"))
+ : _id (node->string_child("Id"))
{
for (auto i: node->node_children("File")) {
- string variant = i->optional_string_attribute("Variant").get_value_or ("Normal");
+ string variant = i->optional_string_attribute("Variant").get_value_or("Normal");
if (variant == "Normal") {
_file = i->content();
}
}
}
+
void
Font::as_xml (xmlpp::Node* node)
{
- node->add_child("Id")->add_child_text (_id);
+ node->add_child("Id")->add_child_text(_id);
if (_file) {
node->add_child("File")->add_child_text(_file->string());
}
return a.file() == b.file();
}
+
bool
dcpomatic::operator!= (Font const & a, Font const & b)
{
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_FONT_H
#define DCPOMATIC_FONT_H
+
#include <libcxml/cxml.h>
#include <boost/optional.hpp>
#include <boost/signals2.hpp>
#include <boost/filesystem.hpp>
#include <string>
+
namespace dcpomatic {
+
class Font
{
public:
boost::optional<boost::filesystem::path> _file;
};
+
bool operator!= (Font const & a, Font const & b);
bool operator== (Font const & a, Font const & b);
+
}
#endif
*/
+
#include "dcp_content_type.h"
#include "hints.h"
#include "types.h"
#include "i18n.h"
+
using std::cout;
using std::make_shared;
using std::max;
}
+
void
Hints::start ()
{
_thread = boost::thread (bind(&Hints::thread, this));
}
+
Hints::~Hints ()
{
boost::this_thread::disable_interruption dis;
for (auto i: film()->content()) {
for (auto j: i->text) {
for (auto k: j->fonts()) {
- optional<boost::filesystem::path> const p = k->file ();
+ auto const p = k->file ();
if (p && boost::filesystem::file_size(p.get()) >= (MAX_FONT_FILE_SIZE - SIZE_SLACK)) {
big_font_files = true;
}
{
int vob = 0;
for (auto i: film()->content()) {
- if (boost::algorithm::starts_with (i->path(0).filename().string(), "VTS_")) {
+ if (boost::algorithm::starts_with(i->path(0).filename().string(), "VTS_")) {
++vob;
}
}
ch = ch.substr (0, ch.length() - 2);
- if (!ch.empty ()) {
- hint (String::compose (
+ if (!ch.empty()) {
+ hint(String::compose(
_("Your audio level is very high (on %1). You should reduce the gain of your audio content."),
ch
)
bool ccap_mxf_too_big = false;
bool subs_mxf_too_big = false;
- boost::filesystem::path dcp_dir = film->dir("hints") / dcpomatic::get_process_id();
+ auto dcp_dir = film->dir("hints") / dcpomatic::get_process_id();
boost::filesystem::remove_all (dcp_dir);
_writer->finish (film->dir("hints") / dcpomatic::get_process_id());
store_current ();
}
+
void
Hints::hint (string h)
{
/*
- Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "audio_analyser.h"
#include "signaller.h"
#include "player_text.h"
*/
+
#include "image_content.h"
#include "image_decoder.h"
#include "video_decoder.h"
#include "i18n.h"
+
using std::cout;
using std::make_shared;
using std::shared_ptr;
using dcp::Size;
using namespace dcpomatic;
+
ImageDecoder::ImageDecoder (shared_ptr<const Film> film, shared_ptr<const ImageContent> c)
: Decoder (film)
, _image_content (c)
- , _frame_video_position (0)
{
video = make_shared<VideoDecoder>(this, c);
}
+
bool
ImageDecoder::pass ()
{
return false;
}
+
void
ImageDecoder::seek (ContentTime time, bool accurate)
{
/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "decoder.h"
+
class ImageContent;
class Log;
class ImageProxy;
+
class ImageDecoder : public Decoder
{
public:
return _image_content;
}
- bool pass ();
- void seek (dcpomatic::ContentTime, bool);
+ bool pass () override;
+ void seek (dcpomatic::ContentTime, bool) override;
private:
std::shared_ptr<const ImageContent> _image_content;
std::shared_ptr<ImageProxy> _image;
- Frame _frame_video_position;
+ Frame _frame_video_position = 0;
};
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "kdm_recipient.h"
+
KDMRecipient::KDMRecipient (cxml::ConstNodePtr node)
: name (node->string_child("Name"))
- , notes (node->optional_string_child("Notes").get_value_or (""))
+ , notes (node->optional_string_child("Notes").get_value_or(""))
{
if (node->optional_string_child("Certificate")) {
recipient = dcp::Certificate (node->string_child("Certificate"));
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_KDM_RECIPIENT_H
#define DCPOMATIC_KDM_RECIPIENT_H
+
#include "warnings.h"
#include <dcp/certificate.h>
#include <libcxml/cxml.h>
#include <boost/optional.hpp>
#include <string>
+
class KDMRecipient
{
public:
boost::optional<dcp::Certificate> recipient;
};
+
#endif
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "scp_uploader.h"
#include "exceptions.h"
#include "job.h"
#include "i18n.h"
-using std::string;
+
+using std::function;
using std::min;
using std::shared_ptr;
-using boost::function;
+using std::string;
+
SCPUploader::SCPUploader (function<void (string)> set_status, function<void (float)> set_progress)
: Uploader (set_status, set_progress)
{
_session = ssh_new ();
if (!_session) {
- throw NetworkError (_("could not start SSH session"));
+ throw NetworkError (String::compose(_("SSH error [%1]"), "ssh_new"));
}
- ssh_options_set (_session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str ());
- ssh_options_set (_session, SSH_OPTIONS_USER, Config::instance()->tms_user().c_str ());
+ ssh_options_set (_session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str());
+ ssh_options_set (_session, SSH_OPTIONS_USER, Config::instance()->tms_user().c_str());
int const port = 22;
ssh_options_set (_session, SSH_OPTIONS_PORT, &port);
int r = ssh_connect (_session);
if (r != SSH_OK) {
- throw NetworkError (String::compose (_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error(_session)));
}
DCPOMATIC_DISABLE_WARNINGS
r = ssh_is_server_known (_session);
if (r == SSH_SERVER_ERROR) {
- throw NetworkError (String::compose (_("SSH error (%1)"), ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_is_server_known", ssh_get_error(_session)));
}
DCPOMATIC_ENABLE_WARNINGS
r = ssh_userauth_password (_session, 0, Config::instance()->tms_password().c_str ());
if (r != SSH_AUTH_SUCCESS) {
- throw NetworkError (String::compose (_("Failed to authenticate with server (%1)"), ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("Failed to authenticate with server (%1)"), ssh_get_error(_session)));
}
- _scp = ssh_scp_new (_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str ());
+ _scp = ssh_scp_new (_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str());
if (!_scp) {
- throw NetworkError (String::compose (_("could not start SCP session (%1)"), ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_scp_new", ssh_get_error(_session)));
}
r = ssh_scp_init (_scp);
if (r != SSH_OK) {
- throw NetworkError (String::compose (_("Could not start SCP session (%1)"), ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_scp_init", ssh_get_error(_session)));
}
}
+
SCPUploader::~SCPUploader ()
{
ssh_scp_free (_scp);
ssh_free (_session);
}
+
void
SCPUploader::create_directory (boost::filesystem::path directory)
{
/* Use generic_string so that we get forward-slashes in the path, even on Windows */
int const r = ssh_scp_push_directory (_scp, directory.generic_string().c_str(), S_IRWXU);
if (r != SSH_OK) {
- throw NetworkError (String::compose (_("Could not create remote directory %1 (%2)"), directory, ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("Could not create remote directory %1 (%2)"), directory, ssh_get_error(_session)));
}
}
+
void
SCPUploader::upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size)
{
- boost::uintmax_t to_do = boost::filesystem::file_size (from);
+ auto to_do = boost::filesystem::file_size (from);
/* Use generic_string so that we get forward-slashes in the path, even on Windows */
ssh_scp_push_file (_scp, to.generic_string().c_str(), to_do, S_IRUSR | S_IWUSR);
- FILE* f = fopen_boost (from, "rb");
- if (f == 0) {
- throw NetworkError (String::compose (_("Could not open %1 to send"), from));
+ auto f = fopen_boost (from, "rb");
+ if (f == nullptr) {
+ throw NetworkError (String::compose(_("Could not open %1 to send"), from));
}
boost::uintmax_t buffer_size = 64 * 1024;
int const r = ssh_scp_write (_scp, buffer, t);
if (r != SSH_OK) {
fclose (f);
- throw NetworkError (String::compose (_("Could not write to remote file (%1)"), ssh_get_error (_session)));
+ throw NetworkError (String::compose(_("Could not write to remote file (%1)"), ssh_get_error(_session)));
}
to_do -= t;
transferred += t;
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "uploader.h"
#include <libssh/libssh.h>
+
class SCPUploader : public Uploader
{
public:
- SCPUploader (boost::function<void (std::string)> set_status, boost::function<void (float)> set_progress);
+ SCPUploader (std::function<void (std::string)> set_status, std::function<void (float)> set_progress);
~SCPUploader ();
protected:
- virtual void create_directory (boost::filesystem::path directory);
- virtual void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size);
+ virtual void create_directory (boost::filesystem::path directory) override;
+ virtual void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) override;
private:
ssh_session _session;
/*
- Copyright (C) 2018-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "content_store.h"
#include "spl.h"
#include "warnings.h"
DCPOMATIC_ENABLE_WARNINGS
#include <iostream>
+
using std::cout;
using std::string;
using std::shared_ptr;
using dcp::raw_convert;
+
void
SPL::read (boost::filesystem::path path, ContentStore* store)
{
_id = doc.string_child("Id");
_name = doc.string_child("Name");
for (auto i: doc.node_children("Entry")) {
- shared_ptr<Content> c = store->get(i->string_child("Digest"));
+ auto c = store->get(i->string_child("Digest"));
if (c) {
add (SPLEntry(c));
} else {
}
}
+
void
SPL::write (boost::filesystem::path path) const
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("SPL");
+ auto root = doc.create_root_node ("SPL");
root->add_child("Id")->add_child_text (_id);
root->add_child("Name")->add_child_text (_name);
for (auto i: _spl) {
/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "usl.h"
#include "i18n.h"
+
USL::USL ()
: CinemaSoundProcessor ("usl", _("USL"), 5.5f, 10, 3.33333333333333333)
{
/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/lib/usl.h
* @brief USL class.
*/
+
#include "cinema_sound_processor.h"
+
class USL : public CinemaSoundProcessor
{
public:
*/
+
#include "video_mxf_decoder.h"
#include "video_decoder.h"
#include "video_mxf_content.h"
#include <dcp/stereo_picture_asset_reader.h>
#include <dcp/exceptions.h>
+
+using std::make_shared;
using std::shared_ptr;
using boost::optional;
using namespace dcpomatic;
+
VideoMXFDecoder::VideoMXFDecoder (shared_ptr<const Film> film, shared_ptr<const VideoMXFContent> content)
: Decoder (film)
, _content (content)
{
- video.reset (new VideoDecoder (this, content));
+ video = make_shared<VideoDecoder>(this, content);
shared_ptr<dcp::MonoPictureAsset> mono;
try {
- mono.reset (new dcp::MonoPictureAsset (_content->path(0)));
+ mono = make_shared<dcp::MonoPictureAsset>(_content->path(0));
} catch (dcp::MXFFileError& e) {
/* maybe it's stereo */
} catch (dcp::ReadError& e) {
shared_ptr<dcp::StereoPictureAsset> stereo;
try {
- stereo.reset (new dcp::StereoPictureAsset (_content->path(0)));
+ stereo = make_shared<dcp::StereoPictureAsset>(_content->path(0));
} catch (dcp::MXFFileError& e) {
if (!mono) {
throw;
}
}
+
bool
VideoMXFDecoder::pass ()
{
- double const vfr = _content->active_video_frame_rate (film());
- int64_t const frame = _next.frames_round (vfr);
+ auto const vfr = _content->active_video_frame_rate (film());
+ auto const frame = _next.frames_round (vfr);
if (frame >= _content->video->length()) {
return true;
if (_mono_reader) {
video->emit (
film(),
- shared_ptr<ImageProxy> (
- new J2KImageProxy (_mono_reader->get_frame(frame), _size, AV_PIX_FMT_XYZ12LE, optional<int>())
- ),
+ std::make_shared<J2KImageProxy>(_mono_reader->get_frame(frame), _size, AV_PIX_FMT_XYZ12LE, optional<int>()),
frame
);
} else {
video->emit (
film(),
- shared_ptr<ImageProxy> (
- new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::Eye::LEFT, AV_PIX_FMT_XYZ12LE, optional<int>())
- ),
+ std::make_shared<J2KImageProxy>(_stereo_reader->get_frame(frame), _size, dcp::Eye::LEFT, AV_PIX_FMT_XYZ12LE, optional<int>()),
frame
);
video->emit (
film(),
- shared_ptr<ImageProxy> (
- new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::Eye::RIGHT, AV_PIX_FMT_XYZ12LE, optional<int>())
- ),
+ std::make_shared<J2KImageProxy>(_stereo_reader->get_frame(frame), _size, dcp::Eye::RIGHT, AV_PIX_FMT_XYZ12LE, optional<int>()),
frame
);
}
return false;
}
+
void
VideoMXFDecoder::seek (ContentTime t, bool accurate)
{
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "decoder.h"
#include <dcp/mono_picture_asset_reader.h>
#include <dcp/stereo_picture_asset_reader.h>
+
class VideoMXFContent;
class Log;
+
class VideoMXFDecoder : public Decoder
{
public:
VideoMXFDecoder (std::shared_ptr<const Film> film, std::shared_ptr<const VideoMXFContent>);
- bool pass ();
- void seek (dcpomatic::ContentTime t, bool accurate);
+ bool pass () override;
+ void seek (dcpomatic::ContentTime t, bool accurate) override;
private:
/*
- Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "batch_job_view.h"
#include "dcpomatic_button.h"
#include "lib/job_manager.h"
#include <wx/sizer.h>
#include <wx/button.h>
+
using std::list;
using std::shared_ptr;
+
BatchJobView::BatchJobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
: JobView (job, parent, container, table)
{
}
+
int
BatchJobView::insert_position () const
{
return _table->GetEffectiveRowsCount() * _table->GetEffectiveColsCount();
}
+
void
BatchJobView::finish_setup (wxWindow* parent, wxSizer* sizer)
{
_higher_priority = new Button (parent, _("Higher priority"));
- _higher_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::higher_priority_clicked, this));
+ _higher_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::higher_priority_clicked, this));
sizer->Add (_higher_priority, 1, wxALIGN_CENTER_VERTICAL);
_lower_priority = new Button (parent, _("Lower priority"));
- _lower_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::lower_priority_clicked, this));
+ _lower_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::lower_priority_clicked, this));
sizer->Add (_lower_priority, 1, wxALIGN_CENTER_VERTICAL);
}
+
+
void
BatchJobView::higher_priority_clicked ()
{
JobManager::instance()->increase_priority (_job);
}
+
void
BatchJobView::lower_priority_clicked ()
{
JobManager::instance()->decrease_priority (_job);
}
+
void
BatchJobView::job_list_changed ()
{
bool high = false;
bool low = false;
- list<shared_ptr<Job> > jobs = JobManager::instance()->get();
- if (!jobs.empty ()) {
+ auto jobs = JobManager::instance()->get();
+ if (!jobs.empty()) {
if (_job != jobs.front()) {
high = true;
}
/*
- Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "job_view.h"
+
class BatchJobView : public JobView
{
public:
/*
- Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "content_properties_dialog.h"
#include "wx_util.h"
#include "static_text.h"
#include "lib/audio_content.h"
#include <boost/algorithm/string.hpp>
+
using std::string;
using std::list;
using std::pair;
using std::shared_ptr;
using std::dynamic_pointer_cast;
+
ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<const Film> film, shared_ptr<Content> content)
: TableDialog (parent, _("Content Properties"), 2, 1, false)
{
- map<UserProperty::Category, list<UserProperty> > grouped;
+ map<UserProperty::Category, list<UserProperty>> grouped;
for (auto i: content->user_properties(film)) {
if (grouped.find(i.category) == grouped.end()) {
grouped[i.category] = list<UserProperty> ();
maybe_add_group (grouped, UserProperty::LENGTH);
/* Nasty hack to stop the bottom property being cut off on Windows / OS X */
- add (wxString (), false);
- add (wxString (), false);
+ add (wxString(), false);
+ add (wxString(), false);
layout ();
}
+
void
-ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserProperty> > const & groups, UserProperty::Category category)
+ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserProperty>> const & groups, UserProperty::Category category)
{
- map<UserProperty::Category, list<UserProperty> >::const_iterator i = groups.find (category);
+ auto i = groups.find (category);
if (i == groups.end()) {
return;
}
break;
}
- wxStaticText* m = new StaticText (this, category_name);
+ auto m = new StaticText (this, category_name);
wxFont font (*wxNORMAL_FONT);
font.SetWeight (wxFONTWEIGHT_BOLD);
m->SetFont (font);
/*
- Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "table_dialog.h"
#include "lib/user_property.h"
#include <list>
#include <map>
+
class Content;
class Film;
class UserProperty;
+
class ContentPropertiesDialog : public TableDialog
{
public:
/*
- 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.
*/
+
#include "dkdm_dialog.h"
#include "wx_util.h"
#include "recipients_panel.h"
#include <wx/listctrl.h>
#include <iostream>
+
using std::string;
using std::exception;
using std::map;
, _film (film)
{
/* Main sizers */
- wxBoxSizer* horizontal = new wxBoxSizer (wxHORIZONTAL);
- wxBoxSizer* left = new wxBoxSizer (wxVERTICAL);
- wxBoxSizer* right = new wxBoxSizer (wxVERTICAL);
+ auto horizontal = new wxBoxSizer (wxHORIZONTAL);
+ auto left = new wxBoxSizer (wxVERTICAL);
+ auto right = new wxBoxSizer (wxVERTICAL);
horizontal->Add (left, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP * 4);
horizontal->Add (right, 1, wxEXPAND);
subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
/* Sub-heading: Screens */
- wxStaticText* h = new StaticText (this, _("Recipients"));
+ auto h = new StaticText (this, _("Recipients"));
h->SetFont (subheading_font);
left->Add (h, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
_recipients = new RecipientsPanel (this);
/* Make an overall sizer to get a nice border */
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
overall_sizer->Add (horizontal, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
/* Bind */
overall_sizer->SetSizeHints (this);
}
+
void
DKDMDialog::setup_sensitivity ()
{
_make->Enable (!_recipients->recipients().empty() && _timing->valid() && _cpl->has_selected());
}
+
bool
DKDMDialog::confirm_overwrite (boost::filesystem::path path)
{
return confirm_dialog (
this,
- wxString::Format (_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data())
+ wxString::Format(_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data())
);
}
+
void
DKDMDialog::make_clicked ()
{
- shared_ptr<const Film> film = _film.lock ();
+ auto film = _film.lock ();
DCPOMATIC_ASSERT (film);
list<KDMWithMetadataPtr> kdms;
try {
for (auto i: _recipients->recipients()) {
- KDMWithMetadataPtr p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until());
+ auto p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until());
if (p) {
kdms.push_back (p);
}
return;
}
- pair<shared_ptr<Job>, int> result = _output->make (kdms, film->name(), bind(&DKDMDialog::confirm_overwrite, this, _1));
+ auto result = _output->make (kdms, film->name(), bind(&DKDMDialog::confirm_overwrite, this, _1));
if (result.first) {
JobManager::instance()->add (result.first);
}
if (result.second > 0) {
/* XXX: proper plural form support in wxWidgets? */
- wxString s = result.second == 1 ? _("%d DKDM written to %s") : _("%d DKDMs written to %s");
+ auto s = result.second == 1 ? _("%d DKDM written to %s") : _("%d DKDMs written to %s");
message_dialog (
this,
- wxString::Format (s, result.second, std_to_wx(_output->directory().string()).data())
+ wxString::Format(s, result.second, std_to_wx(_output->directory().string()).data())
);
}
}
/*
- 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.
*/
+
#include "wx_util.h"
#include <wx/wx.h>
#include <map>
+
class Film;
class ScreensPanel;
class RecipientsPanel;
class KDMCPLPanel;
struct CPLSummary;
+
class DKDMDialog : public wxDialog
{
public:
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "download_certificate_panel.h"
+
class DolbyDoremiCertificatePanel : public DownloadCertificatePanel
{
public:
DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog);
- void do_download ();
- wxString name () const;
+ void do_download () override;
+ wxString name () const override;
};
/*
- Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "wx_util.h"
#include "download_certificate_panel.h"
#include "download_certificate_dialog.h"
#include <dcp/exceptions.h>
#include <boost/bind/bind.hpp>
+
using std::string;
using boost::function;
using boost::optional;
+
DownloadCertificatePanel::DownloadCertificatePanel (DownloadCertificateDialog* dialog)
: wxPanel (dialog->notebook(), wxID_ANY)
, _dialog (dialog)
DownloadCertificatePanel::load_certificate (boost::filesystem::path file)
{
try {
- _certificate = dcp::Certificate (dcp::file_to_string (file));
+ _certificate = dcp::Certificate (dcp::file_to_string(file));
} catch (dcp::MiscError& e) {
return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what());
}
- return optional<string>();
+ return {};
}
} catch (dcp::MiscError& e) {
return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what());
}
- return optional<string>();
+ return {};
}
DownloadCertificatePanel::certificate () const
{
return _certificate;
+
}
void
/* Hack: without this the SetLabel() above has no visible effect */
wxMilliSleep (200);
- signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this));
+ signal_manager->when_idle (boost::bind(&DownloadCertificatePanel::do_download, this));
}
+
bool
DownloadCertificatePanel::ready_to_download () const
{
- return !_serial->IsEmpty ();
+ return !_serial->IsEmpty();
}
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
#define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
+
#include "lib/warnings.h"
#include <dcp/certificate.h>
DCPOMATIC_DISABLE_WARNINGS
DCPOMATIC_ENABLE_WARNINGS
#include <boost/optional.hpp>
+
class DownloadCertificateDialog;
+
class DownloadCertificatePanel : public wxPanel
{
public:
boost::optional<dcp::Certificate> _certificate;
};
+
#endif
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "email_dialog.h"
#include "wx_util.h"
+
using std::string;
using std::shared_ptr;
using boost::optional;
+
EmailDialog::EmailDialog (wxWindow* parent)
: TableDialog (parent, _("Email address"), 2, 1, true)
{
add (_("Email address"), true);
- _email = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (400, -1)));
+ _email = add (new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(400, -1)));
layout ();
_email->SetFocus ();
}
+
void
EmailDialog::set (string address)
{
- _email->SetValue (std_to_wx (address));
+ _email->SetValue (std_to_wx(address));
}
+
optional<string>
EmailDialog::get () const
{
- string s = wx_to_std (_email->GetValue ());
- if (s.empty ()) {
+ auto s = wx_to_std (_email->GetValue ());
+ if (s.empty()) {
/* Invalid email address */
- return optional<string> ();
+ return {};
}
return s;
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "table_dialog.h"
#include <boost/optional.hpp>
+
class EmailDialog : public TableDialog
{
public:
private:
wxTextCtrl* _email;
};
+
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "html_dialog.h"
#include "wx_util.h"
#include "lib/cross.h"
DCPOMATIC_ENABLE_WARNINGS
#include <iostream>
+
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
+
HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html)
: wxDialog (parent, wxID_ANY, title)
{
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
wxFileSystem::AddHandler(new wxMemoryFSHandler);
wxBitmap(std_to_wx(boost::filesystem::path(resources_path() / "me.jpg").string()), wxBITMAP_TYPE_JPEG), wxBITMAP_TYPE_JPEG
);
- wxHtmlWindow* h = new wxHtmlWindow (this);
+ auto h = new wxHtmlWindow (this);
h->SetPage (html);
sizer->Add (h, 1, wxEXPAND | wxALL, 6);
SetSize (h->GetInternalRepresentation()->GetWidth(), h->GetInternalRepresentation()->GetHeight() + 64);
}
+
void
HTMLDialog::link_clicked (wxHtmlLinkEvent& ev)
{
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
+
class wxHtmlLinkEvent;
+
class HTMLDialog : public wxDialog
{
public:
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "move_to_dialog.h"
#include "lib/film.h"
#include <wx/spinctrl.h>
+
using std::list;
using std::shared_ptr;
using boost::optional;
using namespace dcpomatic;
+
MoveToDialog::MoveToDialog (wxWindow* parent, optional<DCPTime> position, shared_ptr<const Film> film)
: TableDialog (parent, _("Move content"), 2, 0, true)
, _film (film)
}
}
+
DCPTime
MoveToDialog::position () const
{
- shared_ptr<const Film> film = _film.lock ();
+ auto film = _film.lock ();
DCPOMATIC_ASSERT (film);
- list<DCPTimePeriod> reels = film->reels ();
- list<DCPTimePeriod>::const_iterator i = reels.begin ();
+ auto reels = film->reels ();
+ auto i = reels.begin ();
for (int j = 0; j < _reel->GetValue() - 1; ++j) {
DCPOMATIC_ASSERT (i != reels.end());
++i;
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "table_dialog.h"
#include "lib/dcpomatic_time.h"
#include <boost/optional.hpp>
+
class Film;
class wxSpinCtrl;
+
class MoveToDialog : public TableDialog
{
public:
/*
- Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "name_format_editor.h"
#include "wx_util.h"
#include "static_text.h"
#include "lib/util.h"
+
using std::string;
+
NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples, string suffix)
- : _panel (new wxPanel (parent))
- , _example (new StaticText (_panel, ""))
- , _sizer (new wxBoxSizer (wxVERTICAL))
- , _specification (new wxTextCtrl (_panel, wxID_ANY, ""))
+ : _panel (new wxPanel(parent))
+ , _example (new StaticText(_panel, ""))
+ , _sizer (new wxBoxSizer(wxVERTICAL))
+ , _specification (new wxTextCtrl(_panel, wxID_ANY, ""))
, _name (name)
, _examples (examples)
, _suffix (suffix)
}
_panel->SetSizer (_sizer);
- for (dcp::NameFormat::Map::const_iterator i = titles.begin(); i != titles.end(); ++i) {
- wxStaticText* t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i->first, i->second)));
+ for (auto const& i: titles) {
+ auto t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i.first, i.second)));
_sizer->Add (t);
- wxFont font = t->GetFont();
+ auto font = t->GetFont();
font.SetStyle (wxFONTSTYLE_ITALIC);
font.SetPointSize (font.GetPointSize() - 1);
t->SetFont (font);
t->SetForegroundColour (wxColour (0, 0, 204));
}
- _specification->SetValue (std_to_wx (_name.specification ()));
- _specification->Bind (wxEVT_TEXT, boost::bind (&NameFormatEditor::changed, this));
+ _specification->SetValue (std_to_wx (_name.specification()));
+ _specification->Bind (wxEVT_TEXT, boost::bind(&NameFormatEditor::changed, this));
update_example ();
}
+
void
NameFormatEditor::changed ()
{
Changed ();
}
+
void
NameFormatEditor::update_example ()
{
return;
}
- _name.set_specification (careful_string_filter (wx_to_std (_specification->GetValue ())));
+ _name.set_specification (careful_string_filter(wx_to_std(_specification->GetValue())));
- wxString example = wxString::Format (_("e.g. %s"), std_to_wx (_name.get (_examples, _suffix)));
+ auto example = wxString::Format (_("e.g. %s"), std_to_wx (_name.get (_examples, _suffix)));
wxString wrapped;
for (size_t i = 0; i < example.Length(); ++i) {
if (i > 0 && (i % 40) == 0) {
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_NAME_FORMAT_EDITOR_H
#define DCPOMATIC_NAME_FORMAT_EDITOR_H
+
#include "lib/compose.hpp"
#include "lib/warnings.h"
#include <dcp/name_format.h>
DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
+
class NameFormatEditor
{
public:
std::string _suffix;
};
+
#endif
/*
- Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "normal_job_view.h"
#include "dcpomatic_button.h"
#include "lib/job.h"
#include <wx/wx.h>
+
using std::shared_ptr;
+
NormalJobView::NormalJobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
: JobView (job, parent, container, table)
- , _pause (0)
{
}
+
void
NormalJobView::finish_setup (wxWindow* parent, wxSizer* sizer)
{
}
int
+
NormalJobView::insert_position () const
{
return 0;
}
+
void
NormalJobView::pause_clicked ()
{
}
}
+
void
NormalJobView::finished ()
{
/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "job_view.h"
+
class wxSizer;
+
class NormalJobView : public JobView
{
public:
void pause_clicked ();
void finished ();
- wxButton* _pause;
+ wxButton* _pause = nullptr;
};
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "paste_dialog.h"
#include "check_box.h"
+
PasteDialog::PasteDialog (wxWindow* parent, bool video, bool audio, bool text)
: TableDialog (parent, _("Paste"), 1, 0, true)
{
layout ();
}
+
bool
PasteDialog::video () const
{
return _video->GetValue ();
}
+
bool
PasteDialog::audio () const
{
return _audio->GetValue ();
}
+
bool
PasteDialog::text () const
{
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "table_dialog.h"
+
class PasteDialog : public TableDialog
{
public:
/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "qube_certificate_panel.h"
#include "download_certificate_dialog.h"
#include "wx_util.h"
#include "lib/config.h"
#include <boost/algorithm/string/predicate.hpp>
+
using std::string;
using std::list;
using boost::optional;
using namespace boost::placeholders;
#endif
+
static string const base = "ftp://certificates.qubecinema.com/";
+
QubeCertificatePanel::QubeCertificatePanel (DownloadCertificateDialog* dialog, string type)
: DownloadCertificatePanel (dialog)
, _type (type)
}
+
void
QubeCertificatePanel::do_download ()
{
- list<string> files = ls_url(String::compose("%1SMPTE-%2/", base, _type));
+ auto files = ls_url(String::compose("%1SMPTE-%2/", base, _type));
if (files.empty()) {
error_dialog (this, _("Could not read certificates from Qube server."));
return;
}
- string const serial = wx_to_std(_serial->GetValue());
+ auto const serial = wx_to_std(_serial->GetValue());
optional<string> name;
for (auto i: files) {
if (boost::algorithm::starts_with(i, String::compose("%1-%2-", _type, serial))) {
return;
}
- optional<string> error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1));
+ auto error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1));
if (error) {
_dialog->message()->SetLabel(wxT(""));
}
}
+
wxString
QubeCertificatePanel::name () const
{
/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "download_certificate_panel.h"
+
class QubeCertificatePanel : public DownloadCertificatePanel
{
public:
QubeCertificatePanel (DownloadCertificateDialog* dialog, std::string type);
- void do_download ();
- wxString name () const;
+ void do_download () override;
+ wxString name () const override;
private:
std::string _type;
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "rename_template_dialog.h"
+
RenameTemplateDialog::RenameTemplateDialog (wxWindow* parent)
: TableDialog (parent, _("Rename template"), 2, 1, true)
{
add (_("New name"), true);
- _name = add (new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (300, -1)));
+ _name = add (new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1)));
layout ();
_name->SetFocus ();
}
+
wxString
RenameTemplateDialog::get () const
{
return _name->GetValue ();
}
+
void
RenameTemplateDialog::set (wxString s)
{
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "table_dialog.h"
+
class RenameTemplateDialog : public TableDialog
{
public:
/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "self_dkdm_dialog.h"
#include "wx_util.h"
#include "kdm_output_panel.h"
DCPOMATIC_ENABLE_WARNINGS
#include <iostream>
+
using std::string;
using std::map;
using std::list;
using std::shared_ptr;
using boost::bind;
+
SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr<const Film> film)
: wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic"))
{
/* Main sizer */
- wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL);
+ auto vertical = new wxBoxSizer (wxVERTICAL);
/* Font for sub-headings */
wxFont subheading_font (*wxNORMAL_FONT);
subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
/* Sub-heading: CPL */
- wxStaticText* h = new StaticText (this, _("CPL"));
+ auto h = new StaticText (this, _("CPL"));
h->SetFont (subheading_font);
vertical->Add (h);
_cpl = new KDMCPLPanel (this, film->cpls ());
_internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM Creator tool's list"));
vertical->Add (_internal, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP);
- wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL);
+ auto w = new wxBoxSizer (wxHORIZONTAL);
_write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
/* Make an overall sizer to get a nice border, and put some buttons in */
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
if (buttons) {
overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
}
_write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this));
}
+
void
SelfDKDMDialog::dkdm_write_type_changed ()
{
setup_sensitivity ();
- if (_internal->GetValue ()) {
- Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL);
- } else if (_write_to->GetValue ()) {
- Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE);
+ if (_internal->GetValue()) {
+ Config::instance()->set_last_dkdm_write_type(Config::DKDM_WRITE_INTERNAL);
+ } else if (_write_to->GetValue()) {
+ Config::instance()->set_last_dkdm_write_type(Config::DKDM_WRITE_FILE);
}
}
+
void
SelfDKDMDialog::setup_sensitivity ()
{
_folder->Enable (_write_to->GetValue ());
- wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+ auto ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this));
if (ok) {
ok->Enable (_cpl->has_selected ());
}
}
+
boost::filesystem::path
SelfDKDMDialog::cpl () const
{
return _cpl->cpl ();
}
+
bool
SelfDKDMDialog::internal () const
{
return _internal->GetValue ();
}
+
boost::filesystem::path
SelfDKDMDialog::directory () const
{
- return wx_to_std (_folder->GetPath ());
+ return wx_to_std (_folder->GetPath());
}
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "wx_util.h"
#include "lib/warnings.h"
#include <dcp/types.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <map>
+
class Film;
class KDMCPLPanel;
class wxDirPickerCtrl;
class DirPickerCtrl;
+
class SelfDKDMDialog : public wxDialog
{
public:
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "standard_controls.h"
+
#include "film_viewer.h"
-#include <wx/wx.h>
+#include "standard_controls.h"
#include <wx/tglbtn.h>
+#include <wx/wx.h>
+
using std::shared_ptr;
+
StandardControls::StandardControls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor_controls)
: Controls (parent, viewer, editor_controls)
, _play_button (new wxToggleButton(this, wxID_ANY, _("Play")))
_play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind(&StandardControls::play_clicked, this));
}
+
void
StandardControls::started ()
{
_play_button->SetValue (true);
}
+
void
StandardControls::stopped ()
{
_play_button->SetValue (false);
}
+
void
StandardControls::play_clicked ()
{
check_play_state ();
}
+
void
StandardControls::check_play_state ()
{
}
}
+
void
StandardControls::setup_sensitivity ()
{
_play_button->Enable (_film && !_film->content().empty() && !active_job);
}
+
void
StandardControls::play ()
{
play_clicked ();
}
+
void
StandardControls::stop ()
{
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "controls.h"
+
class StandardControls : public Controls
{
public:
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "suspender.h"
+
Suspender::Suspender(boost::function<void (int)> handler)
: _handler (handler)
, _count (0)
}
+
Suspender::Block::Block (Suspender* s)
: _suspender (s)
{
_suspender->increment ();
}
+
Suspender::Block::~Block ()
{
_suspender->decrement ();
}
+
Suspender::Block
Suspender::block ()
{
return Block (this);
}
+
void
Suspender::increment ()
{
++_count;
}
+
void
Suspender::decrement ()
{
}
}
+
bool
Suspender::check (int property)
{
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include <boost/function.hpp>
#include <set>
+
class Suspender
{
public:
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "templates_dialog.h"
#include "wx_util.h"
#include "rename_template_dialog.h"
#include "lib/config.h"
#include <wx/wx.h>
+
using std::string;
using boost::bind;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
+
TemplatesDialog::TemplatesDialog (wxWindow* parent)
: wxDialog (parent, wxID_ANY, _("Templates"))
{
_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (_sizer);
- wxSizer* hs = new wxBoxSizer (wxHORIZONTAL);
+ auto hs = new wxBoxSizer (wxHORIZONTAL);
_list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (200, 100), wxLC_REPORT | wxLC_SINGLE_SEL);
wxListItem ip;
hs->Add (_list, 1, wxEXPAND, DCPOMATIC_SIZER_GAP);
{
- wxSizer* s = new wxBoxSizer (wxVERTICAL);
+ auto s = new wxBoxSizer (wxVERTICAL);
_rename = new Button (this, _("Rename..."));
s->Add (_rename, 0, wxTOP | wxBOTTOM, 2);
_remove = new Button (this, _("Remove"));
_sizer->Add (hs, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
- wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
+ auto buttons = CreateSeparatedButtonSizer (wxCLOSE);
if (buttons) {
_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
- _rename->Bind (wxEVT_BUTTON, bind (&TemplatesDialog::rename_clicked, this));
- _remove->Bind (wxEVT_BUTTON, bind (&TemplatesDialog::remove_clicked, this));
+ _rename->Bind (wxEVT_BUTTON, bind(&TemplatesDialog::rename_clicked, this));
+ _remove->Bind (wxEVT_BUTTON, bind(&TemplatesDialog::remove_clicked, this));
- _list->Bind (wxEVT_LIST_ITEM_SELECTED, bind (&TemplatesDialog::selection_changed, this));
- _list->Bind (wxEVT_LIST_ITEM_DESELECTED, bind (&TemplatesDialog::selection_changed, this));
- _list->Bind (wxEVT_SIZE, bind (&TemplatesDialog::resized, this, _1));
- _config_connection = Config::instance()->Changed.connect (bind (&TemplatesDialog::refresh, this));
+ _list->Bind (wxEVT_LIST_ITEM_SELECTED, bind(&TemplatesDialog::selection_changed, this));
+ _list->Bind (wxEVT_LIST_ITEM_DESELECTED, bind(&TemplatesDialog::selection_changed, this));
+ _list->Bind (wxEVT_SIZE, bind(&TemplatesDialog::resized, this, _1));
+ _config_connection = Config::instance()->Changed.connect (bind(&TemplatesDialog::refresh, this));
refresh ();
selection_changed ();
}
+
void
TemplatesDialog::refresh ()
{
}
}
+
void
TemplatesDialog::layout ()
{
_sizer->Layout ();
}
+
void
TemplatesDialog::selection_changed ()
{
_remove->Enable (i >= 0);
}
+
void
TemplatesDialog::rename_clicked ()
{
li.m_mask = wxLIST_MASK_TEXT;
_list->GetItem (li);
- RenameTemplateDialog* d = new RenameTemplateDialog (this);
+ auto d = new RenameTemplateDialog (this);
d->set (li.m_text);
if (d->ShowModal() == wxID_OK) {
if (!d->get().IsEmpty()) {
d->Destroy ();
}
+
void
TemplatesDialog::remove_clicked ()
{
li.m_mask = wxLIST_MASK_TEXT;
_list->GetItem (li);
- Config::instance()->delete_template (wx_to_std (li.m_text));
+ Config::instance()->delete_template (wx_to_std(li.m_text));
_list->DeleteItem (i);
selection_changed ();
}
+
void
TemplatesDialog::resized (wxSizeEvent& ev)
{
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
+
class TemplatesDialog : public wxDialog
{
public:
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "timeline_atmos_content_view.h"
+
using std::shared_ptr;
+
/** @class TimelineAtmosContentView
* @brief Timeline view for AtmosContent.
*/
}
+
wxColour
TimelineAtmosContentView::background_colour () const
{
return wxColour (149, 121, 232, 255);
}
+
wxColour
TimelineAtmosContentView::foreground_colour () const
{
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "timeline_content_view.h"
+
/** @class TimelineAtmosContentView
* @brief Timeline view for AtmosContent.
*/
TimelineAtmosContentView (Timeline& tl, std::shared_ptr<Content> c);
private:
- bool active () const {
+ bool active () const override {
return true;
}
- wxColour background_colour () const;
- wxColour foreground_colour () const;
+
+ wxColour background_colour () const override;
+ wxColour foreground_colour () const override;
};
*/
+
#include "timeline_content_view.h"
+
/** @class TimelineAudioContentView
* @brief Timeline view for AudioContent.
*/
TimelineAudioContentView (Timeline& tl, std::shared_ptr<Content> c);
private:
- bool active () const {
+ bool active () const override {
return true;
}
- wxColour background_colour () const;
- wxColour foreground_colour () const;
- wxString label () const;
+ wxColour background_colour () const override;
+ wxColour foreground_colour () const override;
+ wxString label () const override;
};
*/
+
#ifndef DCPOMATIC_TIMELINE_CONTENT_VIEW_H
#define DCPOMATIC_TIMELINE_CONTENT_VIEW_H
+
#include "lib/change_signaller.h"
#include "lib/types.h"
#include "lib/warnings.h"
class Content;
+
/** @class TimelineContentView
* @brief Parent class for views of pieces of content.
*/
public:
TimelineContentView (Timeline& tl, std::shared_ptr<Content> c);
- dcpomatic::Rect<int> bbox () const;
+ dcpomatic::Rect<int> bbox () const override;
void set_selected (bool s);
bool selected () const;
private:
- void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int> > overlaps);
+ void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps) override;
int y_pos (int t) const;
void content_change (ChangeType type, int p);
boost::signals2::scoped_connection _content_connection;
};
-typedef std::vector<std::shared_ptr<TimelineContentView> > TimelineContentViewList;
+
+typedef std::vector<std::shared_ptr<TimelineContentView>> TimelineContentViewList;
+
#endif
/*
- 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.
*/
+
+#include "content_panel.h"
#include "film_editor.h"
#include "timeline_dialog.h"
#include "wx_util.h"
-#include "content_panel.h"
-#include "lib/playlist.h"
-#include "lib/cross.h"
#include "lib/compose.hpp"
+#include "lib/cross.h"
+#include "lib/playlist.h"
#include <wx/graphics.h>
#include <iostream>
#include <list>
+
using std::list;
using std::cout;
using std::string;
using namespace boost::placeholders;
#endif
+
TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer)
: wxDialog (
cp->window(),
sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12);
#ifdef DCPOMATIC_LINUX
- wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
+ auto buttons = CreateSeparatedButtonSizer (wxCLOSE);
if (buttons) {
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
_film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2));
}
+
void
TimelineDialog::film_change (ChangeType type, Film::Property p)
{
}
}
+
void
TimelineDialog::set_selection (ContentList selection)
{
_timeline.set_selection (selection);
}
+
void
TimelineDialog::tool_clicked (wxCommandEvent& ev)
{
- Timeline::Tool t = (Timeline::Tool) ev.GetId();
+ Timeline::Tool t = static_cast<Timeline::Tool>(ev.GetId());
_timeline.tool_clicked (t);
if (t == Timeline::SNAP) {
- _timeline.set_snap (_toolbar->GetToolState ((int) t));
+ _timeline.set_snap (_toolbar->GetToolState(static_cast<int>(t)));
} else if (t == Timeline::SEQUENCE) {
auto film = _film.lock ();
if (film) {
- film->set_sequence (_toolbar->GetToolState ((int) t));
+ film->set_sequence (_toolbar->GetToolState(static_cast<int>(t)));
}
}
}
/*
- 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.
*/
+
#include <wx/wx.h>
#include "timeline.h"
+
class Playlist;
+
class TimelineDialog : public wxDialog
{
public:
public:
explicit TimelineLabelsView (Timeline& tl);
- dcpomatic::Rect<int> bbox () const;
+ dcpomatic::Rect<int> bbox () const override;
void set_video_tracks (int n);
void set_audio_tracks (int n);
void set_atmos (bool s);
private:
- void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps);
+ void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps) override;
int _width = 0;
int _video_tracks = 0;
public:
TimelineReelsView (Timeline& tl, int y);
- dcpomatic::Rect<int> bbox () const;
+ dcpomatic::Rect<int> bbox () const override;
void set_y (int y);
private:
- void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps);
+ void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int>> overlaps) override;
int _y;
};
*/
+
#include "timeline_content_view.h"
+
/** @class TimelineVideoContentView
* @brief Timeline view for VideoContent.
*/
TimelineVideoContentView (Timeline& tl, std::shared_ptr<Content> c);
private:
- bool active () const;
- wxColour background_colour () const;
- wxColour foreground_colour () const;
+ bool active () const override;
+ wxColour background_colour () const override;
+ wxColour foreground_colour () const override;
};
TimelineView (TimelineView const&) = delete;
TimelineView& operator= (TimelineView const&) = delete;
- void paint (wxGraphicsContext* g, std::list<dcpomatic::Rect<int> > overlaps);
+ void paint (wxGraphicsContext* g, std::list<dcpomatic::Rect<int>> overlaps);
void force_redraw ();
virtual dcpomatic::Rect<int> bbox () const = 0;
protected:
- virtual void do_paint (wxGraphicsContext *, std::list<dcpomatic::Rect<int> > overlaps) = 0;
+ virtual void do_paint (wxGraphicsContext *, std::list<dcpomatic::Rect<int>> overlaps) = 0;
int time_x (dcpomatic::DCPTime t) const;
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "try_unmount_dialog.h"
#include "wx_util.h"
#include "static_text.h"
#include <wx/wx.h>
+
TryUnmountDialog::TryUnmountDialog (wxWindow* parent, wxString description)
: wxDialog (parent, wxID_ANY, _("DCP-o-matic Disk Writer"))
{
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
- wxStaticText* text = new StaticText (this, wxEmptyString);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
+ auto text = new StaticText (this, wxEmptyString);
sizer->Add (text, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
text->SetLabelMarkup (
wxString::Format(_("The drive <b>%s</b> is mounted.\n\nIt must be unmounted before DCP-o-matic can write to it.\n\nShould DCP-o-matic try to unmount it now?"), description)
);
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
if (buttons) {
sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder());
}
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
+
class TryUnmountDialog : public wxDialog
{
public:
/*
- Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "video_waveform_plot.h"
+
#include "film_viewer.h"
+#include "video_waveform_plot.h"
#include "wx_util.h"
-#include "lib/image.h"
-#include "lib/film.h"
#include "lib/dcp_video.h"
+#include "lib/film.h"
+#include "lib/image.h"
#include "lib/player_video.h"
#include <dcp/locale_convert.h>
#include <dcp/openjpeg_image.h>
#include <boost/bind/bind.hpp>
#include <iostream>
+
using std::cout;
-using std::min;
+using std::make_shared;
using std::max;
+using std::min;
+using std::shared_ptr;
using std::string;
using std::weak_ptr;
-using std::shared_ptr;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
VideoWaveformPlot::VideoWaveformPlot (wxWindow* parent, weak_ptr<const Film> film, weak_ptr<FilmViewer> viewer)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
, _film (film)
- , _dirty (true)
- , _enabled (false)
- , _component (0)
- , _contrast (0)
{
#ifndef __WXOSX__
SetDoubleBuffered (true);
#endif
- shared_ptr<FilmViewer> fv = viewer.lock ();
+ auto fv = viewer.lock ();
DCPOMATIC_ASSERT (fv);
- _viewer_connection = fv->ImageChanged.connect (boost::bind (&VideoWaveformPlot::set_image, this, _1));
+ _viewer_connection = fv->ImageChanged.connect (boost::bind(&VideoWaveformPlot::set_image, this, _1));
- Bind (wxEVT_PAINT, boost::bind (&VideoWaveformPlot::paint, this));
- Bind (wxEVT_SIZE, boost::bind (&VideoWaveformPlot::sized, this, _1));
- Bind (wxEVT_MOTION, boost::bind (&VideoWaveformPlot::mouse_moved, this, _1));
+ Bind (wxEVT_PAINT, boost::bind(&VideoWaveformPlot::paint, this));
+ Bind (wxEVT_SIZE, boost::bind(&VideoWaveformPlot::sized, this, _1));
+ Bind (wxEVT_MOTION, boost::bind(&VideoWaveformPlot::mouse_moved, this, _1));
SetMinSize (wxSize (640, 512));
SetBackgroundColour (wxColour (0, 0, 0));
}
+
void
VideoWaveformPlot::paint ()
{
return;
}
- wxGraphicsContext* gc = wxGraphicsContext::Create (dc);
+ auto gc = wxGraphicsContext::Create (dc);
if (!gc) {
return;
}
}
for (int i = 0; i < label_gaps + 1; ++i) {
- wxGraphicsPath p = gc->CreatePath ();
+ auto p = gc->CreatePath ();
int const y = _vertical_margin + height - (i * height / label_gaps) - 1;
p.MoveToPoint (label_width + 8, y);
p.AddLineToPoint (_x_axis_width - 4, y);
} else if (n < 1000) {
x += extra[2];
}
- gc->DrawText (std_to_wx (locale_convert<string> (n)), x, y - (label_height / 2));
+ gc->DrawText (std_to_wx(locale_convert<string>(n)), x, y - (label_height / 2));
}
wxImage waveform (_waveform->size().width, height, _waveform->data()[0], true);
delete gc;
}
+
void
VideoWaveformPlot::create_waveform ()
{
return;
}
- dcp::Size const image_size = _image->size();
+ auto const image_size = _image->size();
int const waveform_height = GetSize().GetHeight() - _vertical_margin * 2;
- _waveform.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true));
+ _waveform = make_shared<Image>(AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true);
for (int x = 0; x < image_size.width; ++x) {
);
}
-static void
-note ()
-{
-
-}
void
VideoWaveformPlot::set_image (shared_ptr<PlayerVideo> image)
/* We must copy the PlayerVideo here as we will call ::image() on it, potentially
with a different pixel_format than was used when ::prepare() was called.
*/
- _image = DCPVideo::convert_to_xyz (image->shallow_copy(), boost::bind(¬e));
+ _image = DCPVideo::convert_to_xyz (image->shallow_copy(), [](dcp::NoteType, string) {});
_dirty = true;
Refresh ();
}
+
void
VideoWaveformPlot::sized (wxSizeEvent &)
{
_dirty = true;
}
+
void
VideoWaveformPlot::set_enabled (bool e)
{
_enabled = e;
}
+
void
VideoWaveformPlot::set_component (int c)
{
Refresh ();
}
+
/** Set `contrast', i.e. a fudge multiplication factor to make low-level signals easier to see,
* between 0 and 256.
*/
Refresh ();
}
+
void
VideoWaveformPlot::mouse_moved (wxMouseEvent& ev)
{
_dirty = false;
}
- shared_ptr<const Film> film = _film.lock ();
+ auto film = _film.lock ();
if (!film) {
return;
}
- dcp::Size const full = film->frame_size ();
+ auto const full = film->frame_size ();
- double const xs = static_cast<double> (full.width) / _waveform->size().width;
+ auto const xs = static_cast<double> (full.width) / _waveform->size().width;
int const x1 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width - 0.5) * xs)));
int const x2 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width + 0.5) * xs)));
- double const ys = static_cast<double> (_pixel_values) / _waveform->size().height;
+ auto const ys = static_cast<double> (_pixel_values) / _waveform->size().height;
int const fy = _waveform->size().height - (ev.GetPosition().y - _vertical_margin);
int const y1 = max (0, min (_pixel_values - 1, int (floor (fy - 0.5) * ys)));
int const y2 = max (0, min (_pixel_values - 1, int (floor (fy + 0.5) * ys)));
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
+
namespace dcp {
class OpenJPEGImage;
}
class Film;
class FilmViewer;
+
class VideoWaveformPlot : public wxPanel
{
public:
std::weak_ptr<const Film> _film;
std::shared_ptr<dcp::OpenJPEGImage> _image;
std::shared_ptr<const Image> _waveform;
- bool _dirty;
- bool _enabled;
- int _component;
- int _contrast;
+ bool _dirty = true;
+ bool _enabled = false;
+ int _component = 0;
+ int _contrast = 0;
static int const _vertical_margin;
static int const _pixel_values;
/*
- 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.
return m;
}
+
wxStaticText *
#ifdef __WXOSX__
add_label_to_sizer (wxSizer* s, wxStaticText* t, bool left, int prop, int flags)
return t;
}
+
wxStaticText *
add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBPosition pos, wxGBSpan span)
{
return m;
}
+
wxStaticText *
#ifdef __WXOSX__
add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool left, wxGBPosition pos, wxGBSpan span)
return t;
}
+
/** Pop up an error dialogue box.
* @param parent Parent.
* @param m Message.
d->Destroy ();
}
+
/** Pop up an error dialogue box.
* @param parent Parent.
* @param m Message.
d->Destroy ();
}
+
/** @return true if the user answered "yes" */
bool
confirm_dialog (wxWindow* parent, wxString m)
{
- wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION);
+ auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION);
int const r = d->ShowModal ();
d->Destroy ();
return r == wxID_YES;
string
wx_to_std (wxString s)
{
- return string (s.ToUTF8 ());
+ return string (s.ToUTF8());
}
+
/** @param s STL string.
* @return Corresponding wxWidgets string.
*/
return wxString (s.c_str(), wxConvUTF8);
}
+
string
string_client_data (wxClientData* o)
{
return wx_to_std (dynamic_cast<wxStringClientData*>(o)->GetData());
}
+
void
checked_set (FilePickerCtrl* widget, boost::filesystem::path value)
{
}
}
+
void
checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value)
{
}
}
+
void
checked_set (wxSpinCtrl* widget, int value)
{
}
}
+
void
checked_set (wxSpinCtrlDouble* widget, double value)
{
}
}
+
void
checked_set (wxChoice* widget, int value)
{
}
}
+
void
checked_set (wxChoice* widget, string value)
{
}
}
+
void
checked_set (wxChoice* widget, vector<pair<string, string> > items)
{
- vector<pair<string, string> > current;
+ vector<pair<string, string>> current;
for (unsigned int i = 0; i < widget->GetCount(); ++i) {
current.push_back (
- make_pair (
- wx_to_std (widget->GetString (i)),
- string_client_data (widget->GetClientObject (i))
+ make_pair(
+ wx_to_std(widget->GetString(i)),
+ string_client_data(widget->GetClientObject(i))
)
);
}
}
}
+
void
checked_set (wxTextCtrl* widget, string value)
{
}
}
+
void
checked_set (PasswordEntry* entry, string value)
{
}
}
+
void
checked_set (wxTextCtrl* widget, wxString value)
{
}
}
+
void
checked_set (wxStaticText* widget, string value)
{
}
}
+
void
checked_set (wxStaticText* widget, wxString value)
{
}
}
+
void
checked_set (wxCheckBox* widget, bool value)
{
}
}
+
void
checked_set (wxRadioButton* widget, bool value)
{
}
}
+
void
dcpomatic_setup_i18n ()
{
}
}
+
int
wx_get (wxSpinCtrl* w)
{
return w->GetValue ();
}
+
int
wx_get (wxChoice* w)
{
return w->GetSelection ();
}
+
double
wx_get (wxSpinCtrlDouble* w)
{
return w->GetValue ();
}
+
/** @param s String of the form Context|String
* @return translation, or String if no translation is available.
*/
return t;
}
+
wxString
time_to_timecode (DCPTime t, double fps)
{
return wxString::Format (wxT("%02d:%02d:%02d.%02d"), h, m, s, f);
}
+
void
setup_audio_channels_choice (wxChoice* choice, int minimum)
{
- vector<pair<string, string> > items;
+ vector<pair<string, string>> items;
for (int i = minimum; i <= 16; i += 2) {
if (i == 2) {
- items.push_back (make_pair (wx_to_std (_("2 - stereo")), locale_convert<string> (i)));
+ items.push_back (make_pair(wx_to_std(_("2 - stereo")), locale_convert<string>(i)));
} else if (i == 4) {
- items.push_back (make_pair (wx_to_std (_("4 - L/C/R/Lfe")), locale_convert<string> (i)));
+ items.push_back (make_pair(wx_to_std(_("4 - L/C/R/Lfe")), locale_convert<string>(i)));
} else if (i == 6) {
- items.push_back (make_pair (wx_to_std (_("6 - 5.1")), locale_convert<string> (i)));
+ items.push_back (make_pair(wx_to_std(_("6 - 5.1")), locale_convert<string>(i)));
} else if (i == 8) {
- items.push_back (make_pair (wx_to_std (_("8 - 5.1/HI/VI")), locale_convert<string> (i)));
+ items.push_back (make_pair(wx_to_std(_("8 - 5.1/HI/VI")), locale_convert<string>(i)));
} else if (i == 12) {
- items.push_back (make_pair (wx_to_std (_("12 - 7.1/HI/VI")), locale_convert<string> (i)));
+ items.push_back (make_pair(wx_to_std(_("12 - 7.1/HI/VI")), locale_convert<string>(i)));
} else {
- items.push_back (make_pair (locale_convert<string> (i), locale_convert<string> (i)));
+ items.push_back (make_pair(locale_convert<string> (i), locale_convert<string>(i)));
}
}
return splash;
}
+
double
calculate_mark_interval (double mark_interval)
{
base = resources_path();
#endif
- boost::filesystem::path p = base / String::compose("%1.png", name);
+ auto p = base / String::compose("%1.png", name);
return std_to_wx (p.string());
}
/*
- 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.
*/
+
/** @file src/wx/wx_util.h
* @brief Some utility functions and classes.
*/
+
#ifndef DCPOMATIC_WX_UTIL_H
#define DCPOMATIC_WX_UTIL_H
+
#include "lib/dcpomatic_time.h"
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <boost/thread.hpp>
#include <boost/signals2.hpp>
+
class FilePickerCtrl;
class wxDirPickerCtrl;
class wxSpinCtrl;
class wxSplashScreen;
class PasswordEntry;
+
#define DCPOMATIC_SIZER_X_GAP 8
#define DCPOMATIC_SIZER_Y_GAP 8
#define DCPOMATIC_SIZER_GAP 8
#define DCPOMATIC_RTAUDIO_API RtAudio::MACOSX_CORE
#endif
+
/** i18n macro to support strings like Context|String
* so that `String' can be translated to different things
* in different contexts.
*/
#define S_(x) context_translation(x)
+
extern void error_dialog (wxWindow *, wxString, boost::optional<wxString> e = boost::optional<wxString>());
extern void message_dialog (wxWindow *, wxString);
extern bool confirm_dialog (wxWindow *, wxString);
extern wxString bitmap_path (std::string name);
extern wxSize small_button_size (wxWindow* parent, wxString text);
+
struct Offset
{
Offset (wxString n, int h, int m)
#define DCPOMATIC_USE_OWN_PICKER
#endif
+
#endif
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @defgroup completedcp Complete builds of DCPs */
/** @file test/4k_test.cc
* The output is checked against test/data/4k_test.
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/film.h"
#include "lib/ffmpeg_content.h"
#include "lib/dcpomatic_log.h"
#include "test.h"
+
using std::shared_ptr;
using std::make_shared;
+
BOOST_AUTO_TEST_CASE (fourk_test)
{
auto film = new_test_film ("4k_test");
dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE
});
- boost::filesystem::path p (test_film_dir ("4k_test"));
+ boost::filesystem::path p (test_film_dir("4k_test"));
p /= film->dcp_name ();
- check_dcp ("test/data/4k_test", p.string ());
+ check_dcp ("test/data/4k_test", p.string());
}
/*
- 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.
*/
+
/** @defgroup selfcontained Self-contained tests of single classes / method sets */
/** @file test/audio_analysis_test.cc
* @ingroup selfcontained
*/
-#include <boost/test/unit_test.hpp>
-#include "lib/audio_analysis.h"
+
+#include "test.h"
#include "lib/analyse_audio_job.h"
-#include "lib/film.h"
-#include "lib/ffmpeg_content.h"
+#include "lib/audio_analysis.h"
+#include "lib/audio_content.h"
+#include "lib/content_factory.h"
#include "lib/dcp_content_type.h"
#include "lib/ffmpeg_content.h"
-#include "lib/ratio.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/film.h"
#include "lib/job_manager.h"
-#include "lib/audio_content.h"
-#include "lib/content_factory.h"
#include "lib/playlist.h"
-#include "test.h"
+#include "lib/ratio.h"
+#include <boost/test/unit_test.hpp>
#include <iostream>
-using std::vector;
+
+using std::make_shared;
using std::shared_ptr;
+using std::vector;
using namespace dcpomatic;
-static float
-random_float ()
-{
- return (float (rand ()) / RAND_MAX) * 2 - 1;
-}
BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test)
{
int const channels = 3;
int const points = 4096;
+ auto random_float = []() {
+ return (float (rand ()) / RAND_MAX) * 2 - 1;
+ };
+
AudioAnalysis a (3);
for (int i = 0; i < channels; ++i) {
for (int j = 0; j < points; ++j) {
vector<AudioAnalysis::PeakTime> peak;
for (int i = 0; i < channels; ++i) {
- peak.push_back (AudioAnalysis::PeakTime (random_float(), DCPTime (rand())));
+ peak.push_back (AudioAnalysis::PeakTime(random_float(), DCPTime(rand())));
}
a.set_sample_peak (peak);
BOOST_CHECK_EQUAL (a.sample_rate(), 48000);
}
-static void
-finished ()
-{
-
-}
BOOST_AUTO_TEST_CASE (audio_analysis_test)
{
- shared_ptr<Film> film = new_test_film ("audio_analysis_test");
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
- film->set_container (Ratio::from_id ("185"));
+ auto film = new_test_film ("audio_analysis_test");
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR"));
+ film->set_container (Ratio::from_id("185"));
film->set_name ("audio_analysis_test");
boost::filesystem::path p = TestPaths::private_data() / "betty_L.wav";
- shared_ptr<FFmpegContent> c (new FFmpegContent(p));
+ auto c = make_shared<FFmpegContent>(p);
film->examine_and_add_content (c);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist(), false));
- job->Finished.connect (boost::bind (&finished));
+ auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), false);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
}
+
/** Check that audio analysis works (i.e. runs without error) with a -ve delay */
BOOST_AUTO_TEST_CASE (audio_analysis_negative_delay_test)
{
- shared_ptr<Film> film = new_test_film ("audio_analysis_negative_delay_test");
+ auto film = new_test_film ("audio_analysis_negative_delay_test");
film->set_name ("audio_analysis_negative_delay_test");
- shared_ptr<FFmpegContent> c (new FFmpegContent(TestPaths::private_data() / "boon_telly.mkv"));
+ auto c = make_shared<FFmpegContent>(TestPaths::private_data() / "boon_telly.mkv");
film->examine_and_add_content (c);
BOOST_REQUIRE (!wait_for_jobs());
c->audio->set_delay (-250);
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist(), false));
- job->Finished.connect (boost::bind (&finished));
+ auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), false);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
}
+
/** Check audio analysis that is incorrect in 2e98263 */
BOOST_AUTO_TEST_CASE (audio_analysis_test2)
{
- shared_ptr<Film> film = new_test_film ("audio_analysis_test2");
+ auto film = new_test_film ("audio_analysis_test2");
film->set_name ("audio_analysis_test2");
- shared_ptr<FFmpegContent> c (new FFmpegContent(TestPaths::private_data() / "3d_thx_broadway_2010_lossless.m2ts"));
+ auto c = make_shared<FFmpegContent>(TestPaths::private_data() / "3d_thx_broadway_2010_lossless.m2ts");
film->examine_and_add_content (c);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist(), false));
- job->Finished.connect (boost::bind (&finished));
+ auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), false);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
}
done = true;
}
+
/* Test a case which was reported to throw an exception; analysing
* a 12-channel DCP's audio.
*/
BOOST_AUTO_TEST_CASE (audio_analysis_test3)
{
- shared_ptr<Film> film = new_test_film ("analyse_audio_test");
+ auto film = new_test_film ("analyse_audio_test");
film->set_container (Ratio::from_id ("185"));
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
film->set_name ("frobozz");
- shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/white.wav"));
+ auto content = make_shared<FFmpegContent>("test/data/white.wav");
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
film->set_audio_channels (12);
boost::signals2::connection connection;
- JobManager::instance()->analyse_audio (film, film->playlist(), false, connection, boost::bind (&analysis_finished));
+ JobManager::instance()->analyse_audio(film, film->playlist(), false, connection, boost::bind(&analysis_finished));
BOOST_REQUIRE (!wait_for_jobs());
BOOST_CHECK (done);
}
+
/** Run an audio analysis that triggered an exception in the audio decoder at one point */
BOOST_AUTO_TEST_CASE (analyse_audio_test4)
{
- shared_ptr<Film> film = new_test_film ("analyse_audio_test");
+ auto film = new_test_film ("analyse_audio_test");
film->set_container (Ratio::from_id ("185"));
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
film->set_name ("frobozz");
- shared_ptr<Content> content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front();
+ auto content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front();
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Playlist> playlist (new Playlist);
+ auto playlist = make_shared<Playlist>();
playlist->add (film, content);
boost::signals2::connection c;
- JobManager::instance()->analyse_audio (film, playlist, false, c, boost::bind (&finished));
+ JobManager::instance()->analyse_audio(film, playlist, false, c, []() {});
BOOST_CHECK (!wait_for_jobs ());
}
+
BOOST_AUTO_TEST_CASE (analyse_audio_leqm_test)
{
- shared_ptr<Film> film = new_test_film2 ("analyse_audio_leqm_test");
+ auto film = new_test_film2 ("analyse_audio_leqm_test");
film->set_audio_channels (2);
- shared_ptr<Content> content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front();
+ auto content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front();
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Playlist> playlist (new Playlist);
+ auto playlist = make_shared<Playlist>();
playlist->add (film, content);
boost::signals2::connection c;
- JobManager::instance()->analyse_audio (film, playlist, false, c, boost::bind (&finished));
+ JobManager::instance()->analyse_audio(film, playlist, false, c, []() {});
BOOST_CHECK (!wait_for_jobs());
AudioAnalysis analysis(film->audio_analysis_path(playlist));
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/audio_filter_test.cc
* @brief Test AudioFilter, LowPassAudioFilter, HighPassAudioFilter classes.
* @ingroup selfcontained
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/audio_filter.h"
#include "lib/audio_buffers.h"
+
+using std::make_shared;
using std::shared_ptr;
+
static void
audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks)
{
for (int i = 0; i < num_blocks; ++i) {
- shared_ptr<AudioBuffers> in (new AudioBuffers (1, block_size));
+ auto in = make_shared<AudioBuffers>(1, block_size);
for (int j = 0; j < block_size; ++j) {
in->data()[0][j] = c + j;
}
- shared_ptr<AudioBuffers> out = f.run (in);
+ auto out = f.run (in);
for (int j = 0; j < out->frames(); ++j) {
BOOST_CHECK_EQUAL (out->data()[0][j], c + j);
}
}
+
/** Create a filter with an impulse as a kernel and check that it
* passes data through unaltered.
*/
audio_filter_impulse_test_one (f, 2048, 1);
}
+
/** Create filters and pass them impulses as input and check that
* the filter kernels comes back.
*/
{
LowPassAudioFilter lpf (0.02, 0.3);
- shared_ptr<AudioBuffers> in (new AudioBuffers (1, 1751));
+ auto in = make_shared<AudioBuffers>(1, 1751);
in->make_silent ();
in->data(0)[0] = 1;
- shared_ptr<AudioBuffers> out = lpf.run (in);
+ auto out = lpf.run (in);
for (int j = 0; j < out->frames(); ++j) {
if (j <= lpf._M) {
BOOST_CHECK_EQUAL (out->data(0)[j], lpf._ir[j]);
HighPassAudioFilter hpf (0.02, 0.3);
- in.reset (new AudioBuffers (1, 9133));
+ in = make_shared<AudioBuffers>(1, 9133);
in->make_silent ();
in->data(0)[0] = 1;
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/audio_processor_delay_test.cc
* @brief Test the AudioDelay class.
* @ingroup selfcontained
*/
-#include "lib/audio_delay.h"
+
#include "lib/audio_buffers.h"
+#include "lib/audio_delay.h"
#include <boost/test/unit_test.hpp>
#include <cmath>
#include <iostream>
+
using std::cerr;
using std::cout;
+using std::make_shared;
using std::shared_ptr;
+
#define CHECK_SAMPLE(c,f,r) \
if (fabs(out->data(c)[f] - (r)) > 0.1) { \
cerr << "Sample " << f << " at line " << __LINE__ << " is " << out->data(c)[f] << " not " << r << "; difference is " << fabs(out->data(c)[f] - (r)) << "\n"; \
BOOST_REQUIRE (fabs(out->data(c)[f] - (r)) <= 0.1); \
}
+
/** Block size greater than delay */
BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
{
int const C = 2;
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 256));
+ auto in = make_shared<AudioBuffers>(C, 256);
for (int i = 0; i < C; ++i) {
for (int j = 0; j < 256; ++j) {
in->data(i)[j] = j;
}
}
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
BOOST_REQUIRE_EQUAL (out->frames(), in->frames());
/* Silence at the start */
}
}
+
/** Block size less than delay */
BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
{
/* Feeding 4 blocks of 64 should give silence each time */
for (int i = 0; i < 4; ++i) {
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 64));
+ auto in = make_shared<AudioBuffers>(C, 64);
for (int j = 0; j < C; ++j) {
for (int k = 0; k < 64; ++k) {
in->data(j)[k] = k + i * 64;
}
}
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
BOOST_REQUIRE_EQUAL (out->frames(), in->frames());
/* Check for silence */
/* Now feed 4 blocks of silence and we should see the data */
for (int i = 0; i < 4; ++i) {
/* Feed some silence */
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 64));
+ auto in = make_shared<AudioBuffers>(C, 64);
in->make_silent ();
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
/* Should now see the delayed data */
for (int j = 0; j < C; ++j) {
/*
- Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/butler.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+
+using std::make_shared;
using std::shared_ptr;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
using namespace dcpomatic;
+
BOOST_AUTO_TEST_CASE (butler_test1)
{
- shared_ptr<Film> film = new_test_film ("butler_test1");
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
+ auto film = new_test_film ("butler_test1");
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR"));
film->set_name ("butler_test1");
film->set_container (Ratio::from_id ("185"));
- shared_ptr<Content> video = content_factory("test/data/flat_red.png").front ();
+ auto video = content_factory("test/data/flat_red.png").front();
film->examine_and_add_content (video);
- shared_ptr<Content> audio = content_factory("test/data/staircase.wav").front ();
+ auto audio = content_factory("test/data/staircase.wav").front();
film->examine_and_add_content (audio);
BOOST_REQUIRE (!wait_for_jobs ());
film->set_audio_channels (6);
/* This is the map of the player output (5.1) to the butler output (also 5.1) */
- AudioMapping map = AudioMapping (6, 6);
+ auto map = AudioMapping (6, 6);
for (int i = 0; i < 6; ++i) {
map.set (i, i, 1);
}
- Butler butler (film, shared_ptr<Player>(new Player(film)), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false);
+ Butler butler (film, make_shared<Player>(film), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false);
BOOST_CHECK (butler.get_video(true, 0).second == DCPTime());
BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24));
/* XXX: check the frame contents */
float buffer[256 * 6];
- BOOST_REQUIRE (butler.get_audio (buffer, 256) == DCPTime());
+ BOOST_REQUIRE (butler.get_audio(buffer, 256) == DCPTime());
for (int i = 0; i < 256; ++i) {
BOOST_REQUIRE_EQUAL (buffer[i * 6 + 0], 0);
BOOST_REQUIRE_EQUAL (buffer[i * 6 + 1], 0);
/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/client_server_test.cc
* @brief Test the server class.
* @ingroup feature
* encoded data to check that they are the same.
*/
-#include "lib/encode_server.h"
-#include "lib/image.h"
+
#include "lib/cross.h"
#include "lib/dcp_video.h"
-#include "lib/player_video.h"
-#include "lib/raw_image_proxy.h"
-#include "lib/j2k_image_proxy.h"
+#include "lib/dcpomatic_log.h"
+#include "lib/encode_server.h"
#include "lib/encode_server_description.h"
#include "lib/file_log.h"
-#include "lib/dcpomatic_log.h"
+#include "lib/image.h"
+#include "lib/j2k_image_proxy.h"
+#include "lib/player_video.h"
+#include "lib/raw_image_proxy.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
+
using std::list;
+using std::make_shared;
using std::shared_ptr;
using std::weak_ptr;
-using std::make_shared;
using boost::thread;
using boost::optional;
using dcp::ArrayData;
+
void
do_remote_encode (shared_ptr<DCPVideo> frame, EncodeServerDescription description, ArrayData locally_encoded)
{
BOOST_CHECK_EQUAL (memcmp (locally_encoded.data(), remotely_encoded.data(), locally_encoded.size()), 0);
}
+
BOOST_AUTO_TEST_CASE (client_server_test_rgb)
{
auto image = make_shared<Image>(AV_PIX_FMT_RGB24, dcp::Size (1998, 1080), true);
delete server;
}
+
BOOST_AUTO_TEST_CASE (client_server_test_yuv)
{
auto image = make_shared<Image>(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), true);
delete server;
}
+
BOOST_AUTO_TEST_CASE (client_server_test_j2k)
{
auto image = make_shared<Image>(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), true);
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/config.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
#include <fstream>
+
using std::ofstream;
+
static void
rewrite_bad_config ()
{
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/crypto.h"
#include "lib/exceptions.h"
#include "test.h"
#include <openssl/rand.h>
#include <boost/test/unit_test.hpp>
+
using std::string;
using std::list;
+
BOOST_AUTO_TEST_CASE (crypto_test)
{
dcp::ArrayData key (dcpomatic::crypto_key_length());
RAND_bytes (key.data(), dcpomatic::crypto_key_length());
- dcp::ArrayData ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv);
+ auto ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv);
BOOST_REQUIRE_EQUAL (dcpomatic::decrypt (ciphertext, key, iv), "Can you see any fish?");
key.data()[5]++;
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
/*
- Copyright (C) 2017-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/empty_test.cc
* @brief Test the creation of Empty objects.
* @ingroup feature
*/
-#include "lib/film.h"
+
#include "lib/dcp_content_type.h"
-#include "lib/ratio.h"
-#include "lib/video_content.h"
-#include "lib/image_content.h"
+#include "lib/decoder.h"
#include "lib/empty.h"
+#include "lib/film.h"
+#include "lib/image_content.h"
#include "lib/player.h"
-#include "lib/decoder.h"
+#include "lib/ratio.h"
+#include "lib/video_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+
using std::list;
using std::make_shared;
using std::shared_ptr;
#endif
using namespace dcpomatic;
+
bool
has_video (shared_ptr<const Content> content)
{
return static_cast<bool>(content->video);
}
+
BOOST_AUTO_TEST_CASE (empty_test1)
{
- shared_ptr<Film> film = new_test_film2 ("empty_test1");
+ auto film = new_test_film2 ("empty_test1");
film->set_sequence (false);
- shared_ptr<ImageContent> contentA (new ImageContent("test/data/simple_testcard_640x480.png"));
- shared_ptr<ImageContent> contentB (new ImageContent("test/data/simple_testcard_640x480.png"));
+ auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+ auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
film->examine_and_add_content (contentA);
film->examine_and_add_content (contentB);
* A A A B
*/
contentA->video->set_length (3);
- contentA->set_position (film, DCPTime::from_frames (2, vfr));
+ contentA->set_position (film, DCPTime::from_frames(2, vfr));
contentB->video->set_length (1);
- contentB->set_position (film, DCPTime::from_frames (7, vfr));
+ contentB->set_position (film, DCPTime::from_frames(7, vfr));
Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 2U);
- list<dcpomatic::DCPTimePeriod>::const_iterator i = black._periods.begin();
+ auto i = black._periods.begin();
BOOST_CHECK (i->from == DCPTime::from_frames(0, vfr));
BOOST_CHECK (i->to == DCPTime::from_frames(2, vfr));
++i;
BOOST_CHECK (i->to == DCPTime::from_frames(7, vfr));
}
+
/** Some tests where the first empty period is not at time 0 */
BOOST_AUTO_TEST_CASE (empty_test2)
{
- shared_ptr<Film> film = new_test_film2 ("empty_test2");
+ auto film = new_test_film2 ("empty_test2");
film->set_sequence (false);
- shared_ptr<ImageContent> contentA (new ImageContent("test/data/simple_testcard_640x480.png"));
- shared_ptr<ImageContent> contentB (new ImageContent("test/data/simple_testcard_640x480.png"));
+ auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+ auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
film->examine_and_add_content (contentA);
film->examine_and_add_content (contentB);
BOOST_CHECK (black.done ());
}
+
/** Test for when the film's playlist is not the same as the one passed into Empty */
BOOST_AUTO_TEST_CASE (empty_test3)
{
- shared_ptr<Film> film = new_test_film2 ("empty_test3");
+ auto film = new_test_film2 ("empty_test3");
film->set_sequence (false);
- shared_ptr<ImageContent> contentA (new ImageContent("test/data/simple_testcard_640x480.png"));
- shared_ptr<ImageContent> contentB (new ImageContent("test/data/simple_testcard_640x480.png"));
+ auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+ auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
film->examine_and_add_content (contentA);
film->examine_and_add_content (contentB);
contentB->video->set_length (1);
contentB->set_position (film, DCPTime::from_frames(7, vfr));
- shared_ptr<Playlist> playlist (new Playlist);
+ auto playlist = make_shared<Playlist>();
playlist->add (film, contentB);
Empty black (film, playlist, bind(&has_video, _1), playlist->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 1U);
BOOST_CHECK (black.position() == DCPTime::from_frames(0, vfr));
}
+
BOOST_AUTO_TEST_CASE (empty_test_with_overlapping_content)
{
auto film = new_test_film2 ("empty_test_with_overlapping_content");
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/ffmpeg_decoder_sequential_test.cc
* @brief Check that the FFmpeg decoder and Player produce sequential frames without gaps or dropped frames;
* Also that the decoder picks up frame rates correctly.
* @ingroup feature
*/
+
#include "lib/ffmpeg_content.h"
#include "lib/ffmpeg_decoder.h"
#include "lib/content_video.h"
#include <boost/test/unit_test.hpp>
#include <iostream>
-using std::cout;
+
using std::cerr;
+using std::cout;
using std::list;
+using std::make_shared;
using std::shared_ptr;
using boost::optional;
using boost::bind;
#endif
using namespace dcpomatic;
+
static DCPTime next;
static DCPTime frame;
+
static void
check (shared_ptr<PlayerVideo>, DCPTime time)
{
next += frame;
}
+
void
ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int video_length)
{
- boost::filesystem::path path = TestPaths::private_data() / file;
+ auto path = TestPaths::private_data() / file;
BOOST_REQUIRE (boost::filesystem::exists (path));
- shared_ptr<Film> film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string());
- shared_ptr<FFmpegContent> content (new FFmpegContent(path));
+ auto film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string());
+ auto content = make_shared<FFmpegContent>(path);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
film->write_metadata ();
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
BOOST_REQUIRE (content->video_frame_rate());
BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01);
BOOST_REQUIRE (next == DCPTime::from_frames (video_length, film->video_frame_rate()));
}
+
BOOST_AUTO_TEST_CASE (ffmpeg_decoder_sequential_test)
{
ffmpeg_decoder_sequential_test_one ("boon_telly.mkv", 29.97, 6912);
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/ffmpeg_pts_offset_test.cc
* @brief Check the computation of _pts_offset in FFmpegDecoder.
* @ingroup selfcontained
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/film.h"
#include "lib/ffmpeg_decoder.h"
#include "lib/audio_content.h"
#include "test.h"
+
+using std::make_shared;
using std::shared_ptr;
using namespace dcpomatic;
+
BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test)
{
- shared_ptr<Film> film = new_test_film ("ffmpeg_pts_offset_test");
- shared_ptr<FFmpegContent> content (new FFmpegContent ("test/data/test.mp4"));
+ auto film = new_test_film ("ffmpeg_pts_offset_test");
+ auto content = make_shared<FFmpegContent>("test/data/test.mp4");
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- content->audio.reset (new AudioContent (content.get()));
+ content->audio = make_shared<AudioContent>(content.get());
content->audio->add_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream));
content->_video_frame_rate = 24;
/*
- Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/job_test.cc
* @brief Test Job and JobManager.
* @ingroup selfcontained
*/
-#include <boost/test/unit_test.hpp>
+
+#include "lib/cross.h"
#include "lib/job.h"
#include "lib/job_manager.h"
-#include "lib/cross.h"
+#include <boost/test/unit_test.hpp>
-using std::string;
+
+using std::make_shared;
using std::shared_ptr;
+using std::string;
+
class TestJob : public Job
{
}
};
+
BOOST_AUTO_TEST_CASE (job_manager_test)
{
shared_ptr<Film> film;
/* Single job */
- shared_ptr<TestJob> a (new TestJob (film));
+ auto a = make_shared<TestJob>(film);
JobManager::instance()->add (a);
dcpomatic_sleep_seconds (1);
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/pixel_formats_test.cc
* @brief Make sure that Image::sample_size() and Image::bytes_per_pixel() return the right
* things for various pixel formats.
* @see test/image_test.cc
*/
+
#include <boost/test/unit_test.hpp>
#include <list>
extern "C" {
#include "lib/image.h"
#include <iostream>
+
using std::list;
using std::cout;
+
/** @struct Case
* @brief A test case for pixel_formats_test.
*/
BOOST_AUTO_TEST_CASE (pixel_formats_test)
{
- list<Case> cases;
- cases.push_back(Case(AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 ));
- cases.push_back(Case(AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 ));
- cases.push_back(Case(AV_PIX_FMT_YUV420P, 3, 480, 240, 240, 1, 0.5, 0.5));
- cases.push_back(Case(AV_PIX_FMT_YUV422P, 3, 480, 480, 480, 1, 0.5, 0.5));
- cases.push_back(Case(AV_PIX_FMT_YUV422P10LE, 3, 480, 480, 480, 2, 1, 1 ));
- cases.push_back(Case(AV_PIX_FMT_YUV422P16LE, 3, 480, 480, 480, 2, 1, 1 ));
- cases.push_back(Case(AV_PIX_FMT_UYVY422, 1, 480, 480, 480, 2, 0, 0 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P, 3, 480, 480, 480, 1, 1, 1 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P9BE, 3, 480, 480, 480, 2, 2, 2 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P9LE, 3, 480, 480, 480, 2, 2, 2 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P10BE, 3, 480, 480, 480, 2, 2, 2 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P10LE, 3, 480, 480, 480, 2, 2, 2 ));
-
- for (list<Case>::iterator i = cases.begin(); i != cases.end(); ++i) {
- AVFrame* f = av_frame_alloc ();
+ list<Case> cases = {
+ { AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 },
+ { AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 },
+ { AV_PIX_FMT_YUV420P, 3, 480, 240, 240, 1, 0.5, 0.5},
+ { AV_PIX_FMT_YUV422P, 3, 480, 480, 480, 1, 0.5, 0.5},
+ { AV_PIX_FMT_YUV422P10LE, 3, 480, 480, 480, 2, 1, 1 },
+ { AV_PIX_FMT_YUV422P16LE, 3, 480, 480, 480, 2, 1, 1 },
+ { AV_PIX_FMT_UYVY422, 1, 480, 480, 480, 2, 0, 0 },
+ { AV_PIX_FMT_YUV444P, 3, 480, 480, 480, 1, 1, 1 },
+ { AV_PIX_FMT_YUV444P9BE, 3, 480, 480, 480, 2, 2, 2 },
+ { AV_PIX_FMT_YUV444P9LE, 3, 480, 480, 480, 2, 2, 2 },
+ { AV_PIX_FMT_YUV444P10BE, 3, 480, 480, 480, 2, 2, 2 },
+ { AV_PIX_FMT_YUV444P10LE, 3, 480, 480, 480, 2, 2, 2 }
+ };
+
+ for (auto const& i: cases) {
+ auto f = av_frame_alloc ();
f->width = 640;
f->height = 480;
- f->format = static_cast<int> (i->format);
+ f->format = static_cast<int> (i.format);
av_frame_get_buffer (f, true);
Image t (f);
- BOOST_CHECK_EQUAL(t.planes(), i->planes);
- BOOST_CHECK_EQUAL(t.sample_size(0).height, i->lines[0]);
- BOOST_CHECK_EQUAL(t.sample_size(1).height, i->lines[1]);
- BOOST_CHECK_EQUAL(t.sample_size(2).height, i->lines[2]);
- BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i->bpp[0]);
- BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i->bpp[1]);
- BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i->bpp[2]);
+ BOOST_CHECK_EQUAL(t.planes(), i.planes);
+ BOOST_CHECK_EQUAL(t.sample_size(0).height, i.lines[0]);
+ BOOST_CHECK_EQUAL(t.sample_size(1).height, i.lines[1]);
+ BOOST_CHECK_EQUAL(t.sample_size(2).height, i.lines[2]);
+ BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i.bpp[0]);
+ BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i.bpp[1]);
+ BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i.bpp[2]);
}
}
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/rect_test.cc
* @brief Test dcpomatic::Rect class.
* @ingroup selfcontained
*/
+
#include "lib/rect.h"
#include <boost/test/unit_test.hpp>
#include <iostream>
+
using boost::optional;
+
BOOST_AUTO_TEST_CASE (rect_test1)
{
dcpomatic::Rect<int> a (0, 0, 100, 100);
dcpomatic::Rect<int> b (200, 200, 100, 100);
- optional<dcpomatic::Rect<int> > c = a.intersection (b);
+ auto c = a.intersection (b);
BOOST_CHECK (!c);
}
+
BOOST_AUTO_TEST_CASE (rect_test2)
{
dcpomatic::Rect<int> a (0, 330, 100, 85);
- a.extend (dcpomatic::Rect<int> (50, 235, 100, 85));
+ a.extend (dcpomatic::Rect<int>(50, 235, 100, 85));
BOOST_CHECK_EQUAL (a.x, 0);
BOOST_CHECK_EQUAL (a.y, 235);
BOOST_CHECK_EQUAL (a.width, 150);
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/silence_padding_test.cc
* @brief Test the padding (with silence) of a mono source to a 6-channel DCP.
* @ingroup feature
*/
+
#include "lib/ffmpeg_content.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
#include <dcp/sound_asset_reader.h>
#include <boost/test/unit_test.hpp>
+
using std::make_shared;
using std::string;
using std::shared_ptr;
using boost::lexical_cast;
+
static void
test_silence_padding (int channels)
{
}
+
BOOST_AUTO_TEST_CASE (silence_padding_test)
{
for (int i = 1; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
}
}
+
/** Test a situation that used to crash because of a sub-sample rounding confusion
* caused by a trim.
*/
/*
- 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.
*/
+
/** @file test/threed_test.cc
* @brief Create some 3D DCPs (without comparing the results to anything).
* @ingroup completedcp
*/
+
#include "lib/config.h"
#include "lib/content_factory.h"
#include "lib/cross.h"
/*
- Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/time_calculation_test.cc
* @brief Test calculation of timings when frame rates change.
* @ingroup feature
*/
+
#include "lib/film.h"
#include "lib/ffmpeg_content.h"
#include "lib/video_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
-using std::string;
+
using std::list;
+using std::make_shared;
using std::shared_ptr;
+using std::string;
using namespace dcpomatic;
+
static string const xml = "<Content>"
"<Type>FFmpeg</Type>"
"<BurnSubtitles>0</BurnSubtitles>"
"<FirstVideo>0</FirstVideo>"
"</Content>";
+
BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test)
{
- shared_ptr<Film> film = new_test_film ("ffmpeg_time_calculation_test");
+ auto film = new_test_film ("ffmpeg_time_calculation_test");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
/* 25fps content, 25fps DCP */
film->set_video_frame_rate (25);
}
+
/** Test Player::dcp_to_content_video */
BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
{
- shared_ptr<Film> film = new_test_film ("player_time_calculation_test1");
+ auto film = new_test_film ("player_time_calculation_test1");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
/* Position 0, no trim, content rate = DCP rate */
content->set_position (film, DCPTime());
/** Test Player::content_video_to_dcp */
BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
{
- shared_ptr<Film> film = new_test_film ("player_time_calculation_test2");
+ auto film = new_test_film ("player_time_calculation_test2");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
/* Position 0, no trim, content rate = DCP rate */
content->set_position (film, DCPTime());
/** Test Player::dcp_to_content_audio */
BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
{
- shared_ptr<Film> film = new_test_film ("player_time_calculation_test3");
+ auto film = new_test_film ("player_time_calculation_test3");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
- AudioStreamPtr stream = content->audio->streams().front();
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
+ auto stream = content->audio->streams().front();
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
/* Position 0, no trim, video/audio content rate = video/audio DCP rate */
content->set_position (film, DCPTime());
stream->_frame_rate = 48000;
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U);
- shared_ptr<Piece> piece = player->_pieces.front ();
+ auto piece = player->_pieces.front ();
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000);
/*
- Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/torture_test.cc
* @brief Tricky arrangements of content whose resulting DCPs are checked programmatically.
* @ingroup completedcp
*/
+
#include "lib/audio_content.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
#include <boost/test/unit_test.hpp>
#include <iostream>
+
using std::list;
using std::cout;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using namespace dcpomatic;
+
/** Test start/end trim and positioning of some audio content */
BOOST_AUTO_TEST_CASE (torture_test1)
{
staircase->audio->set_gain (20 * log10(2));
/* And again at an offset of 50000 samples, trimmed both start and end, with a gain of exactly 2 (linear) */
- staircase = content_factory("test/data/staircase.wav").front ();
+ staircase = content_factory("test/data/staircase.wav").front();
film->examine_and_add_content (staircase);
BOOST_REQUIRE (!wait_for_jobs());
staircase->set_position (film, DCPTime::from_frames(50000, film->audio_frame_rate()));
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
pair<int, int>
pixel_range (shared_ptr<Film> film, shared_ptr<const FFmpegContent> content)
{
- shared_ptr<FFmpegDecoder> decoder(new FFmpegDecoder(film, content, false));
+ auto decoder = make_shared<FFmpegDecoder>(film, content, false);
decoder->video->Data.connect (bind(&video_handler, _1));
content_video = boost::none;
while (!content_video) {
pair<int, int>
pixel_range (shared_ptr<Film> film, shared_ptr<const ImageContent> content)
{
- shared_ptr<ImageDecoder> decoder(new ImageDecoder(film, content));
+ auto decoder = make_shared<ImageDecoder>(film, content);
decoder->video->Data.connect (bind(&video_handler, _1));
content_video = boost::none;
while (!content_video) {
dcp::DCP dcp (dcp_path);
dcp.read ();
- shared_ptr<dcp::MonoPictureAsset> picture = dynamic_pointer_cast<dcp::MonoPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
+ auto picture = dynamic_pointer_cast<dcp::MonoPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
BOOST_REQUIRE (picture);
- shared_ptr<dcp::OpenJPEGImage> frame = picture->start_read()->get_frame(0)->xyz_image();
+ auto frame = picture->start_read()->get_frame(0)->xyz_image();
int const width = frame->size().width;
int const height = frame->size().height;
shared_ptr<Film>
movie_V (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
shared_ptr<Film>
movie_VoF (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
shared_ptr<Film>
movie_F (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
shared_ptr<Film>
movie_FoV (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
shared_ptr<Film>
image_F (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<ImageContent> content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
shared_ptr<Film>
image_FoV (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<ImageContent> content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
dcp_F (string name)
{
boost::filesystem::path const dcp = "test/data/RgbGreyTestcar_TST-1_F_MOS_2K_20201115_SMPTE_OV";
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<DCPContent> content(new DCPContent(dcp));
- film->examine_and_add_content (shared_ptr<DCPContent>(new DCPContent(dcp)));
+ auto film = new_test_film2 (name);
+ auto content = make_shared<DCPContent>(dcp);
+ film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
auto range = pixel_range (dcp);
pair<int, int>
V_movie_range (shared_ptr<Film> film)
{
- shared_ptr<TranscodeJob> job (new TranscodeJob(film));
+ auto job = make_shared<TranscodeJob>(film);
job->set_encoder (
- shared_ptr<FFmpegEncoder>(
- new FFmpegEncoder (film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23)
- )
+ make_shared<FFmpegEncoder>(film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23)
);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/zipper_test.cc
* @brief Test Zipper class.
* @ingroup selfcontained
*/
-#include "lib/zipper.h"
+
#include "lib/exceptions.h"
+#include "lib/zipper.h"
#include "test.h"
#include <dcp/util.h>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
+
/** Basic test of Zipper working normally */
BOOST_AUTO_TEST_CASE (zipper_test1)
{