/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
void
AudioContent::set_mapping (AudioMapping mapping)
{
- ContentChange cc (_parent, AudioContentProperty::STREAMS);
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
int c = 0;
BOOST_FOREACH (AudioStreamPtr i, streams ()) {
void
AudioContent::set_streams (vector<AudioStreamPtr> streams)
{
- ContentChange cc (_parent, AudioContentProperty::STREAMS);
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
{
boost::mutex::scoped_lock lm (_mutex);
void
AudioContent::add_stream (AudioStreamPtr stream)
{
- ContentChange cc (_parent, AudioContentProperty::STREAMS);
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
{
boost::mutex::scoped_lock lm (_mutex);
void
AudioContent::set_stream (AudioStreamPtr stream)
{
- ContentChange cc (_parent, AudioContentProperty::STREAMS);
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
{
boost::mutex::scoped_lock lm (_mutex);
--- /dev/null
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_CHANGE_H
+#define DCPOMATIC_CHANGE_H
+
+#include <boost/noncopyable.hpp>
+
+template <class T>
+class ChangeSignaller : public boost::noncopyable
+{
+public:
+ ChangeSignaller (T* t, int p)
+ : _thing (t)
+ , _property (p)
+ , _done (true)
+ {
+ _thing->signal_change (CHANGE_TYPE_PENDING, _property);
+ }
+
+ ~ChangeSignaller ()
+ {
+ if (_done) {
+ _thing->signal_change (CHANGE_TYPE_DONE, _property);
+ } else {
+ _thing->signal_change (CHANGE_TYPE_CANCELLED, _property);
+ }
+ }
+
+ void abort ()
+ {
+ _done = false;
+ }
+
+private:
+ T* _thing;
+ int _property;
+ bool _done;
+};
+
+#endif
*/
#include "content.h"
+#include "change_signaller.h"
#include "util.h"
#include "content_factory.h"
#include "video_content.h"
audio->modify_position (p);
}
- ContentChange cc (this, ContentProperty::POSITION);
+ ChangeSignaller<Content> cc (this, ContentProperty::POSITION);
{
boost::mutex::scoped_lock lm (_mutex);
audio->modify_trim_start (t);
}
- ContentChange cc (this, ContentProperty::TRIM_START);
+ ChangeSignaller<Content> cc (this, ContentProperty::TRIM_START);
{
boost::mutex::scoped_lock lm (_mutex);
void
Content::set_trim_end (ContentTime t)
{
- ContentChange cc (this, ContentProperty::TRIM_END);
+ ChangeSignaller<Content> cc (this, ContentProperty::TRIM_END);
{
boost::mutex::scoped_lock lm (_mutex);
void
Content::set_path (boost::filesystem::path path)
{
- ContentChange cc (this, ContentProperty::PATH);
+ ChangeSignaller<Content> cc (this, ContentProperty::PATH);
_paths.clear ();
_paths.push_back (path);
}
void
Content::set_paths (vector<boost::filesystem::path> paths)
{
- ContentChange cc (this, ContentProperty::PATH);
+ ChangeSignaller<Content> cc (this, ContentProperty::PATH);
_paths = paths;
}
void
Content::set_video_frame_rate (double r)
{
- ContentChange cc (this, ContentProperty::VIDEO_FRAME_RATE);
+ ChangeSignaller<Content> cc (this, ContentProperty::VIDEO_FRAME_RATE);
{
boost::mutex::scoped_lock lm (_mutex);
void
Content::unset_video_frame_rate ()
{
- ContentChange cc (this, ContentProperty::VIDEO_FRAME_RATE);
+ ChangeSignaller<Content> cc (this, ContentProperty::VIDEO_FRAME_RATE);
{
boost::mutex::scoped_lock lm (_mutex);
#include "types.h"
#include "signaller.h"
#include "dcpomatic_time.h"
+#include "change_signaller.h"
#include "user_property.h"
#include <libcxml/cxml.h>
#include <boost/filesystem.hpp>
friend struct best_dcp_frame_rate_test_single;
friend struct best_dcp_frame_rate_test_double;
friend struct audio_sampling_rate_test;
- friend class ContentChange;
+ template<class> friend class ChangeSignaller;
void signal_change (ChangeType, int);
+++ /dev/null
-/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- DCP-o-matic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "content_change.h"
-#include "content.h"
-
-ContentChange::ContentChange (Content* c, int p)
- : _content (c)
- , _property (p)
- , _done (true)
-{
- _content->signal_change (CHANGE_TYPE_PENDING, _property);
-}
-
-
-ContentChange::~ContentChange ()
-{
- if (_done) {
- _content->signal_change (CHANGE_TYPE_DONE, _property);
- } else {
- _content->signal_change (CHANGE_TYPE_CANCELLED, _property);
- }
-}
-
-void
-ContentChange::abort ()
-{
- _done = false;
-}
+++ /dev/null
-/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- DCP-o-matic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-class Content;
-
-class ContentChange
-{
-public:
- ContentChange (Content* c, int p);
- ~ContentChange ();
-
- void abort ();
-
-private:
- Content* _content;
- int _property;
- bool _done;
-};
#define DCPOMATIC_CONTENT_PART_H
#include "content.h"
-#include "content_change.h"
+#include "change_signaller.h"
#include <boost/weak_ptr.hpp>
#include <boost/thread/mutex.hpp>
void
maybe_set (T& member, T new_value, int property) const
{
- ContentChange cc (_parent, property);
+ ChangeSignaller<Content> cc (_parent, property);
{
boost::mutex::scoped_lock lm (_mutex);
if (member == new_value) {
void
maybe_set (boost::optional<T>& member, T new_value, int property) const
{
- ContentChange cc (_parent, property);
+ ChangeSignaller<Content> cc (_parent, property);
{
boost::mutex::scoped_lock lm (_mutex);
if (member && member.get() == new_value) {
string const old_name = name ();
int const old_texts = text.size ();
- ContentChange cc_texts (this, DCPContentProperty::TEXTS);
- ContentChange cc_assets (this, DCPContentProperty::NEEDS_ASSETS);
- ContentChange cc_kdm (this, DCPContentProperty::NEEDS_KDM);
- ContentChange cc_name (this, DCPContentProperty::NAME);
- ContentChange cc_streams (this, AudioContentProperty::STREAMS);
+ ChangeSignaller<Content> cc_texts (this, DCPContentProperty::TEXTS);
+ ChangeSignaller<Content> cc_assets (this, DCPContentProperty::NEEDS_ASSETS);
+ ChangeSignaller<Content> cc_kdm (this, DCPContentProperty::NEEDS_KDM);
+ ChangeSignaller<Content> cc_name (this, DCPContentProperty::NAME);
+ ChangeSignaller<Content> cc_streams (this, AudioContentProperty::STREAMS);
if (job) {
job->set_progress_unknown ();
}
if (examiner->has_audio()) {
- ContentChange cc (this, AudioContentProperty::STREAMS);
+ ChangeSignaller<Content> cc (this, AudioContentProperty::STREAMS);
{
boost::mutex::scoped_lock lm (_mutex);
audio.reset (new AudioContent (this));
void
DCPContent::set_reference_video (bool r)
{
- ContentChange cc (this, DCPContentProperty::REFERENCE_VIDEO);
+ ChangeSignaller<Content> cc (this, DCPContentProperty::REFERENCE_VIDEO);
{
boost::mutex::scoped_lock lm (_mutex);
void
DCPContent::set_reference_audio (bool r)
{
- ContentChange cc (this, DCPContentProperty::REFERENCE_AUDIO);
+ ChangeSignaller<Content> cc (this, DCPContentProperty::REFERENCE_AUDIO);
{
boost::mutex::scoped_lock lm (_mutex);
void
DCPContent::set_reference_text (TextType type, bool r)
{
- ContentChange cc (this, DCPContentProperty::REFERENCE_TEXT);
+ ChangeSignaller<Content> cc (this, DCPContentProperty::REFERENCE_TEXT);
{
boost::mutex::scoped_lock lm (_mutex);
void
DCPContent::set_cpl (string id)
{
- ContentChange cc (this, DCPContentProperty::CPL);
+ ChangeSignaller<Content> cc (this, DCPContentProperty::CPL);
{
boost::mutex::scoped_lock lm (_mutex);
void
FFmpegContent::examine (shared_ptr<Job> job)
{
- ContentChange cc1 (this, FFmpegContentProperty::SUBTITLE_STREAMS);
- ContentChange cc2 (this, FFmpegContentProperty::SUBTITLE_STREAM);
+ ChangeSignaller<Content> cc1 (this, FFmpegContentProperty::SUBTITLE_STREAMS);
+ ChangeSignaller<Content> cc2 (this, FFmpegContentProperty::SUBTITLE_STREAM);
job->set_progress_unknown ();
void
FFmpegContent::set_subtitle_stream (shared_ptr<FFmpegSubtitleStream> s)
{
- ContentChange cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
+ ChangeSignaller<Content> cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
{
boost::mutex::scoped_lock lm (_mutex);
void
FFmpegContent::set_filters (vector<Filter const *> const & filters)
{
- ContentChange cc (this, FFmpegContentProperty::FILTERS);
+ ChangeSignaller<Content> cc (this, FFmpegContentProperty::FILTERS);
{
boost::mutex::scoped_lock lm (_mutex);
FFmpegContent::signal_subtitle_stream_changed ()
{
/* XXX: this is too late; really it should be before the change */
- ContentChange cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
+ ChangeSignaller<Content> cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
}
vector<shared_ptr<FFmpegAudioStream> >
#include "dcp_content.h"
#include "screen_kdm.h"
#include "cinema.h"
+#include "change_signaller.h"
#include <libcxml/cxml.h>
#include <dcp/cpl.h>
#include <dcp/certificate_chain.h>
void
Film::set_name (string n)
{
+ ChangeSignaller<Film> ch (this, NAME);
_name = n;
- signal_changed (NAME);
}
void
Film::set_use_isdcf_name (bool u)
{
+ ChangeSignaller<Film> ch (this, USE_ISDCF_NAME);
_use_isdcf_name = u;
- signal_changed (USE_ISDCF_NAME);
}
void
Film::set_dcp_content_type (DCPContentType const * t)
{
+ ChangeSignaller<Film> ch (this, DCP_CONTENT_TYPE);
_dcp_content_type = t;
- signal_changed (DCP_CONTENT_TYPE);
}
void
Film::set_container (Ratio const * c)
{
+ ChangeSignaller<Film> ch (this, CONTAINER);
_container = c;
- signal_changed (CONTAINER);
}
void
Film::set_resolution (Resolution r)
{
+ ChangeSignaller<Film> ch (this, RESOLUTION);
_resolution = r;
- signal_changed (RESOLUTION);
}
void
Film::set_j2k_bandwidth (int b)
{
+ ChangeSignaller<Film> ch (this, J2K_BANDWIDTH);
_j2k_bandwidth = b;
- signal_changed (J2K_BANDWIDTH);
}
void
Film::set_isdcf_metadata (ISDCFMetadata m)
{
+ ChangeSignaller<Film> ch (this, ISDCF_METADATA);
_isdcf_metadata = m;
- signal_changed (ISDCF_METADATA);
}
void
Film::set_video_frame_rate (int f)
{
+ ChangeSignaller<Film> ch (this, VIDEO_FRAME_RATE);
_video_frame_rate = f;
- signal_changed (VIDEO_FRAME_RATE);
}
void
Film::set_audio_channels (int c)
{
+ ChangeSignaller<Film> ch (this, AUDIO_CHANNELS);
_audio_channels = c;
- signal_changed (AUDIO_CHANNELS);
}
void
Film::set_three_d (bool t)
{
+ ChangeSignaller<Film> ch (this, THREE_D);
_three_d = t;
- signal_changed (THREE_D);
if (_three_d && _isdcf_metadata.two_d_version_of_three_d) {
+ ChangeSignaller<Film> ch (this, ISDCF_METADATA);
_isdcf_metadata.two_d_version_of_three_d = false;
- signal_changed (ISDCF_METADATA);
}
}
void
Film::set_interop (bool i)
{
+ ChangeSignaller<Film> ch (this, INTEROP);
_interop = i;
- signal_changed (INTEROP);
}
void
Film::set_audio_processor (AudioProcessor const * processor)
{
+ ChangeSignaller<Film> ch1 (this, AUDIO_PROCESSOR);
+ ChangeSignaller<Film> ch2 (this, AUDIO_CHANNELS);
_audio_processor = processor;
- signal_changed (AUDIO_PROCESSOR);
- signal_changed (AUDIO_CHANNELS);
}
void
Film::set_reel_type (ReelType t)
{
+ ChangeSignaller<Film> ch (this, REEL_TYPE);
_reel_type = t;
- signal_changed (REEL_TYPE);
}
/** @param r Desired reel length in bytes */
void
Film::set_reel_length (int64_t r)
{
+ ChangeSignaller<Film> ch (this, REEL_LENGTH);
_reel_length = r;
- signal_changed (REEL_LENGTH);
}
void
Film::set_upload_after_make_dcp (bool u)
{
+ ChangeSignaller<Film> ch (this, UPLOAD_AFTER_MAKE_DCP);
_upload_after_make_dcp = u;
- signal_changed (UPLOAD_AFTER_MAKE_DCP);
}
void
-Film::signal_changed (Property p)
+Film::signal_change (ChangeType type, int p)
{
- _dirty = true;
-
- Change (CHANGE_TYPE_PENDING, p);
- bool changed = false;
+ signal_change (type, static_cast<Property>(p));
+}
- switch (p) {
- case Film::CONTENT:
- set_video_frame_rate (_playlist->best_video_frame_rate ());
- changed = true;
- break;
- case Film::VIDEO_FRAME_RATE:
- case Film::SEQUENCE:
- _playlist->maybe_sequence ();
- changed = true;
- break;
- default:
- break;
- }
+void
+Film::signal_change (ChangeType type, Property p)
+{
+ if (type == CHANGE_TYPE_DONE) {
+ _dirty = true;
+
+ switch (p) {
+ case Film::CONTENT:
+ set_video_frame_rate (_playlist->best_video_frame_rate ());
+ break;
+ case Film::VIDEO_FRAME_RATE:
+ case Film::SEQUENCE:
+ _playlist->maybe_sequence ();
+ break;
+ default:
+ break;
+ }
- if (changed) {
- emit (boost::bind (boost::ref (Change), CHANGE_TYPE_DONE, p));
+ emit (boost::bind (boost::ref (Change), type, p));
} else {
- Change (CHANGE_TYPE_CANCELLED, p);
+ Change (type, p);
}
}
void
Film::set_signed (bool s)
{
+ ChangeSignaller<Film> ch (this, SIGNED);
_signed = s;
- signal_changed (SIGNED);
}
void
Film::set_encrypted (bool e)
{
+ ChangeSignaller<Film> ch (this, ENCRYPTED);
_encrypted = e;
- signal_changed (ENCRYPTED);
}
void
Film::set_key (dcp::Key key)
{
+ ChangeSignaller<Film> ch (this, KEY);
_key = key;
- signal_changed (KEY);
}
ContentList
void
Film::playlist_content_change (ChangeType type, weak_ptr<Content> c, int p, bool frequent)
{
- if (type != CHANGE_TYPE_DONE) {
- return;
- }
-
- _dirty = true;
-
if (p == ContentProperty::VIDEO_FRAME_RATE) {
- set_video_frame_rate (_playlist->best_video_frame_rate ());
+ signal_change (type, Film::CONTENT);
} else if (p == AudioContentProperty::STREAMS) {
- signal_changed (NAME);
+ signal_change (type, Film::NAME);
}
- emit (boost::bind (boost::ref (ContentChange), type, c, p, frequent));
+ if (type == CHANGE_TYPE_DONE) {
+ emit (boost::bind (boost::ref (ContentChange), type, c, p, frequent));
+ } else {
+ ContentChange (type, c, p, frequent);
+ }
}
void
Film::playlist_change (ChangeType type)
{
- if (type == CHANGE_TYPE_DONE) {
- signal_changed (CONTENT);
- signal_changed (NAME);
- }
+ signal_change (type, CONTENT);
+ signal_change (type, NAME);
}
void
Film::playlist_order_changed ()
{
- signal_changed (CONTENT_ORDER);
+ /* XXX: missing PENDING */
+ signal_change (CHANGE_TYPE_DONE, CONTENT_ORDER);
}
int
return;
}
+ ChangeSignaller<Film> cc (this, SEQUENCE);
_sequence = s;
_playlist->set_sequence (s);
- signal_changed (SEQUENCE);
}
/** @return Size of the largest possible image in whatever resolution we are using */
private:
friend struct ::isdcf_name_test;
+ template <typename> friend class ChangeSignaller;
- void signal_changed (Property);
+ void signal_change (ChangeType, Property);
+ void signal_change (ChangeType, int);
std::string video_identifier () const;
void playlist_change (ChangeType);
void playlist_order_changed ();
TextContent::font_changed ()
{
/* XXX: too late */
- ContentChange cc (_parent, TextContentProperty::FONTS);
+ ChangeSignaller<Content> cc (_parent, TextContentProperty::FONTS);
}
void
optional<double> const ar = d->sample_aspect_ratio ();
bool const yuv = d->yuv ();
- ContentChange cc1 (_parent, VideoContentProperty::SIZE);
- ContentChange cc2 (_parent, VideoContentProperty::SCALE);
- ContentChange cc3 (_parent, ContentProperty::LENGTH);
+ ChangeSignaller<Content> cc1 (_parent, VideoContentProperty::SIZE);
+ ChangeSignaller<Content> cc2 (_parent, VideoContentProperty::SCALE);
+ ChangeSignaller<Content> cc3 (_parent, ContentProperty::LENGTH);
{
boost::mutex::scoped_lock lm (_mutex);
colour_conversion.cc
config.cc
content.cc
- content_change.cc
content_factory.cc
cross.cc
curl_uploader.cc