#include "format.h"
#include "job.h"
#include "filter.h"
-#include "transcoder.h"
#include "util.h"
#include "job_manager.h"
#include "ab_transcode_job.h"
#include "config.h"
#include "version.h"
#include "ui_signaller.h"
-#include "video_decoder.h"
-#include "audio_decoder.h"
-#include "sndfile_decoder.h"
#include "analyse_audio_job.h"
#include "playlist.h"
+#include "player.h"
#include "ffmpeg_content.h"
#include "imagemagick_content.h"
#include "sndfile_content.h"
+#include "dcp_content_type.h"
#include "i18n.h"
, _use_dci_name (true)
, _trust_content_headers (true)
, _dcp_content_type (0)
- , _format (0)
+ , _format (Format::from_id ("185"))
, _scaler (Scaler::from_id ("bicubic"))
, _trim_start (0)
, _trim_end (0)
, _dirty (false)
{
set_dci_date_today ();
+
+ _playlist->ContentChanged.connect (bind (&Film::content_changed, this, _1, _2));
/* Make state.directory a complete path without ..s (where possible)
(Code swiped from Adam Bowen on stackoverflow)
, _colour_lut (o._colour_lut)
, _j2k_bandwidth (o._j2k_bandwidth)
, _dci_metadata (o._dci_metadata)
- , _dci_date (o._dci_date)
, _dcp_frame_rate (o._dcp_frame_rate)
+ , _dci_date (o._dci_date)
, _dirty (o._dirty)
{
+ for (ContentList::const_iterator i = o._content.begin(); i != o._content.end(); ++i) {
+ _content.push_back ((*i)->clone ());
+ }
+
+ _playlist->ContentChanged.connect (bind (&Film::content_changed, this, _1, _2));
+
_playlist->setup (_content);
}
-Film::~Film ()
-{
-
-}
-
string
Film::video_state_identifier () const
{
}
}
-/** Start a job to analyse the audio of our content file */
+/** Start a job to analyse the audio in our Playlist */
void
Film::analyse_audio ()
{
Film::examine_content (shared_ptr<Content> c)
{
shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c, trust_content_headers ()));
- j->Finished.connect (bind (&Film::examine_content_finished, this));
JobManager::instance()->add (j);
}
_analyse_audio_job.reset ();
}
-void
-Film::examine_content_finished ()
-{
- /* XXX */
-}
-
/** Start a job to send our DCP to the configured TMS */
void
Film::send_dcp_to_tms ()
root->add_child("ColourLUT")->add_child_text (boost::lexical_cast<string> (_colour_lut));
root->add_child("J2KBandwidth")->add_child_text (boost::lexical_cast<string> (_j2k_bandwidth));
_dci_metadata.as_xml (root->add_child ("DCIMetadata"));
- root->add_child("DCIDate")->add_child_text (boost::gregorian::to_iso_string (_dci_date));
root->add_child("DCPFrameRate")->add_child_text (boost::lexical_cast<string> (_dcp_frame_rate));
+ root->add_child("DCIDate")->add_child_text (boost::gregorian::to_iso_string (_dci_date));
+ _audio_mapping.as_xml (root->add_child("AudioMapping"));
for (ContentList::iterator i = the_content.begin(); i != the_content.end(); ++i) {
(*i)->as_xml (root->add_child ("Content"));
_colour_lut = f.number_child<int> ("ColourLUT");
_j2k_bandwidth = f.number_child<int> ("J2KBandwidth");
_dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
- _dci_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
_dcp_frame_rate = f.number_child<int> ("DCPFrameRate");
+ _dci_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
list<shared_ptr<cxml::Node> > c = f.node_children ("Content");
for (list<shared_ptr<cxml::Node> >::iterator i = c.begin(); i != c.end(); ++i) {
string const type = (*i)->string_child ("Type");
+ boost::shared_ptr<Content> c;
if (type == "FFmpeg") {
- _content.push_back (shared_ptr<Content> (new FFmpegContent (*i)));
+ c.reset (new FFmpegContent (*i));
} else if (type == "ImageMagick") {
- _content.push_back (shared_ptr<Content> (new ImageMagickContent (*i)));
+ c.reset (new ImageMagickContent (*i));
} else if (type == "Sndfile") {
- _content.push_back (shared_ptr<Content> (new SndfileContent (*i)));
+ c.reset (new SndfileContent (*i));
}
+
+ _content.push_back (c);
}
+ /* This must come after we've loaded the content, as we're looking things up in _content */
+ _audio_mapping.set_from_xml (_content, f.node_child ("AudioMapping"));
+
_dirty = false;
+
+ _playlist->setup (_content);
}
libdcp::Size
int
Film::target_audio_sample_rate () const
{
- if (has_audio ()) {
+ if (!has_audio ()) {
return 0;
}
}
}
- /* XXX */
- switch (2) {
+ switch (audio_channels ()) {
case 1:
d << "_10";
break;
if (!_trust_content_headers && !content().empty()) {
/* We just said that we don't trust the content's header */
- /* XXX */
-// examine_content ();
+ ContentList c = content ();
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ examine_content (*i);
+ }
}
}
_dirty = true;
}
+ switch (p) {
+ case Film::CONTENT:
+ _playlist->setup (content ());
+ set_dcp_frame_rate (best_dcp_frame_rate (video_frame_rate ()));
+ set_audio_mapping (_playlist->default_audio_mapping ());
+ break;
+ default:
+ break;
+ }
+
if (ui_signaller) {
ui_signaller->emit (boost::bind (boost::ref (Changed), p));
}
{
boost::mutex::scoped_lock lm (_state_mutex);
_content.push_back (c);
- _playlist->setup (_content);
}
signal_changed (CONTENT);
examine_content (c);
}
+void
+Film::remove_content (shared_ptr<Content> c)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ ContentList::iterator i = find (_content.begin(), _content.end(), c);
+ if (i != _content.end ()) {
+ _content.erase (i);
+ }
+ }
+
+ signal_changed (CONTENT);
+}
+
+void
+Film::move_content_earlier (shared_ptr<Content> c)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ ContentList::iterator i = find (_content.begin(), _content.end(), c);
+ if (i == _content.begin () || i == _content.end()) {
+ return;
+ }
+
+ ContentList::iterator j = i;
+ --j;
+
+ swap (*i, *j);
+ _playlist->setup (_content);
+ }
+
+ signal_changed (CONTENT);
+}
+
+void
+Film::move_content_later (shared_ptr<Content> c)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ ContentList::iterator i = find (_content.begin(), _content.end(), c);
+ if (i == _content.end()) {
+ return;
+ }
+
+ ContentList::iterator j = i;
+ ++j;
+ if (j == _content.end ()) {
+ return;
+ }
+
+ swap (*i, *j);
+ _playlist->setup (_content);
+ }
+
+ signal_changed (CONTENT);
+
+}
+
ContentAudioFrame
Film::audio_length () const
{
return _playlist->video_length ();
}
+/** Unfortunately this is needed as the GUI has FFmpeg-specific controls */
+shared_ptr<FFmpegContent>
+Film::ffmpeg () const
+{
+ boost::mutex::scoped_lock lm (_state_mutex);
+
+ for (ContentList::const_iterator i = _content.begin (); i != _content.end(); ++i) {
+ shared_ptr<FFmpegContent> f = boost::dynamic_pointer_cast<FFmpegContent> (*i);
+ if (f) {
+ return f;
+ }
+ }
+
+ return shared_ptr<FFmpegContent> ();
+}
+
+vector<FFmpegSubtitleStream>
+Film::ffmpeg_subtitle_streams () const
+{
+ shared_ptr<FFmpegContent> f = ffmpeg ();
+ if (f) {
+ return f->subtitle_streams ();
+ }
+
+ return vector<FFmpegSubtitleStream> ();
+}
+
+boost::optional<FFmpegSubtitleStream>
+Film::ffmpeg_subtitle_stream () const
+{
+ shared_ptr<FFmpegContent> f = ffmpeg ();
+ if (f) {
+ return f->subtitle_stream ();
+ }
+
+ return boost::none;
+}
+
+vector<FFmpegAudioStream>
+Film::ffmpeg_audio_streams () const
+{
+ shared_ptr<FFmpegContent> f = ffmpeg ();
+ if (f) {
+ return f->audio_streams ();
+ }
+
+ return vector<FFmpegAudioStream> ();
+}
+
+boost::optional<FFmpegAudioStream>
+Film::ffmpeg_audio_stream () const
+{
+ shared_ptr<FFmpegContent> f = ffmpeg ();
+ if (f) {
+ return f->audio_stream ();
+ }
+
+ return boost::none;
+}
+
+void
+Film::set_ffmpeg_subtitle_stream (FFmpegSubtitleStream s)
+{
+ shared_ptr<FFmpegContent> f = ffmpeg ();
+ if (f) {
+ f->set_subtitle_stream (s);
+ }
+}
+
+void
+Film::set_ffmpeg_audio_stream (FFmpegAudioStream s)
+{
+ shared_ptr<FFmpegContent> f = ffmpeg ();
+ if (f) {
+ f->set_audio_stream (s);
+ }
+}
+
+void
+Film::set_audio_mapping (AudioMapping m)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _audio_mapping = m;
+ }
+
+ signal_changed (AUDIO_MAPPING);
+}
+
+void
+Film::content_changed (boost::weak_ptr<Content> c, int p)
+{
+ if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
+ set_dcp_frame_rate (best_dcp_frame_rate (video_frame_rate ()));
+ } else if (p == AudioContentProperty::AUDIO_CHANNELS) {
+ set_audio_mapping (_playlist->default_audio_mapping ());
+ }
+
+ if (ui_signaller) {
+ ui_signaller->emit (boost::bind (boost::ref (ContentChanged), c, p));
+ }
+}