/*
- 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 "analyse_subtitles_job.h"
-#include "playlist.h"
-#include "player.h"
-#include "subtitle_analysis.h"
#include "bitmap_text.h"
+#include "image.h"
+#include "player.h"
+#include "playlist.h"
#include "render_text.h"
+#include "subtitle_analysis.h"
#include "text_content.h"
-#include "image.h"
#include <iostream>
#include "i18n.h"
+
using std::make_shared;
using std::shared_ptr;
using std::string;
using namespace boost::placeholders;
#endif
+
AnalyseSubtitlesJob::AnalyseSubtitlesJob (shared_ptr<const Film> film, shared_ptr<Content> content)
: Job (film)
, _content (content)
/*
- 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 "job.h"
#include "types.h"
#include "player_text.h"
+
class Film;
class Content;
+
class AnalyseSubtitlesJob : public Job
{
public:
AnalyseSubtitlesJob (std::shared_ptr<const Film> film, std::shared_ptr<Content> content);
- std::string name () const;
- std::string json_name () const;
- void run ();
+ std::string name () const override;
+ std::string json_name () const override;
+ void run () override;
boost::filesystem::path path () const {
return _path;
std::weak_ptr<Content> _content;
boost::filesystem::path _path;
- boost::optional<dcpomatic::Rect<double> > _bounding_box;
+ boost::optional<dcpomatic::Rect<double>> _bounding_box;
};
/*
- 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.
DCPOMATIC_ENABLE_WARNINGS
+using std::make_shared;
using std::string;
using std::shared_ptr;
AtmosContent::from_xml (Content* parent, cxml::ConstNodePtr node)
{
if (!node->optional_node_child("AtmosLength")) {
- return shared_ptr<AtmosContent>();
+ return {};
}
- return shared_ptr<AtmosContent> (new AtmosContent(parent, node));
+ return make_shared<AtmosContent>(parent, node);
}
/*
- 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.
class AtmosContent : public ContentPart
{
public:
- AtmosContent (Content* parent);
+ explicit AtmosContent (Content* parent);
+ AtmosContent (Content* parent, cxml::ConstNodePtr node);
static std::shared_ptr<AtmosContent> from_xml (Content* parent, cxml::ConstNodePtr node);
}
private:
- AtmosContent (Content* parent, cxml::ConstNodePtr node);
-
Frame _length;
dcp::Fraction _edit_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.
/*
- 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.
public:
AtmosDecoder (Decoder* parent, std::shared_ptr<const Content> content);
- boost::optional<dcpomatic::ContentTime> position (std::shared_ptr<const Film>) const {
+ boost::optional<dcpomatic::ContentTime> position (std::shared_ptr<const Film>) const override {
return _position;
}
- void seek ();
+ void seek () override;
void emit (std::shared_ptr<const Film> film, std::shared_ptr<const dcp::AtmosFrame> data, Frame frame, AtmosMetadata metadata);
/*
- 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 "atmos_content.h"
#include "atmos_mxf_content.h"
-#include "job.h"
-#include "film.h"
#include "compose.hpp"
+#include "film.h"
+#include "job.h"
#include <asdcp/KM_log.h>
#include <dcp/atmos_asset.h>
#include <dcp/exceptions.h>
#include "i18n.h"
+
using std::list;
+using std::make_shared;
using std::string;
using std::shared_ptr;
using namespace dcpomatic;
+
AtmosMXFContent::AtmosMXFContent (boost::filesystem::path path)
: Content (path)
{
}
+
AtmosMXFContent::AtmosMXFContent (cxml::ConstNodePtr node, int)
: Content (node)
{
atmos = AtmosContent::from_xml (this, node);
}
+
bool
AtmosMXFContent::valid_mxf (boost::filesystem::path path)
{
Kumu::DefaultLogSink().UnsetFilterFlag(Kumu::LOG_ALLOW_ALL);
try {
- shared_ptr<dcp::AtmosAsset> a (new dcp::AtmosAsset (path));
+ dcp::AtmosAsset a (path);
return true;
} catch (dcp::MXFFileError& e) {
return false;
}
+
void
AtmosMXFContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
{
job->set_progress_unknown ();
Content::examine (film, job);
- shared_ptr<dcp::AtmosAsset> a (new dcp::AtmosAsset (path(0)));
+ auto a = make_shared<dcp::AtmosAsset>(path(0));
{
boost::mutex::scoped_lock lm (_mutex);
- atmos.reset (new AtmosContent(this));
+ atmos = make_shared<AtmosContent>(this);
atmos->set_length (a->intrinsic_duration());
atmos->set_edit_rate (a->edit_rate());
}
}
+
string
AtmosMXFContent::summary () const
{
return String::compose (_("%1 [Atmos]"), path_summary());
}
+
void
AtmosMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const
{
- node->add_child("Type")->add_child_text ("AtmosMXF");
+ node->add_child("Type")->add_child_text("AtmosMXF");
Content::as_xml (node, with_paths);
atmos->as_xml (node);
}
+
DCPTime
AtmosMXFContent::full_length (shared_ptr<const Film> film) const
{
FrameRateChange const frc (film, shared_from_this());
- return DCPTime::from_frames (llrint (atmos->length() * frc.factor()), film->video_frame_rate());
+ return DCPTime::from_frames (llrint(atmos->length() * frc.factor()), film->video_frame_rate());
}
+
DCPTime
AtmosMXFContent::approximate_length () 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.
return std::dynamic_pointer_cast<const AtmosMXFContent> (Content::shared_from_this());
}
- void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job> job);
- std::string summary () const;
- void as_xml (xmlpp::Node* node, bool with_path) const;
- dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const;
- dcpomatic::DCPTime approximate_length () const;
+ void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job> job) override;
+ std::string summary () const override;
+ void as_xml (xmlpp::Node* node, bool with_path) const override;
+ dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override;
+ dcpomatic::DCPTime approximate_length () const override;
static bool valid_mxf (boost::filesystem::path path);
};
/*
- 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 "atmos_content.h"
#include "atmos_decoder.h"
#include "atmos_mxf_content.h"
#include <dcp/atmos_asset.h>
#include <dcp/atmos_asset_reader.h>
+
+using std::make_shared;
using std::shared_ptr;
+
AtmosMXFDecoder::AtmosMXFDecoder (std::shared_ptr<const Film> film, std::shared_ptr<const AtmosMXFContent> content)
: Decoder (film)
, _content (content)
{
- atmos.reset (new AtmosDecoder(this, content));
+ atmos = make_shared<AtmosDecoder>(this, content);
- shared_ptr<dcp::AtmosAsset> asset (new dcp::AtmosAsset(_content->path(0)));
+ auto asset = make_shared<dcp::AtmosAsset>(_content->path(0));
_reader = asset->start_read ();
_metadata = AtmosMetadata (asset);
}
bool
AtmosMXFDecoder::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->atmos->length()) {
return true;
/*
- 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 "atmos_metadata.h"
#include "dcpomatic_time.h"
#include "decoder.h"
#include <dcp/atmos_asset_reader.h>
+
class AtmosMXFContent;
+
class AtmosMXFDecoder : public Decoder
{
public:
AtmosMXFDecoder (std::shared_ptr<const Film> film, std::shared_ptr<const AtmosMXFContent>);
- bool pass ();
- void seek (dcpomatic::ContentTime t, bool accurate);
+ bool pass () override;
+ void seek (dcpomatic::ContentTime t, bool accurate) override;
private:
std::shared_ptr<const AtmosMXFContent> _content;
/*
- 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 "util.h"
#include "audio_buffers.h"
#include "dcpomatic_assert.h"
#include <cmath>
#include <stdexcept>
+
using std::bad_alloc;
using std::shared_ptr;
+using std::make_shared;
+
/** Construct an AudioBuffers. Audio data is undefined after this constructor.
* @param channels Number of channels.
allocate (channels, frames);
}
+
/** Copy constructor.
* @param other Other AudioBuffers; data is copied.
*/
copy_from (&other, other._frames, 0, 0);
}
+
AudioBuffers::AudioBuffers (std::shared_ptr<const AudioBuffers> other)
{
allocate (other->_channels, other->_frames);
copy_from (other.get(), other->_frames, 0, 0);
}
+
AudioBuffers::AudioBuffers (std::shared_ptr<const AudioBuffers> other, int32_t frames_to_copy, int32_t read_offset)
{
allocate (other->_channels, frames_to_copy);
copy_from (other.get(), frames_to_copy, read_offset, 0);
}
+
AudioBuffers &
AudioBuffers::operator= (AudioBuffers const & other)
{
return *this;
}
+
/** AudioBuffers destructor */
AudioBuffers::~AudioBuffers ()
{
deallocate ();
}
+
void
AudioBuffers::allocate (int channels, int32_t frames)
{
_frames = frames;
_allocated_frames = frames;
- _data = static_cast<float**> (malloc (_channels * sizeof (float *)));
+ _data = static_cast<float**> (malloc(_channels * sizeof(float *)));
if (!_data) {
throw bad_alloc ();
}
for (int i = 0; i < _channels; ++i) {
- _data[i] = static_cast<float*> (malloc (frames * sizeof (float)));
+ _data[i] = static_cast<float*> (malloc(frames * sizeof(float)));
if (!_data[i]) {
throw bad_alloc ();
}
}
}
+
void
AudioBuffers::deallocate ()
{
free (_data);
}
+
/** @param c Channel index.
* @return Buffer for this channel.
*/
return _data[c];
}
+
/** Set the number of frames that these AudioBuffers will report themselves
* as having. If we reduce the number of frames, the `lost' frames will
* be silenced.
_frames = f;
}
+
/** Make all frames silent */
void
AudioBuffers::make_silent ()
}
}
+
/** Make all samples on a given channel silent.
* @param c Channel.
*/
memset (_data[c], 0, _frames * sizeof(float));
}
+
/** Make some frames.
* @param from Start frame.
* @param frames Number of frames to silence.
}
}
+
/** Copy data from another AudioBuffers to this one. All channels are copied.
* @param from AudioBuffers to copy from; must have the same number of channels as this.
* @param frames_to_copy Number of frames to copy.
}
}
+
/** Move audio data around.
* @param from Offset to move from.
* @param to Offset to move to.
}
}
+
/** Add data from from `from', `from_channel' to our channel `to_channel'.
* @param from Buffers to copy data from.
* @param from_channel Channel index to read in \p from.
DCPOMATIC_ASSERT (from->frames() == N);
DCPOMATIC_ASSERT (to_channel <= _channels);
- float* s = from->data (from_channel);
- float* d = _data[to_channel];
+ auto s = from->data (from_channel);
+ auto d = _data[to_channel];
for (int i = 0; i < N; ++i) {
*d++ += (*s++) * gain;
}
}
+
/** Ensure we have space for at least a certain number of frames. If we extend
* the buffers, fill the new space with silence.
*/
frames++;
for (int i = 0; i < _channels; ++i) {
- _data[i] = static_cast<float*> (realloc (_data[i], frames * sizeof (float)));
+ _data[i] = static_cast<float*> (realloc(_data[i], frames * sizeof(float)));
if (!_data[i]) {
throw bad_alloc ();
}
}
- int32_t const old_allocated = _allocated_frames;
+ auto const old_allocated = _allocated_frames;
_allocated_frames = frames;
if (old_allocated < _allocated_frames) {
make_silent (old_allocated, _allocated_frames - old_allocated);
}
}
+
/** Mix some other buffers with these ones. The AudioBuffers must have the same number of channels.
* @param from Audio buffers to get data from.
* @param frames Number of frames to mix.
DCPOMATIC_ASSERT (read_offset >= 0);
DCPOMATIC_ASSERT (write_offset >= 0);
- float** from_data = from->data ();
+ auto from_data = from->data ();
for (int i = 0; i < _channels; ++i) {
for (int j = 0; j < frames; ++j) {
_data[i][j + write_offset] += from_data[i][j + read_offset];
}
}
+
/** @param dB gain in dB */
void
AudioBuffers::apply_gain (float dB)
{
- float const linear = db_to_linear (dB);
+ auto const linear = db_to_linear (dB);
for (int i = 0; i < _channels; ++i) {
for (int j = 0; j < _frames; ++j) {
}
}
+
/** @param c Channel index.
* @return AudioBuffers object containing only channel `c' from this AudioBuffers.
*/
shared_ptr<AudioBuffers>
AudioBuffers::channel (int c) const
{
- shared_ptr<AudioBuffers> o (new AudioBuffers (1, frames ()));
+ auto o = make_shared<AudioBuffers>(1, frames());
o->copy_channel_from (this, c, 0);
return o;
}
+
/** Copy all the samples from a channel on another AudioBuffers to a channel on this one.
* @param from AudioBuffers to copy from.
* @param from_channel Channel index in `from' to copy from.
memcpy (data(to_channel), from->data(from_channel), frames() * sizeof (float));
}
+
/** Make a copy of these AudioBuffers */
shared_ptr<AudioBuffers>
AudioBuffers::clone () const
{
- shared_ptr<AudioBuffers> b (new AudioBuffers (channels (), frames ()));
- b->copy_from (this, frames (), 0, 0);
+ auto b = make_shared<AudioBuffers>(channels(), frames());
+ b->copy_from (this, frames(), 0, 0);
return b;
}
+
/** Extend these buffers with the data from another. The AudioBuffers must have the same number of channels. */
void
AudioBuffers::append (shared_ptr<const AudioBuffers> other)
_frames += other->frames();
}
+
/** Remove some frames from the start of these AudioBuffers */
void
AudioBuffers::trim_start (int32_t frames)
/*
- Copyright (C) 2012-2014 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/audio_buffers.h
* @brief AudioBuffers class.
*/
float** _data;
};
+
#endif
/*
- 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 "butler.h"
#include "player.h"
#include "util.h"
using namespace boost::placeholders;
#endif
+
/** Minimum video readahead in frames */
#define MINIMUM_VIDEO_READAHEAD 10
/** Maximum video readahead in frames; should never be exceeded (by much) unless there are bugs in Player */
/** Maximum audio readahead in frames; should never be exceeded (by much) unless there are bugs in Player */
#define MAXIMUM_AUDIO_READAHEAD (48000 * MAXIMUM_VIDEO_READAHEAD / 24)
+
/** @param pixel_format Pixel format functor that will be used when calling ::image on PlayerVideos coming out of this
* butler. This will be used (where possible) to prepare the PlayerVideos so that calling image() on them is quick.
* @param aligned Same as above for the `aligned' flag.
)
: _film (film)
, _player (player)
- , _prepare_work (new boost::asio::io_service::work (_prepare_service))
+ , _prepare_work (new boost::asio::io_service::work(_prepare_service))
, _pending_seek_accurate (false)
, _suspended (0)
, _finished (false)
}
}
+
Butler::~Butler ()
{
boost::this_thread::disable_interruption dis;
return (_video.size() < MAXIMUM_VIDEO_READAHEAD) && (_audio.size() < MAXIMUM_AUDIO_READAHEAD);
}
+
void
Butler::thread ()
try
_arrived.notify_all ();
}
+
/** @param blocking true if we should block until video is available. If blocking is false
* and no video is immediately available the method will return a 0 PlayerVideo and the error AGAIN.
* @param e if non-0 this is filled with an error code (if an error occurs) or is untouched if no error occurs.
return r;
}
+
optional<TextRingBuffers::Data>
Butler::get_closed_caption ()
{
return _closed_caption.get ();
}
+
void
Butler::seek (DCPTime position, bool accurate)
{
seek_unlocked (position, accurate);
}
+
void
Butler::seek_unlocked (DCPTime position, bool accurate)
{
_summon.notify_all ();
}
+
void
Butler::prepare (weak_ptr<PlayerVideo> weak_video)
try
_died = true;
}
+
void
Butler::video (shared_ptr<PlayerVideo> video, DCPTime time)
{
return;
}
- _prepare_service.post (bind (&Butler::prepare, this, weak_ptr<PlayerVideo>(video)));
+ _prepare_service.post (bind(&Butler::prepare, this, weak_ptr<PlayerVideo>(video)));
_video.put (video, time);
}
+
void
Butler::audio (shared_ptr<AudioBuffers> audio, DCPTime time, int frame_rate)
{
return;
}
- _audio.put (remap (audio, _audio_channels, _audio_mapping), time, frame_rate);
+ _audio.put (remap(audio, _audio_channels, _audio_mapping), time, frame_rate);
}
+
/** Try to get `frames' frames of audio and copy it into `out'. Silence
* will be filled if no audio is available.
* @return time of this audio, or unset if there was a buffer underrun.
return t;
}
+
void
Butler::disable_audio ()
{
_disable_audio = true;
}
+
pair<size_t, string>
Butler::memory_used () const
{
return _video.memory_used();
}
+
void
Butler::player_change (ChangeType type, int property)
{
_summon.notify_all ();
}
+
void
Butler::text (PlayerText pt, TextType type, optional<DCPTextTrack> track, DCPTimePeriod period)
{
_closed_caption.put (pt, *track, period);
}
+
string
Butler::Error::summary () const
{
*/
+
#include "audio_mapping.h"
#include "audio_ring_buffers.h"
#include "change_signaller.h"
#include <boost/thread.hpp>
#include <boost/thread/condition.hpp>
+
class Player;
class PlayerVideo;
+
class Butler : public ExceptionStore
{
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 "case_insensitive_sorter.h"
#include <boost/filesystem.hpp>
-#include <iostream>
+
using std::string;
+
bool
CaseInsensitiveSorter::operator() (boost::filesystem::path a, boost::filesystem::path b)
{
- string x = a.string ();
- string y = b.string ();
+ auto x = a.string();
+ auto y = b.string();
transform (x.begin(), x.end(), x.begin(), ::tolower);
transform (y.begin(), y.end(), y.begin(), ::tolower);
return x < y;
/*
- 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 <boost/filesystem.hpp>
+
class CaseInsensitiveSorter
{
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.
*/
+
#ifndef DCPOMATIC_CONTENT_PART_H
#define DCPOMATIC_CONTENT_PART_H
-#include "content.h"
+
#include "change_signaller.h"
+#include "content.h"
#include <boost/thread/mutex.hpp>
+
class Content;
class Film;
+
class ContentPart
{
public:
mutable boost::mutex _mutex;
};
+
#endif
/*
- 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) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
class DCPContent;
class Film;
+
extern void copy_dcp_details_to_film (std::shared_ptr<const DCPContent> dcp, std::shared_ptr<Film> film);
/*
- 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 "compose.hpp"
+#include "config.h"
#include "create_cli.h"
#include "dcp_content_type.h"
#include "ratio.h"
-#include "config.h"
-#include "compose.hpp"
#include <dcp/raw_convert.h>
+#include <iostream>
#include <string>
-#include <iostream>
using std::string;
using std::cout;
using boost::optional;
+
string CreateCLI::_help =
"\nSyntax: %1 [OPTION] <CONTENT> [OPTION] [<CONTENT> ...]\n"
" -v, --version show DCP-o-matic version\n"
" --left-eye next piece of content is for the left eye\n"
" --right-eye next piece of content is for the right eye\n";
+
template <class T>
void
argument_option (int& n, int argc, char* argv[], string short_name, string long_name, bool* claimed, optional<string>* error, T* out)
*claimed = true;
}
+
CreateCLI::CreateCLI (int argc, char* argv[])
: version (false)
, encrypt (false)
/*
- 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 "types.h"
#include <dcp/types.h>
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
#include <vector>
+
class DCPContentType;
class Ratio;
+
class CreateCLI
{
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 "cross.h"
#include "compose.hpp"
#include "log.h"
#include "i18n.h"
+
using std::pair;
using std::list;
using std::ifstream;
using boost::optional;
using std::function;
+
/** @param s Number of seconds to sleep for */
void
dcpomatic_sleep_seconds (int s)
sleep (s);
}
+
void
dcpomatic_sleep_milliseconds (int ms)
{
usleep (ms * 1000);
}
+
/** @return A string of CPU information (model name etc.) */
string
cpu_info ()
char buffer[64];
size_t N = sizeof (buffer);
- if (sysctlbyname ("machdep.cpu.brand_string", buffer, &N, 0, 0) == 0) {
+ if (sysctlbyname("machdep.cpu.brand_string", buffer, &N, 0, 0) == 0) {
info = buffer;
}
void
run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
{
- boost::filesystem::path path = directory_containing_executable () / "ffprobe";
+ auto path = directory_containing_executable () / "ffprobe";
string ffprobe = "\"" + path.string() + "\" \"" + content.string() + "\" 2> \"" + out.string() + "\"";
LOG_GENERAL (N_("Probing with %1"), ffprobe);
}
-list<pair<string, string> >
+
+list<pair<string, string>>
mount_info ()
{
- list<pair<string, string> > m;
- return m;
+ return {};
}
+
boost::filesystem::path
openssl_path ()
{
}
#endif
+
/* Apparently there is no way to create an ofstream using a UTF-8
filename under Windows. We are hence reduced to using fopen
with this wrapper.
FILE *
fopen_boost (boost::filesystem::path p, string t)
{
- return fopen (p.c_str(), t.c_str ());
+ return fopen (p.c_str(), t.c_str());
}
+
int
dcpomatic_fseek (FILE* stream, int64_t offset, int whence)
{
return fseek (stream, offset, whence);
}
+
void
Waker::nudge ()
{
}
+
Waker::Waker ()
{
boost::mutex::scoped_lock lm (_mutex);
IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id);
}
+
Waker::~Waker ()
{
boost::mutex::scoped_lock lm (_mutex);
IOPMAssertionRelease (_assertion_id);
}
+
void
start_tool (string executable, string app)
{
- boost::filesystem::path exe_path = directory_containing_executable();
- exe_path = exe_path.parent_path (); // Contents
- exe_path = exe_path.parent_path (); // DCP-o-matic 2.app
- exe_path = exe_path.parent_path (); // Applications
+ auto exe_path = directory_containing_executable();
+ exe_path = exe_path.parent_path(); // Contents
+ exe_path = exe_path.parent_path(); // DCP-o-matic 2.app
+ exe_path = exe_path.parent_path(); // Applications
exe_path /= app;
exe_path /= "Contents";
exe_path /= "MacOS";
return (uint64_t) pthread_self ();
}
+
int
avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
{
return avio_open (s, file.c_str(), flags);
}
+
boost::filesystem::path
home_directory ()
{
- return getenv("HOME");
+ return getenv("HOME");
}
+
/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
bool
running_32_on_64 ()
return false;
}
+
static optional<string>
get_vendor (CFDictionaryRef& description)
{
return s;
}
+
static optional<string>
get_model (CFDictionaryRef& description)
{
return s;
}
+
struct MediaPath
{
bool real; ///< true for a "real" disk, false for a synthesized APFS one
std::string prt; ///< "PRT" entry from the media path
};
+
static optional<MediaPath>
analyse_media_path (CFDictionaryRef& description)
{
return mp;
}
+
static bool
is_whole_drive (DADiskRef& disk)
{
return whole_media;
}
+
static optional<boost::filesystem::path>
mount_point (CFDictionaryRef& description)
{
return boost::filesystem::path(mount_path_buffer);
}
+
/* Here follows some rather intricate and (probably) fragile code to find the list of available
* "real" drives on macOS that we might want to write a DCP to.
*
unsigned long size;
};
+
static void
disk_appeared (DADiskRef disk, void* context)
{
reinterpret_cast<vector<Disk>*>(context)->push_back(this_disk);
}
+
vector<Drive>
Drive::get ()
{
using namespace boost::algorithm;
vector<Disk> disks;
- DASessionRef session = DASessionCreate(kCFAllocatorDefault);
+ auto session = DASessionCreate(kCFAllocatorDefault);
if (!session) {
return {};
}
DARegisterDiskAppearedCallback (session, NULL, disk_appeared, &disks);
- CFRunLoopRef run_loop = CFRunLoopGetCurrent ();
+ auto run_loop = CFRunLoopGetCurrent ();
DASessionScheduleWithRunLoop (session, run_loop, kCFRunLoopDefaultMode);
CFRunLoopStop (run_loop);
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, 0);
}
/* Make a map of the PRT codes and mount points of mounted, synthesized disks */
- map<string, vector<boost::filesystem::path> > mounted_synths;
+ map<string, vector<boost::filesystem::path>> mounted_synths;
for (auto& i: disks) {
if (!i.real && !i.mount_points.empty()) {
LOG_DISK("Found a mounted synth %1 with %2", i.mount_point, i.prt);
{
LOG_DISK_NC("Unmount operation started");
- DASessionRef session = DASessionCreate(kCFAllocatorDefault);
+ auto session = DASessionCreate(kCFAllocatorDefault);
if (!session) {
return false;
}
- DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, session, _device.c_str());
+ auto disk = DADiskCreateFromBSDName(kCFAllocatorDefault, session, _device.c_str());
if (!disk) {
return false;
}
/*
- 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.
*/
+
/* Based on code from https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption */
+
#include "crypto.h"
#include "exceptions.h"
#include <openssl/conf.h>
#include <openssl/rand.h>
#include <boost/scoped_array.hpp>
+
using std::string;
using namespace dcpomatic;
+
/** The cipher that this code uses */
#define CIPHER EVP_aes_256_cbc()
+
dcp::ArrayData
dcpomatic::random_iv ()
{
return iv;
}
+
dcp::ArrayData
dcpomatic::encrypt (string plaintext, dcp::ArrayData key, dcp::ArrayData iv)
{
- EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new ();
+ auto ctx = EVP_CIPHER_CTX_new ();
if (!ctx) {
throw CryptoError ("could not create cipher context");
}
return ciphertext;
}
+
string
dcpomatic::decrypt (dcp::ArrayData ciphertext, dcp::ArrayData key, dcp::ArrayData iv)
{
- EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new ();
+ auto ctx = EVP_CIPHER_CTX_new ();
if (!ctx) {
throw CryptoError ("could not create cipher context");
}
return string ((char *) plaintext.data());
}
+
int
dcpomatic::crypto_key_length ()
{
/*
- 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 <dcp/array_data.h>
+
namespace dcpomatic {
+
dcp::ArrayData random_iv ();
dcp::ArrayData encrypt (std::string plaintext, dcp::ArrayData key, dcp::ArrayData iv);
std::string decrypt (dcp::ArrayData ciphertext, dcp::ArrayData key, dcp::ArrayData iv);
int crypto_key_length ();
+
}
/*
- 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 "curl_uploader.h"
#include "exceptions.h"
#include "config.h"
#include "i18n.h"
+
using std::string;
using std::cout;
using std::function;
+
static size_t
read_callback (void* ptr, size_t size, size_t nmemb, void* object)
{
return u->read_callback (ptr, size, nmemb);
}
+
CurlUploader::CurlUploader (function<void (string)> set_status, function<void (float)> set_progress)
: Uploader (set_status, set_progress)
- , _file (0)
- , _transferred (0)
- , _total_size (0)
{
_curl = curl_easy_init ();
if (!_curl) {
curl_easy_setopt (_curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt (_curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
curl_easy_setopt (_curl, CURLOPT_READDATA, this);
- curl_easy_setopt (_curl, CURLOPT_USERNAME, Config::instance()->tms_user().c_str ());
- curl_easy_setopt (_curl, CURLOPT_PASSWORD, Config::instance()->tms_password().c_str ());
+ curl_easy_setopt (_curl, CURLOPT_USERNAME, Config::instance()->tms_user().c_str());
+ curl_easy_setopt (_curl, CURLOPT_PASSWORD, Config::instance()->tms_password().c_str());
}
+
CurlUploader::~CurlUploader ()
{
if (_file) {
curl_easy_cleanup (_curl);
}
+
void
CurlUploader::create_directory (boost::filesystem::path)
{
/* this is done by libcurl */
}
+
void
CurlUploader::upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size)
{
_transferred = &transferred;
_total_size = total_size;
- CURLcode const r = curl_easy_perform (_curl);
+ auto const r = curl_easy_perform (_curl);
if (r != CURLE_OK) {
throw NetworkError (String::compose (_("Could not write to remote file (%1)"), curl_easy_strerror (r)));
}
_file = 0;
}
+
size_t
CurlUploader::read_callback (void* ptr, size_t size, size_t nmemb)
{
/*
- 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 "uploader.h"
#include <curl/curl.h>
+
class CurlUploader : public Uploader
{
public:
private:
CURL* _curl;
- FILE* _file;
- boost::uintmax_t* _transferred;
- boost::uintmax_t _total_size;
+ FILE* _file = nullptr;
+ boost::uintmax_t* _transferred = nullptr;
+ boost::uintmax_t _total_size = 0;
};
/*
- 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 "datasat_ap2x.h"
#include "i18n.h"
+
DatasatAP2x::DatasatAP2x ()
: CinemaSoundProcessor ("dataset_ap2x", _("Datasat AP20 or AP25"), 3.2f, 20, 5)
{
/*
- 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/datasat_ap2x.h
* @brief DatasatAP2x class.
*/
+
#include "cinema_sound_processor.h"
+
class DatasatAP2x : public CinemaSoundProcessor
{
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 "i18n.h"
+
+using boost::optional;
using namespace std;
+
vector<DCPContentType const *> DCPContentType::_dcp_content_types;
+
DCPContentType::DCPContentType (string p, dcp::ContentKind k, string d)
: _pretty_name (p)
, _libdcp_kind (k)
}
+
void
DCPContentType::setup_dcp_content_types ()
{
- _dcp_content_types.push_back (new DCPContentType(_("Feature"), dcp::ContentKind::FEATURE, N_("FTR")));
- _dcp_content_types.push_back (new DCPContentType(_("Short"), dcp::ContentKind::SHORT, N_("SHR")));
- _dcp_content_types.push_back (new DCPContentType(_("Trailer"), dcp::ContentKind::TRAILER, N_("TLR")));
- _dcp_content_types.push_back (new DCPContentType(_("Test"), dcp::ContentKind::TEST, N_("TST")));
- _dcp_content_types.push_back (new DCPContentType(_("Transitional"), dcp::ContentKind::TRANSITIONAL, N_("XSN")));
- _dcp_content_types.push_back (new DCPContentType(_("Rating"), dcp::ContentKind::RATING, N_("RTG")));
- _dcp_content_types.push_back (new DCPContentType(_("Teaser"), dcp::ContentKind::TEASER, N_("TSR")));
- _dcp_content_types.push_back (new DCPContentType(_("Policy"), dcp::ContentKind::POLICY, N_("POL")));
- _dcp_content_types.push_back (new DCPContentType(_("Public Service Announcement"), dcp::ContentKind::PUBLIC_SERVICE_ANNOUNCEMENT, N_("PSA")));
- _dcp_content_types.push_back (new DCPContentType(_("Advertisement"), dcp::ContentKind::ADVERTISEMENT, N_("ADV")));
- _dcp_content_types.push_back (new DCPContentType(_("Episode"), dcp::ContentKind::EPISODE, N_("EPS")));
- _dcp_content_types.push_back (new DCPContentType(_("Promo"), dcp::ContentKind::PROMO, N_("PRO")));
+ _dcp_content_types = {
+ new DCPContentType(_("Feature"), dcp::ContentKind::FEATURE, N_("FTR")),
+ new DCPContentType(_("Short"), dcp::ContentKind::SHORT, N_("SHR")),
+ new DCPContentType(_("Trailer"), dcp::ContentKind::TRAILER, N_("TLR")),
+ new DCPContentType(_("Test"), dcp::ContentKind::TEST, N_("TST")),
+ new DCPContentType(_("Transitional"), dcp::ContentKind::TRANSITIONAL, N_("XSN")),
+ new DCPContentType(_("Rating"), dcp::ContentKind::RATING, N_("RTG")),
+ new DCPContentType(_("Teaser"), dcp::ContentKind::TEASER, N_("TSR")),
+ new DCPContentType(_("Policy"), dcp::ContentKind::POLICY, N_("POL")),
+ new DCPContentType(_("Public Service Announcement"), dcp::ContentKind::PUBLIC_SERVICE_ANNOUNCEMENT, N_("PSA")),
+ new DCPContentType(_("Advertisement"), dcp::ContentKind::ADVERTISEMENT, N_("ADV")),
+ new DCPContentType(_("Episode"), dcp::ContentKind::EPISODE, N_("EPS")),
+ new DCPContentType(_("Promo"), dcp::ContentKind::PROMO, N_("PRO"))
+ };
}
+
DCPContentType const *
DCPContentType::from_isdcf_name (string n)
{
return 0;
}
+
DCPContentType const *
DCPContentType::from_libdcp_kind (dcp::ContentKind kind)
{
}
DCPOMATIC_ASSERT (false);
- return 0;
+ return nullptr;
}
DCPContentType const *
DCPContentType::from_index (int n)
{
- DCPOMATIC_ASSERT (n >= 0 && n < int (_dcp_content_types.size ()));
+ DCPOMATIC_ASSERT (n >= 0 && n < int(_dcp_content_types.size()));
return _dcp_content_types[n];
}
-int
+
+optional<int>
DCPContentType::as_index (DCPContentType const * c)
{
vector<DCPContentType*>::size_type i = 0;
++i;
}
- if (i == _dcp_content_types.size ()) {
- return -1;
+ if (i == _dcp_content_types.size()) {
+ return {};
}
return i;
}
+
vector<DCPContentType const *>
DCPContentType::all ()
{
/*
- 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.
static DCPContentType const * from_isdcf_name (std::string);
static DCPContentType const * from_libdcp_kind (dcp::ContentKind);
static DCPContentType const * from_index (int);
- static int as_index (DCPContentType const *);
+ static boost::optional<int> as_index (DCPContentType const *);
static std::vector<DCPContentType const *> all ();
static void setup_dcp_content_types ();
/*
- 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 "dkdm_recipient.h"
#include "kdm_with_metadata.h"
#include "film.h"
#include <dcp/raw_convert.h>
+using std::make_shared;
+using std::shared_ptr;
using std::string;
using std::vector;
-using std::shared_ptr;
using dcp::raw_convert;
dcp::LocalTime const begin(valid_from, recipient->utc_offset_hour, recipient->utc_offset_minute);
dcp::LocalTime const end (valid_to, recipient->utc_offset_hour, recipient->utc_offset_minute);
- dcp::EncryptedKDM const kdm = film->make_kdm (
+ auto const kdm = film->make_kdm (
recipient->recipient.get(),
vector<string>(),
cpl,
name_values['e'] = end.date() + " " + end.time_of_day(true, false);
name_values['i'] = kdm.cpl_id();
- return KDMWithMetadataPtr(new KDMWithMetadata(name_values, 0, recipient->emails, kdm));
+ return make_shared<KDMWithMetadata>(name_values, nullptr, recipient->emails, kdm);
}
/*
- 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"
#include "kdm_with_metadata.h"
+
class Film;
+
class DKDMRecipient : public KDMRecipient
{
public:
/*
- Copyright (C) 2015-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "compose.hpp"
#include "config.h"
#include "emailer.h"
#include "i18n.h"
-using std::string;
-using std::min;
-using std::list;
+
using std::cout;
+using std::list;
+using std::min;
using std::pair;
using std::shared_ptr;
+using std::string;
using dcp::ArrayData;
+
Emailer::Emailer (string from, list<string> to, string subject, string body)
: _from (from)
, _to (to)
}
+
string
Emailer::fix (string s) const
{
return s;
}
+
void
Emailer::add_cc (string cc)
{
_cc.push_back (cc);
}
+
void
Emailer::add_bcc (string bcc)
{
_bcc.push_back (bcc);
}
+
void
Emailer::add_attachment (boost::filesystem::path file, string name, string mime_type)
{
_attachments.push_back (a);
}
+
static size_t
curl_data_shim (void* ptr, size_t size, size_t nmemb, void* userp)
{
return reinterpret_cast<Emailer*>(userp)->get_data (ptr, size, nmemb);
}
+
static int
curl_debug_shim (CURL* curl, curl_infotype type, char* data, size_t size, void* userp)
{
return reinterpret_cast<Emailer*>(userp)->debug (curl, type, data, size);
}
+
size_t
Emailer::get_data (void* ptr, size_t size, size_t nmemb)
{
return t;
}
+
void
Emailer::send (string server, int port, EmailProtocol protocol, string user, string password)
{
char date_buffer[128];
time_t now = time (0);
- strftime (date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime (&now));
+ strftime (date_buffer, sizeof(date_buffer), "%a, %d %b %Y %H:%M:%S ", localtime(&now));
- boost::posix_time::ptime const utc_now = boost::posix_time::second_clock::universal_time ();
- boost::posix_time::ptime const local_now = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local (utc_now);
- boost::posix_time::time_duration offset = local_now - utc_now;
+ auto const utc_now = boost::posix_time::second_clock::universal_time ();
+ auto const local_now = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local (utc_now);
+ auto offset = local_now - utc_now;
sprintf (date_buffer + strlen(date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), int(abs(offset.hours())), int(offset.minutes()));
_email = "Date: " + string(date_buffer) + "\r\n"
"To: " + address_list (_to) + "\r\n"
"From: " + _from + "\r\n";
- if (!_cc.empty ()) {
- _email += "Cc: " + address_list (_cc) + "\r\n";
+ if (!_cc.empty()) {
+ _email += "Cc: " + address_list(_cc) + "\r\n";
}
- if (!_bcc.empty ()) {
- _email += "Bcc: " + address_list (_bcc) + "\r\n";
+ if (!_bcc.empty()) {
+ _email += "Bcc: " + address_list(_bcc) + "\r\n";
}
string const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
"Content-Transfer-Encoding: Base64\r\n"
"Content-Disposition: attachment; filename=" + i.name + "\r\n\r\n";
- BIO* b64 = BIO_new (BIO_f_base64());
+ auto b64 = BIO_new (BIO_f_base64());
- BIO* bio = BIO_new (BIO_s_mem());
+ auto bio = BIO_new (BIO_s_mem());
bio = BIO_push (b64, bio);
ArrayData data (i.file);
curl_global_init (CURL_GLOBAL_DEFAULT);
- CURL* curl = curl_easy_init ();
+ auto curl = curl_easy_init ();
if (!curl) {
throw NetworkError ("Could not initialise libcurl");
}
curl_easy_setopt (curl, CURLOPT_MAIL_FROM, _from.c_str());
- struct curl_slist* recipients = 0;
+ struct curl_slist* recipients = nullptr;
for (auto i: _to) {
recipients = curl_slist_append (recipients, i.c_str());
}
curl_easy_setopt (curl, CURLOPT_DEBUGFUNCTION, curl_debug_shim);
curl_easy_setopt (curl, CURLOPT_DEBUGDATA, this);
- CURLcode const r = curl_easy_perform (curl);
+ auto const r = curl_easy_perform (curl);
if (r != CURLE_OK) {
throw KDMError (_("Failed to send email"), curl_easy_strerror (r));
}
curl_global_cleanup ();
}
+
string
Emailer::address_list (list<string> addresses)
{
return o.substr (0, o.length() - 2);
}
+
int
Emailer::debug (CURL *, curl_infotype type, char* data, size_t size)
{
/*
- Copyright (C) 2015-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include <curl/curl.h>
#include <boost/scoped_array.hpp>
+
class Emailer
{
public:
/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "encode_server_finder.h"
#include "exceptions.h"
#include "util.h"
#include "i18n.h"
-using std::string;
-using std::list;
-using std::vector;
+
using std::cout;
+using std::list;
+using std::make_shared;
using std::shared_ptr;
-using boost::scoped_array;
+using std::string;
+using std::vector;
using std::weak_ptr;
using boost::optional;
+using boost::scoped_array;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
using dcp::raw_convert;
+
EncodeServerFinder* EncodeServerFinder::_instance = 0;
+
EncodeServerFinder::EncodeServerFinder ()
: _stop (false)
{
Config::instance()->Changed.connect (boost::bind (&EncodeServerFinder::config_changed, this, _1));
}
+
void
EncodeServerFinder::start ()
{
stop ();
}
+
void
EncodeServerFinder::stop ()
{
_servers.clear ();
}
+
void
EncodeServerFinder::search_thread ()
try
throw NetworkError ("failed to set up broadcast socket");
}
- socket.set_option (boost::asio::ip::udp::socket::reuse_address (true));
- socket.set_option (boost::asio::socket_base::broadcast (true));
+ socket.set_option (boost::asio::ip::udp::socket::reuse_address(true));
+ socket.set_option (boost::asio::socket_base::broadcast(true));
string const data = DCPOMATIC_HELLO;
int const interval = 10;
while (!_stop) {
- if (Config::instance()->use_any_servers ()) {
+ if (Config::instance()->use_any_servers()) {
/* Broadcast to look for servers */
try {
boost::asio::ip::udp::endpoint end_point (boost::asio::ip::address_v4::broadcast(), HELLO_PORT);
- socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point);
+ socket.send_to (boost::asio::buffer(data.c_str(), data.size() + 1), end_point);
} catch (...) {
}
for (auto const& i: Config::instance()->servers()) {
try {
boost::asio::ip::udp::resolver resolver (io_service);
- boost::asio::ip::udp::resolver::query query (i, raw_convert<string> (HELLO_PORT));
- boost::asio::ip::udp::endpoint end_point (*resolver.resolve (query));
- socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point);
+ boost::asio::ip::udp::resolver::query query (i, raw_convert<string>(HELLO_PORT));
+ boost::asio::ip::udp::endpoint end_point (*resolver.resolve(query));
+ socket.send_to (boost::asio::buffer(data.c_str(), data.size() + 1), end_point);
} catch (...) {
}
{
boost::mutex::scoped_lock lm (_servers_mutex);
- list<EncodeServerDescription>::iterator i = _servers.begin();
+ auto i = _servers.begin();
while (i != _servers.end()) {
if (i->last_seen_seconds() > 2 * interval) {
- list<EncodeServerDescription>::iterator j = i;
+ auto j = i;
++j;
_servers.erase (i);
i = j;
}
if (removed) {
- emit (boost::bind (boost::ref (ServersListChanged)));
+ emit (boost::bind(boost::ref(ServersListChanged)));
}
boost::mutex::scoped_lock lm (_search_condition_mutex);
- _search_condition.timed_wait (lm, boost::get_system_time() + boost::posix_time::seconds (interval));
+ _search_condition.timed_wait (lm, boost::get_system_time() + boost::posix_time::seconds(interval));
}
}
catch (...)
store_current ();
}
+
void
EncodeServerFinder::listen_thread ()
try {
try {
_listen_acceptor.reset (
- new tcp::acceptor (_listen_io_service, tcp::endpoint (tcp::v4(), is_batch_converter ? BATCH_SERVER_PRESENCE_PORT : MAIN_SERVER_PRESENCE_PORT))
+ new tcp::acceptor (_listen_io_service, tcp::endpoint(tcp::v4(), is_batch_converter ? BATCH_SERVER_PRESENCE_PORT : MAIN_SERVER_PRESENCE_PORT))
);
} catch (...) {
boost::throw_exception (NetworkError (_("Could not listen for remote encode servers. Perhaps another instance of DCP-o-matic is running.")));
store_current ();
}
+
void
EncodeServerFinder::start_accept ()
{
- shared_ptr<Socket> socket (new Socket ());
+ auto socket = make_shared<Socket>();
_listen_acceptor->async_accept (
socket->socket(),
- boost::bind (&EncodeServerFinder::handle_accept, this, boost::asio::placeholders::error, socket)
+ boost::bind(&EncodeServerFinder::handle_accept, this, boost::asio::placeholders::error, socket)
);
}
+
void
EncodeServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> socket)
{
}
uint32_t length;
- socket->read (reinterpret_cast<uint8_t*> (&length), sizeof (uint32_t));
+ socket->read (reinterpret_cast<uint8_t*>(&length), sizeof(uint32_t));
length = ntohl (length);
- scoped_array<char> buffer (new char[length]);
- socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
+ scoped_array<char> buffer(new char[length]);
+ socket->read (reinterpret_cast<uint8_t*>(buffer.get()), length);
string s (buffer.get());
- shared_ptr<cxml::Document> xml (new cxml::Document ("ServerAvailable"));
+ auto xml = make_shared<cxml::Document>("ServerAvailable");
xml->read_string (s);
- string const ip = socket->socket().remote_endpoint().address().to_string ();
- optional<list<EncodeServerDescription>::iterator> found = server_found (ip);
+ auto const ip = socket->socket().remote_endpoint().address().to_string();
+ auto found = server_found (ip);
if (found) {
(*found)->set_seen ();
} else {
boost::mutex::scoped_lock lm (_servers_mutex);
_servers.push_back (sd);
}
- emit (boost::bind (boost::ref (ServersListChanged)));
+ emit (boost::bind(boost::ref (ServersListChanged)));
}
start_accept ();
}
+
optional<list<EncodeServerDescription>::iterator>
EncodeServerFinder::server_found (string ip)
{
boost::mutex::scoped_lock lm (_servers_mutex);
- list<EncodeServerDescription>::iterator i = _servers.begin();
+ auto i = _servers.begin();
while (i != _servers.end() && i->host_name() != ip) {
++i;
}
return i;
}
- return optional<list<EncodeServerDescription>::iterator>();
+ return {};
}
+
EncodeServerFinder*
EncodeServerFinder::instance ()
{
return _instance;
}
+
void
EncodeServerFinder::drop ()
{
delete _instance;
- _instance = 0;
+ _instance = nullptr;
}
+
list<EncodeServerDescription>
EncodeServerFinder::servers () const
{
return _servers;
}
+
void
EncodeServerFinder::config_changed (Config::Property what)
{
/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/lib/encode_server_finder.h
* @brief EncodeServerFinder class.
*/
-#include "signaller.h"
-#include "encode_server_description.h"
+
#include "config.h"
+#include "encode_server_description.h"
#include "exception_store.h"
+#include "signaller.h"
#include <boost/signals2.hpp>
#include <boost/thread/condition.hpp>
+
class Socket;
+
/** @class EncodeServerFinder
* @brief Locater of encoding servers.
*
/*
- 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 "encoded_log_entry.h"
#include <cstdio>
+
using std::string;
+
EncodedLogEntry::EncodedLogEntry (int frame, string ip, double receive, double encode, double send)
: LogEntry (LogEntry::TYPE_GENERAL)
, _frame (frame)
}
+
string
EncodedLogEntry::message () const
{
/*
- 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 "log_entry.h"
+
class EncodedLogEntry : public LogEntry
{
public:
/*
- Copyright (C) 2017-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "event_history.h"
#include "util.h"
#include <boost/thread/mutex.hpp>
+
using boost::optional;
+
EventHistory::EventHistory (int size)
: _size (size)
{
}
+
optional<float>
EventHistory::rate () const
{
boost::mutex::scoped_lock lock (_mutex);
- if (int (_history.size()) < _size) {
- return optional<float>();
+ if (int(_history.size()) < _size) {
+ return {};
}
struct timeval now;
return _size / (seconds (now) - seconds (_history.back ()));
}
+
void
EventHistory::event ()
{
struct timeval tv;
gettimeofday (&tv, 0);
_history.push_front (tv);
- if (int (_history.size()) > _size) {
+ if (int(_history.size()) > _size) {
_history.pop_back ();
}
}
/*
- Copyright (C) 2017-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_EVENT_HISTORY_H
#define DCPOMATIC_EVENT_HISTORY_H
+
#include <boost/thread/mutex.hpp>
#include <boost/optional.hpp>
#include <list>
+
class EventHistory
{
public:
int const _size;
};
+
#endif
/*
- 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 "exceptions.h"
#include "compose.hpp"
#include "i18n.h"
+
using std::string;
using std::runtime_error;
using boost::optional;
+
/** @param f File that we were trying to open */
OpenFileError::OpenFileError (boost::filesystem::path f, int error, Mode mode)
: FileError (
}
+
FileNotFoundError::FileNotFoundError (boost::filesystem::path f)
: runtime_error(String::compose("File %1 not found", f.string()))
, _file (f)
}
+
ReadFileError::ReadFileError (boost::filesystem::path f, int e)
- : FileError (String::compose (_("could not read from file %1 (%2)"), f.string(), strerror (e)), f)
+ : FileError (String::compose(_("could not read from file %1 (%2)"), f.string(), strerror(e)), f)
{
}
+
WriteFileError::WriteFileError (boost::filesystem::path f, int e)
- : FileError (String::compose (_("could not write to file %1 (%2)"), f.string(), strerror (e)), f)
+ : FileError (String::compose(_("could not write to file %1 (%2)"), f.string(), strerror(e)), f)
{
}
+
MissingSettingError::MissingSettingError (string s)
- : SettingError (s, String::compose (_("Missing required setting %1"), s))
+ : SettingError (s, String::compose(_("Missing required setting %1"), s))
{
}
+
PixelFormatError::PixelFormatError (string o, AVPixelFormat f)
- : runtime_error (String::compose (_("Cannot handle pixel format %1 during %2"), (int) f, o))
+ : runtime_error (String::compose(_("Cannot handle pixel format %1 during %2"), (int) f, o))
{
}
+
TextSubtitleError::TextSubtitleError (string saw, string expecting, boost::filesystem::path f)
- : FileError (String::compose (_("Error in subtitle file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f)
+ : FileError (String::compose(_("Error in subtitle file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f)
{
}
+
InvalidSignerError::InvalidSignerError ()
: runtime_error (_("The certificate chain for signing is invalid"))
{
}
+
InvalidSignerError::InvalidSignerError (string reason)
- : runtime_error (String::compose (_("The certificate chain for signing is invalid (%1)"), reason))
+ : runtime_error (String::compose(_("The certificate chain for signing is invalid (%1)"), reason))
{
}
+
ProgrammingError::ProgrammingError (string file, int line, string message)
- : runtime_error (String::compose (_("Programming error at %1:%2 %3"), file, line, message))
+ : runtime_error (String::compose(_("Programming error at %1:%2 %3"), file, line, message))
{
}
+
KDMAsContentError::KDMAsContentError ()
: runtime_error (_("This file is a KDM. KDMs should be added to DCP content by right-clicking the content and choosing \"Add KDM\"."))
{
}
+
KDMError::KDMError (string s, string d)
- : runtime_error (String::compose ("%1 (%2)", s, d))
+ : runtime_error (String::compose("%1 (%2)", s, d))
, _summary (s)
, _detail (d)
{
}
+
GLError::GLError (char const * last, int e)
: runtime_error (String::compose("%1 failed %2", last, e))
{
}
+
CopyError::CopyError (string m, optional<int> n)
: runtime_error (String::compose("%1%2", m, n ? String::compose(" (%1)", *n) : ""))
, _message (m)
}
+
CommunicationFailedError::CommunicationFailedError ()
: CopyError (_("Lost communication between main and writer processes"))
{
}
+
VerifyError::VerifyError (string m, int n)
: runtime_error (String::compose("%1 (%2)", m, n))
, _message (m)
/*
- 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/lib/exceptions.h
* @brief Our exceptions.
*/
+
#ifndef DCPOMATIC_EXCEPTIONS_H
#define DCPOMATIC_EXCEPTIONS_H
+
#include "compose.hpp"
extern "C" {
#include <libavutil/pixfmt.h>
}
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
-#include <stdexcept>
#include <cstring>
+#include <stdexcept>
+
/** @class DecodeError
* @brief A low-level problem with the decoder (possibly due to the nature
: std::runtime_error (s)
{}
- explicit DecodeError (std::string function, std::string caller)
+ DecodeError (std::string function, std::string caller)
: std::runtime_error (String::compose("%1 failed [%2", function, caller))
{}
- explicit DecodeError (std::string function, std::string caller, int error)
+ DecodeError (std::string function, std::string caller, int error)
: std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, error))
{}
};
+
class CryptoError : public std::runtime_error
{
public:
boost::filesystem::path _file;
};
+
class JoinError : public std::runtime_error
{
public:
{}
};
+
/** @class OpenFileError.
* @brief Indicates that some error occurred when trying to open a file.
*/
OpenFileError (boost::filesystem::path f, int error, Mode mode);
};
+
class FileNotFoundError : public std::runtime_error
{
public:
boost::filesystem::path _file;
};
+
/** @class ReadFileError.
* @brief Indicates that some error occurred when trying to read from a file
*/
ReadFileError (boost::filesystem::path f, int e = 0);
};
+
/** @class WriteFileError.
* @brief Indicates that some error occurred when trying to write to a file
*/
WriteFileError (boost::filesystem::path f, int e);
};
+
/** @class SettingError.
* @brief Indicates that something is wrong with a setting.
*/
std::string _setting;
};
+
/** @class MissingSettingError.
* @brief Indicates that a Film is missing a setting that is required for some operation.
*/
explicit MissingSettingError (std::string s);
};
+
/** @class BadSettingError
* @brief Indicates that a setting is bad in some way.
*/
{}
};
+
/** @class NetworkError
* @brief Indicates some problem with communication on the network.
*/
{}
};
+
/** @class KDMError
* @brief A problem with a KDM.
*/
std::string _detail;
};
+
/** @class PixelFormatError
* @brief A problem with an unsupported pixel format.
*/
PixelFormatError (std::string o, AVPixelFormat f);
};
+
/** @class TextSubtitleError
* @brief An error that occurs while parsing a TextSubtitleError file.
*/
TextSubtitleError (std::string, std::string, boost::filesystem::path);
};
+
class DCPError : public std::runtime_error
{
public:
};
class ProgrammingError : public std::runtime_error
+
{
public:
ProgrammingError (std::string file, int line, std::string message = "");
};
+
class TextEncodingError : public std::runtime_error
{
public:
{}
};
+
class MetadataError : public std::runtime_error
{
public:
{}
};
+
class OldFormatError : public std::runtime_error
{
public:
{}
};
+
class KDMAsContentError : public std::runtime_error
{
public:
KDMAsContentError ();
};
+
class GLError : public std::runtime_error
{
public:
GLError (char const * last, int e);
};
+
/** @class CopyError
* @brief An error which occurs when copying a DCP to a distribution drive.
*/
{}
};
+
#endif
/*
- 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 "file_log.h"
#include "cross.h"
#include "config.h"
#include <iostream>
#include <cerrno>
+
using std::cout;
using std::string;
using std::max;
using std::shared_ptr;
+
/** @param file Filename to write log to */
FileLog::FileLog (boost::filesystem::path file)
: _file (file)
set_types (Config::instance()->log_types());
}
+
FileLog::FileLog (boost::filesystem::path file, int types)
: _file (file)
{
set_types (types);
}
+
void
FileLog::do_log (shared_ptr<const LogEntry> entry)
{
- FILE* f = fopen_boost (_file, "a");
+ auto f = fopen_boost (_file, "a");
if (!f) {
cout << "(could not log to " << _file.string() << " error " << errno << "): " << entry->get() << "\n";
return;
}
- fprintf (f, "%s\n", entry->get().c_str ());
+ fprintf (f, "%s\n", entry->get().c_str());
fclose (f);
}
+
string
FileLog::head_and_tail (int amount) const
{
tail_amount = 0;
}
- FILE* f = fopen_boost (_file, "r");
+ auto f = fopen_boost (_file, "r");
if (!f) {
return "";
}
string out;
- char* buffer = new char[max(head_amount, tail_amount) + 1];
+ auto buffer = new char[max(head_amount, tail_amount) + 1];
int N = fread (buffer, 1, head_amount, f);
buffer[N] = '\0';
/*
- 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 "log.h"
+
class FileLog : public Log
{
public:
/*
- 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/filter.cc
* @brief A class to describe one of FFmpeg's video or audio filters.
*/
+
#include "filter.h"
extern "C" {
#include <libavfilter/avfilter.h>
#include "i18n.h"
+
using namespace std;
+
vector<Filter const *> Filter::_filters;
+
/** @param i Our id.
* @param n User-visible name.
* @param c User-visible category.
}
+
/** @return All available filters */
vector<Filter const *>
Filter::all ()
return _filters;
}
+
/** Set up the static _filters vector; must be called before from_*
* methods are used.
*/
maybe_add (N_("ow"), _("Overcomplete wavelet denoiser"), _("Noise reduction"), N_("mp=ow"));
}
+
void
Filter::maybe_add (string i, string n, string c, string f)
{
check_name = check_name.substr (0, end);
}
- if (avfilter_get_by_name (check_name.c_str())) {
- _filters.push_back (new Filter (i, n, c, f));
+ if (avfilter_get_by_name(check_name.c_str())) {
+ _filters.push_back (new Filter(i, n, c, f));
}
}
+
/** @param filters Set of filters.
* @return String to pass to FFmpeg for the video filters.
*/
return ff;
}
+
/** @param d Our id.
* @return Corresponding Filter, or 0.
*/
Filter const *
Filter::from_id (string d)
{
- vector<Filter const *>::iterator i = _filters.begin ();
+ auto i = _filters.begin ();
while (i != _filters.end() && (*i)->id() != d) {
++i;
}
if (i == _filters.end ()) {
- return 0;
+ return nullptr;
}
return *i;
/*
- 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.
/*
- 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) 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) 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 "frame_rate_change.h"
#include "types.h"
#include "content.h"
#include "i18n.h"
+
using std::string;
using std::shared_ptr;
-static bool
-about_equal (double a, double b)
-{
- return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON);
-}
FrameRateChange::FrameRateChange ()
- : source (24)
- , dcp (24)
- , skip (false)
- , repeat (1)
- , change_speed (false)
- , speed_up (1)
{
}
-FrameRateChange::FrameRateChange (double source_, int dcp_)
- : skip (false)
- , repeat (1)
- , change_speed (false)
-{
- construct (source_, dcp_);
-}
-void
-FrameRateChange::construct (double source_, int dcp_)
+FrameRateChange::FrameRateChange (double source_, int dcp_)
{
source = source_;
dcp = dcp_;
- if (fabs (source / 2.0 - dcp) < fabs (source - dcp)) {
+ if (fabs(source / 2.0 - dcp) < fabs(source - dcp)) {
/* The difference between source and DCP frame rate will be lower
(i.e. better) if we skip.
*/
skip = true;
- } else if (fabs (source * 2 - dcp) < fabs (source - dcp)) {
+ } else if (fabs(source * 2 - dcp) < fabs(source - dcp)) {
/* The difference between source and DCP frame rate would be better
if we repeated each frame once; it may be better still if we
repeated more than once. Work out the required repeat.
}
speed_up = dcp / (source * factor());
+
+ auto about_equal = [](double a, double b) {
+ return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON);
+ };
+
change_speed = !about_equal (speed_up, 1.0);
}
+
FrameRateChange::FrameRateChange (shared_ptr<const Film> film, shared_ptr<const Content> content)
- : skip (false)
- , repeat (1)
+ : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate())
{
- construct (content->active_video_frame_rate(film), film->video_frame_rate());
+
}
+
FrameRateChange::FrameRateChange (shared_ptr<const Film> film, Content const * content)
- : skip (false)
- , repeat (1)
+ : FrameRateChange (content->active_video_frame_rate(film), film->video_frame_rate())
{
- construct (content->active_video_frame_rate(film), film->video_frame_rate());
+
}
+
string
FrameRateChange::description () const
{
/*
- 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.
*/
+
#ifndef DCPOMATIC_FRAME_RATE_CHANGE_H
#define DCPOMATIC_FRAME_RATE_CHANGE_H
class Film;
class Content;
+
class FrameRateChange
{
public:
return repeat;
}
- double source;
- int dcp;
+ double source = 24;
+ int dcp = 24;
/** true to skip every other frame */
- bool skip;
+ bool skip = false;
/** number of times to use each frame (e.g. 1 is normal, 2 means repeat each frame once, and so on) */
- int repeat;
+ int repeat = 1;
/** true if this DCP will run its video faster or slower than the source
* without taking into account `repeat' nor `skip'.
* (e.g. change_speed will be true if
* source is 15.00fps, DCP is 30fps
* source is 12.50fps, DCP is 25fps)
*/
- bool change_speed;
+ bool change_speed = false;
/** Amount by which the video is being sped-up in the DCP; e.g. for a
* 24fps source in a 25fps DCP this would be 25/24.
*/
- double speed_up;
+ double speed_up = 1.0;
std::string description () const;
-
-private:
- void construct (double source_, int dcp_);
};
+
#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 "log_entry.h"
#include <inttypes.h>
#include <cstdio>
#include "i18n.h"
+
int const LogEntry::TYPE_GENERAL = 0x001;
int const LogEntry::TYPE_WARNING = 0x002;
int const LogEntry::TYPE_ERROR = 0x004;
int const LogEntry::TYPE_DEBUG_PLAYER = 0x200;
int const LogEntry::TYPE_DEBUG_AUDIO_ANALYSIS = 0x400;
+
using std::string;
+
LogEntry::LogEntry (int type)
: _type (type)
{
gettimeofday (&_time, 0);
}
+
string
LogEntry::get () const
{
string s;
if (_type & TYPE_TIMING) {
char buffer[64];
- snprintf (buffer, sizeof(buffer), "%" PRId64 ":%" PRId64 " ", static_cast<int64_t> (_time.tv_sec), static_cast<int64_t> (_time.tv_usec));
+ snprintf (buffer, sizeof(buffer), "%" PRId64 ":%" PRId64 " ", static_cast<int64_t>(_time.tv_sec), static_cast<int64_t>(_time.tv_usec));
s += buffer;
} else {
char buffer[64];
return s;
}
+
double
LogEntry::seconds () const
{
/*
- Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_LOG_ENTRY_H
#define DCPOMATIC_LOG_ENTRY_H
+
#include <sys/time.h>
#include <string>
+
class LogEntry
{
public:
int _type;
};
+
#endif
/*
- 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 "mid_side_decoder.h"
#include "audio_buffers.h"
#include "audio_mapping.h"
#include "i18n.h"
-using std::string;
+
+using std::make_shared;
using std::min;
-using std::vector;
using std::shared_ptr;
+using std::string;
+using std::vector;
+
string
MidSideDecoder::name () const
return _("Mid-side decoder");
}
+
string
MidSideDecoder::id () const
{
return N_("mid-side-decoder");
}
+
int
MidSideDecoder::out_channels () const
{
return 3;
}
+
shared_ptr<AudioProcessor>
MidSideDecoder::clone (int) const
{
- return shared_ptr<AudioProcessor> (new MidSideDecoder ());
+ return make_shared<MidSideDecoder>();
}
+
shared_ptr<AudioBuffers>
MidSideDecoder::run (shared_ptr<const AudioBuffers> in, int channels)
{
int const N = min (channels, 3);
- shared_ptr<AudioBuffers> out (new AudioBuffers (channels, in->frames ()));
+ auto out = make_shared<AudioBuffers>(channels, in->frames ());
for (int i = 0; i < in->frames(); ++i) {
- float const left = in->data()[0][i];
- float const right = in->data()[1][i];
- float const mid = (left + right) / 2;
+ auto const left = in->data()[0][i];
+ auto const right = in->data()[1][i];
+ auto const mid = (left + right) / 2;
if (N > 0) {
out->data()[0][i] = left - mid;
}
return out;
}
+
void
MidSideDecoder::make_audio_mapping_default (AudioMapping& mapping) const
{
/* Just map the first two input channels to our M/S */
mapping.make_zero ();
- for (int i = 0; i < min (2, mapping.input_channels()); ++i) {
+ for (int i = 0; i < min(2, mapping.input_channels()); ++i) {
mapping.set (i, i, 1);
}
}
+
vector<NamedChannel>
MidSideDecoder::input_names () const
{
- vector<NamedChannel> n;
- n.push_back (NamedChannel(_("Left"), 0));
- n.push_back (NamedChannel(_("Right"), 1));
- return n;
+ return {
+ NamedChannel(_("Left"), 0),
+ NamedChannel(_("Right"), 1)
+ };
}
/*
- 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 "audio_processor.h"
+
class MidSideDecoder : public AudioProcessor
{
public:
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "overlaps.h"
#include "types.h"
#include "content.h"
-using std::shared_ptr;
+
using std::function;
+using std::shared_ptr;
using namespace dcpomatic;
+
ContentList overlaps (shared_ptr<const Film> film, ContentList cl, function<bool (shared_ptr<const Content>)> part, DCPTime from, DCPTime to)
{
ContentList overlaps;
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "types.h"
#include "dcpomatic_time.h"
+
class ContentPart;
class Film;
+
/** @return Pieces of content with a given part (video, audio,
* subtitle) that overlap a specified time range in the given
* ContentList
/*
- Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "raw_image_proxy.h"
#include "image.h"
#include "warnings.h"
#include "i18n.h"
-using std::string;
-using std::pair;
+
+using std::dynamic_pointer_cast;
using std::make_pair;
+using std::make_shared;
+using std::pair;
using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::string;
using boost::optional;
using dcp::raw_convert;
+
RawImageProxy::RawImageProxy (shared_ptr<Image> image)
: _image (image)
{
}
+
RawImageProxy::RawImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket)
{
dcp::Size size (
- xml->number_child<int> ("Width"), xml->number_child<int> ("Height")
+ xml->number_child<int>("Width"), xml->number_child<int>("Height")
);
- _image.reset (new Image (static_cast<AVPixelFormat> (xml->number_child<int> ("PixelFormat")), size, true));
+ _image = make_shared<Image>(static_cast<AVPixelFormat>(xml->number_child<int>("PixelFormat")), size, true);
_image->read_from_socket (socket);
}
+
ImageProxy::Result
RawImageProxy::image (optional<dcp::Size>) const
{
return Result (_image, 0);
}
+
void
RawImageProxy::add_metadata (xmlpp::Node* node) const
{
- node->add_child("Type")->add_child_text (N_("Raw"));
- node->add_child("Width")->add_child_text (raw_convert<string> (_image->size().width));
- node->add_child("Height")->add_child_text (raw_convert<string> (_image->size().height));
- node->add_child("PixelFormat")->add_child_text (raw_convert<string> (static_cast<int> (_image->pixel_format ())));
+ node->add_child("Type")->add_child_text(N_("Raw"));
+ node->add_child("Width")->add_child_text(raw_convert<string>(_image->size().width));
+ node->add_child("Height")->add_child_text(raw_convert<string>(_image->size().height));
+ node->add_child("PixelFormat")->add_child_text(raw_convert<string>(static_cast<int>(_image->pixel_format())));
}
+
void
RawImageProxy::write_to_socket (shared_ptr<Socket> socket) const
{
_image->write_to_socket (socket);
}
+
bool
RawImageProxy::same (shared_ptr<const ImageProxy> other) const
{
- shared_ptr<const RawImageProxy> rp = dynamic_pointer_cast<const RawImageProxy> (other);
+ auto rp = dynamic_pointer_cast<const RawImageProxy> (other);
if (!rp) {
return false;
}
return (*_image.get()) == (*rp->image().image.get());
}
+
size_t
RawImageProxy::memory_used () const
{
/*
- 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_RAW_IMAGE_PROXY_H
#define DCPOMATIC_RAW_IMAGE_PROXY_H
+
#include "image_proxy.h"
+
class RawImageProxy : public ImageProxy
{
public:
std::shared_ptr<Image> _image;
};
+
#endif
/*
- 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) 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) 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 "scoped_temporary.h"
#include "exceptions.h"
#include "cross.h"
+
/** Construct a ScopedTemporary. A temporary filename is decided but the file is not opened
* until open() is called.
*/
ScopedTemporary::ScopedTemporary ()
- : _open (0)
{
_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path ();
}
+
/** Close and delete the temporary file */
ScopedTemporary::~ScopedTemporary ()
{
boost::filesystem::remove (_file, ec);
}
+
/** @return temporary filename */
char const *
ScopedTemporary::c_str () const
{
- return _file.string().c_str ();
+ return _file.string().c_str();
}
+
/** Open the temporary file.
* @return File's FILE pointer.
*/
return _open;
}
+
/** Close the file */
void
ScopedTemporary::close ()
{
if (_open) {
fclose (_open);
- _open = 0;
+ _open = nullptr;
}
}
/*
- 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.
private:
boost::filesystem::path _file;
- FILE* _open;
+ FILE* _open = nullptr;
};
/*
- Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "screen.h"
#include "kdm_with_metadata.h"
#include "film.h"
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-using std::string;
-using std::vector;
+
using std::list;
+using std::make_shared;
using std::shared_ptr;
+using std::string;
+using std::vector;
using boost::optional;
using namespace dcpomatic;
+
Screen::Screen (cxml::ConstNodePtr node)
: KDMRecipient (node)
{
}
}
+
void
Screen::as_xml (xmlpp::Element* parent) const
{
}
}
+
vector<string>
Screen::trusted_device_thumbprints () const
{
)
{
if (!screen->recipient) {
- return KDMWithMetadataPtr();
+ return {};
}
- shared_ptr<const Cinema> cinema = screen->cinema;
+ auto cinema = screen->cinema;
dcp::LocalTime const begin(valid_from, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0);
dcp::LocalTime const end (valid_to, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0);
- dcp::EncryptedKDM const kdm = film->make_kdm (
+ auto const kdm = film->make_kdm (
screen->recipient.get(),
screen->trusted_device_thumbprints(),
cpl,
name_values['e'] = end.date() + " " + end.time_of_day(true, false);
name_values['i'] = kdm.cpl_id();
- return KDMWithMetadataPtr(new KDMWithMetadata(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm));
+ return make_shared<KDMWithMetadata>(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm);
}
/*
- 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.
*/
+
#ifndef DCPOMATIC_SCREEN_H
#define DCPOMATIC_SCREEN_H
+
#include "kdm_with_metadata.h"
#include "kdm_recipient.h"
#include "trusted_device.h"
#include <boost/optional.hpp>
#include <string>
+
class Cinema;
class Film;
+
namespace dcpomatic {
+
/** @class Screen
* @brief A representation of a Screen for KDM generation.
*
}
+
KDMWithMetadataPtr
kdm_for_screen (
std::shared_ptr<const Film> film,
/*
- 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 "send_notification_email_job.h"
#include "exceptions.h"
#include "config.h"
#include "i18n.h"
+
using std::string;
using std::list;
using std::shared_ptr;
+
/** @param body Email body */
SendNotificationEmailJob::SendNotificationEmailJob (string body)
: Job (shared_ptr<Film>())
}
+
SendNotificationEmailJob::~SendNotificationEmailJob ()
{
stop_thread ();
}
+
string
SendNotificationEmailJob::name () const
{
return _("Email notification");
}
+
string
SendNotificationEmailJob::json_name () const
{
return N_("send_notification_email");
}
+
void
SendNotificationEmailJob::run ()
{
- Config* config = Config::instance ();
+ auto config = Config::instance ();
if (config->mail_server().empty()) {
throw NetworkError (_("No mail server configured in preferences"));
set_progress_unknown ();
list<string> to;
- to.push_back (config->notification_to ());
+ to.push_back (config->notification_to());
Emailer email (config->notification_from(), to, config->notification_subject(), _body);
for (auto i: config->notification_cc()) {
email.add_cc (i);
}
if (!config->notification_bcc().empty()) {
- email.add_bcc (config->notification_bcc ());
+ email.add_bcc (config->notification_bcc());
}
email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
/*
- 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 "job.h"
+
class SendNotificationEmailJob : public Job
{
public:
explicit SendNotificationEmailJob (std::string body);
~SendNotificationEmailJob ();
- std::string name () const;
- std::string json_name () const;
- void run ();
+ std::string name () const override;
+ std::string json_name () const override;
+ void run () override;
private:
std::string _body;
/*
- Copyright (C) 2014-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "send_problem_report_job.h"
#include "compose.hpp"
#include "film.h"
#include "i18n.h"
-using std::string;
+
using std::list;
using std::shared_ptr;
+using std::string;
+
/** @param film Film thta the problem is with, or 0.
* @param from Email address to use for From:
}
+
SendProblemReportJob::~SendProblemReportJob ()
{
stop_thread ();
}
+
string
SendProblemReportJob::name () const
{
return String::compose (_("Email problem report for %1"), _film->name());
}
+
string
SendProblemReportJob::json_name () const
{
return N_("send_problem_report");
}
+
void
SendProblemReportJob::run ()
{
set_state (FINISHED_OK);
}
+
void
SendProblemReportJob::add_file (string& body, boost::filesystem::path file) const
{
- FILE* f = fopen_boost (_film->file (file), "r");
+ auto f = fopen_boost (_film->file(file), "r");
if (!f) {
return;
}
body += file.string() + ":\n";
body += "---<8----\n";
- uintmax_t const size = boost::filesystem::file_size (_film->file (file));
+ auto const size = boost::filesystem::file_size (_film->file(file));
char* buffer = new char[size + 1];
int const N = fread (buffer, 1, size, f);
buffer[N] = '\0';
/*
- 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 "job.h"
#include <dcp/types.h>
#include <boost/filesystem.hpp>
+
class SendProblemReportJob : public Job
{
public:
~SendProblemReportJob ();
- std::string name () const;
- std::string json_name () const;
- void run ();
+ std::string name () const override;
+ std::string json_name () const override;
+ void run () override;
private:
void add_file (std::string& body, boost::filesystem::path file) const;
/*
- Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "spl_entry.h"
+
#include "dcp_content.h"
#include "dcpomatic_assert.h"
+#include "spl_entry.h"
#include "warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
DCPOMATIC_ENABLE_WARNINGS
+
using std::shared_ptr;
using std::dynamic_pointer_cast;
-SPLEntry::SPLEntry (shared_ptr<Content> content)
-{
- construct (content);
-}
-void
-SPLEntry::construct (shared_ptr<Content> c)
+SPLEntry::SPLEntry (shared_ptr<Content> c)
+ : content (c)
+ , digest (content->digest())
{
- content = c;
- shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (content);
- digest = content->digest ();
+ auto dcp = dynamic_pointer_cast<DCPContent> (content);
if (dcp) {
name = dcp->name ();
DCPOMATIC_ASSERT (dcp->cpl());
}
}
+
void
SPLEntry::as_xml (xmlpp::Element* e)
{
/*
- Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#ifndef DCPOMATIC_SPL_ENTRY_H
#define DCPOMATIC_SPL_ENTRY_H
+
#include <libcxml/cxml.h>
#include <dcp/types.h>
+
namespace xmlpp {
class Element;
}
class Content;
+
class SPLEntry
{
public:
- SPLEntry (std::shared_ptr<Content> content);
+ SPLEntry (std::shared_ptr<Content> c);
void as_xml (xmlpp::Element* e);
void construct (std::shared_ptr<Content> content);
};
+
#endif
/*
- 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 "stdout_log.h"
#include "config.h"
#include <iostream>
+
using std::cout;
using std::string;
using std::shared_ptr;
+
StdoutLog::StdoutLog ()
{
set_types (Config::instance()->log_types());
}
+
StdoutLog::StdoutLog (int types)
{
set_types (types);
}
+
void
StdoutLog::do_log (shared_ptr<const LogEntry> entry)
{
/*
- 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 "log.h"
+
class StdoutLog : public Log
{
public:
/*
- 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 "string_log_entry.h"
#include "i18n.h"
+
using std::string;
+
StringLogEntry::StringLogEntry (int type, string message)
: LogEntry (type)
, _message (message)
/*
- 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 "log_entry.h"
#include <string>
+
class StringLogEntry : public LogEntry
{
public:
/*
- Copyright (C) 2019-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "font_data.h"
-#include "subtitle_encoder.h"
-#include "player.h"
+
#include "compose.hpp"
+#include "font_data.h"
#include "job.h"
+#include "player.h"
+#include "subtitle_encoder.h"
#include <dcp/interop_subtitle_asset.h>
#include <dcp/raw_convert.h>
#include <dcp/smpte_subtitle_asset.h>
#include "i18n.h"
+
using std::make_pair;
using std::make_shared;
using std::pair;
#endif
using dcp::raw_convert;
+
/** @param output Directory, if there will be multiple output files, or a filename.
* @param initial_name Hint that may be used to create filenames, if @ref output is a directory.
* @param include_font true to refer to and export any font file (for Interop; ignored for SMPTE).
_default_font = dcp::ArrayData (default_font_file());
}
+
void
SubtitleEncoder::go ()
{
while (!_player->pass()) {}
int reel = 0;
- for (vector<pair<shared_ptr<dcp::SubtitleAsset>, boost::filesystem::path> >::iterator i = _assets.begin(); i != _assets.end(); ++i) {
- if (!i->first) {
+ for (auto& i: _assets) {
+ if (!i.first) {
/* No subtitles arrived for this asset; make an empty one so we write something to the output */
if (_film->interop()) {
- shared_ptr<dcp::InteropSubtitleAsset> s (new dcp::InteropSubtitleAsset());
+ auto s = make_shared<dcp::InteropSubtitleAsset>();
s->set_movie_title (_film->name());
s->set_reel_number (raw_convert<string>(reel + 1));
- i->first = s;
+ i.first = s;
} else {
- shared_ptr<dcp::SMPTESubtitleAsset> s (new dcp::SMPTESubtitleAsset());
+ auto s = make_shared<dcp::SMPTESubtitleAsset>();
s->set_content_title_text (_film->name());
s->set_reel_number (reel + 1);
- i->first = s;
+ i.first = s;
}
}
if (!_film->interop() || _include_font) {
for (auto j: _player->get_subtitle_fonts()) {
- i->first->add_font (j.id, _default_font);
+ i.first->add_font (j.id, _default_font);
}
}
- i->first->write (i->second);
+ i.first->write (i.second);
++reel;
}
}
+
void
SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period)
{
if (_film->interop() && !_include_font) {
i.unset_font ();
}
- _assets[_reel_index].first->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
+ _assets[_reel_index].first->add (make_shared<dcp::SubtitleString>(i));
}
if (_split_reels && (_reel_index < int(_reels.size()) - 1) && period.from > _reels[_reel_index].from) {
_last = period.from;
- shared_ptr<Job> job = _job.lock ();
+ auto job = _job.lock ();
if (job) {
job->set_progress (float(period.from.get()) / _length.get());
}
}
+
Frame
SubtitleEncoder::frames_done () 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 "types.h"
#include "player_text.h"
#include "dcp_text_track.h"
#include "encoder.h"
#include "dcpomatic_time.h"
+
namespace dcp {
class SubtitleAsset;
}
+
class Film;
+
/** @class SubtitleEncoder.
* @brief An `encoder' which extracts a film's subtitles to DCP XML format.
*/
public:
SubtitleEncoder (std::shared_ptr<const Film> film, std::shared_ptr<Job> job, boost::filesystem::path output, std::string intial_name, bool split_reels, bool include_font);
- void go ();
+ void go () override;
/** @return the number of frames that are done */
Frame frames_done () const;
/*
- 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/transcode_job.cc
* @brief A job which transcodes from one format to another.
*/
+
+#include "analytics.h"
+#include "compose.hpp"
#include "config.h"
-#include "transcode_job.h"
#include "dcp_encoder.h"
-#include "upload_job.h"
-#include "job_manager.h"
-#include "film.h"
+#include "dcpomatic_log.h"
#include "encoder.h"
+#include "film.h"
+#include "job_manager.h"
#include "log.h"
-#include "dcpomatic_log.h"
-#include "compose.hpp"
-#include "analytics.h"
-#include <iostream>
+#include "transcode_job.h"
+#include "upload_job.h"
#include <iomanip>
+#include <iostream>
#include "i18n.h"
-using std::string;
+
+using std::cout;
using std::fixed;
+using std::make_shared;
using std::setprecision;
-using std::cout;
using std::shared_ptr;
+using std::string;
using boost::optional;
using std::dynamic_pointer_cast;
+
/** @param film Film to use */
TranscodeJob::TranscodeJob (shared_ptr<const Film> film)
: Job (film)
}
+
TranscodeJob::~TranscodeJob ()
{
stop_thread ();
}
+
string
TranscodeJob::name () const
{
return String::compose (_("Transcoding %1"), _film->name());
}
+
string
TranscodeJob::json_name () const
{
return N_("transcode");
}
+
void
TranscodeJob::set_encoder (shared_ptr<Encoder> e)
{
_encoder = e;
}
+
void
TranscodeJob::run ()
{
/* XXX: this shouldn't be here */
if (Config::instance()->upload_after_make_dcp() && dynamic_pointer_cast<DCPEncoder>(_encoder)) {
- shared_ptr<Job> job (new UploadJob (_film));
- JobManager::instance()->add (job);
+ JobManager::instance()->add(make_shared<UploadJob>(_film));
}
_encoder.reset ();
}
}
+
string
TranscodeJob::status () const
{
return buffer;
}
+
/** @return Approximate remaining time in seconds */
int
TranscodeJob::remaining_time () const
{
/* _encoder might be destroyed by the job-runner thread */
- shared_ptr<Encoder> e = _encoder;
+ auto e = _encoder;
if (!e || e->finishing()) {
/* We aren't doing any actual encoding so just use the job's guess */
/* We're encoding so guess based on the current encoding rate */
- optional<float> fps = e->current_rate ();
+ auto fps = e->current_rate ();
if (!fps) {
return 0;
/*
- Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file src/transcode_job.h
* @brief A job which transcodes from one format to another.
*/
+
#include "job.h"
+
class Encoder;
+
/** @class TranscodeJob
* @brief A job which transcodes a Film to another format.
*/
explicit TranscodeJob (std::shared_ptr<const Film> film);
~TranscodeJob ();
- std::string name () const;
- std::string json_name () const;
- void run ();
- std::string status () const;
+ std::string name () const override;
+ std::string json_name () const override;
+ void run () override;
+ std::string status () const override;
void set_encoder (std::shared_ptr<Encoder> t);
private:
- int remaining_time () const;
+ int remaining_time () const override;
std::shared_ptr<Encoder> _encoder;
};
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "trusted_device.h"
+
using std::string;
+
TrustedDevice::TrustedDevice (string thumbprint)
: _thumbprint (thumbprint)
{
}
+
TrustedDevice::TrustedDevice (dcp::Certificate certificate)
: _certificate (certificate)
{
}
+
string
TrustedDevice::as_string () const
{
return *_thumbprint;
}
+
string
TrustedDevice::thumbprint () const
{
/*
- 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.
*/
+
#ifndef DCPOMATIC_TRUSTED_DEVICE_H
#define DCPOMATIC_TRUSTED_DEVICE_H
+
#include <dcp/certificate.h>
#include <boost/optional.hpp>
#include <string>
+
class TrustedDevice
{
public:
boost::optional<std::string> _thumbprint;
};
+
#endif
/*
- 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 "cross.h"
#include "verify_dcp_job.h"
#include "content.h"
#include "i18n.h"
+
using std::string;
using std::vector;
using std::shared_ptr;
using namespace boost::placeholders;
#endif
+
VerifyDCPJob::VerifyDCPJob (vector<boost::filesystem::path> directories)
: Job (shared_ptr<Film>())
, _directories (directories)
}
+
VerifyDCPJob::~VerifyDCPJob ()
{
stop_thread ();
}
+
string
VerifyDCPJob::name () const
{
return _("Verify DCP");
}
+
string
VerifyDCPJob::json_name () const
{
return N_("verify_dcp");
}
+
void
VerifyDCPJob::update_stage (string s, optional<boost::filesystem::path> path)
{
sub (s);
}
+
void
VerifyDCPJob::run ()
{
/*
- 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 "job.h"
#include <dcp/verify.h>
+
class Content;
+
class VerifyDCPJob : public Job
{
public:
explicit VerifyDCPJob (std::vector<boost::filesystem::path> directories);
~VerifyDCPJob ();
- std::string name () const;
- std::string json_name () const;
- void run ();
+ std::string name () const override;
+ std::string json_name () const override;
+ void run () override;
std::vector<dcp::VerificationNote> notes () const {
return _notes;
/*
- 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 "video_mxf_examiner.h"
#include "video_mxf_content.h"
#include "video_content.h"
#include "i18n.h"
+
using std::list;
using std::string;
using std::shared_ptr;
+using std::make_shared;
using namespace dcpomatic;
+
VideoMXFContent::VideoMXFContent (boost::filesystem::path path)
: Content (path)
{
}
+
VideoMXFContent::VideoMXFContent (cxml::ConstNodePtr node, int version)
: Content (node)
{
video = VideoContent::from_xml (this, node, version);
}
+
bool
VideoMXFContent::valid_mxf (boost::filesystem::path path)
{
Kumu::DefaultLogSink().UnsetFilterFlag(Kumu::LOG_ALLOW_ALL);
try {
- shared_ptr<dcp::MonoPictureAsset> mp (new dcp::MonoPictureAsset (path));
+ dcp::MonoPictureAsset mp (path);
return true;
} catch (dcp::MXFFileError& e) {
try {
Kumu::DefaultLogSink().SetFilterFlag(0);
- shared_ptr<dcp::StereoPictureAsset> sp (new dcp::StereoPictureAsset (path));
+ dcp::StereoPictureAsset sp (path);
return true;
} catch (dcp::MXFFileError& e) {
return false;
}
+
void
VideoMXFContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
{
Content::examine (film, job);
video.reset (new VideoContent (this));
- shared_ptr<VideoMXFExaminer> examiner (new VideoMXFExaminer (shared_from_this ()));
+ auto examiner = make_shared<VideoMXFExaminer>(shared_from_this());
video->take_from_examiner (examiner);
video->unset_colour_conversion ();
}
+
string
VideoMXFContent::summary () const
{
return String::compose (_("%1 [video]"), path_summary());
}
+
string
VideoMXFContent::technical_summary () const
{
- return Content::technical_summary() + " - " + video->technical_summary ();
+ return Content::technical_summary() + " - " + video->technical_summary();
}
+
string
VideoMXFContent::identifier () const
{
return Content::identifier() + "_" + video->identifier();
}
+
void
VideoMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const
{
- node->add_child("Type")->add_child_text ("VideoMXF");
+ node->add_child("Type")->add_child_text("VideoMXF");
Content::as_xml (node, with_paths);
video->as_xml (node);
}
+
DCPTime
VideoMXFContent::full_length (shared_ptr<const Film> film) const
{
FrameRateChange const frc (film, shared_from_this());
- return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
+ return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
}
+
DCPTime
VideoMXFContent::approximate_length () const
{
return DCPTime::from_frames (video->length_after_3d_combine(), 24);
}
+
void
VideoMXFContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p) 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 "content.h"
+
class VideoMXFContent : public Content
{
public:
VideoMXFContent (cxml::ConstNodePtr node, int version);
std::shared_ptr<VideoMXFContent> shared_from_this () {
- return std::dynamic_pointer_cast<VideoMXFContent> (Content::shared_from_this ());
+ return std::dynamic_pointer_cast<VideoMXFContent>(Content::shared_from_this());
}
std::shared_ptr<const VideoMXFContent> shared_from_this () const {
- return std::dynamic_pointer_cast<const VideoMXFContent> (Content::shared_from_this ());
+ return std::dynamic_pointer_cast<const VideoMXFContent>(Content::shared_from_this());
}
- void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job> job);
- std::string summary () const;
- std::string technical_summary () const;
- std::string identifier () const;
- void as_xml (xmlpp::Node* node, bool with_paths) const;
- dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const;
- dcpomatic::DCPTime approximate_length () const;
- void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const;
+ void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job> job) override;
+ std::string summary () const override;
+ std::string technical_summary () const override;
+ std::string identifier () const override;
+ void as_xml (xmlpp::Node* node, bool with_paths) const override;
+ dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override;
+ dcpomatic::DCPTime approximate_length () const override;
+ void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override;
static bool valid_mxf (boost::filesystem::path path);
};
/*
- Copyright (C) 2016-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
/*
- 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_util.h"
+
#include "wx/about_dialog.h"
-#include "wx/wx_signal_manager.h"
-#include "wx/job_manager_view.h"
+#include "wx/dcpomatic_button.h"
#include "wx/full_config_dialog.h"
+#include "wx/job_manager_view.h"
#include "wx/servers_list_dialog.h"
-#include "wx/dcpomatic_button.h"
-#include "lib/version.h"
+#include "wx/wx_signal_manager.h"
+#include "wx/wx_util.h"
#include "lib/compose.hpp"
#include "lib/config.h"
-#include "lib/util.h"
+#include "lib/dcpomatic_socket.h"
#include "lib/film.h"
-#include "lib/job_manager.h"
#include "lib/job.h"
-#include "lib/dcpomatic_socket.h"
+#include "lib/job_manager.h"
#include "lib/transcode_job.h"
+#include "lib/util.h"
+#include "lib/version.h"
#include <wx/aboutdlg.h>
-#include <wx/stdpaths.h>
#include <wx/cmdline.h>
-#include <wx/splash.h>
#include <wx/preferences.h>
+#include <wx/splash.h>
+#include <wx/stdpaths.h>
#include <wx/wx.h>
#include <iostream>
#include <set>
-using std::exception;
-using std::string;
+
using std::cout;
+using std::dynamic_pointer_cast;
+using std::exception;
using std::list;
+using std::make_shared;
using std::set;
using std::shared_ptr;
-using boost::thread;
+using std::string;
using boost::scoped_array;
-using std::dynamic_pointer_cast;
+using boost::thread;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
+
static list<boost::filesystem::path> films_to_load;
+
enum {
ID_file_add_film = 1,
ID_tools_encoding_servers,
ID_help_about
};
+
void
setup_menu (wxMenuBar* m)
{
- wxMenu* file = new wxMenu;
+ auto file = new wxMenu;
file->Append (ID_file_add_film, _("&Add Film...\tCtrl-A"));
#ifdef DCPOMATIC_OSX
file->Append (wxID_EXIT, _("&Exit"));
#ifdef DCPOMATIC_OSX
file->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
#else
- wxMenu* edit = new wxMenu;
+ auto edit = new wxMenu;
edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
#endif
- wxMenu* tools = new wxMenu;
+ auto tools = new wxMenu;
tools->Append (ID_tools_encoding_servers, _("Encoding servers..."));
- wxMenu* help = new wxMenu;
+ auto help = new wxMenu;
help->Append (ID_help_about, _("About"));
m->Append (file, _("&File"));
m->Append (help, _("&Help"));
}
+
class DOMFrame : public wxFrame
{
public:
explicit DOMFrame (wxString const & title)
- : wxFrame (NULL, -1, title)
- , _sizer (new wxBoxSizer (wxVERTICAL))
- , _config_dialog (0)
- , _servers_list_dialog (0)
+ : wxFrame (nullptr, -1, title)
+ , _sizer (new wxBoxSizer(wxVERTICAL))
{
- wxMenuBar* bar = new wxMenuBar;
+ auto bar = new wxMenuBar;
setup_menu (bar);
SetMenuBar (bar);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_encoding_servers, this), ID_tools_encoding_servers);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), ID_help_about);
- wxPanel* panel = new wxPanel (this);
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ auto panel = new wxPanel (this);
+ auto s = new wxBoxSizer (wxHORIZONTAL);
s->Add (panel, 1, wxEXPAND);
SetSizer (s);
- JobManagerView* job_manager_view = new JobManagerView (panel, true);
+ auto job_manager_view = new JobManagerView (panel, true);
_sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6);
- wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL);
- wxButton* add = new Button (panel, _("Add Film..."));
- add->Bind (wxEVT_BUTTON, boost::bind (&DOMFrame::add_film, this));
+ auto buttons = new wxBoxSizer (wxHORIZONTAL);
+ auto add = new Button (panel, _("Add Film..."));
+ add->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::add_film, this));
buttons->Add (add, 1, wxALL, 6);
_pause = new Button (panel, _("Pause"));
_pause->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::pause, this));
panel->SetSizer (_sizer);
- Bind (wxEVT_CLOSE_WINDOW, boost::bind (&DOMFrame::close, this, _1));
- Bind (wxEVT_SIZE, boost::bind (&DOMFrame::sized, this, _1));
+ Bind (wxEVT_CLOSE_WINDOW, boost::bind(&DOMFrame::close, this, _1));
+ Bind (wxEVT_SIZE, boost::bind(&DOMFrame::sized, this, _1));
}
void setup_sensitivity ()
void pause ()
{
- JobManager::instance()->pause ();
+ JobManager::instance()->pause();
setup_sensitivity ();
}
void resume ()
{
- JobManager::instance()->resume ();
+ JobManager::instance()->resume();
setup_sensitivity ();
}
void start_job (boost::filesystem::path path)
{
try {
- shared_ptr<Film> film (new Film (path));
+ auto film = make_shared<Film>(path);
film->read_metadata ();
double total_required;
film->should_be_enough_disk_space (total_required, available, can_hard_link);
- set<shared_ptr<const Film> > films;
+ set<shared_ptr<const Film>> films;
for (auto i: JobManager::instance()->get()) {
films.insert (i->film());
film->make_dcp ();
} catch (std::exception& e) {
- wxString p = std_to_wx (path.string ());
- wxCharBuffer b = p.ToUTF8 ();
- error_dialog (this, wxString::Format (_("Could not open film at %s"), p.data()), std_to_wx(e.what()));
+ auto p = std_to_wx (path.string ());
+ auto b = p.ToUTF8 ();
+ error_dialog (this, wxString::Format(_("Could not open film at %s"), p.data()), std_to_wx(e.what()));
}
}
bool should_close ()
{
- if (!JobManager::instance()->work_to_do ()) {
+ if (!JobManager::instance()->work_to_do()) {
return true;
}
- wxMessageDialog* d = new wxMessageDialog (
+ auto d = new wxMessageDialog (
0,
_("There are unfinished jobs; are you sure you want to quit?"),
_("Unfinished jobs"),
void close (wxCloseEvent& ev)
{
- if (!should_close ()) {
+ if (!should_close()) {
ev.Veto ();
return;
}
void file_quit ()
{
- if (should_close ()) {
+ if (should_close()) {
Close (true);
}
}
void help_about ()
{
- AboutDialog* d = new AboutDialog (this);
+ auto d = new AboutDialog (this);
d->ShowModal ();
d->Destroy ();
}
void add_film ()
{
- wxDirDialog* c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
+ auto c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
if (_last_parent) {
- c->SetPath (std_to_wx (_last_parent.get().string ()));
+ c->SetPath (std_to_wx(_last_parent.get().string()));
}
int r;
} catch (exception& e) {
error_dialog (
this,
- wxString::Format (
+ wxString::Format(
_("Could not write to cinemas file at %s. Your changes have not been saved."),
std_to_wx (Config::instance()->cinemas_file().string()).data()
)
} catch (exception& e) {
error_dialog (
this,
- wxString::Format (
+ wxString::Format(
_("Could not write to config file at %s. Your changes have not been saved."),
std_to_wx (Config::instance()->cinemas_file().string()).data()
)
boost::optional<boost::filesystem::path> _last_parent;
wxSizer* _sizer;
- wxPreferencesEditor* _config_dialog;
- ServersListDialog* _servers_list_dialog;
+ wxPreferencesEditor* _config_dialog = nullptr;
+ ServersListDialog* _servers_list_dialog = nullptr;
wxButton* _pause;
wxButton* _resume;
};
+
static const wxCmdLineEntryDesc command_line_description[] = {
{ wxCMD_LINE_PARAM, 0, 0, "film to load", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
};
+
class JobServer : public Server
{
public:
{
try {
int const length = socket->read_uint32 ();
- scoped_array<char> buffer (new char[length]);
- socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
+ scoped_array<char> buffer(new char[length]);
+ socket->read (reinterpret_cast<uint8_t*>(buffer.get()), length);
string s (buffer.get());
_frame->start_job (s);
- socket->write (reinterpret_cast<uint8_t const *> ("OK"), 3);
+ socket->write (reinterpret_cast<uint8_t const *>("OK"), 3);
} catch (...) {
}
DOMFrame* _frame;
};
+
class App : public wxApp
{
bool OnInit ()
SetAppName (_("DCP-o-matic Batch Converter"));
is_batch_converter = true;
- Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
- Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
+ Config::FailedToLoad.connect (boost::bind(&App::config_failed_to_load, this));
+ Config::Warning.connect (boost::bind(&App::config_warning, this, _1));
- wxSplashScreen* splash = maybe_show_splash ();
+ auto splash = maybe_show_splash ();
if (!wxApp::OnInit()) {
return false;
}
_frame->Show ();
- JobServer* server = new JobServer (_frame);
+ auto server = new JobServer (_frame);
new thread (boost::bind (&JobServer::run, server));
signal_manager = new wxSignalManager (this);
shared_ptr<Film> film;
for (auto i: films_to_load) {
- if (boost::filesystem::is_directory (i)) {
+ if (boost::filesystem::is_directory(i)) {
try {
- film.reset (new Film (i));
+ film = make_shared<Film>(i);
film->read_metadata ();
film->make_dcp ();
} catch (exception& e) {
error_dialog (
0,
- std_to_wx (String::compose (wx_to_std (_("Could not load film %1")), i.string())),
+ std_to_wx(String::compose(wx_to_std(_("Could not load film %1")), i.string())),
std_to_wx(e.what())
);
}
bool OnCmdLineParsed (wxCmdLineParser& parser)
{
for (size_t i = 0; i < parser.GetParamCount(); ++i) {
- films_to_load.push_back (wx_to_std (parser.GetParam(i)));
+ films_to_load.push_back (wx_to_std(parser.GetParam(i)));
}
return true;
void config_warning (string m)
{
- message_dialog (_frame, std_to_wx (m));
+ message_dialog (_frame, std_to_wx(m));
}
DOMFrame* _frame;
};
+
IMPLEMENT_APP (App)
/*
- 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 <exception>
+using std::dynamic_pointer_cast;
using std::exception;
+using std::make_shared;
+using std::shared_ptr;
using std::string;
using std::vector;
-using std::dynamic_pointer_cast;
using boost::optional;
-using std::shared_ptr;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
{
public:
explicit DOMFrame (wxString const & title)
- : wxFrame (0, -1, title)
+ : wxFrame (nullptr, -1, title)
{
/* Use a panel as the only child of the Frame so that we avoid
the dark-grey background on Windows.
*/
- wxPanel* overall_panel = new wxPanel (this);
- wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ auto overall_panel = new wxPanel (this);
+ auto s = new wxBoxSizer (wxHORIZONTAL);
s->Add (overall_panel, 1, wxEXPAND);
SetSizer (s);
true
);
- wxBoxSizer* output = new wxBoxSizer (wxHORIZONTAL);
+ auto output = new wxBoxSizer (wxHORIZONTAL);
add_label_to_sizer (output, overall_panel, _("Output DCP folder"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
_output = new DirPickerCtrl (overall_panel);
output->Add (_output, 1, wxEXPAND);
_combine = new Button (overall_panel, _("Combine"));
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
sizer->Add (_input, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
sizer->Add (output, 0, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
sizer->Add (_combine, 0, wxALL | wxALIGN_RIGHT, DCPOMATIC_DIALOG_BORDER);
void combine ()
{
- boost::filesystem::path const output = wx_to_std(_output->GetPath());
+ using namespace boost::filesystem;
+
+ path const output = wx_to_std(_output->GetPath());
- if (boost::filesystem::is_directory(output) && !boost::filesystem::is_empty(output)) {
+ if (is_directory(output) && !is_empty(output)) {
if (!confirm_dialog (
this,
std_to_wx (
)) {
return;
}
- } else if (boost::filesystem::is_regular_file(output)) {
+ } else if (is_regular_file(output)) {
error_dialog (
this,
String::compose (wx_to_std(_("%1 already exists as a file, so you cannot use it for a DCP.")), output.string())
return;
}
- JobManager* jm = JobManager::instance ();
- jm->add (shared_ptr<Job>(new CombineDCPJob(_inputs, output)));
+ auto jm = JobManager::instance ();
+ jm->add (make_shared<CombineDCPJob>(_inputs, output));
bool const ok = display_progress (_("DCP-o-matic Combine"), _("Combining DCPs"));
if (!ok) {
return;
}
DCPOMATIC_ASSERT (!jm->get().empty());
- shared_ptr<CombineDCPJob> last = dynamic_pointer_cast<CombineDCPJob> (jm->get().back());
+ auto last = dynamic_pointer_cast<CombineDCPJob> (jm->get().back());
DCPOMATIC_ASSERT (last);
if (last->finished_ok()) {
message_dialog (this, _("DCPs combined successfully."));
} else {
- wxString m = std_to_wx(last->error_summary());
+ auto m = std_to_wx(last->error_summary());
if (!last->error_details().empty()) {
m += wxString::Format(" (%s)", std_to_wx(last->error_details()));
}
class App : public wxApp
{
public:
- App ()
- : _frame (0)
- {}
+ App () {}
- bool OnInit ()
+ bool OnInit () override
{
try {
Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
}
catch (exception& e)
{
- error_dialog (0, wxString::Format ("DCP-o-matic DCP Combiner could not start."), std_to_wx(e.what()));
+ error_dialog (nullptr, wxString::Format ("DCP-o-matic DCP Combiner could not start."), std_to_wx(e.what()));
return false;
}
} catch (FileError& e) {
error_dialog (
0,
- wxString::Format (
+ wxString::Format(
_("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
std_to_wx (e.what()),
std_to_wx (e.file().string().c_str ())
} catch (exception& e) {
error_dialog (
0,
- wxString::Format (
+ wxString::Format(
_("An exception occurred: %s.\n\n") + REPORT_PROBLEM,
std_to_wx (e.what ())
)
);
} catch (...) {
- error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
+ error_dialog (nullptr, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
}
}
- bool OnExceptionInMainLoop ()
+ bool OnExceptionInMainLoop () override
{
report_exception ();
/* This will terminate the program */
return false;
}
- void OnUnhandledException ()
+ void OnUnhandledException () override
{
report_exception ();
}
- DOMFrame* _frame;
+ DOMFrame* _frame = nullptr;
};
IMPLEMENT_APP (App)
/*
- 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 "lib/ratio.h"
-#include "lib/film.h"
-#include "lib/filter.h"
-#include "lib/util.h"
-#include "lib/encode_server.h"
+
#include "lib/dcp_video.h"
#include "lib/decoder.h"
+#include "lib/encode_server.h"
+#include "lib/encode_server_description.h"
#include "lib/exceptions.h"
#include "lib/file_log.h"
-#include "lib/video_decoder.h"
+#include "lib/film.h"
+#include "lib/filter.h"
#include "lib/player.h"
#include "lib/player_video.h"
-#include "lib/encode_server_description.h"
+#include "lib/ratio.h"
+#include "lib/util.h"
+#include "lib/video_decoder.h"
#include <getopt.h>
-#include <iostream>
-#include <iomanip>
#include <exception>
+#include <iomanip>
+#include <iostream>
+
-using std::cout;
using std::cerr;
-using std::string;
+using std::cout;
+using std::make_shared;
using std::pair;
using std::shared_ptr;
+using std::string;
using boost::optional;
using boost::bind;
#if BOOST_VERSION >= 106100
#endif
using dcp::ArrayData;
+
static shared_ptr<Film> film;
static EncodeServerDescription* server;
static int frame_count = 0;
+
void
process_video (shared_ptr<PlayerVideo> pvf)
{
- shared_ptr<DCPVideo> local (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, Resolution::TWO_K));
- shared_ptr<DCPVideo> remote (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, Resolution::TWO_K));
+ auto local = make_shared<DCPVideo>(pvf, frame_count, film->video_frame_rate(), 250000000, Resolution::TWO_K);
+ auto remote = make_shared<DCPVideo>(pvf, frame_count, film->video_frame_rate(), 250000000, Resolution::TWO_K);
cout << "Frame " << frame_count << ": ";
cout.flush ();
++frame_count;
- ArrayData local_encoded = local->encode_locally ();
+ auto local_encoded = local->encode_locally ();
ArrayData remote_encoded;
string remote_error;
remote_error = e.what ();
}
- if (!remote_error.empty ()) {
+ if (!remote_error.empty()) {
cout << "\033[0;31mnetwork problem: " << remote_error << "\033[0m\n";
return;
}
return;
}
- uint8_t* p = local_encoded.data();
- uint8_t* q = remote_encoded.data();
+ auto p = local_encoded.data();
+ auto q = remote_encoded.data();
for (int i = 0; i < local_encoded.size(); ++i) {
if (*p++ != *q++) {
cout << "\033[0;31mdata differ\033[0m at byte " << i << "\n";
cout << "\033[0;32mgood\033[0m\n";
}
+
static void
help (string n)
{
exit (EXIT_FAILURE);
}
+
int
main (int argc, char* argv[])
{
try {
server = new EncodeServerDescription (server_host, 1, SERVER_LINK_VERSION);
- film.reset (new Film (film_dir));
+ film = make_shared<Film>(film_dir);
film->read_metadata ();
- shared_ptr<Player> player (new Player(film));
- player->Video.connect (bind (&process_video, _1));
+ auto player = make_shared<Player>(film);
+ player->Video.connect (bind(&process_video, _1));
while (!player->pass ()) {}
} catch (std::exception& e) {
cerr << "Error: " << e.what() << "\n";
/*
- 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 "cinema_dialog.h"
#include "wx_util.h"
#include "lib/dcpomatic_assert.h"
#include "lib/util.h"
-using std::string;
-using std::vector;
-using std::copy;
+
using std::back_inserter;
-using std::list;
+using std::copy;
using std::cout;
+using std::list;
+using std::string;
+using std::vector;
using boost::bind;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
-static string
-column (string s)
-{
- return s;
-}
CinemaDialog::CinemaDialog (wxWindow* parent, wxString title, string name, list<string> emails, string notes, int utc_offset_hour, int utc_offset_minute)
: wxDialog (parent, wxID_ANY, title)
{
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (overall_sizer);
- wxGridBagSizer* sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ auto sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
int r = 0;
- add_label_to_sizer (sizer, this, _("Name"), true, wxGBPosition (r, 0));
- _name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (500, -1));
- sizer->Add (_name, wxGBPosition (r, 1));
+ add_label_to_sizer (sizer, this, _("Name"), true, wxGBPosition(r, 0));
+ _name = new wxTextCtrl (this, wxID_ANY, std_to_wx(name), wxDefaultPosition, wxSize(500, -1));
+ sizer->Add (_name, wxGBPosition(r, 1));
++r;
- add_label_to_sizer (sizer, this, _("UTC offset (time zone)"), true, wxGBPosition (r, 0));
+ add_label_to_sizer (sizer, this, _("UTC offset (time zone)"), true, wxGBPosition(r, 0));
_utc_offset = new wxChoice (this, wxID_ANY);
- sizer->Add (_utc_offset, wxGBPosition (r, 1));
+ sizer->Add (_utc_offset, wxGBPosition(r, 1));
++r;
- add_label_to_sizer (sizer, this, _("Notes"), true, wxGBPosition (r, 0));
- _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx (notes), wxDefaultPosition, wxSize (500, -1));
- sizer->Add (_notes, wxGBPosition (r, 1));
+ add_label_to_sizer (sizer, this, _("Notes"), true, wxGBPosition(r, 0));
+ _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx(notes), wxDefaultPosition, wxSize(500, -1));
+ sizer->Add (_notes, wxGBPosition(r, 1));
++r;
- add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition (r, 0), wxGBSpan (1, 2));
+ add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition(r, 0), wxGBSpan(1, 2));
++r;
copy (emails.begin(), emails.end(), back_inserter (_emails));
vector<EditableListColumn> columns;
columns.push_back (EditableListColumn(_("Address")));
_email_list = new EditableList<string, EmailDialog> (
- this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), bind (&column, _1)
+ this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), [](string s, int) {
+ return s;
+ }
);
- sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
+ sizer->Add (_email_list, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND);
++r;
overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
if (buttons) {
overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
_name->SetFocus ();
}
+
string
CinemaDialog::name () const
{
return wx_to_std (_name->GetValue());
}
+
void
CinemaDialog::set_emails (vector<string> e)
{
_emails = e;
}
+
vector<string>
CinemaDialog::get_emails () const
{
return _emails;
}
+
list<string>
CinemaDialog::emails () const
{
list<string> e;
- copy (_emails.begin(), _emails.end(), back_inserter (e));
+ copy (_emails.begin(), _emails.end(), back_inserter(e));
return e;
}
+
int
CinemaDialog::utc_offset_hour () const
{
int const sel = _utc_offset->GetSelection();
- if (sel < 0 || sel > int (_offsets.size())) {
+ if (sel < 0 || sel > int(_offsets.size())) {
return 0;
}
return _offsets[sel].hour;
}
+
int
CinemaDialog::utc_offset_minute () const
{
int const sel = _utc_offset->GetSelection();
- if (sel < 0 || sel > int (_offsets.size())) {
+ if (sel < 0 || sel > int(_offsets.size())) {
return 0;
}
return _offsets[sel].minute;
}
+
string
CinemaDialog::notes () const
{
- return wx_to_std (_notes->GetValue ());
+ return wx_to_std (_notes->GetValue());
}
/*
- 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 "table_dialog.h"
+
#include "editable_list.h"
#include "email_dialog.h"
+#include "table_dialog.h"
#include <wx/wx.h>
#include <list>
#include <vector>
+
class CinemaDialog : public wxDialog
{
public:
*/
+
#include "audio_dialog.h"
#include "check_box.h"
#include "check_box.h"
#include <boost/lexical_cast.hpp>
#include <iostream>
+
using std::cout;
using std::list;
using std::string;
#endif
using dcp::locale_convert;
+
DCPPanel::DCPPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer)
- : _audio_dialog (0)
- , _markers_dialog (0)
- , _interop_metadata_dialog (0)
- , _smpte_metadata_dialog (0)
- , _film (film)
+ : _film (film)
, _viewer (viewer)
, _generally_sensitive (true)
{
_notebook->AddPage (make_video_panel (), _("Video"), false);
_notebook->AddPage (make_audio_panel (), _("Audio"), false);
- _name->Bind (wxEVT_TEXT, boost::bind (&DCPPanel::name_changed, this));
- _use_isdcf_name->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::use_isdcf_name_toggled, this));
- _copy_isdcf_name_button->Bind(wxEVT_BUTTON, boost::bind (&DCPPanel::copy_isdcf_name_button_clicked, this));
- _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::dcp_content_type_changed, this));
- _encrypted->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::encrypted_toggled, this));
- _reel_type->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::reel_type_changed, this));
- _reel_length->Bind (wxEVT_SPINCTRL, boost::bind (&DCPPanel::reel_length_changed, this));
- _standard->Bind (wxEVT_CHOICE, boost::bind (&DCPPanel::standard_changed, this));
- _markers->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::markers_clicked, this));
- _metadata->Bind (wxEVT_BUTTON, boost::bind (&DCPPanel::metadata_clicked, this));
+ _name->Bind (wxEVT_TEXT, boost::bind(&DCPPanel::name_changed, this));
+ _use_isdcf_name->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::use_isdcf_name_toggled, this));
+ _copy_isdcf_name_button->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::copy_isdcf_name_button_clicked, this));
+ _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::dcp_content_type_changed, this));
+ _encrypted->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::encrypted_toggled, this));
+ _reel_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::reel_type_changed, this));
+ _reel_length->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::reel_length_changed, this));
+ _standard->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::standard_changed, this));
+ _markers->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::markers_clicked, this));
+ _metadata->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::metadata_clicked, this));
for (auto i: DCPContentType::all()) {
- _dcp_content_type->Append (std_to_wx (i->pretty_name ()));
+ _dcp_content_type->Append (std_to_wx(i->pretty_name()));
}
_reel_type->Append (_("Single reel"));
_standard->Append (_("SMPTE"));
_standard->Append (_("Interop"));
- Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this, _1));
+ Config::instance()->Changed.connect (boost::bind(&DCPPanel::config_changed, this, _1));
add_to_grid ();
}
flags |= wxALIGN_RIGHT;
#endif
- _grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
+ _grid->Add (_use_isdcf_name, wxGBPosition(r, 0), wxDefaultSpan, flags);
{
auto s = new wxBoxSizer (wxHORIZONTAL);
s->Add (_copy_isdcf_name_button, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
- _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
+ _grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND);
}
++r;
_grid->Add (_dcp_name, wxGBPosition(r, 0), wxGBSpan(1, 2), wxALIGN_CENTER_VERTICAL | wxEXPAND);
++r;
- add_label_to_sizer (_grid, _dcp_content_type_label, true, wxGBPosition (r, 0));
- _grid->Add (_dcp_content_type, wxGBPosition (r, 1));
+ add_label_to_sizer (_grid, _dcp_content_type_label, true, wxGBPosition(r, 0));
+ _grid->Add (_dcp_content_type, wxGBPosition(r, 1));
++r;
- _grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
+ _grid->Add (_encrypted, wxGBPosition(r, 0), wxGBSpan(1, 2));
++r;
- add_label_to_sizer (_grid, _reels_label, true, wxGBPosition (r, 0));
- _grid->Add (_reel_type, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+ add_label_to_sizer (_grid, _reels_label, true, wxGBPosition(r, 0));
+ _grid->Add (_reel_type, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
++r;
- add_label_to_sizer (_grid, _reel_length_label, true, wxGBPosition (r, 0));
+ add_label_to_sizer (_grid, _reel_length_label, true, wxGBPosition(r, 0));
{
- wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ auto s = new wxBoxSizer (wxHORIZONTAL);
s->Add (_reel_length);
add_label_to_sizer (s, _reel_length_gb_label, false, 0, wxLEFT | wxALIGN_CENTER_VERTICAL);
- _grid->Add (s, wxGBPosition (r, 1));
+ _grid->Add (s, wxGBPosition(r, 1));
}
++r;
- add_label_to_sizer (_grid, _standard_label, true, wxGBPosition (r, 0));
- _grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+ add_label_to_sizer (_grid, _standard_label, true, wxGBPosition(r, 0));
+ _grid->Add (_standard, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
++r;
auto extra = new wxBoxSizer (wxHORIZONTAL);
++r;
}
+
void
DCPPanel::name_changed ()
{
return;
}
- _film->set_name (string (_name->GetValue().mb_str()));
+ _film->set_name (string(_name->GetValue().mb_str()));
}
+
void
DCPPanel::j2k_bandwidth_changed ()
{
_film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
}
+
void
DCPPanel::encrypted_toggled ()
{
return;
}
- _film->set_encrypted (_encrypted->GetValue ());
+ _film->set_encrypted (_encrypted->GetValue());
}
+
/** Called when the frame rate choice widget has been changed */
void
DCPPanel::frame_rate_choice_changed ()
);
}
+
/** Called when the frame rate spin widget has been changed */
void
DCPPanel::frame_rate_spin_changed ()
return;
}
- _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
+ _film->set_video_frame_rate (_frame_rate_spin->GetValue());
}
+
void
DCPPanel::audio_channels_changed ()
{
return;
}
- _film->set_audio_channels (locale_convert<int> (string_client_data (_audio_channels->GetClientObject (_audio_channels->GetSelection ()))));
+ _film->set_audio_channels (locale_convert<int>(string_client_data(_audio_channels->GetClientObject(_audio_channels->GetSelection()))));
}
+
void
DCPPanel::resolution_changed ()
{
_film->set_resolution (_resolution->GetSelection() == 0 ? Resolution::TWO_K : Resolution::FOUR_K);
}
+
void
DCPPanel::standard_changed ()
{
}
_film->set_interop (_standard->GetSelection() == 1);
+
}
void
{
if (_markers_dialog) {
_markers_dialog->Destroy ();
- _markers_dialog = 0;
+ _markers_dialog = nullptr;
}
_markers_dialog = new MarkersDialog (_panel, _film, _viewer);
_markers_dialog->Show();
}
+
void
DCPPanel::metadata_clicked ()
{
if (_film->interop()) {
if (_interop_metadata_dialog) {
_interop_metadata_dialog->Destroy ();
- _interop_metadata_dialog = 0;
+ _interop_metadata_dialog = nullptr;
}
_interop_metadata_dialog = new InteropMetadataDialog (_panel, _film);
} else {
if (_smpte_metadata_dialog) {
_smpte_metadata_dialog->Destroy ();
- _smpte_metadata_dialog = 0;
+ _smpte_metadata_dialog = nullptr;
}
_smpte_metadata_dialog = new SMPTEMetadataDialog (_panel, _film);
}
}
+
void
DCPPanel::film_changed (Film::Property p)
{
setup_dcp_name ();
break;
case Film::Property::DCP_CONTENT_TYPE:
- checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
+ {
+ auto index = DCPContentType::as_index(_film->dcp_content_type());
+ DCPOMATIC_ASSERT (index);
+ checked_set (_dcp_content_type, *index);
setup_dcp_name ();
break;
+ }
case Film::Property::ENCRYPTED:
checked_set (_encrypted, _film->encrypted ());
break;
break;
case Film::Property::USE_ISDCF_NAME:
{
- checked_set (_use_isdcf_name, _film->use_isdcf_name ());
+ checked_set (_use_isdcf_name, _film->use_isdcf_name());
if (_film->use_isdcf_name()) {
/* We are going back to using an ISDCF name. Remove anything after a _ in the current name,
in case the user has clicked 'Copy as name' then re-ticked 'Use ISDCF name' (#1513).
{
bool done = false;
for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
- if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
+ if (wx_to_std(_frame_rate_choice->GetString(i)) == boost::lexical_cast<string>(_film->video_frame_rate())) {
checked_set (_frame_rate_choice, i);
done = true;
break;
break;
}
case Film::Property::AUDIO_CHANNELS:
- if (_film->audio_channels () < minimum_allowed_audio_channels ()) {
- _film->set_audio_channels (minimum_allowed_audio_channels ());
+ if (_film->audio_channels() < minimum_allowed_audio_channels()) {
+ _film->set_audio_channels (minimum_allowed_audio_channels());
} else {
- checked_set (_audio_channels, locale_convert<string> (max (minimum_allowed_audio_channels(), _film->audio_channels ())));
+ checked_set (_audio_channels, locale_convert<string>(max(minimum_allowed_audio_channels(), _film->audio_channels())));
setup_dcp_name ();
}
break;
case Film::Property::THREE_D:
- checked_set (_three_d, _film->three_d ());
+ checked_set (_three_d, _film->three_d());
setup_dcp_name ();
break;
case Film::Property::REENCODE_J2K:
_markers->Enable (!_film->interop());
break;
case Film::Property::AUDIO_PROCESSOR:
- if (_film->audio_processor ()) {
+ if (_film->audio_processor()) {
checked_set (_audio_processor, _film->audio_processor()->id());
} else {
checked_set (_audio_processor, 0);
}
- setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels ());
+ setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels());
film_changed (Film::Property::AUDIO_CHANNELS);
break;
case Film::Property::REEL_TYPE:
}
}
+
void
DCPPanel::film_content_changed (int property)
{
DCPPanel::setup_container ()
{
int n = 0;
- vector<Ratio const *> ratios = Ratio::containers ();
- vector<Ratio const *>::iterator i = ratios.begin ();
- while (i != ratios.end() && *i != _film->container ()) {
+ auto ratios = Ratio::containers ();
+ auto i = ratios.begin ();
+ while (i != ratios.end() && *i != _film->container()) {
++i;
++n;
}
if (i == ratios.end()) {
checked_set (_container, -1);
- checked_set (_container_size, wxT (""));
+ checked_set (_container_size, wxT(""));
} else {
checked_set (_container, n);
- dcp::Size const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
- checked_set (_container_size, wxString::Format ("%dx%d", size.width, size.height));
+ auto const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
+ checked_set (_container_size, wxString::Format("%dx%d", size.width, size.height));
}
setup_dcp_name ();
}
+
/** Called when the container widget has been changed */
void
DCPPanel::container_changed ()
int const n = _container->GetSelection ();
if (n >= 0) {
- vector<Ratio const *> ratios = Ratio::containers ();
- DCPOMATIC_ASSERT (n < int (ratios.size()));
+ auto ratios = Ratio::containers ();
+ DCPOMATIC_ASSERT (n < int(ratios.size()));
_film->set_container (ratios[n]);
}
}
+
/** Called when the DCP content type widget has been changed */
void
DCPPanel::dcp_content_type_changed ()
int const n = _dcp_content_type->GetSelection ();
if (n != wxNOT_FOUND) {
- _film->set_dcp_content_type (DCPContentType::from_index (n));
+ _film->set_dcp_content_type (DCPContentType::from_index(n));
}
}
+
void
DCPPanel::set_film (shared_ptr<Film> film)
{
set_general_sensitivity(static_cast<bool>(_film));
}
+
void
DCPPanel::set_general_sensitivity (bool s)
{
setup_sensitivity ();
}
+
void
DCPPanel::setup_sensitivity ()
{
_show_audio->Enable (_generally_sensitive && _film);
}
+
void
DCPPanel::use_isdcf_name_toggled ()
{
return;
}
- _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
+ _film->set_use_isdcf_name (_use_isdcf_name->GetValue());
}
void
DCPPanel::setup_dcp_name ()
{
- _dcp_name->SetLabel (std_to_wx (_film->dcp_name (true)));
- _dcp_name->SetToolTip (std_to_wx (_film->dcp_name (true)));
+ _dcp_name->SetLabel (std_to_wx(_film->dcp_name(true)));
+ _dcp_name->SetToolTip (std_to_wx(_film->dcp_name(true)));
}
+
void
DCPPanel::best_frame_rate_clicked ()
{
return;
}
- _film->set_video_frame_rate (_film->best_video_frame_rate ());
+ _film->set_video_frame_rate (_film->best_video_frame_rate());
}
+
void
DCPPanel::three_d_changed ()
{
return;
}
- _film->set_three_d (_three_d->GetValue ());
+ _film->set_three_d (_three_d->GetValue());
}
+
void
DCPPanel::reencode_j2k_changed ()
{
_film->set_reencode_j2k (_reencode_j2k->GetValue());
}
+
void
DCPPanel::config_changed (Config::Property p)
{
}
}
+
void
DCPPanel::setup_frame_rate_widget ()
{
- if (Config::instance()->allow_any_dcp_frame_rate ()) {
+ if (Config::instance()->allow_any_dcp_frame_rate()) {
_frame_rate_choice->Hide ();
_frame_rate_spin->Show ();
} else {
}
}
+
wxPanel *
DCPPanel::make_video_panel ()
{
return panel;
}
+
void
DCPPanel::add_video_panel_to_grid ()
{
add_label_to_sizer (_video_grid, _container_label, true, wxGBPosition (r, 0));
{
- wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ auto s = new wxBoxSizer (wxHORIZONTAL);
s->Add (_container, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
s->Add (_container_size, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
_video_grid->Add (s, wxGBPosition(r, 1));
_video_grid->Add (_reencode_j2k, wxGBPosition(r, 0), wxGBSpan(1, 2));
}
+
int
DCPPanel::minimum_allowed_audio_channels () const
{
return min;
}
+
wxPanel *
DCPPanel::make_audio_panel ()
{
return panel;
}
+
void
DCPPanel::add_audio_panel_to_grid ()
{
++r;
}
+
void
DCPPanel::copy_isdcf_name_button_clicked ()
{
_film->set_use_isdcf_name (false);
}
+
void
DCPPanel::audio_processor_changed ()
{
_film->set_audio_processor (AudioProcessor::from_id (s));
}
+
void
DCPPanel::show_audio_clicked ()
{
d->Show ();
}
+
void
DCPPanel::reel_type_changed ()
{
return;
}
- _film->set_reel_type (static_cast<ReelType> (_reel_type->GetSelection ()));
+ _film->set_reel_type (static_cast<ReelType>(_reel_type->GetSelection()));
}
+
void
DCPPanel::reel_length_changed ()
{
_film->set_reel_length (_reel_length->GetValue() * 1000000000LL);
}
+
void
DCPPanel::add_audio_processors ()
{
- _audio_processor->Append (_("None"), new wxStringClientData (N_("none")));
+ _audio_processor->Append (_("None"), new wxStringClientData(N_("none")));
for (auto ap: AudioProcessor::visible()) {
_audio_processor->Append (std_to_wx(ap->name()), new wxStringClientData(std_to_wx(ap->id())));
}
class FilmViewer;
class Ratio;
+
class DCPPanel
{
public:
wxButton* _metadata;
wxSizer* _audio_panel_sizer;
- AudioDialog* _audio_dialog;
- MarkersDialog* _markers_dialog;
- InteropMetadataDialog* _interop_metadata_dialog;
- SMPTEMetadataDialog* _smpte_metadata_dialog;
+ AudioDialog* _audio_dialog = nullptr;
+ MarkersDialog* _markers_dialog = nullptr;
+ InteropMetadataDialog* _interop_metadata_dialog = nullptr;
+ SMPTEMetadataDialog* _smpte_metadata_dialog = nullptr;
std::shared_ptr<Film> _film;
std::weak_ptr<FilmViewer> _viewer;
/*
- 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 "wx_util.h"
#include <dcp/util.h>
+
template <class T>
class FileDialogWrapper
{
boost::optional<T> get ()
{
- return T (dcp::file_to_string (wx_to_std (_dialog->GetPath ())));
+ return T (dcp::file_to_string(wx_to_std(_dialog->GetPath())));
}
int ShowModal ()
/*
- 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/filter_dialog.cc
* @brief A dialog to select FFmpeg filters.
*/
+
#include "check_box.h"
#include "filter_dialog.h"
#include "static_text.h"
FilterDialog::FilterDialog (wxWindow* parent, vector<Filter const *> const & active)
: wxDialog (parent, wxID_ANY, wxString(_("Filters")))
{
- wxPanel* panel = new wxPanel (this);
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ auto panel = new wxPanel (this);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
- vector<Filter const *> filters = Filter::all ();
+ auto filters = Filter::all ();
- typedef map<string, list<Filter const *> > CategoryMap;
- CategoryMap categories;
+ map<string, list<Filter const *>> categories;
for (auto i: filters) {
- CategoryMap::iterator j = categories.find (i->category());
+ auto j = categories.find (i->category());
if (j == categories.end ()) {
- list<Filter const *> c;
- c.push_back (i);
- categories[i->category()] = c;
+ categories[i->category()] = { i };
} else {
j->second.push_back (i);
}
}
- for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
-
- wxStaticText* c = new StaticText (panel, std_to_wx(i->first));
- wxFont font = c->GetFont();
+ for (auto const& i: categories) {
+ auto c = new StaticText (panel, std_to_wx(i.first));
+ auto font = c->GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
c->SetFont(font);
sizer->Add (c, 1, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_GAP);
- for (auto j: i->second) {
- wxCheckBox* b = new CheckBox(panel, std_to_wx(j->name()));
+ for (auto j: i.second) {
+ auto b = new CheckBox(panel, std_to_wx(j->name()));
bool const a = find (active.begin(), active.end(), j) != active.end();
b->SetValue (a);
_filters[j] = b;
sizer->AddSpacer (6);
}
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
+ auto buttons = CreateSeparatedButtonSizer (wxOK);
if (buttons) {
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
panel->SetSizer (sizer);
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
overall_sizer->Add (panel, 1, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
SetSizerAndFit (overall_sizer);
}
FilterDialog::active () const
{
vector<Filter const *> active;
- for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
- if (i->second->IsChecked()) {
- active.push_back(i->first);
+ for (auto const& i: _filters) {
+ if (i.second->IsChecked()) {
+ active.push_back(i.first);
}
}
/*
- 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/filter_dialog.h
* @brief A dialog to select FFmpeg filters.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
+
class Film;
class Filter;
+
/** @class FilterDialog
* @brief A dialog to select FFmpeg filters.
*/
/*
- Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "fonts_dialog.h"
#include "wx_util.h"
#include "system_font_dialog.h"
#include <wx/wx.h>
#include <iostream>
+
using std::list;
using std::string;
using std::cout;
using std::shared_ptr;
using namespace dcpomatic;
+
FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<Content> content, shared_ptr<TextContent> caption)
: wxDialog (parent, wxID_ANY, _("Fonts"))
, _content (content)
_fonts->InsertColumn (1, ip);
}
- wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
+ auto sizer = new wxBoxSizer (wxHORIZONTAL);
sizer->Add (_fonts, 1, wxEXPAND | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
_edit = new Button (this, _("Edit..."));
sizer->Add (_edit, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
+ auto buttons = CreateSeparatedButtonSizer (wxOK);
if (buttons) {
overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
setup ();
}
+
void
FontsDialog::setup ()
{
- shared_ptr<Content> content = _content.lock ();
- shared_ptr<TextContent> caption = _caption.lock ();
+ auto content = _content.lock ();
+ auto caption = _caption.lock ();
if (!content || !caption) {
return;
}
setup_sensitivity ();
}
+
void
FontsDialog::selection_changed ()
{
setup_sensitivity ();
}
+
void
FontsDialog::setup_sensitivity ()
{
_edit->Enable (item != -1);
}
+
void
FontsDialog::edit_clicked ()
{
- shared_ptr<Content> content = _content.lock ();
- shared_ptr<TextContent> caption = _caption.lock ();
+ auto content = _content.lock ();
+ auto caption = _caption.lock ();
if (!content || !caption) {
return;
}
int const item = _fonts->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- string const id = wx_to_std (_fonts->GetItemText (item, 0));
+ auto const id = wx_to_std (_fonts->GetItemText(item, 0));
shared_ptr<Font> font;
for (auto i: caption->fonts()) {
if (i->id() == id) {
default_dir = "/System/Library/Fonts";
#endif
- wxFileDialog* d = new wxFileDialog (this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf"), wxFD_CHANGE_DIR);
+ auto d = new wxFileDialog (this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf"), wxFD_CHANGE_DIR);
int const r = d->ShowModal ();
if (r != wxID_OK) {
/*
- Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/listctrl.h>
DCPOMATIC_ENABLE_WARNINGS
#include <boost/filesystem.hpp>
+
class Content;
class TextContent;
+
class FontsDialog : public wxDialog
{
public:
/*
- 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 "i18n_hook.h"
#include "instant_i18n_dialog.h"
#include "wx_util.h"
#include <wx/wx.h>
#include <boost/bind/bind.hpp>
+
using std::map;
using std::string;
#if BOOST_VERSION >= 106100
_window->Bind (wxEVT_MIDDLE_DOWN, bind(&I18NHook::handle, this, _1));
}
+
void
I18NHook::handle (wxMouseEvent& ev)
{
- InstantI18NDialog* d = new InstantI18NDialog (_window, get_text());
+ auto d = new InstantI18NDialog (_window, get_text());
d->ShowModal();
set_text (d->get());
d->Destroy ();
- wxWindow* w = _window;
+ auto w = _window;
while (w) {
if (w->GetContainingSizer()) {
w->GetContainingSizer()->Layout();
/*
- 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.
*/
+
#ifndef DCPOMATIC_I18N_HOOK_H
#define DCPOMATIC_I18N_HOOK_H
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
DCPOMATIC_ENABLE_WARNINGS
#include <map>
+
class I18NHook
{
public:
static std::map<std::string, std::string> _translations;
};
+
#endif
/*
- 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 "screen_dialog.h"
-#include "wx_util.h"
+
+#include "dcpomatic_button.h"
+#include "download_certificate_dialog.h"
#include "file_dialog_wrapper.h"
+#include "screen_dialog.h"
#include "static_text.h"
-#include "download_certificate_dialog.h"
#include "table_dialog.h"
-#include "dcpomatic_button.h"
+#include "wx_util.h"
#include "lib/compose.hpp"
#include "lib/util.h"
#include "lib/warnings.h"
DCPOMATIC_ENABLE_WARNINGS
#include <iostream>
+
using std::string;
using std::cout;
using std::vector;
using namespace boost::placeholders;
#endif
-static string
-column (TrustedDevice d)
-{
- return d.thumbprint ();
-}
class TrustedDeviceDialog : public TableDialog
{
void load_certificate ()
{
- wxFileDialog* d = new wxFileDialog (this, _("Trusted Device certificate"));
+ auto d = new wxFileDialog (this, _("Trusted Device certificate"));
if (d->ShowModal() == wxID_OK) {
try {
_certificate = dcp::Certificate(dcp::file_to_string(wx_to_std(d->GetPath())));
optional<TrustedDevice> get ()
{
- string const t = wx_to_std (_thumbprint->GetValue ());
+ auto const t = wx_to_std (_thumbprint->GetValue());
if (_certificate && _certificate->thumbprint() == t) {
return TrustedDevice (*_certificate);
} else if (t.length() == 28) {
return TrustedDevice (t);
}
- return optional<TrustedDevice> ();
+ return {};
}
private:
boost::optional<dcp::Certificate> _certificate;
};
+
ScreenDialog::ScreenDialog (
wxWindow* parent, wxString title, string name, string notes, optional<dcp::Certificate> recipient, vector<TrustedDevice> trusted_devices
)
, _recipient (recipient)
, _trusted_devices (trusted_devices)
{
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (overall_sizer);
_sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
int r = 0;
- add_label_to_sizer (_sizer, this, _("Name"), true, wxGBPosition (r, 0));
+ add_label_to_sizer (_sizer, this, _("Name"), true, wxGBPosition(r, 0));
_name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (320, -1));
_sizer->Add (_name, wxGBPosition (r, 1));
++r;
- add_label_to_sizer (_sizer, this, _("Notes"), true, wxGBPosition (r, 0));
- _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx (notes), wxDefaultPosition, wxSize (320, -1));
- _sizer->Add (_notes, wxGBPosition (r, 1));
+ add_label_to_sizer (_sizer, this, _("Notes"), true, wxGBPosition(r, 0));
+ _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx(notes), wxDefaultPosition, wxSize(320, -1));
+ _sizer->Add (_notes, wxGBPosition(r, 1));
++r;
wxClientDC dc (this);
wxFont font = _name->GetFont ();
font.SetFamily (wxFONTFAMILY_TELETYPE);
dc.SetFont (font);
- wxSize size = dc.GetTextExtent (wxT ("1234567890123456789012345678"));
+ wxSize size = dc.GetTextExtent (wxT("1234567890123456789012345678"));
size.SetHeight (-1);
- add_label_to_sizer (_sizer, this, _("Recipient certificate"), true, wxGBPosition (r, 0));
+ add_label_to_sizer (_sizer, this, _("Recipient certificate"), true, wxGBPosition(r, 0));
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
_recipient_thumbprint = new StaticText (this, wxT (""), wxDefaultPosition, size);
_recipient_thumbprint->SetFont (font);
columns,
bind (&ScreenDialog::trusted_devices, this),
bind (&ScreenDialog::set_trusted_devices, this, _1),
- bind (&column, _1),
+ [] (TrustedDevice const& d, int) {
+ return d.thumbprint();
+ },
false
);
setup_sensitivity ();
}
+
string
ScreenDialog::name () const
{
return wx_to_std (_name->GetValue());
}
+
string
ScreenDialog::notes () const
{
return wx_to_std (_notes->GetValue());
}
+
optional<dcp::Certificate>
ScreenDialog::recipient () const
{
return _recipient;
}
+
void
ScreenDialog::load_recipient (boost::filesystem::path file)
{
try {
/* Load this as a chain, in case it is one, and then pick the leaf certificate */
- dcp::CertificateChain c (dcp::file_to_string (file));
+ dcp::CertificateChain c (dcp::file_to_string(file));
if (c.unordered().empty()) {
error_dialog (this, _("Could not read certificate file."));
return;
}
}
+
void
ScreenDialog::get_recipient_from_file ()
{
- wxFileDialog* d = new wxFileDialog (this, _("Select Certificate File"));
- if (d->ShowModal () == wxID_OK) {
- load_recipient (boost::filesystem::path (wx_to_std (d->GetPath ())));
+ auto d = new wxFileDialog (this, _("Select Certificate File"));
+ if (d->ShowModal() == wxID_OK) {
+ load_recipient (boost::filesystem::path(wx_to_std(d->GetPath())));
}
d->Destroy ();
setup_sensitivity ();
}
+
void
ScreenDialog::download_recipient ()
{
- DownloadCertificateDialog* d = new DownloadCertificateDialog (this);
+ auto d = new DownloadCertificateDialog (this);
if (d->ShowModal() == wxID_OK) {
- set_recipient (d->certificate ());
+ set_recipient (d->certificate());
}
d->Destroy ();
setup_sensitivity ();
}
+
void
ScreenDialog::setup_sensitivity ()
{
- wxButton* ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
+ auto ok = dynamic_cast<wxButton*> (FindWindowById(wxID_OK, this));
if (ok) {
ok->Enable (static_cast<bool>(_recipient) && !_name->GetValue().IsEmpty());
}
}
+
void
ScreenDialog::set_recipient (optional<dcp::Certificate> r)
{
/*
- 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 "editable_list.h"
#include "lib/screen.h"
#include <dcp/certificate.h>
#include <wx/wx.h>
#include <boost/optional.hpp>
+
class Progress;
class TrustedDeviceDialog;
+
class ScreenDialog : public wxDialog
{
public:
wxString,
std::string name = "",
std::string notes = "",
- boost::optional<dcp::Certificate> c = boost::optional<dcp::Certificate> (),
+ boost::optional<dcp::Certificate> c = boost::optional<dcp::Certificate>(),
std::vector<TrustedDevice> d = std::vector<TrustedDevice>()
);
/*
- 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 "system_font_dialog.h"
#include "wx_util.h"
#include <wx/listctrl.h>
#include <boost/filesystem.hpp>
#include <iostream>
+
using std::cout;
using std::string;
using boost::optional;
+
SystemFontDialog::SystemFontDialog (wxWindow* parent)
: wxDialog (parent, wxID_ANY, _("Choose a font"))
{
- wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
boost::filesystem::path fonts = "c:\\Windows\\Fonts";
- char* windir = getenv ("windir");
+ auto windir = getenv ("windir");
if (windir) {
fonts = boost::filesystem::path (windir) / "Fonts";
}
- for (
- boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (fonts);
- i != boost::filesystem::directory_iterator ();
- ++i
- ) {
-
- string ext = i->path().extension().string ();
+ for (auto i: boost::filesystem::directory_iterator (fonts)) {
+ auto ext = i.path().extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
if (ext == ".ttf") {
- _fonts.push_back (i->path());
+ _fonts.push_back (i.path());
}
}
- sort (_fonts.begin (), _fonts.end ());
+ sort (_fonts.begin(), _fonts.end());
_list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
_list->InsertColumn (0, wxT (""));
_list->InsertItem (n++, std_to_wx (i.leaf().stem().string ()));
}
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
if (buttons) {
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
setup_sensitivity ();
}
+
optional<boost::filesystem::path>
SystemFontDialog::get_font () const
{
int const s = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (s == -1) {
- return optional<boost::filesystem::path> ();
+ return {};
}
- if (s < int (_fonts.size ())) {
+ if (s < int(_fonts.size())) {
return _fonts[s];
}
- return optional<boost::filesystem::path> ();
+ return {};
}
+
void
SystemFontDialog::setup_sensitivity ()
{
- wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+ auto ok = dynamic_cast<wxButton *> (FindWindowById(wxID_OK, this));
if (ok) {
ok->Enable (_list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -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.
*/
+
/** @class SystemFontDialog
* @brief A dialog box to select one of the "system" fonts on Windows.
*
* one of those fonts.
*/
+
#include "lib/warnings.h"
DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <boost/optional.hpp>
#include <vector>
+
class wxListCtrl;
+
class SystemFontDialog : public wxDialog
{
public:
/*
- 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_mapping_test.cc
* @brief Test AudioMapping class.
* @ingroup selfcontained
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/audio_mapping.h"
#include "lib/util.h"
+
using std::list;
using std::string;
using boost::optional;
+
BOOST_AUTO_TEST_CASE (audio_mapping_test)
{
AudioMapping none;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < MAX_DCP_AUDIO_CHANNELS; ++j) {
- BOOST_CHECK_EQUAL (four.get (i, j), (i == 0 && j == 1) ? 1 : 0);
+ BOOST_CHECK_EQUAL (four.get(i, j), (i == 0 && j == 1) ? 1 : 0);
}
}
- list<int> mapped = four.mapped_output_channels ();
+ auto mapped = four.mapped_output_channels ();
BOOST_CHECK_EQUAL (mapped.size(), 1U);
BOOST_CHECK_EQUAL (mapped.front(), 1);
}
}
+
static void
-guess_check (string filename, int output_channel)
+guess_check (boost::filesystem::path filename, int output_channel)
{
AudioMapping m (1, 8);
- m.make_default (0, optional<boost::filesystem::path>(filename));
+ m.make_default (0, filename);
for (int i = 0; i < 8; ++i) {
BOOST_TEST_INFO (filename);
BOOST_CHECK_CLOSE (m.get(0, i), i == output_channel ? 1 : 0, 0.01);
}
}
+
BOOST_AUTO_TEST_CASE (audio_mapping_guess_test)
{
guess_check ("stuff_L_nonsense.wav", 0);
/*
- 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 "lib/datasat_ap2x.h"
#include "lib/dolby_cp750.h"
#include "lib/usl.h"
-#include "lib/datasat_ap2x.h"
#include <boost/test/unit_test.hpp>
+
BOOST_AUTO_TEST_CASE (dolby_cp750_test)
{
DolbyCP750 ap;
BOOST_CHECK_CLOSE (ap.db_for_fader_change(6, 3), -(20 + 6.66666666666666666), 0.1);
}
+
BOOST_AUTO_TEST_CASE (usl_test)
{
USL ap;
BOOST_CHECK_CLOSE (ap.db_for_fader_change(6, 3), -(2.5 * 10 + 0.5 * 3.333333333333333333), 0.1);
}
+
BOOST_AUTO_TEST_CASE (datasat_ap2x_test)
{
DatasatAP2x ap;
/*
- 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.
*/
+
/** @file test/colour_conversion_test.cc
* @brief Test ColourConversion class.
* @ingroup selfcontained
*/
+
#include "lib/colour_conversion.h"
#include "lib/film.h"
#include <dcp/gamma_transfer_function.h>
#include <boost/test/unit_test.hpp>
#include <iostream>
+
using std::cout;
+using std::make_shared;
using std::shared_ptr;
+
BOOST_AUTO_TEST_CASE (colour_conversion_test1)
{
- ColourConversion A (dcp::ColourConversion::srgb_to_xyz ());
- ColourConversion B (dcp::ColourConversion::rec709_to_xyz ());
+ ColourConversion A (dcp::ColourConversion::srgb_to_xyz());
+ ColourConversion B (dcp::ColourConversion::rec709_to_xyz());
BOOST_CHECK_EQUAL (A.identifier(), "9840c601d2775bf1b3847254bbaa36a9");
BOOST_CHECK_EQUAL (B.identifier(), "58151ac92fdf333663a62c9a8ba5c5f4");
}
+
BOOST_AUTO_TEST_CASE (colour_conversion_test2)
{
ColourConversion A (dcp::ColourConversion::srgb_to_xyz ());
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("Test");
+ auto root = doc.create_root_node ("Test");
A.as_xml (root);
BOOST_CHECK_EQUAL (
doc.write_to_string_formatted ("UTF-8"),
);
}
+
BOOST_AUTO_TEST_CASE (colour_conversion_test3)
{
- ColourConversion A (dcp::ColourConversion::rec709_to_xyz ());
+ ColourConversion A (dcp::ColourConversion::rec709_to_xyz());
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("Test");
+ auto root = doc.create_root_node ("Test");
A.as_xml (root);
BOOST_CHECK_EQUAL (
doc.write_to_string_formatted ("UTF-8"),
);
}
+
/** Test a round trip via the XML representation */
BOOST_AUTO_TEST_CASE (colour_conversion_test4)
{
- for (auto const& i: PresetColourConversion::all ()) {
+ for (auto const& i: PresetColourConversion::all()) {
xmlpp::Document out;
- xmlpp::Element* out_root = out.create_root_node ("Test");
+ auto out_root = out.create_root_node("Test");
i.conversion.as_xml (out_root);
- shared_ptr<cxml::Document> in (new cxml::Document ("Test"));
- in->read_string (out.write_to_string ("UTF-8"));
- BOOST_CHECK (ColourConversion::from_xml (in, Film::current_state_version).get () == i.conversion);
+ auto in = make_shared<cxml::Document> ("Test");
+ in->read_string (out.write_to_string("UTF-8"));
+ BOOST_CHECK (ColourConversion::from_xml(in, Film::current_state_version).get() == i.conversion);
}
}
/*
- 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/film.h"
+
#include "lib/butler.h"
-#include "lib/player.h"
#include "lib/dcp_content.h"
+#include "lib/film.h"
+#include "lib/player.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+
+using std::make_shared;
using std::pair;
using std::shared_ptr;
using boost::optional;
#endif
using namespace dcpomatic;
+
/** Simulate the work that the player does, for profiling */
BOOST_AUTO_TEST_CASE (dcp_playback_test)
{
- shared_ptr<Film> film = new_test_film ("dcp_playback_test");
- shared_ptr<DCPContent> content (new DCPContent(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV"));
+ auto film = new_test_film ("dcp_playback_test");
+ auto content = make_shared<DCPContent>(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV");
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Butler> butler (
- new Butler(
- film,
- shared_ptr<Player>(new Player(film)),
- AudioMapping(6, 6),
- 6,
- bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
- VideoRange::FULL,
- false,
- true)
+ auto butler = std::make_shared<Butler>(
+ film,
+ shared_ptr<Player>(new Player(film)),
+ AudioMapping(6, 6),
+ 6,
+ bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
+ VideoRange::FULL,
+ false,
+ true
);
- float* audio_buffer = new float[2000*6];
+
+ auto audio_buffer = new float[2000 * 6];
while (true) {
- pair<shared_ptr<PlayerVideo>, DCPTime> p = butler->get_video (true, 0);
+ auto p = butler->get_video (true, 0);
if (!p.first) {
break;
}
/*
- 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/file_group_test.cc
* @brief Test FileGroup class.
* @ingroup selfcontained
*/
-#include <stdint.h>
-#include <cstdio>
+
+#include "lib/file_group.h"
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
-#include "lib/file_group.h"
+#include <stdint.h>
+#include <cstdio>
+
using std::vector;
+
BOOST_AUTO_TEST_CASE (file_group_test)
{
/* Random data; must be big enough for all the files */
total_length += length[i];
}
- vector<boost::filesystem::path> name;
boost::filesystem::create_directories ("build/test/file_group_test");
- name.push_back ("build/test/file_group_test/A");
- name.push_back ("build/test/file_group_test/B");
- name.push_back ("build/test/file_group_test/C");
- name.push_back ("build/test/file_group_test/D");
+ vector<boost::filesystem::path> name = {
+ "build/test/file_group_test/A",
+ "build/test/file_group_test/B",
+ "build/test/file_group_test/C",
+ "build/test/file_group_test/D"
+ };
int base = 0;
for (int i = 0; i < num_files; ++i) {
- FILE* f = fopen (name[i].string().c_str(), "wb");
+ auto f = fopen (name[i].string().c_str(), "wb");
fwrite (data + base, 1, length[i], f);
fclose (f);
base += length[i];
int pos = 0;
/* Basic read from 0 */
- BOOST_CHECK_EQUAL (fg.read (test, 64), 64);
- BOOST_CHECK_EQUAL (memcmp (data, test, 64), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, 64), 64);
+ BOOST_CHECK_EQUAL (memcmp(data, test, 64), 0);
pos += 64;
/* Another read following the previous */
- BOOST_CHECK_EQUAL (fg.read (test, 4), 4);
- BOOST_CHECK_EQUAL (memcmp (data + pos, test, 4), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, 4), 4);
+ BOOST_CHECK_EQUAL (memcmp(data + pos, test, 4), 0);
pos += 4;
/* Read overlapping A and B */
- BOOST_CHECK_EQUAL (fg.read (test, 128), 128);
- BOOST_CHECK_EQUAL (memcmp (data + pos, test, 128), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, 128), 128);
+ BOOST_CHECK_EQUAL (memcmp(data + pos, test, 128), 0);
pos += 128;
/* Read overlapping B/C/D and over-reading by a lot */
- BOOST_CHECK_EQUAL (fg.read (test, total_length * 3), total_length - pos);
- BOOST_CHECK_EQUAL (memcmp (data + pos, test, total_length - pos), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, total_length * 3), total_length - pos);
+ BOOST_CHECK_EQUAL (memcmp(data + pos, test, total_length - pos), 0);
/* Over-read by a little */
- BOOST_CHECK_EQUAL (fg.seek (0, SEEK_SET), 0);
- BOOST_CHECK_EQUAL (fg.read (test, total_length), total_length);
- BOOST_CHECK_EQUAL (fg.read (test, 1), 0);
+ BOOST_CHECK_EQUAL (fg.seek(0, SEEK_SET), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, total_length), total_length);
+ BOOST_CHECK_EQUAL (fg.read(test, 1), 0);
/* Seeking off the end of the file should not give an error */
- BOOST_CHECK_EQUAL (fg.seek (total_length * 2, SEEK_SET), total_length * 2);
+ BOOST_CHECK_EQUAL (fg.seek(total_length * 2, SEEK_SET), total_length * 2);
/* and attempting to read should return nothing */
- BOOST_CHECK_EQUAL (fg.read (test, 64), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, 64), 0);
/* but the requested seek should be remembered, so if we now go back (relatively) */
- BOOST_CHECK_EQUAL (fg.seek (-total_length * 2, SEEK_CUR), 0);
+ BOOST_CHECK_EQUAL (fg.seek(-total_length * 2, SEEK_CUR), 0);
/* we should be at the start again */
- BOOST_CHECK_EQUAL (fg.read (test, 64), 64);
- BOOST_CHECK_EQUAL (memcmp (data, test, 64), 0);
+ BOOST_CHECK_EQUAL (fg.read(test, 64), 64);
+ BOOST_CHECK_EQUAL (memcmp(data, test, 64), 0);
/* SEEK_SET */
- BOOST_CHECK_EQUAL (fg.seek (999, SEEK_SET), 999);
- BOOST_CHECK_EQUAL (fg.read (test, 64), 64);
- BOOST_CHECK_EQUAL (memcmp (data + 999, test, 64), 0);
+ BOOST_CHECK_EQUAL (fg.seek(999, SEEK_SET), 999);
+ BOOST_CHECK_EQUAL (fg.read(test, 64), 64);
+ BOOST_CHECK_EQUAL (memcmp(data + 999, test, 64), 0);
/* SEEK_CUR */
- BOOST_CHECK_EQUAL (fg.seek (42, SEEK_CUR), 999 + 64 + 42);
- BOOST_CHECK_EQUAL (fg.read (test, 64), 64);
- BOOST_CHECK_EQUAL (memcmp (data + 999 + 64 + 42, test, 64), 0);
+ BOOST_CHECK_EQUAL (fg.seek(42, SEEK_CUR), 999 + 64 + 42);
+ BOOST_CHECK_EQUAL (fg.read(test, 64), 64);
+ BOOST_CHECK_EQUAL (memcmp(data + 999 + 64 + 42, test, 64), 0);
/* SEEK_END */
- BOOST_CHECK_EQUAL (fg.seek (1077, SEEK_END), total_length - 1077);
- BOOST_CHECK_EQUAL (fg.read (test, 256), 256);
- BOOST_CHECK_EQUAL (memcmp (data + total_length - 1077, test, 256), 0);
+ BOOST_CHECK_EQUAL (fg.seek(1077, SEEK_END), total_length - 1077);
+ BOOST_CHECK_EQUAL (fg.read(test, 256), 256);
+ BOOST_CHECK_EQUAL (memcmp(data + total_length - 1077, test, 256), 0);
}
/*
- 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/file_log_test.cc
* @brief Test FileLog.
* @ingroup selfcontained
*/
+
#include "lib/file_log.h"
#include <boost/test/unit_test.hpp>
-#include <iostream>
-using std::cout;
BOOST_AUTO_TEST_CASE (file_log_test)
{
FileLog log ("test/data/short.log");
- BOOST_CHECK_EQUAL (log.head_and_tail (1024), "This is a short log.\nWith only two lines.\n");
- BOOST_CHECK_EQUAL (log.head_and_tail (8), "This is \n .\n .\n .\no lines.\n");
+ BOOST_CHECK_EQUAL (log.head_and_tail(1024), "This is a short log.\nWith only two lines.\n");
+ BOOST_CHECK_EQUAL (log.head_and_tail(8), "This is \n .\n .\n .\no lines.\n");
}
/*
- Copyright (C) 2015-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/image_filename_sorter_test.cc
* @brief Test ImageFilenameSorter
* @ingroup selfcontained
*/
+
#include "lib/image_filename_sorter.h"
#include "lib/compose.hpp"
#include <boost/test/unit_test.hpp>
+
using std::random_shuffle;
using std::sort;
using std::vector;
+
BOOST_AUTO_TEST_CASE (image_filename_sorter_test1)
{
ImageFilenameSorter x;
- BOOST_CHECK (x ("abc0000000001", "abc0000000002"));
- BOOST_CHECK (x ("1", "2"));
- BOOST_CHECK (x ("1", "0002"));
- BOOST_CHECK (x ("0001", "2"));
- BOOST_CHECK (x ("1", "999"));
- BOOST_CHECK (x ("00057.tif", "00166.tif"));
- BOOST_CHECK (x ("/my/numeric999/path/00057.tif", "/my/numeric999/path/00166.tif"));
- BOOST_CHECK (x ("1_01.tif", "1_02.tif"));
- BOOST_CHECK (x ("EWS_DCP_092815_000000.j2c", "EWS_DCP_092815_000001.j2c"));
- BOOST_CHECK (x ("ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86352.dpx", "ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86353.dpx"));
-
- BOOST_CHECK (!x ("abc0000000002", "abc0000000001"));
- BOOST_CHECK (!x ("2", "1"));
- BOOST_CHECK (!x ("0002", "1"));
- BOOST_CHECK (!x ("2", "0001"));
- BOOST_CHECK (!x ("999", "1"));
- BOOST_CHECK (!x ("/my/numeric999/path/00166.tif", "/my/numeric999/path/00057.tif"));
- BOOST_CHECK (!x ("1_02.tif", "1_01.tif"));
- BOOST_CHECK (!x ("EWS_DCP_092815_000000.j2c", "EWS_DCP_092815_000000.j2c"));
- BOOST_CHECK (!x ("EWS_DCP_092815_000100.j2c", "EWS_DCP_092815_000000.j2c"));
- BOOST_CHECK (!x ("ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86353.dpx", "ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86352.dpx"));
+ BOOST_CHECK (x("abc0000000001", "abc0000000002"));
+ BOOST_CHECK (x("1", "2"));
+ BOOST_CHECK (x("1", "0002"));
+ BOOST_CHECK (x("0001", "2"));
+ BOOST_CHECK (x("1", "999"));
+ BOOST_CHECK (x("00057.tif", "00166.tif"));
+ BOOST_CHECK (x("/my/numeric999/path/00057.tif", "/my/numeric999/path/00166.tif"));
+ BOOST_CHECK (x("1_01.tif", "1_02.tif"));
+ BOOST_CHECK (x("EWS_DCP_092815_000000.j2c", "EWS_DCP_092815_000001.j2c"));
+ BOOST_CHECK (x("ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86352.dpx", "ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86353.dpx"));
+
+ BOOST_CHECK (!x("abc0000000002", "abc0000000001"));
+ BOOST_CHECK (!x("2", "1"));
+ BOOST_CHECK (!x("0002", "1"));
+ BOOST_CHECK (!x("2", "0001"));
+ BOOST_CHECK (!x("999", "1"));
+ BOOST_CHECK (!x("/my/numeric999/path/00166.tif", "/my/numeric999/path/00057.tif"));
+ BOOST_CHECK (!x("1_02.tif", "1_01.tif"));
+ BOOST_CHECK (!x("EWS_DCP_092815_000000.j2c", "EWS_DCP_092815_000000.j2c"));
+ BOOST_CHECK (!x("EWS_DCP_092815_000100.j2c", "EWS_DCP_092815_000000.j2c"));
+ BOOST_CHECK (!x("ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86353.dpx", "ap_trlr_178_uhd_bt1886_txt_e5c1_033115.86352.dpx"));
}
+
/** Test a sort of a lot of paths. Mostly useful for profiling. */
BOOST_AUTO_TEST_CASE (image_filename_sorter_test2)
{
/*
- 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/test/unit_test.hpp>
+using std::make_shared;
using std::shared_ptr;
/* The files don't matter here, we just need some data to compare */
{
- shared_ptr<J2KImageProxy> proxy1(new J2KImageProxy(data_file0, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48));
- shared_ptr<J2KImageProxy> proxy2(new J2KImageProxy(data_file0, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48));
+ auto proxy1 = make_shared<J2KImageProxy>(data_file0, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48);
+ auto proxy2 = make_shared<J2KImageProxy>(data_file0, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48);
BOOST_CHECK (proxy1->same(proxy2));
}
{
- shared_ptr<J2KImageProxy> proxy1(new J2KImageProxy(data_file0, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48));
- shared_ptr<J2KImageProxy> proxy2(new J2KImageProxy(data_file1, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48));
+ auto proxy1 = make_shared<J2KImageProxy>(data_file0, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48);
+ auto proxy2 = make_shared<J2KImageProxy>(data_file1, dcp::Size(1998, 1080), AV_PIX_FMT_RGB48);
BOOST_CHECK (!proxy1->same(proxy2));
}
}
BOOST_AUTO_TEST_CASE (ffmpeg_image_proxy_same_test)
{
{
- shared_ptr<FFmpegImageProxy> proxy1(new FFmpegImageProxy(data_file0, VideoRange::FULL));
- shared_ptr<FFmpegImageProxy> proxy2(new FFmpegImageProxy(data_file0, VideoRange::FULL));
+ auto proxy1 = make_shared<FFmpegImageProxy>(data_file0, VideoRange::FULL);
+ auto proxy2 = make_shared<FFmpegImageProxy>(data_file0, VideoRange::FULL);
BOOST_CHECK (proxy1->same(proxy2));
}
{
- shared_ptr<FFmpegImageProxy> proxy1(new FFmpegImageProxy(data_file0, VideoRange::FULL));
- shared_ptr<FFmpegImageProxy> proxy2(new FFmpegImageProxy(data_file1, VideoRange::FULL));
+ auto proxy1 = make_shared<FFmpegImageProxy>(data_file0, VideoRange::FULL);
+ auto proxy2 = make_shared<FFmpegImageProxy>(data_file1, VideoRange::FULL);
BOOST_CHECK (!proxy1->same(proxy2));
}
}
/*
- 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/interrupt_encoder_test.cc
* @brief Test clean shutdown of threads if a DCP encode is interrupted.
* @ingroup feature
*/
-#include "lib/film.h"
+
+#include "lib/audio_content.h"
+#include "lib/cross.h"
#include "lib/dcp_content_type.h"
-#include "lib/ratio.h"
#include "lib/ffmpeg_content.h"
-#include "lib/audio_content.h"
+#include "lib/film.h"
#include "lib/job_manager.h"
-#include "lib/cross.h"
+#include "lib/ratio.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+
+using std::make_shared;
using std::shared_ptr;
+
/** Interrupt a DCP encode when it is in progress, as this used to (still does?)
* sometimes give an error related to pthreads.
*/
BOOST_AUTO_TEST_CASE (interrupt_encoder_test)
{
- shared_ptr<Film> film = new_test_film ("interrupt_encoder_test");
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
- film->set_container (Ratio::from_id ("185"));
+ auto film = new_test_film ("interrupt_encoder_test");
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR"));
+ film->set_container (Ratio::from_id("185"));
film->set_name ("interrupt_encoder_test");
- shared_ptr<FFmpegContent> content (new FFmpegContent(TestPaths::private_data() / "prophet_long_clip.mkv"));
+ auto content = make_shared<FFmpegContent>(TestPaths::private_data() / "prophet_long_clip.mkv");
film->examine_and_add_content (content);
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.
*/
+
#include "lib/cinema.h"
-#include "lib/screen.h"
#include "lib/config.h"
#include "lib/content_factory.h"
#include "lib/film.h"
#include "lib/kdm_with_metadata.h"
+#include "lib/screen.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+using std::dynamic_pointer_cast;
using std::list;
+using std::make_shared;
+using std::shared_ptr;
using std::string;
using std::vector;
-using std::shared_ptr;
using boost::optional;
-using std::dynamic_pointer_cast;
+
static
bool
return true;
}
+
static shared_ptr<dcpomatic::Screen> cinema_a_screen_1;
static shared_ptr<dcpomatic::Screen> cinema_a_screen_2;
static shared_ptr<dcpomatic::Screen> cinema_b_screen_x;
static shared_ptr<dcpomatic::Screen> cinema_b_screen_y;
static shared_ptr<dcpomatic::Screen> cinema_b_screen_z;
+
BOOST_AUTO_TEST_CASE (single_kdm_naming_test)
{
- Config* c = Config::instance();
+ auto c = Config::instance();
- dcp::Certificate cert = c->decryption_chain()->leaf();
+ auto cert = c->decryption_chain()->leaf();
/* Cinema A: UTC +4:30 */
- shared_ptr<Cinema> cinema_a (new Cinema("Cinema A", list<string>(), "", 4, 30));
- cinema_a_screen_1.reset(new dcpomatic::Screen("Screen 1", "", cert, vector<TrustedDevice>()));
+ auto cinema_a = make_shared<Cinema>("Cinema A", list<string>(), "", 4, 30);
+ cinema_a_screen_1 = make_shared<dcpomatic::Screen>("Screen 1", "", cert, vector<TrustedDevice>());
cinema_a->add_screen (cinema_a_screen_1);
- cinema_a_screen_2.reset(new dcpomatic::Screen("Screen 2", "", cert, vector<TrustedDevice>()));
+ cinema_a_screen_2 = make_shared<dcpomatic::Screen>("Screen 2", "", cert, vector<TrustedDevice>());
cinema_a->add_screen (cinema_a_screen_2);
c->add_cinema (cinema_a);
/* Cinema B: UTC -1:00 */
- shared_ptr<Cinema> cinema_b (new Cinema("Cinema B", list<string>(), "", -1, 0));
- cinema_b_screen_x.reset(new dcpomatic::Screen("Screen X", "", cert, vector<TrustedDevice>()));
+ auto cinema_b = make_shared<Cinema>("Cinema B", list<string>(), "", -1, 0);
+ cinema_b_screen_x = make_shared<dcpomatic::Screen>("Screen X", "", cert, vector<TrustedDevice>());
cinema_b->add_screen (cinema_b_screen_x);
- cinema_b_screen_y.reset(new dcpomatic::Screen("Screen Y", "", cert, vector<TrustedDevice>()));
+ cinema_b_screen_y = make_shared<dcpomatic::Screen>("Screen Y", "", cert, vector<TrustedDevice>());
cinema_b->add_screen (cinema_b_screen_y);
- cinema_b_screen_z.reset(new dcpomatic::Screen("Screen Z", "", cert, vector<TrustedDevice>()));
+ cinema_b_screen_z = make_shared<dcpomatic::Screen>("Screen Z", "", cert, vector<TrustedDevice>());
cinema_b->add_screen (cinema_b_screen_z);
c->add_cinema (cinema_a);
/* Film */
boost::filesystem::remove_all ("build/test/single_kdm_naming_test");
- shared_ptr<Film> film = new_test_film2 ("single_kdm_naming_test");
+ auto film = new_test_film2 ("single_kdm_naming_test");
film->set_name ("my_great_film");
film->examine_and_add_content (content_factory("test/data/flat_black.png").front());
BOOST_REQUIRE (!wait_for_jobs());
dcp::LocalTime until (cert.not_after());
until.add_months (-2);
- string const from_string = from.date() + " " + from.time_of_day(true, false);
- string const until_string = until.date() + " " + until.time_of_day(true, false);
+ auto const from_string = from.date() + " " + from.time_of_day(true, false);
+ auto const until_string = until.date() + " " + until.time_of_day(true, false);
auto cpl = cpls.front().cpl_file;
auto kdm = kdm_for_screen (
&confirm_overwrite
);
- string from_time = from.time_of_day (true, false);
+ auto from_time = from.time_of_day (true, false);
boost::algorithm::replace_all (from_time, ":", "-");
- string until_time = until.time_of_day (true, false);
+ auto until_time = until.time_of_day (true, false);
boost::algorithm::replace_all (until_time, ":", "-");
- string const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
+ auto const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
BOOST_CHECK_MESSAGE (boost::filesystem::exists("build/test/single_kdm_naming_test/" + ref), "File " << ref << " not found");
}
{
using boost::filesystem::path;
- dcp::Certificate cert = Config::instance()->decryption_chain()->leaf();
+ auto cert = Config::instance()->decryption_chain()->leaf();
/* Film */
boost::filesystem::remove_all ("build/test/directory_kdm_naming_test");
/*
- 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) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/reel_writer_test.cc
* @brief Test ReelWriter class.
* @ingroup selfcontained
*/
-#include "lib/reel_writer.h"
-#include "lib/film.h"
-#include "lib/cross.h"
-#include "lib/content_factory.h"
-#include "lib/content.h"
+
#include "lib/audio_content.h"
+#include "lib/content.h"
+#include "lib/content_factory.h"
+#include "lib/cross.h"
+#include "lib/film.h"
+#include "lib/reel_writer.h"
#include "lib/video_content.h"
#include "test.h"
#include <dcp/dcp.h>
#include <dcp/reel_sound_asset.h>
#include <boost/test/unit_test.hpp>
-using std::string;
+
using std::shared_ptr;
+using std::string;
using boost::optional;
+
static bool equal (dcp::FrameInfo a, ReelWriter const & writer, shared_ptr<InfoFileHandle> file, Frame frame, Eyes eyes)
{
- dcp::FrameInfo b = writer.read_frame_info(file, frame, eyes);
+ auto b = writer.read_frame_info(file, frame, eyes);
return a.offset == b.offset && a.size == b.size && a.hash == b.hash;
}
+
BOOST_AUTO_TEST_CASE (write_frame_info_test)
{
auto film = new_test_film2 ("write_frame_info_test");
}
}
+
/** Check that the reel writer correctly re-uses a video asset changed if we remake
* a DCP with no video changes.
*/
BOOST_AUTO_TEST_CASE (reel_reuse_video_test)
{
/* Make a DCP */
- auto film = new_test_film2 ("reel_reuse_video_test");
auto video = content_factory("test/data/flat_red.png").front();
- film->examine_and_add_content (video);
- BOOST_REQUIRE (!wait_for_jobs());
auto audio = content_factory("test/data/white.wav").front();
- film->examine_and_add_content (audio);
- BOOST_REQUIRE (!wait_for_jobs());
+ auto film = new_test_film2 ("reel_reuse_video_test", { video, audio });
make_and_verify_dcp (film);
/* Find main picture and sound asset IDs */
dcp::DCP dcp1 (film->dir(film->dcp_name()));
dcp1.read ();
BOOST_REQUIRE_EQUAL (dcp1.cpls().size(), 1U);
- BOOST_REQUIRE_EQUAL (dcp1.cpls().front()->reels().size(), 1U);
- BOOST_REQUIRE (dcp1.cpls().front()->reels().front()->main_picture());
- BOOST_REQUIRE (dcp1.cpls().front()->reels().front()->main_sound());
- string const picture_id = dcp1.cpls().front()->reels().front()->main_picture()->asset()->id();
- string const sound_id = dcp1.cpls().front()->reels().front()->main_sound()->asset()->id();
+ BOOST_REQUIRE_EQUAL (dcp1.cpls()[0]->reels().size(), 1U);
+ BOOST_REQUIRE (dcp1.cpls()[0]->reels()[0]->main_picture());
+ BOOST_REQUIRE (dcp1.cpls()[0]->reels()[0]->main_sound());
+ auto const picture_id = dcp1.cpls()[0]->reels()[0]->main_picture()->asset()->id();
+ auto const sound_id = dcp1.cpls()[0]->reels()[0]->main_sound()->asset()->id();
/* Change the audio and re-make */
audio->audio->set_gain (-3);
dcp::DCP dcp2 (film->dir(film->dcp_name()));
dcp2.read ();
BOOST_REQUIRE_EQUAL (dcp2.cpls().size(), 1U);
- BOOST_REQUIRE_EQUAL (dcp2.cpls().front()->reels().size(), 1U);
- BOOST_REQUIRE (dcp2.cpls().front()->reels().front()->main_picture());
- BOOST_REQUIRE (dcp2.cpls().front()->reels().front()->main_sound());
- BOOST_CHECK_EQUAL (picture_id, dcp2.cpls().front()->reels().front()->main_picture()->asset()->id());
- BOOST_CHECK (sound_id != dcp2.cpls().front()->reels().front()->main_sound()->asset()->id());
+ BOOST_REQUIRE_EQUAL (dcp2.cpls()[0]->reels().size(), 1U);
+ BOOST_REQUIRE (dcp2.cpls()[0]->reels()[0]->main_picture());
+ BOOST_REQUIRE (dcp2.cpls()[0]->reels()[0]->main_sound());
+ BOOST_CHECK_EQUAL (picture_id, dcp2.cpls()[0]->reels()[0]->main_picture()->asset()->id());
+ BOOST_CHECK (sound_id != dcp2.cpls()[0]->reels().front()->main_sound()->asset()->id());
/* Crop video and re-make */
video->video->set_left_crop (5);
dcp::DCP dcp3 (film->dir(film->dcp_name()));
dcp3.read ();
BOOST_REQUIRE_EQUAL (dcp3.cpls().size(), 1U);
- BOOST_REQUIRE_EQUAL (dcp3.cpls().front()->reels().size(), 1U);
- BOOST_REQUIRE (dcp3.cpls().front()->reels().front()->main_picture());
- BOOST_REQUIRE (dcp3.cpls().front()->reels().front()->main_sound());
- BOOST_CHECK (picture_id != dcp3.cpls().front()->reels().front()->main_picture()->asset()->id());
- BOOST_CHECK (sound_id != dcp3.cpls().front()->reels().front()->main_sound()->asset()->id());
+ BOOST_REQUIRE_EQUAL (dcp3.cpls()[0]->reels().size(), 1U);
+ BOOST_REQUIRE (dcp3.cpls()[0]->reels()[0]->main_picture());
+ BOOST_REQUIRE (dcp3.cpls()[0]->reels()[0]->main_sound());
+ BOOST_CHECK (picture_id != dcp3.cpls()[0]->reels()[0]->main_picture()->asset()->id());
+ BOOST_CHECK (sound_id != dcp3.cpls()[0]->reels().front()->main_sound()->asset()->id());
}
/*
- 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/resampler_test.cc
* @brief Check that the timings that come back from Resampler correspond
* to the number of samples it generates.
* @ingroup selfcontained
*/
-#include <boost/test/unit_test.hpp>
+
#include "lib/audio_buffers.h"
#include "lib/resampler.h"
+#include <boost/test/unit_test.hpp>
#include <iostream>
-using std::pair;
+
using std::cout;
+using std::make_shared;
+using std::pair;
using std::shared_ptr;
+
static void
resampler_test_one (int from, int to)
{
/* XXX: no longer checks anything */
for (int64_t i = 0; i < N; i += 1000) {
- shared_ptr<AudioBuffers> a (new AudioBuffers (1, 1000));
+ auto a = make_shared<AudioBuffers> (1, 1000);
a->make_silent ();
- pair<shared_ptr<const AudioBuffers>, Frame> r = resamp.run (a, 0);
+ auto r = resamp.run (a, 0);
}
}
+
BOOST_AUTO_TEST_CASE (resampler_test)
{
resampler_test_one (44100, 48000);
/*
- 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/server.h"
+
#include "lib/dcpomatic_socket.h"
+#include "lib/server.h"
#include <dcp/raw_convert.h>
-#include <boost/thread.hpp>
#include <boost/test/unit_test.hpp>
+#include <boost/thread.hpp>
#include <cstring>
#include <iostream>
-using std::string;
+using std::make_shared;
using std::shared_ptr;
+using std::string;
using boost::bind;
socket->write (reinterpret_cast<uint8_t const *>(message), strlen(message) + 1);
}
+
/** Basic test to see if Socket can send and receive data */
BOOST_AUTO_TEST_CASE (socket_basic_test)
{
tcp::resolver::query query ("127.0.0.1", dcp::raw_convert<string>(TEST_SERVER_PORT));
tcp::resolver::iterator endpoint_iterator = resolver.resolve (query);
- shared_ptr<Socket> socket (new Socket);
+ auto socket = make_shared<Socket>();
socket->connect (*endpoint_iterator);
send (socket, "Hello world!");
/*
- 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 "test.h"
+
#include "lib/content.h"
-#include "lib/film.h"
#include "lib/content_factory.h"
+#include "lib/film.h"
#include "lib/string_text_file.h"
#include "lib/string_text_file_content.h"
+#include "test.h"
#include <boost/test/unit_test.hpp>
+
using std::shared_ptr;
using std::dynamic_pointer_cast;
+
/** Test parsing of UTF16 CR/LF input */
BOOST_AUTO_TEST_CASE (subtitle_charset_test1)
{
- shared_ptr<Film> film = new_test_film2 ("subtitle_charset_test1");
- shared_ptr<Content> content = content_factory (TestPaths::private_data() / "PADDINGTON soustitresVFdef.srt").front();
- film->examine_and_add_content (content);
- BOOST_REQUIRE (!wait_for_jobs ());
+ auto content = content_factory (TestPaths::private_data() / "PADDINGTON soustitresVFdef.srt").front();
+ auto film = new_test_film2 ("subtitle_charset_test1", { content });
}
+
/** Test parsing of OSX input */
BOOST_AUTO_TEST_CASE (subtitle_charset_test2)
{
- shared_ptr<Film> film = new_test_film2 ("subtitle_charset_test2");
- shared_ptr<Content> content = content_factory ("test/data/osx.srt").front();
- film->examine_and_add_content (content);
- BOOST_REQUIRE (!wait_for_jobs ());
- shared_ptr<StringTextFileContent> ts = dynamic_pointer_cast<StringTextFileContent> (content);
+ auto content = content_factory ("test/data/osx.srt").front();
+ auto film = new_test_film2 ("subtitle_charset_test2", { content });
+ auto ts = dynamic_pointer_cast<StringTextFileContent> (content);
BOOST_REQUIRE (ts);
/* Make sure we got the subtitle data from the file */
BOOST_REQUIRE_EQUAL (content->full_length(film).get(), 6052032);
/*
- 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) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
/** @file test/upmixer_a_test.cc
* @brief Check the Upmixer A against some reference sound files.
* @ingroup selfcontained
*/
-#include <boost/test/unit_test.hpp>
-#include <sndfile.h>
-#include "lib/film.h"
-#include "lib/ratio.h"
+
+#include "lib/audio_buffers.h"
#include "lib/dcp_content_type.h"
#include "lib/ffmpeg_content.h"
+#include "lib/film.h"
#include "lib/player.h"
-#include "lib/audio_buffers.h"
+#include "lib/ratio.h"
#include "lib/upmixer_a.h"
#include "test.h"
+#include <sndfile.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;
+
static SNDFILE* L;
static SNDFILE* R;
static SNDFILE* C;
static SNDFILE* Ls;
static SNDFILE* Rs;
+
static void
write (shared_ptr<AudioBuffers> b, DCPTime)
{
}
+
BOOST_AUTO_TEST_CASE (upmixer_a_test)
{
- shared_ptr<Film> film = new_test_film ("upmixer_a_test");
- film->set_container (Ratio::from_id ("185"));
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ auto film = new_test_film ("upmixer_a_test");
+ film->set_container (Ratio::from_id("185"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
film->set_name ("frobozz");
- film->set_audio_processor (AudioProcessor::from_id ("stereo-5.1-upmix-a"));
- shared_ptr<FFmpegContent> content (new FFmpegContent ("test/data/white.wav"));
+ film->set_audio_processor (AudioProcessor::from_id("stereo-5.1-upmix-a"));
+ auto content = make_shared<FFmpegContent>("test/data/white.wav");
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
Ls = sf_open ("build/test/upmixer_a_test/Ls.wav", SFM_WRITE, &info);
Rs = sf_open ("build/test/upmixer_a_test/Rs.wav", SFM_WRITE, &info);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
player->Audio.connect (bind (&write, _1, _2));
while (!player->pass()) {}