bool has_any_audio = false;
BOOST_FOREACH (shared_ptr<Content> c, _playlist->content ()) {
- if (dynamic_pointer_cast<AudioContent> (c)) {
+ if (c->audio) {
has_any_audio = true;
}
}
/* If there was only one piece of content in this analysis we may later need to know what its
gain was when we analysed it.
*/
- shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (_playlist->content().front ());
+ shared_ptr<const AudioContent> ac = _playlist->content().front()->audio;
DCPOMATIC_ASSERT (ac);
_analysis->set_analysis_gain (ac->audio_gain ());
}
we know that content's gain when the analysis was run. Hence we can work out
what correction is now needed to make it look `right'.
*/
- shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (playlist->content().front ());
- DCPOMATIC_ASSERT (ac);
- return ac->audio_gain() - analysis_gain().get ();
+ DCPOMATIC_ASSERT (playlist->content().front()->audio);
+ return playlist->content().front()->audio->audio_gain() - analysis_gain().get ();
}
return 0.0f;
int const AudioContentProperty::AUDIO_DELAY = 202;
int const AudioContentProperty::AUDIO_VIDEO_FRAME_RATE = 203;
-AudioContent::AudioContent (shared_ptr<const Film> film)
- : Content (film)
+AudioContent::AudioContent (Content* parent, shared_ptr<const Film> film)
+ : ContentPart (parent, film)
, _audio_gain (0)
, _audio_delay (Config::instance()->default_audio_delay ())
{
}
-AudioContent::AudioContent (shared_ptr<const Film> film, DCPTime s)
- : Content (film, s)
- , _audio_gain (0)
- , _audio_delay (Config::instance()->default_audio_delay ())
-{
-
-}
-
-AudioContent::AudioContent (shared_ptr<const Film> film, boost::filesystem::path p)
- : Content (film, p)
- , _audio_gain (0)
- , _audio_delay (Config::instance()->default_audio_delay ())
-{
-
-}
-
-AudioContent::AudioContent (shared_ptr<const Film> film, cxml::ConstNodePtr node)
- : Content (film, node)
+AudioContent::AudioContent (Content* parent, shared_ptr<const Film> film, cxml::ConstNodePtr node)
+ : ContentPart (parent, film)
{
_audio_gain = node->number_child<double> ("AudioGain");
_audio_delay = node->number_child<int> ("AudioDelay");
_audio_video_frame_rate = node->optional_number_child<double> ("AudioVideoFrameRate");
}
-AudioContent::AudioContent (shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
- : Content (film, c)
+AudioContent::AudioContent (Content* parent, shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
+ : ContentPart (parent, film)
{
- shared_ptr<AudioContent> ref = dynamic_pointer_cast<AudioContent> (c[0]);
+ shared_ptr<AudioContent> ref = c[0]->audio;
DCPOMATIC_ASSERT (ref);
- for (size_t i = 0; i < c.size(); ++i) {
- shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c[i]);
-
- if (ac->audio_gain() != ref->audio_gain()) {
+ for (size_t i = 1; i < c.size(); ++i) {
+ if (c[i]->audio->audio_gain() != ref->audio_gain()) {
throw JoinError (_("Content to be joined must have the same audio gain."));
}
- if (ac->audio_delay() != ref->audio_delay()) {
+ if (c[i]->audio->audio_delay() != ref->audio_delay()) {
throw JoinError (_("Content to be joined must have the same audio delay."));
}
_audio_delay = ref->audio_delay ();
/* Preserve the optional<> part of this */
_audio_video_frame_rate = ref->_audio_video_frame_rate;
+ _streams = ref->streams ();
}
void
}
}
-
void
AudioContent::set_audio_gain (double g)
{
- {
- boost::mutex::scoped_lock lm (_mutex);
- _audio_gain = g;
- }
-
- signal_changed (AudioContentProperty::AUDIO_GAIN);
+ maybe_set (_audio_gain, g, AudioContentProperty::AUDIO_GAIN);
}
void
AudioContent::set_audio_delay (int d)
{
- {
- boost::mutex::scoped_lock lm (_mutex);
- _audio_delay = d;
- }
-
- signal_changed (AudioContentProperty::AUDIO_DELAY);
+ maybe_set (_audio_delay, d, AudioContentProperty::AUDIO_DELAY);
}
string
AudioContent::technical_summary () const
{
string s = "audio :";
- BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr i, streams ()) {
s += String::compose ("stream channels %1 rate %2", i->channels(), i->frame_rate());
}
AudioContent::set_audio_mapping (AudioMapping mapping)
{
int c = 0;
- BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr i, streams ()) {
AudioMapping stream_mapping (i->channels (), MAX_DCP_AUDIO_CHANNELS);
for (int j = 0; j < i->channels(); ++j) {
for (int k = 0; k < MAX_DCP_AUDIO_CHANNELS; ++k) {
i->set_mapping (stream_mapping);
}
- signal_changed (AudioContentProperty::AUDIO_STREAMS);
+ _parent->signal_changed (AudioContentProperty::AUDIO_STREAMS);
}
AudioMapping
AudioContent::audio_mapping () const
{
int channels = 0;
- BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr i, streams ()) {
channels += i->channels ();
}
int c = 0;
int s = 0;
- BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr i, streams ()) {
AudioMapping mapping = i->mapping ();
for (int j = 0; j < mapping.input_channels(); ++j) {
for (int k = 0; k < MAX_DCP_AUDIO_CHANNELS; ++k) {
/* Resample to a DCI-approved sample rate */
double t = has_rate_above_48k() ? 96000 : 48000;
- FrameRateChange frc (audio_video_frame_rate(), film()->video_frame_rate());
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ FrameRateChange frc (audio_video_frame_rate(), film->video_frame_rate());
/* Compensate if the DCP is being run at a different frame rate
to the source; that is, if the video is run such that it will
string
AudioContent::processing_description () const
{
- vector<AudioStreamPtr> streams = audio_streams ();
- if (streams.empty ()) {
+ if (streams().empty ()) {
return "";
}
bool same = true;
optional<int> common_frame_rate;
- BOOST_FOREACH (AudioStreamPtr i, streams) {
+ BOOST_FOREACH (AudioStreamPtr i, streams()) {
if (i->frame_rate() != resampled_audio_frame_rate()) {
resampled = true;
} else {
bool
AudioContent::has_rate_above_48k () const
{
- BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr i, streams ()) {
if (i->frame_rate() > 48000) {
return true;
}
vector<string> n;
int t = 1;
- BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr i, streams ()) {
for (int j = 0; j < i->channels(); ++j) {
n.push_back (String::compose ("%1:%2", t, j + 1));
}
AudioContent::add_properties (list<UserProperty>& p) const
{
shared_ptr<const AudioStream> stream;
- if (audio_streams().size() == 1) {
- stream = audio_streams().front ();
+ if (streams().size() == 1) {
+ stream = streams().front ();
}
if (stream) {
p.push_back (UserProperty (_("Audio"), _("Content audio frame rate"), stream->frame_rate(), _("Hz")));
}
- FrameRateChange const frc (audio_video_frame_rate(), film()->video_frame_rate());
- ContentTime const c (full_length(), frc);
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+
+ FrameRateChange const frc (audio_video_frame_rate(), film->video_frame_rate());
+ ContentTime const c (_parent->full_length(), frc);
p.push_back (
UserProperty (_("Length"), _("Full length in video frames at content rate"), c.frames_round(frc.source))
*/
return film()->active_frame_rate_change(position()).source;
}
+
+AudioContent::set_streams (vector<AudioStreamPtr> streams)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _streams = streams;
+ }
+
+ _parent->signal_changed (AudioContentProperty::AUDIO_STREAMS);
+}
+
+AudioStreamPtr
+AudioContent::stream () const
+{
+ boost::mutex::scoped_lock lm (_mutex);
+ DCPOMATIC_ASSERT (_streams.size() == 1);
+ return _streams.front ();
+}
+
+void
+AudioContent::add_stream (AudioStreamPtr stream)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _streams.push_back (stream);
+ }
+
+ _parent->signal_changed (AudioContentProperty::AUDIO_STREAMS);
+}
+
+void
+AudioContent::set_stream (AudioStreamPtr stream)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _streams.clear ();
+ _streams.push_back (stream);
+ }
+
+ _parent->signal_changed (AudioContentProperty::AUDIO_STREAMS);
+}
#ifndef DCPOMATIC_AUDIO_CONTENT_H
#define DCPOMATIC_AUDIO_CONTENT_H
-#include "content.h"
+#include "content_part.h"
#include "audio_stream.h"
#include "audio_mapping.h"
static int const AUDIO_VIDEO_FRAME_RATE;
};
-/** @class AudioContent
- * @brief Parent class for content which may contain audio data.
- */
-class AudioContent : public virtual Content
+class AudioContent : public ContentPart
{
public:
- AudioContent (boost::shared_ptr<const Film>);
- AudioContent (boost::shared_ptr<const Film>, DCPTime);
- AudioContent (boost::shared_ptr<const Film>, boost::filesystem::path);
- AudioContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr);
- AudioContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
+ AudioContent (Content* parent, boost::shared_ptr<const Film>);
+ AudioContent (Content* parent, boost::shared_ptr<const Film>, cxml::ConstNodePtr);
+ AudioContent (Content* parent, boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
void as_xml (xmlpp::Node *) const;
std::string technical_summary () const;
- virtual std::vector<AudioStreamPtr> audio_streams () const = 0;
-
AudioMapping audio_mapping () const;
void set_audio_mapping (AudioMapping);
int resampled_audio_frame_rate () const;
std::string processing_description () const;
-protected:
+ std::vector<AudioStreamPtr> streams () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _streams;
+ }
+
+ void add_stream (AudioStreamPtr stream);
+ void set_stream (AudioStreamPtr stream);
+ void set_streams (std::vector<AudioStreamPtr> streams);
+ AudioStreamPtr stream () const;
void add_properties (std::list<UserProperty> &) const;
private:
+
/** Gain to apply to audio in dB */
double _audio_gain;
/** Delay to apply to audio (positive moves audio later) in milliseconds */
int _audio_delay;
boost::optional<double> _audio_video_frame_rate;
+ std::vector<AudioStreamPtr> _streams;
};
#endif
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
using std::map;
using boost::shared_ptr;
-AudioDecoder::AudioDecoder (shared_ptr<const AudioContent> content, bool fast)
+AudioDecoder::AudioDecoder (shared_ptr<const AudioContent> content, bool fast, shared_ptr<Log> log)
: _audio_content (content)
, _ignore_audio (false)
, _fast (fast)
{
- BOOST_FOREACH (AudioStreamPtr i, content->audio_streams ()) {
- _streams[i] = shared_ptr<AudioDecoderStream> (new AudioDecoderStream (_audio_content, i, this));
+ BOOST_FOREACH (AudioStreamPtr i, content->streams ()) {
+ _streams[i] = shared_ptr<AudioDecoderStream> (new AudioDecoderStream (_audio_content, i, this, log));
}
}
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
class AudioBuffers;
class AudioContent;
class AudioDecoderStream;
+class Log;
/** @class AudioDecoder.
* @brief Parent class for audio decoders.
class AudioDecoder : public virtual Decoder, public boost::enable_shared_from_this<AudioDecoder>
{
public:
- AudioDecoder (boost::shared_ptr<const AudioContent>, bool fast);
+ AudioDecoder (boost::shared_ptr<const AudioContent>, bool fast, boost::shared_ptr<Log> log);
boost::shared_ptr<const AudioContent> audio_content () const {
return _audio_content;
using boost::optional;
using boost::shared_ptr;
-AudioDecoderStream::AudioDecoderStream (shared_ptr<const AudioContent> content, AudioStreamPtr stream, AudioDecoder* decoder)
+AudioDecoderStream::AudioDecoderStream (shared_ptr<const AudioContent> content, AudioStreamPtr stream, AudioDecoder* decoder, shared_ptr<Log> log)
: _content (content)
, _stream (stream)
, _decoder (decoder)
+ , _log (log)
{
if (content->resampled_audio_frame_rate() != _stream->frame_rate() && _stream->channels() > 0) {
_resampler.reset (new Resampler (_stream->frame_rate(), content->resampled_audio_frame_rate(), _stream->channels (), decoder->fast ()));
{
shared_ptr<ContentAudio> dec;
- _content->film()->log()->log (String::compose ("-> ADS has request for %1 %2", frame, length), LogEntry::TYPE_DEBUG_DECODE);
+ _log->log (String::compose ("-> ADS has request for %1 %2", frame, length), LogEntry::TYPE_DEBUG_DECODE);
Frame const end = frame + length - 1;
decoded_offset = frame - _decoded.frame;
- _content->film()->log()->log (
+ _log->log (
String::compose ("Accurate ADS::get has offset %1 from request %2 and available %3", decoded_offset, frame, _decoded.frame),
LogEntry::TYPE_DEBUG_DECODE
);
void
AudioDecoderStream::audio (shared_ptr<const AudioBuffers> data, ContentTime time)
{
- _content->film()->log()->log (String::compose ("ADS receives %1 %2", time, data->frames ()), LogEntry::TYPE_DEBUG_DECODE);
+ _log->log (String::compose ("ADS receives %1 %2", time, data->frames ()), LogEntry::TYPE_DEBUG_DECODE);
if (_resampler) {
data = _resampler->run (data);
class AudioContent;
class AudioDecoder;
class Resampler;
+class Log;
class AudioDecoderStream
{
public:
- AudioDecoderStream (boost::shared_ptr<const AudioContent>, AudioStreamPtr, AudioDecoder* decoder);
+ AudioDecoderStream (boost::shared_ptr<const AudioContent>, AudioStreamPtr, AudioDecoder* decoder, boost::shared_ptr<Log> log);
ContentAudio get (Frame time, Frame length, bool accurate);
void audio (boost::shared_ptr<const AudioBuffers>, ContentTime);
boost::shared_ptr<const AudioContent> _content;
AudioStreamPtr _stream;
AudioDecoder* _decoder;
+ boost::shared_ptr<Log> _log;
boost::shared_ptr<Resampler> _resampler;
boost::optional<Frame> _position;
/** Currently-available decoded audio data */
public:
AudioStream (int frame_rate, int channels);
AudioStream (int frame_rate, AudioMapping mapping);
+ virtual ~AudioStream () {}
void set_mapping (AudioMapping mapping);
void
Content::signal_changed (int p)
{
+ changed (p);
emit (boost::bind (boost::ref (Changed), shared_from_this (), p, _change_signals_frequent));
}
*/
virtual std::list<DCPTime> reel_split_points () const;
+ virtual void changed (int) {}
+
boost::shared_ptr<Content> clone () const;
void set_path (boost::filesystem::path);
boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> Changed;
boost::shared_ptr<VideoContent> video;
+ boost::shared_ptr<AudioContent> audio;
boost::shared_ptr<SubtitleContent> subtitle;
void signal_changed (int);
#include "dcp_content.h"
#include "video_content.h"
+#include "audio_content.h"
#include "dcp_examiner.h"
#include "job.h"
#include "film.h"
DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
: Content (film)
- , AudioContent (film)
, _has_subtitles (false)
, _encrypted (false)
, _kdm_valid (false)
, _reference_subtitle (false)
{
video.reset (new VideoContent (this, film));
+ audio.reset (new AudioContent (this, film));
subtitle.reset (new SubtitleContent (this, film));
read_directory (p);
DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
: Content (film, node)
- , AudioContent (film, node)
- , _audio_stream (new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version)))
{
video.reset (new VideoContent (this, film, node, version));
+ audio.reset (new AudioContent (this, film, node));
+ audio->set_stream (
+ AudioStreamPtr (
+ new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version))
+ )
+ );
subtitle.reset (new SubtitleContent (this, film, node, version));
_name = node->string_child ("Name");
{
boost::mutex::scoped_lock lm (_mutex);
- _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
- AudioMapping m = _audio_stream->mapping ();
+
+ AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
+ audio->set_stream (as);
+ AudioMapping m = as->mapping ();
film()->make_audio_mapping_default (m);
- _audio_stream->set_mapping (m);
+ as->set_mapping (m);
}
signal_changed (AudioContentProperty::AUDIO_STREAMS);
{
return Content::technical_summary() + " - "
+ video->technical_summary() + " - "
- + AudioContent::technical_summary() + " - ";
+ + audio->technical_summary() + " - ";
}
void
Content::as_xml (node);
video->as_xml (node);
- AudioContent::as_xml (node);
- node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio_stream()->frame_rate ()));
- audio_stream()->mapping().as_xml (node->add_child("AudioMapping"));
+ audio->as_xml (node);
+ node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio->stream()->frame_rate()));
+ audio->stream()->mapping().as_xml (node->add_child("AudioMapping"));
subtitle->as_xml (node);
boost::mutex::scoped_lock lm (_mutex);
void
DCPContent::add_properties (list<UserProperty>& p) const
{
- AudioContent::add_properties (p);
+ audio->add_properties (p);
}
void
bool
DCPContent::can_reference_audio (list<string>& why_not) const
{
- DCPDecoder decoder (shared_from_this(), film()->log(), false);
- BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) {
- if (!i->main_sound()) {
- why_not.push_back (_("The DCP does not have sound in all reels."));
- return false;
- }
- }
-
- return can_reference<AudioContent> (_("There is other audio content overlapping this DCP; remove it."), why_not);
+ /* XXX: this needs to be fixed */
+ return true;
}
bool
return true;
}
-double
-DCPContent::subtitle_video_frame_rate () const
-{
- return video->video_frame_rate ();
-}
-
-vector<AudioStreamPtr>
-DCPContent::audio_streams () const
+void
+DCPContent::changed (int property)
{
- vector<AudioStreamPtr> s;
- s.push_back (_audio_stream);
- return s;
+ if (property == VideoContentProperty::VIDEO_FRAME_RATE && subtitle) {
+ subtitle->set_subtitle_video_frame_rate (video->video_frame_rate ());
+ }
}
* @brief DCPContent class.
*/
-#include "audio_content.h"
+#include "content.h"
#include <libcxml/cxml.h>
#include <dcp/encrypted_kdm.h>
/** @class DCPContent
* @brief An existing DCP used as input.
*/
-class DCPContent : public AudioContent
+class DCPContent : public Content
{
public:
DCPContent (boost::shared_ptr<const Film>, boost::filesystem::path p);
void set_default_colour_conversion ();
std::list<DCPTime> reel_split_points () const;
- /* SubtitleContent */
-
bool has_text_subtitles () const {
boost::mutex::scoped_lock lm (_mutex);
return _has_subtitles;
return false;
}
- double subtitle_video_frame_rate () const;
+ void changed (int property);
boost::filesystem::path directory () const;
bool can_reference_subtitle (std::list<std::string> &) const;
- std::vector<AudioStreamPtr> audio_streams () const;
-
- AudioStreamPtr audio_stream () const {
- return _audio_stream;
- }
-
-protected:
+private:
void add_properties (std::list<UserProperty>& p) const;
-private:
void read_directory (boost::filesystem::path);
std::list<DCPTimePeriod> reels () const;
template <class T> bool can_reference (std::string overlapping, std::list<std::string>& why_not) const;
* rather than by rewrapping.
*/
bool _reference_subtitle;
-
- boost::shared_ptr<AudioStream> _audio_stream;
};
#endif
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "dcp_decoder.h"
#include "dcp_content.h"
+#include "audio_content.h"
#include "j2k_image_proxy.h"
#include "image.h"
#include "config.h"
DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, shared_ptr<Log> log, bool fast)
: VideoDecoder (c->video, log)
- , AudioDecoder (c, fast)
+ , AudioDecoder (c->audio, fast, log)
, SubtitleDecoder (c->subtitle)
, _dcp_content (c)
{
shared_ptr<const dcp::SoundFrame> sf = (*_reel)->main_sound()->asset()->get_frame (entry_point + frame);
uint8_t const * from = sf->data ();
- int const channels = _dcp_content->audio_stream()->channels ();
+ int const channels = _dcp_content->audio->stream()->channels ();
int const frames = sf->size() / (3 * channels);
shared_ptr<AudioBuffers> data (new AudioBuffers (channels, frames));
for (int i = 0; i < frames; ++i) {
}
}
- audio (_dcp_content->audio_stream(), data, ContentTime::from_frames (offset, vfr) + _next);
+ audio (_dcp_content->audio->stream(), data, ContentTime::from_frames (offset, vfr) + _next);
}
if ((*_reel)->main_subtitle ()) {
DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
: Content (film, node)
, _length (node->number_child<ContentTime::Type> ("Length"))
- , _frame_rate (node->optional_number_child<int>("SubtitleFrameRate"))
{
subtitle.reset (new SubtitleContent (this, film, node, version));
}
shared_ptr<dcp::SMPTESubtitleAsset> smpte = dynamic_pointer_cast<dcp::SMPTESubtitleAsset> (sc);
if (smpte) {
subtitle->set_subtitle_language (smpte->language().get_value_or (""));
- _frame_rate = smpte->edit_rate().numerator;
+ subtitle->set_subtitle_video_frame_rate (smpte->edit_rate().numerator);
}
_length = ContentTime::from_seconds (sc->latest_subtitle_out().as_seconds ());
DCPTime
DCPSubtitleContent::full_length () const
{
- FrameRateChange const frc (subtitle_video_frame_rate(), film()->video_frame_rate());
+ FrameRateChange const frc (subtitle->subtitle_video_frame_rate(), film()->video_frame_rate());
return DCPTime (_length, frc);
}
subtitle->as_xml (node);
node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ()));
}
-
-void
-DCPSubtitleContent::set_subtitle_video_frame_rate (int r)
-{
- {
- boost::mutex::scoped_lock lm (_mutex);
- _frame_rate = r;
- }
-
- signal_changed (SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE);
-}
-
-double
-DCPSubtitleContent::subtitle_video_frame_rate () const
-{
- {
- boost::mutex::scoped_lock lm (_mutex);
- if (_frame_rate) {
- return _frame_rate.get ();
- }
- }
-
- /* No frame rate specified, so assume this content has been
- prepared for any concurrent video content.
- */
- return film()->active_frame_rate_change(position()).source;
-}
return false;
}
- double subtitle_video_frame_rate () const;
- void set_subtitle_video_frame_rate (int r);
-
private:
ContentTime _length;
- /** Video frame rate that this content has been prepared for, if known */
- boost::optional<double> _frame_rate;
};
#include "ffmpeg_content.h"
#include "video_content.h"
+#include "audio_content.h"
#include "ffmpeg_examiner.h"
#include "ffmpeg_subtitle_stream.h"
#include "ffmpeg_audio_stream.h"
FFmpegContent::FFmpegContent (shared_ptr<const Film> film, boost::filesystem::path p)
: Content (film, p)
- , AudioContent (film, p)
{
video.reset (new VideoContent (this, film));
+ audio.reset (new AudioContent (this, film));
subtitle.reset (new SubtitleContent (this, film));
set_default_colour_conversion ();
FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes)
: Content (film, node)
- , AudioContent (film, node)
{
video.reset (new VideoContent (this, film, node, version));
+ audio.reset (new AudioContent (this, film, node));
subtitle.reset (new SubtitleContent (this, film, node, version));
list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
c = node->node_children ("AudioStream");
for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
- _audio_streams.push_back (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream (*i, version)));
+ shared_ptr<FFmpegAudioStream> as (new FFmpegAudioStream (*i, version));
+ audio->add_stream (as);
if (version < 11 && !(*i)->optional_node_child ("Selected")) {
/* This is an old file and this stream is not selected, so un-map it */
- _audio_streams.back()->set_mapping (AudioMapping (_audio_streams.back()->channels (), MAX_DCP_AUDIO_CHANNELS));
+ as->set_mapping (AudioMapping (_audio_streams.back()->channels (), MAX_DCP_AUDIO_CHANNELS));
}
}
FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<boost::shared_ptr<Content> > c)
: Content (film, c)
- , AudioContent (film, c)
{
video.reset (new VideoContent (this, film, c));
+ audio.reset (new AudioContent (this, film, c));
subtitle.reset (new SubtitleContent (this, film, c));
shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
_subtitle_streams = ref->subtitle_streams ();
_subtitle_stream = ref->subtitle_stream ();
- _audio_streams = ref->ffmpeg_audio_streams ();
_first_video = ref->_first_video;
_filters = ref->_filters;
_color_range = ref->_color_range;
node->add_child("Type")->add_child_text ("FFmpeg");
Content::as_xml (node);
video->as_xml (node);
- AudioContent::as_xml (node);
+ audio->as_xml (node);
subtitle->as_xml (node);
boost::mutex::scoped_lock lm (_mutex);
(*i)->as_xml (t);
}
- for (vector<shared_ptr<FFmpegAudioStream> >::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
- (*i)->as_xml (node->add_child("AudioStream"));
+ BOOST_FOREACH (AudioStreamPtr i, audio->streams ()) {
+ shared_ptr<FFmpegAudioStream> f = dynamic_pointer_cast<FFmpegAudioStream> (i);
+ DCPOMATIC_ASSERT (f);
+ f->as_xml (node->add_child("AudioStream"));
}
for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
_subtitle_stream = _subtitle_streams.front ();
}
- _audio_streams = examiner->audio_streams ();
+ BOOST_FOREACH (shared_ptr<FFmpegAudioStream> i, examiner->audio_streams ()) {
+ audio->add_stream (i);
+ }
- if (!_audio_streams.empty ()) {
- AudioMapping m = _audio_streams.front()->mapping ();
+ if (!audio->streams().empty ()) {
+ AudioStreamPtr as = audio->streams().front();
+ AudioMapping m = as->mapping ();
film()->make_audio_mapping_default (m);
- _audio_streams.front()->set_mapping (m);
+ as->set_mapping (m);
}
_first_video = examiner->first_video ();
signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
- signal_changed (AudioContentProperty::AUDIO_STREAMS);
}
string
return Content::technical_summary() + " - "
+ video->technical_summary() + " - "
- + AudioContent::technical_summary() + " - "
+ + audio->technical_summary() + " - "
+ String::compose (
"ffmpeg: audio %1 subtitle %2 filters %3", as, ss, filt
);
{
Content::add_properties (p);
video->add_properties (p);
- AudioContent::add_properties (p);
+ audio->add_properties (p);
if (_bits_per_pixel) {
int const sub = 219 * pow (2, _bits_per_pixel.get() - 8);
signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
}
-double
-FFmpegContent::subtitle_video_frame_rate () const
+void
+FFmpegContent::changed (int property)
{
- return video->video_frame_rate ();
+ if (property == VideoContentProperty::VIDEO_FRAME_RATE && subtitle) {
+ subtitle->set_subtitle_video_frame_rate (video->video_frame_rate ());
+ }
}
#ifndef DCPOMATIC_FFMPEG_CONTENT_H
#define DCPOMATIC_FFMPEG_CONTENT_H
-#include "audio_content.h"
+#include "content.h"
+#include "audio_stream.h"
struct AVFormatContext;
struct AVStream;
static int const FILTERS;
};
-class FFmpegContent : public AudioContent
+class FFmpegContent : public Content
{
public:
FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
std::string identifier () const;
- /* VideoContent */
void set_default_colour_conversion ();
- /* AudioContent */
std::vector<AudioStreamPtr> audio_streams () const;
- /* SubtitleContent */
bool has_text_subtitles () const;
bool has_image_subtitles () const;
- double subtitle_video_frame_rate () const;
void set_filters (std::vector<Filter const *> const &);
+ void changed (int property);
+
std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
boost::mutex::scoped_lock lm (_mutex);
return _subtitle_streams;
void signal_subtitle_stream_changed ();
-protected:
+private:
void add_properties (std::list<UserProperty> &) const;
-private:
friend struct ffmpeg_pts_offset_test;
friend struct audio_sampling_rate_test;
FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> log, bool fast)
: VideoDecoder (c->video, log)
- , AudioDecoder (c, fast)
+ , AudioDecoder (c->audio, fast, log)
, SubtitleDecoder (c->subtitle)
, FFmpeg (c)
, _log (log)
MD5Digester digester;
BOOST_FOREACH (shared_ptr<Content> i, playlist->content ()) {
- shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
- if (!ac) {
+ if (!i->audio) {
continue;
}
- digester.add (ac->digest ());
- digester.add (ac->audio_mapping().digest ());
+ digester.add (i->digest ());
+ digester.add (i->audio->audio_mapping().digest ());
if (playlist->content().size() != 1) {
/* Analyses should be considered equal regardless of gain
if they were made from just one piece of content. This
analysis at the plotting stage rather than having to
recompute it.
*/
- digester.add (ac->audio_gain ());
+ digester.add (i->audio->audio_gain ());
}
}
}
} else {
BOOST_FOREACH (shared_ptr<Content> i, content ()) {
- shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (i);
- if (ac) {
- list<int> c = ac->audio_mapping().mapped_output_channels ();
+ if (i->audio) {
+ list<int> c = i->audio->mapping().mapped_output_channels ();
copy (c.begin(), c.end(), back_inserter (mapped));
}
}
bool burnt_in = true;
BOOST_FOREACH (shared_ptr<Content> i, content ()) {
- shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (i);
- if (!sc) {
+ if (!i->subtitle) {
continue;
}
- if (sc->use_subtitles() && !sc->burn_subtitles()) {
+ if (i->subtitle->use_subtitles() && !i->subtitle->burn_subtitles()) {
burnt_in = false;
}
}
}
add_content (content);
- if (Config::instance()->automatic_audio_analysis() && dynamic_pointer_cast<AudioContent> (content)) {
+ if (Config::instance()->automatic_audio_analysis() && content->audio) {
shared_ptr<Playlist> playlist (new Playlist);
playlist->add (content);
boost::signals2::connection c;
/* Add {video,subtitle} content after any existing {video,subtitle} content */
if (c->video) {
c->set_position (_playlist->video_end ());
- } else if (dynamic_pointer_cast<SubtitleContent> (c)) {
+ } else if (c->subtitle) {
c->set_position (_playlist->subtitle_end ());
}
Film::audio_frame_rate () const
{
BOOST_FOREACH (shared_ptr<Content> i, content ()) {
- shared_ptr<AudioContent> a = dynamic_pointer_cast<AudioContent> (i);
- if (a && a->has_rate_above_48k ()) {
+ if (i->audio && i->audio->has_rate_above_48k ()) {
return 96000;
}
}
ContentList cl = content ();
BOOST_FOREACH (shared_ptr<Content>& c, cl) {
- shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c);
- if (sc) {
- languages.insert (sc->subtitle_language ());
+ if (c->subtitle) {
+ languages.insert (c->subtitle->subtitle_language ());
}
}
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "film.h"
#include "ffmpeg_decoder.h"
#include "audio_buffers.h"
+#include "audio_content.h"
#include "ffmpeg_content.h"
#include "image_decoder.h"
#include "image_content.h"
/* SndfileContent */
shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (i);
if (sc) {
- decoder.reset (new SndfileDecoder (sc, _fast));
+ decoder.reset (new SndfileDecoder (sc, _fast, _film->log()));
/* Work out a FrameRateChange for the best overlap video for this content */
DCPTime best_overlap_t;
shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (i);
if (rc) {
decoder.reset (new TextSubtitleDecoder (rc));
- frc = FrameRateChange (rc->subtitle_video_frame_rate(), _film->video_frame_rate());
+ frc = FrameRateChange (rc->subtitle->subtitle_video_frame_rate(), _film->video_frame_rate());
}
/* DCPSubtitleContent */
shared_ptr<const DCPSubtitleContent> dsc = dynamic_pointer_cast<const DCPSubtitleContent> (i);
if (dsc) {
decoder.reset (new DCPSubtitleDecoder (dsc));
- frc = FrameRateChange (dsc->subtitle_video_frame_rate(), _film->video_frame_rate());
+ frc = FrameRateChange (dsc->subtitle->subtitle_video_frame_rate(), _film->video_frame_rate());
}
shared_ptr<VideoDecoder> vd = dynamic_pointer_cast<VideoDecoder> (decoder);
bool all_referenced = true;
BOOST_FOREACH (shared_ptr<Piece> i, ov) {
- shared_ptr<AudioContent> audio_content = dynamic_pointer_cast<AudioContent> (i->content);
shared_ptr<DCPContent> dcp_content = dynamic_pointer_cast<DCPContent> (i->content);
- if (audio_content && (!dcp_content || !dcp_content->reference_audio ())) {
+ if (i->content->audio && (!dcp_content || !dcp_content->reference_audio ())) {
/* There is audio content which is not from a DCP or not set to be referenced */
all_referenced = false;
}
BOOST_FOREACH (shared_ptr<Piece> i, ov) {
- shared_ptr<AudioContent> content = dynamic_pointer_cast<AudioContent> (i->content);
- DCPOMATIC_ASSERT (content);
+ DCPOMATIC_ASSERT (i->content->audio);
shared_ptr<AudioDecoder> decoder = dynamic_pointer_cast<AudioDecoder> (i->decoder);
DCPOMATIC_ASSERT (decoder);
/* The time that we should request from the content */
- DCPTime request = time - DCPTime::from_seconds (content->audio_delay() / 1000.0);
+ DCPTime request = time - DCPTime::from_seconds (i->content->audio->audio_delay() / 1000.0);
Frame request_frames = length_frames;
DCPTime offset;
if (request < DCPTime ()) {
Frame const content_frame = dcp_to_resampled_audio (i, request);
- BOOST_FOREACH (AudioStreamPtr j, content->audio_streams ()) {
+ BOOST_FOREACH (AudioStreamPtr j, i->content->audio->streams ()) {
if (j->channels() == 0) {
/* Some content (e.g. DCPs) can have streams with no channels */
ContentAudio all = decoder->get_audio (j, content_frame, request_frames, accurate);
/* Gain */
- if (content->audio_gain() != 0) {
+ if (i->content->audio->audio_gain() != 0) {
shared_ptr<AudioBuffers> gain (new AudioBuffers (all.audio));
- gain->apply_gain (content->audio_gain ());
+ gain->apply_gain (i->content->audio->audio_gain ());
all.audio = gain;
}
Frame
Player::dcp_to_content_video (shared_ptr<const Piece> piece, DCPTime t) const
{
- shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (piece->content);
DCPTime s = t - piece->content->position ();
s = min (piece->content->length_after_trim(), s);
s = max (DCPTime(), s + DCPTime (piece->content->trim_start(), piece->frc));
DCPTime
Player::content_video_to_dcp (shared_ptr<const Piece> piece, Frame f) const
{
- shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (piece->content);
/* See comment in dcp_to_content_video */
DCPTime const d = DCPTime::from_frames (f * piece->frc.factor(), piece->frc.dcp) - DCPTime (piece->content->trim_start (), piece->frc);
return max (DCPTime (), d + piece->content->position ());
list<shared_ptr<Font> > fonts;
BOOST_FOREACH (shared_ptr<Piece>& p, _pieces) {
- shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (p->content);
- if (sc) {
+ if (p->content->subtitle) {
/* XXX: things may go wrong if there are duplicate font IDs
with different font files.
*/
- list<shared_ptr<Font> > f = sc->fonts ();
+ list<shared_ptr<Font> > f = p->content->subtitle->fonts ();
copy (f.begin(), f.end(), back_inserter (fonts));
}
}
string t;
BOOST_FOREACH (shared_ptr<const Content> i, _content) {
- shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (i);
- shared_ptr<const SubtitleContent> sc = dynamic_pointer_cast<const SubtitleContent> (i);
- if (vc) {
- t += vc->identifier ();
- } else if (sc && sc->burn_subtitles ()) {
- t += sc->identifier ();
+ if (i->video || (i->subtitle && i->subtitle->burn_subtitles())) {
+ t += i->identifier ();
}
}
{
DCPTime end;
BOOST_FOREACH (shared_ptr<Content> i, _content) {
- if (dynamic_pointer_cast<const VideoContent> (i)) {
+ if (i->video) {
end = max (end, i->end ());
}
}
{
DCPTime end;
BOOST_FOREACH (shared_ptr<Content> i, _content) {
- if (dynamic_pointer_cast<const SubtitleContent> (i)) {
+ if (i->subtitle) {
end = max (end, i->end ());
}
}
#include "sndfile_content.h"
#include "sndfile_decoder.h"
#include "sndfile_examiner.h"
+#include "audio_content.h"
#include "film.h"
#include "compose.hpp"
#include "job.h"
SndfileContent::SndfileContent (shared_ptr<const Film> film, boost::filesystem::path p)
: Content (film, p)
- , AudioContent (film, p)
{
-
+ audio.reset (new AudioContent (this, film));
}
SndfileContent::SndfileContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
: Content (film, node)
- , AudioContent (film, node)
, _audio_length (node->number_child<Frame> ("AudioLength"))
- , _audio_stream (new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version)))
{
-
+ audio.reset (new AudioContent (this, film, node));
+ audio->set_stream (
+ AudioStreamPtr (
+ new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version)))
+ );
}
void
{
node->add_child("Type")->add_child_text ("Sndfile");
Content::as_xml (node);
- AudioContent::as_xml (node);
- node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio_stream()->frame_rate ()));
- audio_stream()->mapping().as_xml (node->add_child("AudioMapping"));
+ audio->as_xml (node);
+ node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio->stream()->frame_rate ()));
+ audio->stream()->mapping().as_xml (node->add_child("AudioMapping"));
node->add_child("AudioLength")->add_child_text (raw_convert<string> (audio_length ()));
}
SndfileContent::technical_summary () const
{
return Content::technical_summary() + " - "
- + AudioContent::technical_summary ()
+ + audio->technical_summary ()
+ " - sndfile";
}
{
{
boost::mutex::scoped_lock lm (_mutex);
- _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
- AudioMapping m = _audio_stream->mapping ();
+ AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
+ audio->set_stream (as);
+ AudioMapping m = as->mapping ();
film()->make_audio_mapping_default (m);
- _audio_stream->set_mapping (m);
+ as->set_mapping (m);
_audio_length = examiner->audio_length ();
}
DCPTime
SndfileContent::full_length () const
{
- FrameRateChange const frc (audio_video_frame_rate(), film()->video_frame_rate());
- return DCPTime::from_frames (audio_length() / frc.speed_up, audio_stream()->frame_rate ());
-}
-
-vector<AudioStreamPtr>
-SndfileContent::audio_streams () const
-{
- vector<AudioStreamPtr> s;
- s.push_back (_audio_stream);
- return s;
+ FrameRateChange const frc (audio->audio_video_frame_rate(), film->video_frame_rate());
+ return DCPTime::from_frames (audio_length() / frc.speed_up, audio->stream()->frame_rate ());
}
#ifndef DCPOMATIC_SNDFILE_CONTENT_H
#define DCPOMATIC_SNDFILE_CONTENT_H
-#include "audio_content.h"
+#include "content.h"
class AudioExaminer;
-class SndfileContent : public AudioContent
+class SndfileContent : public Content
{
public:
SndfileContent (boost::shared_ptr<const Film>, boost::filesystem::path);
void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>);
- std::vector<AudioStreamPtr> audio_streams () const;
-
- AudioStreamPtr audio_stream () const {
- return _audio_stream;
- }
-
static bool valid_file (boost::filesystem::path);
private:
}
Frame _audio_length;
-
- boost::shared_ptr<AudioStream> _audio_stream;
};
#endif
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <iostream>
#include <sndfile.h>
+#include "audio_content.h"
#include "sndfile_content.h"
#include "sndfile_decoder.h"
#include "exceptions.h"
using std::cout;
using boost::shared_ptr;
-SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c, bool fast)
+SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c, bool fast, shared_ptr<Log> log)
: Sndfile (c)
- , AudioDecoder (c, fast)
+ , AudioDecoder (c->audio, fast, log)
, _done (0)
, _remaining (_info.frames)
, _deinterleave_buffer (0)
/* Do things in half second blocks as I think there may be limits
to what FFmpeg (and in particular the resampler) can cope with.
*/
- sf_count_t const block = _sndfile_content->audio_stream()->frame_rate() / 2;
+ sf_count_t const block = _sndfile_content->audio->stream()->frame_rate() / 2;
sf_count_t const this_time = min (block, _remaining);
- int const channels = _sndfile_content->audio_stream()->channels ();
+ int const channels = _sndfile_content->audio->stream()->channels ();
shared_ptr<AudioBuffers> data (new AudioBuffers (channels, this_time));
- if (_sndfile_content->audio_stream()->channels() == 1) {
+ if (_sndfile_content->audio->stream()->channels() == 1) {
/* No de-interleaving required */
sf_read_float (_sndfile, data->data(0), this_time);
} else {
}
data->set_frames (this_time);
- audio (_sndfile_content->audio_stream (), data, ContentTime::from_frames (_done, _info.samplerate));
+ audio (_sndfile_content->audio->stream (), data, ContentTime::from_frames (_done, _info.samplerate));
_done += this_time;
_remaining -= this_time;
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
class SndfileDecoder : public Sndfile, public AudioDecoder
{
public:
- SndfileDecoder (boost::shared_ptr<const SndfileContent> c, bool fast);
+ SndfileDecoder (boost::shared_ptr<const SndfileContent> c, bool fast, boost::shared_ptr<Log> log);
~SndfileDecoder ();
private:
#include "font.h"
#include "raw_convert.h"
#include "content.h"
+#include "film.h"
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
node->optional_number_child<int>("OutlineGreen").get_value_or(255),
node->optional_number_child<int>("OutlineBlue").get_value_or(255)
)
+ , _frame_rate (node->optional_number_child<double>("SubtitleFrameRate"))
{
if (version >= 32) {
_use_subtitles = node->bool_child ("UseSubtitles");
SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> film, vector<shared_ptr<Content> > c)
: ContentPart (parent, film)
{
- shared_ptr<SubtitleContent> ref = dynamic_pointer_cast<SubtitleContent> (c[0]);
+ shared_ptr<SubtitleContent> ref = c[0]->subtitle;
DCPOMATIC_ASSERT (ref);
list<shared_ptr<Font> > ref_fonts = ref->fonts ();
- for (size_t i = 0; i < c.size(); ++i) {
- shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c[i]);
+ for (size_t i = 1; i < c.size(); ++i) {
- if (sc->use_subtitles() != ref->use_subtitles()) {
+ if (c[i]->subtitle->use_subtitles() != ref->use_subtitles()) {
throw JoinError (_("Content to be joined must have the same 'use subtitles' setting."));
}
- if (sc->burn_subtitles() != ref->burn_subtitles()) {
+ if (c[i]->subtitle->burn_subtitles() != ref->burn_subtitles()) {
throw JoinError (_("Content to be joined must have the same 'burn subtitles' setting."));
}
- if (sc->subtitle_x_offset() != ref->subtitle_x_offset()) {
+ if (c[i]->subtitle->subtitle_x_offset() != ref->subtitle_x_offset()) {
throw JoinError (_("Content to be joined must have the same subtitle X offset."));
}
- if (sc->subtitle_y_offset() != ref->subtitle_y_offset()) {
+ if (c[i]->subtitle->subtitle_y_offset() != ref->subtitle_y_offset()) {
throw JoinError (_("Content to be joined must have the same subtitle Y offset."));
}
- if (sc->subtitle_x_scale() != ref->subtitle_x_scale()) {
+ if (c[i]->subtitle->subtitle_x_scale() != ref->subtitle_x_scale()) {
throw JoinError (_("Content to be joined must have the same subtitle X scale."));
}
- if (sc->subtitle_y_scale() != ref->subtitle_y_scale()) {
+ if (c[i]->subtitle->subtitle_y_scale() != ref->subtitle_y_scale()) {
throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
}
- list<shared_ptr<Font> > fonts = sc->fonts ();
+ list<shared_ptr<Font> > fonts = c[i]->subtitle->fonts ();
if (fonts.size() != ref_fonts.size()) {
throw JoinError (_("Content to be joined must use the same fonts."));
}
{
maybe_set (_subtitle_language, language, SubtitleContentProperty::SUBTITLE_LANGUAGE);
}
+
+void
+SubtitleContent::set_subtitle_video_frame_rate (double r)
+{
+ maybe_set (_frame_rate, r, SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE);
+}
+
+double
+SubtitleContent::subtitle_video_frame_rate () const
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_frame_rate) {
+ return _frame_rate.get ();
+ }
+ }
+
+ /* No frame rate specified, so assume this content has been
+ prepared for any concurrent video content.
+ */
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ return film->active_frame_rate_change(_parent->position()).source;
+}
return _outline_colour;
}
+ double subtitle_video_frame_rate () const;
+ void set_subtitle_video_frame_rate (double r);
+
protected:
/** subtitle language (e.g. "German") or empty if it is not known */
std::string _subtitle_language;
bool _outline;
dcp::Colour _outline_colour;
std::list<boost::signals2::connection> _font_connections;
+ /** Video frame rate that this content has been prepared for, if known */
+ boost::optional<double> _frame_rate;
};
#endif
DCPTime
TextSubtitleContent::full_length () const
{
- FrameRateChange const frc (subtitle_video_frame_rate(), film()->video_frame_rate ());
+ FrameRateChange const frc (subtitle->subtitle_video_frame_rate(), film()->video_frame_rate ());
return DCPTime (_length, frc);
}
-
-void
-TextSubtitleContent::set_subtitle_video_frame_rate (double r)
-{
- {
- boost::mutex::scoped_lock lm (_mutex);
- _frame_rate = r;
- }
-
- signal_changed (SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE);
-}
-
-double
-TextSubtitleContent::subtitle_video_frame_rate () const
-{
- {
- boost::mutex::scoped_lock lm (_mutex);
- if (_frame_rate) {
- return _frame_rate.get ();
- }
- }
-
- /* No frame rate specified, so assume this content has been
- prepared for any concurrent video content.
- */
- return film()->active_frame_rate_change(position()).source;
-}
void as_xml (xmlpp::Node *) const;
DCPTime full_length () const;
- double subtitle_video_frame_rate () const;
- void set_subtitle_video_frame_rate (double r);
-
static std::string const font_id;
private:
ContentTime _length;
- /** Video frame rate that this content has been prepared for, if known */
- boost::optional<double> _frame_rate;
};
int burnt_subtitles = 0;
int non_burnt_subtitles = 0;
BOOST_FOREACH (shared_ptr<const Content> c, _film->content ()) {
- shared_ptr<const SubtitleContent> sc = dynamic_pointer_cast<const SubtitleContent> (c);
- if (sc && sc->use_subtitles()) {
- if (sc->burn_subtitles()) {
+ if (c->subtitle && c->subtitle->use_subtitles()) {
+ if (c->subtitle->burn_subtitles()) {
++burnt_subtitles;
} else {
++non_burnt_subtitles;
/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#define SERVER_LINK_VERSION (64+0)
typedef std::vector<boost::shared_ptr<Content> > ContentList;
-typedef std::vector<boost::shared_ptr<AudioContent> > AudioContentList;
typedef std::vector<boost::shared_ptr<FFmpegContent> > FFmpegContentList;
typedef int64_t Frame;
, _video_length (0)
, _yuv (false)
{
- shared_ptr<VideoContent> ref = dynamic_pointer_cast<VideoContent> (c[0]);
+ shared_ptr<VideoContent> ref = c[0]->video;
DCPOMATIC_ASSERT (ref);
- for (size_t i = 0; i < c.size(); ++i) {
- shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c[i]);
+ for (size_t i = 1; i < c.size(); ++i) {
- if (vc->video_size() != ref->video_size()) {
+ if (c[i]->video->video_size() != ref->video_size()) {
throw JoinError (_("Content to be joined must have the same picture size."));
}
- if (vc->video_frame_rate() != ref->video_frame_rate()) {
+ if (c[i]->video->video_frame_rate() != ref->video_frame_rate()) {
throw JoinError (_("Content to be joined must have the same video frame rate."));
}
- if (vc->video_frame_type() != ref->video_frame_type()) {
+ if (c[i]->video->video_frame_type() != ref->video_frame_type()) {
throw JoinError (_("Content to be joined must have the same video frame type."));
}
- if (vc->crop() != ref->crop()) {
+ if (c[i]->video->crop() != ref->crop()) {
throw JoinError (_("Content to be joined must have the same crop."));
}
- if (vc->scale() != ref->scale()) {
+ if (c[i]->video->scale() != ref->scale()) {
throw JoinError (_("Content to be joined must have the same scale setting."));
}
- if (vc->colour_conversion() != ref->colour_conversion()) {
+ if (c[i]->video->colour_conversion() != ref->colour_conversion()) {
throw JoinError (_("Content to be joined must have the same colour conversion."));
}
- if (vc->fade_in() != ref->fade_in() || vc->fade_out() != ref->fade_out()) {
+ if (c[i]->video->fade_in() != ref->fade_in() || c[i]->video->fade_out() != ref->fade_out()) {
throw JoinError (_("Content to be joined must have the same fades."));
}
- _video_length += vc->video_length ();
+ _video_length += c[i]->video->video_length ();
- if (vc->yuv ()) {
+ if (c[i]->video->yuv ()) {
_yuv = true;
}
}
<< " start trim " << c->trim_start().seconds ()
<< " end trim " << c->trim_end().seconds () << "\n";
- shared_ptr<VideoContent> video = dynamic_pointer_cast<VideoContent> (c);
- if (video) {
- cout << "\t" << video->video_size().width << "x" << video->video_size().height << "\n"
- << "\t" << video->video_frame_rate() << "fps\n"
- << "\tcrop left " << video->left_crop()
- << " right " << video->right_crop()
- << " top " << video->top_crop()
- << " bottom " << video->bottom_crop() << "\n"
- << "\tscale " << video->scale().name() << "\n";
- if (video->colour_conversion()) {
- if (video->colour_conversion().get().preset()) {
+ if (c->video) {
+ cout << "\t" << c->video->video_size().width << "x" << c->video->video_size().height << "\n"
+ << "\t" << c->video->video_frame_rate() << "fps\n"
+ << "\tcrop left " << c->video->left_crop()
+ << " right " << c->video->right_crop()
+ << " top " << c->video->top_crop()
+ << " bottom " << c->video->bottom_crop() << "\n"
+ << "\tscale " << c->video->scale().name() << "\n";
+ if (c->video->colour_conversion()) {
+ if (c->video->colour_conversion().get().preset()) {
cout << "\tcolour conversion "
- << PresetColourConversion::all()[video->colour_conversion().get().preset().get()].name
+ << PresetColourConversion::all()[c->video->colour_conversion().get().preset().get()].name
<< "\n";
} else {
cout << "\tcustom colour conversion\n";
}
- shared_ptr<AudioContent> audio = dynamic_pointer_cast<AudioContent> (c);
- if (audio) {
- cout << "\t" << audio->audio_delay() << " delay\n"
- << "\t" << audio->audio_gain() << " gain\n";
+ if (c->audio) {
+ cout << "\t" << c->audio->audio_delay() << " delay\n"
+ << "\t" << c->audio->audio_gain() << " gain\n";
}
}
}
using boost::dynamic_pointer_cast;
/** @param content Content to analyse, or 0 to analyse all of the film's audio */
-AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<AudioContent> content)
+AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content)
: wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
, _film (film)
, _content (content)
class AudioDialog : public wxDialog
{
public:
- AudioDialog (wxWindow *, boost::shared_ptr<Film> film, boost::shared_ptr<AudioContent> content = boost::shared_ptr<AudioContent> ());
+ AudioDialog (wxWindow *, boost::shared_ptr<Film> film, boost::shared_ptr<Content> content = boost::shared_ptr<Content> ());
bool Show (bool show = true);
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/cinema_sound_processor.h"
#include "lib/job_manager.h"
#include "lib/dcp_content.h"
+#include "lib/audio_content.h"
#include <wx/spinctrl.h>
#include <boost/foreach.hpp>
#include <iostream>
this,
new wxSpinCtrlDouble (this),
AudioContentProperty::AUDIO_GAIN,
+ &Content::audio,
boost::mem_fn (&AudioContent::audio_gain),
boost::mem_fn (&AudioContent::set_audio_gain)
);
this,
new wxSpinCtrl (this),
AudioContentProperty::AUDIO_DELAY,
+ &Content::audio,
boost::mem_fn (&AudioContent::audio_delay),
boost::mem_fn (&AudioContent::set_audio_delay)
);
void
AudioPanel::film_content_changed (int property)
{
- AudioContentList ac = _parent->selected_audio ();
+ ContentList ac = _parent->selected_audio ();
if (property == AudioContentProperty::AUDIO_STREAMS) {
if (ac.size() == 1) {
- _mapping->set (ac.front()->audio_mapping());
- _mapping->set_input_channels (ac.front()->audio_channel_names ());
+ _mapping->set (ac.front()->audio->audio_mapping());
+ _mapping->set_input_channels (ac.front()->audio->audio_channel_names ());
} else {
_mapping->set (AudioMapping ());
}
void
AudioPanel::setup_description ()
{
- AudioContentList ac = _parent->selected_audio ();
+ ContentList ac = _parent->selected_audio ();
if (ac.size () != 1) {
checked_set (_description, wxT (""));
return;
}
- checked_set (_description, ac.front()->processing_description ());
+ checked_set (_description, ac.front()->audio->processing_description ());
}
void
AudioPanel::mapping_changed (AudioMapping m)
{
- AudioContentList c = _parent->selected_audio ();
+ ContentList c = _parent->selected_audio ();
if (c.size() == 1) {
- c.front()->set_audio_mapping (m);
+ c.front()->audio->set_audio_mapping (m);
}
}
void
AudioPanel::content_selection_changed ()
{
- AudioContentList sel = _parent->selected_audio ();
+ ContentList sel = _parent->selected_audio ();
_gain->set_content (sel);
_delay->set_content (sel);
void
AudioPanel::setup_sensitivity ()
{
- AudioContentList sel = _parent->selected_audio ();
+ ContentList sel = _parent->selected_audio ();
shared_ptr<DCPContent> dcp;
if (sel.size() == 1) {
_audio_dialog = 0;
}
- AudioContentList ac = _parent->selected_audio ();
+ ContentList ac = _parent->selected_audio ();
if (ac.size() != 1) {
return;
}
void
AudioPanel::setup_peak ()
{
- AudioContentList sel = _parent->selected_audio ();
+ ContentList sel = _parent->selected_audio ();
bool alert = false;
if (sel.size() != 1) {
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/exceptions.h"
#include "lib/dcp_content.h"
#include "lib/ffmpeg_content.h"
+#include "lib/audio_content.h"
#include <wx/wx.h>
#include <wx/dirdlg.h>
#include <boost/foreach.hpp>
}
if (!video && audio) {
- AudioMapping m = fc->audio_mapping ();
+ AudioMapping m = fc->audio->audio_mapping ();
m.unmap_all ();
- fc->set_audio_mapping (m);
+ fc->audio->set_audio_mapping (m);
handled = true;
}
}
return vc;
}
-AudioContentList
+ContentList
ContentPanel::selected_audio ()
{
- AudioContentList ac;
+ ContentList ac;
BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
- shared_ptr<AudioContent> t = dynamic_pointer_cast<AudioContent> (i);
- if (t) {
- ac.push_back (t);
+ if (i->audio) {
+ ac.push_back (i);
}
}
ContentList selection = selected ();
ContentList video_selection = selected_video ();
- AudioContentList audio_selection = selected_audio ();
+ ContentList audio_selection = selected_audio ();
_remove->Enable (!selection.empty() && _generally_sensitive);
_earlier->Enable (selection.size() == 1 && _generally_sensitive);
_video_panel->Enable (video_selection.size() > 0 && _generally_sensitive);
_audio_panel->Enable (audio_selection.size() > 0 && _generally_sensitive);
- _subtitle_panel->Enable (selection.size() == 1 && dynamic_pointer_cast<SubtitleContent> (selection.front()) && _generally_sensitive);
+ _subtitle_panel->Enable (selection.size() == 1 && selection.front()->subtitle && _generally_sensitive);
_timing_panel->Enable (selection.size() == 1 && _generally_sensitive);
}
ContentList selected ();
ContentList selected_video ();
- AudioContentList selected_audio ();
+ ContentList selected_audio ();
ContentList selected_subtitle ();
FFmpegContentList selected_ffmpeg ();
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
* @brief ContentWidget class.
*/
-#ifndef DCPOMATIC_MULTIPLE_WIDGET_H
-#define DCPOMATIC_MULTIPLE_WIDGET_H
+#ifndef DCPOMATIC_CONTENT_WIDGET_H
+#define DCPOMATIC_CONTENT_WIDGET_H
-#include <vector>
+#include "wx_util.h"
+#include "lib/content.h"
#include <wx/wx.h>
#include <wx/gbsizer.h>
#include <wx/spinctrl.h>
#include <boost/function.hpp>
-#include "wx_util.h"
+#include <vector>
/** @class ContentWidget
* @brief A widget which represents some Content state and which can be used
* when multiple pieces of content are selected.
*
- * @param S Type containing the content being represented (e.g. VideoContent)
+ * @param S Type of ContentPart being manipulated (e.g. VideoContent)
* @param T Type of the widget (e.g. wxSpinCtrl)
* @param U Data type of state as used by the model.
* @param V Data type of state as used by the view.
wxWindow* parent,
T* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content*)> part,
boost::function<U (S*)> model_getter,
boost::function<void (S*, U)> model_setter,
boost::function<U (V)> view_to_model,
, _sizer (0)
, _button (new wxButton (parent, wxID_ANY, _("Multiple values")))
, _property (property)
+ , _part (part)
, _model_getter (model_getter)
, _model_setter (model_setter)
, _view_to_model (view_to_model)
return _wrapped;
}
- typedef std::vector<boost::shared_ptr<S> > List;
+ typedef std::vector<boost::shared_ptr<Content> > List;
/** Set the content that this control is working on (i.e. the selected content) */
void set_content (List content)
}
typename List::iterator i = _content.begin ();
- U const v = boost::bind (_model_getter, _content.front().get())();
- while (i != _content.end() && boost::bind (_model_getter, i->get())() == v) {
+ U const v = boost::bind (_model_getter, _part(_content.front().get()).get())();
+ while (i != _content.end() && boost::bind (_model_getter, _part(i->get()).get())() == v) {
++i;
}
{
_ignore_model_changes = true;
for (size_t i = 0; i < _content.size(); ++i) {
- boost::bind (_model_setter, _content[i].get(), _view_to_model (wx_get (_wrapped))) ();
+ boost::bind (_model_setter, _part (_content[i].get()).get(), _view_to_model (wx_get (_wrapped))) ();
}
_ignore_model_changes = false;
}
void button_clicked ()
{
- U const v = boost::bind (_model_getter, _content.front().get())();
+ U const v = boost::bind (_model_getter, _part(_content.front().get()).get())();
for (typename List::iterator i = _content.begin (); i != _content.end(); ++i) {
- boost::bind (_model_setter, i->get(), v) ();
+ boost::bind (_model_setter, _part(i->get()).get(), v) ();
}
}
wxButton* _button;
List _content;
int _property;
+ boost::function<boost::shared_ptr<S> (Content *)> _part;
boost::function<U (S*)> _model_getter;
boost::function<void (S*, U)> _model_setter;
boost::function<U (V)> _view_to_model;
wxWindow* parent,
wxSpinCtrl* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content *)> part,
boost::function<int (S*)> getter,
boost::function<void (S*, int)> setter
)
parent,
wrapped,
property,
+ part,
getter, setter,
&caster<int, int>,
&caster<int, int>
wxWindow* parent,
wxSpinCtrlDouble* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content *)> part,
boost::function<double (S*)> getter,
boost::function<void (S*, double)> setter
)
parent,
wrapped,
property,
+ part,
getter, setter,
&caster<double, double>,
&caster<double, double>
wxWindow* parent,
wxChoice* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content *)> part,
boost::function<U (S*)> getter,
boost::function<void (S*, U)> setter,
boost::function<U (int)> view_to_model,
parent,
wrapped,
property,
+ part,
getter,
setter,
view_to_model,
#include "lib/video_content.h"
#include "lib/subtitle_content.h"
#include "lib/dcp_content.h"
+#include "lib/audio_content.h"
#include <dcp/key.h>
#include <dcp/raw_convert.h>
#include <wx/wx.h>
bool big_font_files = false;
if (film->interop ()) {
BOOST_FOREACH (shared_ptr<Content> i, content) {
- shared_ptr<SubtitleContent> s = dynamic_pointer_cast<SubtitleContent> (i);
- if (s) {
- BOOST_FOREACH (shared_ptr<Font> j, s->fonts ()) {
- for (int i = 0; i < FontFiles::VARIANTS; ++i) {
- optional<boost::filesystem::path> const p = j->file (static_cast<FontFiles::Variant> (i));
+ if (i->subtitle) {
+ BOOST_FOREACH (shared_ptr<Font> j, i->subtitle->fonts ()) {
+ for (int k = 0; k < FontFiles::VARIANTS; ++k) {
+ optional<boost::filesystem::path> const p = j->file (static_cast<FontFiles::Variant> (k));
if (p && boost::filesystem::file_size (p.get()) >= (640 * 1024)) {
big_font_files = true;
}
int flat_or_narrower = 0;
int scope = 0;
BOOST_FOREACH (shared_ptr<const Content> i, content) {
- shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (i);
- if (vc) {
- Ratio const * r = vc->scale().ratio ();
+ if (i->video) {
+ Ratio const * r = i->video->scale().ratio ();
if (r && r->id() == "239") {
++scope;
} else if (r && r->id() != "239" && r->id() != "full-frame") {
int three_d = 0;
BOOST_FOREACH (shared_ptr<const Content> i, content) {
- shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (i);
- if (vc && vc->video_frame_type() != VIDEO_FRAME_TYPE_2D) {
+ if (i->video && i->video->video_frame_type() != VIDEO_FRAME_TYPE_2D) {
++three_d;
}
}
_views.push_back (shared_ptr<TimelineView> (new TimelineVideoContentView (*this, i)));
}
- shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
- if (ac && !ac->audio_mapping().mapped_output_channels().empty ()) {
+ if (i->audio && !i->audio->audio_mapping().mapped_output_channels().empty ()) {
_views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, i)));
}
} else if (ac) {
checked_set (_video_frame_rate, raw_convert<string> (ac->audio->audio_video_frame_rate (), 5));
} else if (sc) {
- checked_set (_video_frame_rate, raw_convert<string> (sc->subtitle_video_frame_rate (), 5));
+ checked_set (_video_frame_rate, raw_convert<string> (sc->subtitle->subtitle_video_frame_rate (), 5));
}
_video_frame_rate->Enable (true);
} else {
TimingPanel::set_video_frame_rate ()
{
BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
- shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (i);
- shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
shared_ptr<DCPSubtitleContent> dsc = dynamic_pointer_cast<DCPSubtitleContent> (i);
shared_ptr<TextSubtitleContent> tsc = dynamic_pointer_cast<TextSubtitleContent> (i);
double const fr = raw_convert<double> (wx_to_std (_video_frame_rate->GetValue ()));
- if (vc) {
- vc->set_video_frame_rate (fr);
- } else if (ac) {
+ if (i->video) {
+ i->video->set_video_frame_rate (fr);
+ } else if (i->audio) {
/* Audio but not video, i.e. SndfileContent */
- ac->set_audio_video_frame_rate (fr);
+ i->audio->set_audio_video_frame_rate (fr);
} else if (dsc) {
dsc->set_subtitle_video_frame_rate (fr);
} else if (tsc) {
this,
new wxChoice (this, wxID_ANY),
VideoContentProperty::VIDEO_FRAME_TYPE,
+ &Content::video,
boost::mem_fn (&VideoContent::video_frame_type),
boost::mem_fn (&VideoContent::set_video_frame_type),
&caster<int, VideoFrameType>,
this,
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
VideoContentProperty::VIDEO_CROP,
+ &Content::video,
boost::mem_fn (&VideoContent::left_crop),
boost::mem_fn (&VideoContent::set_left_crop)
);
this,
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
VideoContentProperty::VIDEO_CROP,
+ &Content::video,
boost::mem_fn (&VideoContent::right_crop),
boost::mem_fn (&VideoContent::set_right_crop)
);
this,
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
VideoContentProperty::VIDEO_CROP,
+ &Content::video,
boost::mem_fn (&VideoContent::top_crop),
boost::mem_fn (&VideoContent::set_top_crop)
);
this,
new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
VideoContentProperty::VIDEO_CROP,
+ &Content::video,
boost::mem_fn (&VideoContent::bottom_crop),
boost::mem_fn (&VideoContent::set_bottom_crop)
);
this,
new wxChoice (this, wxID_ANY),
VideoContentProperty::VIDEO_SCALE,
+ &Content::video,
boost::mem_fn (&VideoContent::scale),
boost::mem_fn (&VideoContent::set_scale),
&index_to_scale,
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/ffmpeg_content.h"
#include "lib/ratio.h"
#include "lib/job_manager.h"
+#include "lib/audio_content.h"
#include "test.h"
using boost::shared_ptr;
{
shared_ptr<Film> film = new_test_film ("audio_analysis_negative_delay_test");
film->set_name ("audio_analysis_negative_delay_test");
- shared_ptr<AudioContent> c (new FFmpegContent (film, private_data / "boon_telly.mkv"));
- c->set_audio_delay (-250);
+ shared_ptr<FFmpegContent> c (new FFmpegContent (film, private_data / "boon_telly.mkv"));
+ c->audio->set_audio_delay (-250);
film->examine_and_add_content (c);
wait_for_jobs ();
{
shared_ptr<Film> film = new_test_film ("audio_analysis_test2");
film->set_name ("audio_analysis_test2");
- shared_ptr<AudioContent> c (new FFmpegContent (film, private_data / "3d_thx_broadway_2010_lossless.m2ts"));
+ shared_ptr<FFmpegContent> c (new FFmpegContent (film, private_data / "3d_thx_broadway_2010_lossless.m2ts"));
film->examine_and_add_content (c);
wait_for_jobs ();
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
* @brief Tests of the AudioDecoder class.
*/
-#include <cassert>
-#include <boost/test/unit_test.hpp>
#include "test.h"
+#include "lib/content.h"
#include "lib/audio_decoder.h"
-#include "lib/single_stream_audio_content.h"
+#include "lib/audio_content.h"
+#include "lib/film.h"
+#include <boost/test/unit_test.hpp>
+#include <cassert>
#include <iostream>
using std::string;
using std::min;
using boost::shared_ptr;
-class TestAudioContent : public SingleStreamAudioContent
+class TestAudioContent : public Content
{
public:
TestAudioContent (shared_ptr<const Film> film)
: Content (film)
- , SingleStreamAudioContent (film)
{
- _audio_stream.reset (new AudioStream (48000, 2));
+ audio.reset (new AudioContent (this, film));
+ audio->set_stream (AudioStreamPtr (new AudioStream (48000, 2)));
}
std::string summary () const {
}
DCPTime full_length () const {
- return DCPTime::from_seconds (float (audio_length()) / audio_stream()->frame_rate ());
+ return DCPTime::from_seconds (float (audio_length()) / audio->stream()->frame_rate ());
}
Frame audio_length () const {
- return llrint (61.2942 * audio_stream()->frame_rate ());
+ return llrint (61.2942 * audio->stream()->frame_rate ());
}
};
class TestAudioDecoder : public AudioDecoder
{
public:
- TestAudioDecoder (shared_ptr<TestAudioContent> content)
- : AudioDecoder (content, false)
+ TestAudioDecoder (shared_ptr<TestAudioContent> content, shared_ptr<Log> log)
+ : AudioDecoder (content->audio, false, log)
, _test_audio_content (content)
, _position (0)
{}
_test_audio_content->audio_length() - _position
);
- shared_ptr<AudioBuffers> buffers (new AudioBuffers (_test_audio_content->audio_stream()->channels(), N));
- for (int i = 0; i < _test_audio_content->audio_stream()->channels(); ++i) {
+ shared_ptr<AudioBuffers> buffers (new AudioBuffers (_test_audio_content->audio->stream()->channels(), N));
+ for (int i = 0; i < _test_audio_content->audio->stream()->channels(); ++i) {
for (int j = 0; j < N; ++j) {
buffers->data(i)[j] = j + _position;
}
}
- audio (_test_audio_content->audio_stream(), buffers, ContentTime::from_frames (_position, 48000));
+ audio (_test_audio_content->audio->stream(), buffers, ContentTime::from_frames (_position, 48000));
_position += N;
return N < 2000;
void seek (ContentTime t, bool accurate)
{
AudioDecoder::seek (t, accurate);
- _position = t.frames_round (_test_audio_content->resampled_audio_frame_rate ());
+ _position = t.frames_round (_test_audio_content->audio->resampled_audio_frame_rate ());
}
private:
static ContentAudio
get (Frame from, Frame length)
{
- decoder->seek (ContentTime::from_frames (from, content->resampled_audio_frame_rate ()), true);
- ContentAudio ca = decoder->get_audio (content->audio_stream(), from, length, true);
+ decoder->seek (ContentTime::from_frames (from, content->audio->resampled_audio_frame_rate ()), true);
+ ContentAudio ca = decoder->get_audio (content->audio->stream(), from, length, true);
BOOST_CHECK_EQUAL (ca.frame, from);
return ca;
}
check (Frame from, Frame length)
{
ContentAudio ca = get (from, length);
- for (int i = 0; i < content->audio_stream()->channels(); ++i) {
+ for (int i = 0; i < content->audio->stream()->channels(); ++i) {
for (int j = 0; j < length; ++j) {
BOOST_REQUIRE_EQUAL (ca.audio->data(i)[j], j + from);
}
shared_ptr<Film> film = new_test_film ("audio_decoder_test");
content.reset (new TestAudioContent (film));
- decoder.reset (new TestAudioDecoder (content));
+ decoder.reset (new TestAudioDecoder (content, film->log()));
/* Simple reads */
+
check (0, 48000);
check (44, 9123);
check (9991, 22);
/* Read off the end */
- Frame const from = content->resampled_audio_frame_rate() * 61;
- Frame const length = content->resampled_audio_frame_rate() * 4;
+ Frame const from = content->audio->resampled_audio_frame_rate() * 61;
+ Frame const length = content->audio->resampled_audio_frame_rate() * 4;
ContentAudio ca = get (from, length);
- for (int i = 0; i < content->audio_stream()->channels(); ++i) {
+ for (int i = 0; i < content->audio->stream()->channels(); ++i) {
for (int j = 0; j < ca.audio->frames(); ++j) {
BOOST_REQUIRE_EQUAL (ca.audio->data(i)[j], j + from);
}
#include "lib/dcp_content_type.h"
#include "lib/ratio.h"
#include "lib/film.h"
+#include "lib/audio_content.h"
#include "test.h"
#include <iostream>
film->set_name (film_name);
shared_ptr<SndfileContent> content (new SndfileContent (film, "test/data/staircase.wav"));
- content->set_audio_delay (delay_in_ms);
+ content->audio->set_audio_delay (delay_in_ms);
film->examine_and_add_content (content);
wait_for_jobs ();
#include "lib/ratio.h"
#include "lib/dcp_decoder.h"
#include "lib/dcp_content_type.h"
+#include "lib/subtitle_content.h"
#include "test.h"
#include <iostream>
BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (2));
- content->set_use_subtitles (true);
- content->set_burn_subtitles (false);
+ content->subtitle->set_use_subtitles (true);
+ content->subtitle->set_burn_subtitles (false);
film->make_dcp ();
wait_for_jobs ();
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/ffmpeg_audio_stream.h"
#include "lib/frame_rate_change.h"
#include "lib/video_content.h"
+#include "lib/audio_content.h"
#include "test.h"
using boost::shared_ptr;
content->video->_video_frame_rate = 24;
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 48000);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 48000);
stream->_frame_rate = 44100;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 48000);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 48000);
stream->_frame_rate = 80000;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 96000);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 96000);
content->video->_video_frame_rate = 23.976;
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 47952);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 47952);
content->video->_video_frame_rate = 29.97;
film->set_video_frame_rate (30);
BOOST_CHECK_EQUAL (film->video_frame_rate (), 30);
stream->_frame_rate = 48000;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 47952);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 47952);
content->video->_video_frame_rate = 25;
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 50000);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 50000);
content->video->_video_frame_rate = 25;
film->set_video_frame_rate (24);
stream->_frame_rate = 44100;
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 50000);
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), 50000);
/* Check some out-there conversions (not the best) */
/* The FrameRateChange within resampled_audio_frame_rate should choose to double-up
the 14.99 fps video to 30 and then run it slow at 25.
*/
- BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), lrint (48000 * 2 * 14.99 / 25));
+ BOOST_CHECK_EQUAL (content->audio->resampled_audio_frame_rate(), lrint (48000 * 2 * 14.99 / 25));
}
#include "lib/image_content.h"
#include "lib/sndfile_content.h"
#include "lib/video_content.h"
+#include "lib/audio_mapping.h"
+#include "lib/audio_content.h"
#include "test.h"
#include <iostream>
wait_for_jobs ();
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_10_4K_DI_20140704_PP_SMPTE_OV");
- AudioMapping mapping = sound->audio_mapping ();
+ AudioMapping mapping = sound->audio->audio_mapping ();
mapping.set (0, dcp::LEFT, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_20_4K_DI_20140704_PP_SMPTE_OV");
mapping.set (0, dcp::RIGHT, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_30_4K_DI_20140704_PP_SMPTE_OV");
mapping.set (0, dcp::LFE, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_31_4K_DI_20140704_PP_SMPTE_OV");
mapping.set (0, dcp::LS, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_41_4K_DI_20140704_PP_SMPTE_OV");
mapping.set (0, dcp::RS, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PP_SMPTE_OV");
mapping.set (0, dcp::HI, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_51_4K_DI_20140704_PP_SMPTE_OV");
film->set_audio_channels (8);
mapping.set (0, dcp::HI, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_61_4K_DI_20140704_PP_SMPTE_OV");
mapping.set (0, dcp::VI, 1.0);
- sound->set_audio_mapping (mapping);
+ sound->audio->set_mapping (mapping);
BOOST_CHECK_EQUAL (film->isdcf_name(false), "LikeShouting_XSN-2_F-133_DE-fr_US-R_71_4K_DI_20140704_PP_SMPTE_OV");
}
#include "lib/dcp_content_type.h"
#include "lib/image_content.h"
#include "lib/ffmpeg_content.h"
+#include "lib/video_content.h"
#include "lib/ratio.h"
#include <dcp/mono_picture_asset.h>
#include <dcp/stereo_picture_asset.h>
film->set_three_d (true);
shared_ptr<ImageContent> content (new ImageContent (film, "test/data/3d_test"));
- content->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
+ content->video->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
film->examine_and_add_content (content);
wait_for_jobs ();
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/image_content.h"
#include "lib/dcp_content_type.h"
#include "lib/dcp_content.h"
+#include "lib/video_content.h"
#include "lib/text_subtitle_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/flat_red.png"));
film->examine_and_add_content (c);
wait_for_jobs ();
- c->set_video_length (24);
+ c->video->set_video_length (24);
}
{
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/flat_green.png"));
film->examine_and_add_content (c);
wait_for_jobs ();
- c->set_video_length (24);
+ c->video->set_video_length (24);
}
{
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/flat_blue.png"));
film->examine_and_add_content (c);
wait_for_jobs ();
- c->set_video_length (24);
+ c->video->set_video_length (24);
}
film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
content[i].reset (new ImageContent (film, "test/data/flat_green.png"));
film->examine_and_add_content (content[i]);
wait_for_jobs ();
- content[i]->set_video_length (24);
+ content[i]->video->set_video_length (24);
}
shared_ptr<TextSubtitleContent> subs (new TextSubtitleContent (film, "test/data/subrip3.srt"));
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/ratio.h"
#include "lib/ffmpeg_content.h"
#include "lib/dcp_content_type.h"
+#include "lib/video_content.h"
using boost::shared_ptr;
wait_for_jobs ();
- c->set_scale (VideoContentScale (Ratio::from_id ("185")));
+ c->video->set_scale (VideoContentScale (Ratio::from_id ("185")));
film->set_video_frame_rate (48);
film->make_dcp ();
/* Should be 32 frames of red */
check_dcp ("test/data/repeat_frame_test", film->dir (film->dcp_name ()));
}
-
#include "lib/ratio.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
+#include "lib/video_content.h"
#include "test.h"
using std::string;
using boost::shared_ptr;
-static void scaling_test_for (shared_ptr<Film> film, shared_ptr<VideoContent> content, string image, string container)
+static void scaling_test_for (shared_ptr<Film> film, shared_ptr<Content> content, string image, string container)
{
- content->set_scale (VideoContentScale (Ratio::from_id (image)));
+ content->video->set_scale (VideoContentScale (Ratio::from_id (image)));
film->set_container (Ratio::from_id (container));
film->make_dcp ();
wait_for_jobs ();
- imc->set_video_length (1);
+ imc->video->set_video_length (1);
/* F-133: 133 image in a flat container */
scaling_test_for (film, imc, "133", "185");
/* S: scope image in a scope container */
scaling_test_for (film, imc, "239", "239");
}
-
shared_ptr<FFmpegContent> content (new FFmpegContent (film, "test/data/count300bd48.m2ts"));
film->examine_and_add_content (content);
wait_for_jobs ();
- content->set_scale (VideoContentScale (Ratio::from_id ("185")));
+ content->video->set_scale (VideoContentScale (Ratio::from_id ("185")));
/* Work out the first video frame index that we will be given, taking into account
* the difference between first video and first audio.
video_delay = ContentTime ();
}
- Frame const first_frame = video_delay.round_up (content->video_frame_rate ()).frames_round (content->video_frame_rate ());
+ Frame const first_frame = video_delay.round_up (content->video->video_frame_rate ()).frames_round (content->video->video_frame_rate ());
FFmpegDecoder decoder (content, film->log(), false);
list<ContentVideo> a = decoder.get_video (first_frame, true);
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/ratio.h"
#include "lib/ffmpeg_content.h"
#include "lib/dcp_content_type.h"
+#include "lib/video_content.h"
using boost::shared_ptr;
wait_for_jobs ();
- c->set_scale (VideoContentScale (Ratio::from_id ("185")));
+ c->video->set_scale (VideoContentScale (Ratio::from_id ("185")));
film->write_metadata ();
film->set_video_frame_rate (24);
*/
check_dcp ("test/data/skip_frame_test", film->dir (film->dcp_name ()));
}
-
#include "lib/dcp_content_type.h"
#include "lib/font.h"
#include "lib/ratio.h"
+#include "lib/subtitle_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.hpp>
film->examine_and_add_content (content);
wait_for_jobs ();
- content->set_use_subtitles (true);
- content->set_burn_subtitles (false);
+ content->subtitle->set_use_subtitles (true);
+ content->subtitle->set_burn_subtitles (false);
film->make_dcp ();
wait_for_jobs ();
film->examine_and_add_content (content);
wait_for_jobs ();
- content->set_use_subtitles (true);
- content->set_burn_subtitles (false);
+ content->subtitle->set_use_subtitles (true);
+ content->subtitle->set_burn_subtitles (false);
/* Use test/data/subrip2.srt as if it were a font file */
- content->fonts().front()->set_file (FontFiles::NORMAL, "test/data/subrip2.srt");
+ content->subtitle->fonts().front()->set_file (FontFiles::NORMAL, "test/data/subrip2.srt");
film->make_dcp ();
wait_for_jobs ();
film->examine_and_add_content (content);
wait_for_jobs ();
- content->set_use_subtitles (true);
- content->set_burn_subtitles (false);
+ content->subtitle->set_use_subtitles (true);
+ content->subtitle->set_burn_subtitles (false);
film->make_dcp ();
wait_for_jobs ();
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/ratio.h"
#include "lib/dcp_content_type.h"
#include "lib/ffmpeg_content.h"
+#include "lib/video_content.h"
#include <iostream>
using std::cout;
shared_ptr<Film> film = new_test_film ("threed_test");
film->set_name ("test_film2");
shared_ptr<FFmpegContent> c (new FFmpegContent (film, "test/data/test.mp4"));
- c->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
+ c->video->set_video_frame_type (VIDEO_FRAME_TYPE_3D_LEFT_RIGHT);
film->examine_and_add_content (c);
wait_for_jobs ();
- c->set_scale (VideoContentScale (Ratio::from_id ("185")));
+ c->video->set_scale (VideoContentScale (Ratio::from_id ("185")));
film->set_container (Ratio::from_id ("185"));
film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "lib/film.h"
#include "lib/ffmpeg_content.h"
+#include "lib/video_content.h"
#include "lib/player.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
/* 25fps content, 25fps DCP */
film->set_video_frame_rate (25);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->video_length() / 25.0));
/* 25fps content, 24fps DCP; length should be increased */
film->set_video_frame_rate (24);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 24.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->video_length() / 24.0));
/* 25fps content, 30fps DCP; length should be decreased */
film->set_video_frame_rate (30);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 30.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->video_length() / 30.0));
/* 25fps content, 50fps DCP; length should be the same */
film->set_video_frame_rate (50);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->video_length() / 25.0));
/* 25fps content, 60fps DCP; length should be decreased */
film->set_video_frame_rate (60);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() * (50.0 / 60) / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->video_length() * (50.0 / 60) / 25.0));
}
/** Test Player::dcp_to_content_video */
/* Position 0, no trim, content rate = DCP rate */
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate = DCP rate */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.5s trim, content rate = DCP rate */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate 24, DCP rate 25 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.6));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (48);
+ content->video->set_video_frame_rate (48);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (48);
+ content->video->set_video_frame_rate (48);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (48);
+ content->video->set_video_frame_rate (48);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 0s, no trim, content rate 29.9978733, DCP rate 30 */
content->set_position (DCPTime::from_seconds (0));
content->set_trim_start (ContentTime::from_seconds (0));
- content->set_video_frame_rate (29.9978733);
+ content->video->set_video_frame_rate (29.9978733);
film->set_video_frame_rate (30);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 0, no trim, content rate = DCP rate */
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate = DCP rate */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.5s trim, content rate = DCP rate */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate 24, DCP rate 25 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.6s trim, content rate 24, DCP rate 25, so the 1.6s trim is at 24fps */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.6));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (48);
+ content->video->set_video_frame_rate (48);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (48);
+ content->video->set_video_frame_rate (48);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (48);
+ content->video->set_video_frame_rate (48);
film->set_video_frame_rate (24);
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
/* Position 0, no trim, video/audio content rate = video/audio DCP rate */
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, no trim, video/audio content rate = video/audio DCP rate */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, 1.5s trim, video/audio content rate = video/audio DCP rate */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 0, no trim, content video rate 24, DCP video rate 25, both audio rates still 48k */
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, no trim, content video rate 24, DCP rate 25, both audio rates still 48k. */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
stream->_frame_rate = 48000;
player->setup_pieces ();
*/
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.6));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (25);
stream->_frame_rate = 48000;
player->setup_pieces ();
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
*/
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (48);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
/* Position 0, no trim, video content rate = video DCP rate, content audio rate = 44.1k */
content->set_position (DCPTime ());
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 44100;
player->setup_pieces ();
/* Position 3s, no trim, video content rate = video DCP rate, content audio rate = 44.1k */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime ());
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 44100;
player->setup_pieces ();
/* Position 3s, 1.5s trim, video content rate = video DCP rate, content audio rate = 44.1k */
content->set_position (DCPTime::from_seconds (3));
content->set_trim_start (ContentTime::from_seconds (1.5));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 44100;
player->setup_pieces ();
/* Check with a large start trim */
content->set_position (DCPTime::from_seconds (0));
content->set_trim_start (ContentTime::from_seconds (54143));
- content->set_video_frame_rate (24);
+ content->video->set_video_frame_rate (24);
film->set_video_frame_rate (24);
stream->_frame_rate = 48000;
player->setup_pieces ();
#include <boost/test/unit_test.hpp>
#include "lib/ffmpeg_content.h"
#include "lib/ratio.h"
+#include "lib/video_content.h"
using std::list;
using std::string;
doc->read_string(s.str ());
list<string> notes;
- shared_ptr<VideoContent> vc (new FFmpegContent (film, doc, 10, notes));
+ shared_ptr<FFmpegContent> vc (new FFmpegContent (film, doc, 10, notes));
optional<VideoContentScale> sc;
if (ratio) {
sc = VideoContentScale (scale);
}
- dcp::Size answer = sc.get().size (vc, display_size, film_size);
+ dcp::Size answer = sc.get().size (vc->video, display_size, film_size);
if (answer != correct) {
- cerr << "Testing " << vc->video_size().width << "x" << vc->video_size().height << "\n";
+ cerr << "Testing " << vc->video->video_size().width << "x" << vc->video->video_size().height << "\n";
cerr << "Testing " << display_size.width << "x" << display_size.height << "\n";
cerr << answer.width << "x" << answer.height << " instead of " << correct.width << "x" << correct.height << "\n";
}
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <boost/test/unit_test.hpp>
#include "lib/image_decoder.h"
#include "lib/image_content.h"
+#include "lib/film.h"
#include "test.h"
#include <iostream>
{
shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
- ImageDecoder decoder (c);
+ ImageDecoder decoder (c, film->log());
decoder.fill_one_eye (0, 4, EYES_BOTH);
BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 4U);
{
shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
- ImageDecoder decoder (c);
+ ImageDecoder decoder (c, film->log());
decoder.fill_both_eyes (0, 4, EYES_LEFT);
BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 8);
#include "lib/film.h"
#include "lib/ratio.h"
#include "lib/dcp_content_type.h"
+#include "lib/subtitle_content.h"
#include "test.h"
#include <iostream>
film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
film->set_name ("frobozz");
shared_ptr<TextSubtitleContent> content (new TextSubtitleContent (film, "test/data/subrip2.srt"));
- content->set_use_subtitles (true);
- content->set_burn_subtitles (false);
+ content->subtitle->set_use_subtitles (true);
+ content->subtitle->set_burn_subtitles (false);
film->examine_and_add_content (content);
wait_for_jobs ();
film->make_dcp ();
film->set_interop (true);
film->set_sequence (false);
shared_ptr<TextSubtitleContent> content (new TextSubtitleContent (film, "test/data/subrip2.srt"));
- content->set_use_subtitles (true);
- content->set_burn_subtitles (false);
+ content->subtitle->set_use_subtitles (true);
+ content->subtitle->set_burn_subtitles (false);
film->examine_and_add_content (content);
film->examine_and_add_content (content);
wait_for_jobs ();