diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-07 00:39:34 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-07 00:39:34 +0100 |
| commit | 3cc96e5cc65456f4aeb4625f56087da33da47b48 (patch) | |
| tree | 6c9bd627b56a86f4e2169509ccea70cc47accbfd /src | |
| parent | c921cfe23b593d7c367ad76094308c5f08037374 (diff) | |
Save audio mapping to XML; fix initial video display.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/audio_mapping.cc | 42 | ||||
| -rw-r--r-- | src/lib/audio_mapping.h | 3 | ||||
| -rw-r--r-- | src/lib/film.cc | 4 | ||||
| -rw-r--r-- | src/lib/player.cc | 1 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 10 |
5 files changed, 52 insertions, 8 deletions
diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index 48cc23307..b85ea7314 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -17,13 +17,18 @@ */ +#include <boost/lexical_cast.hpp> +#include <libcxml/cxml.h> #include "audio_mapping.h" using std::list; using std::cout; using std::make_pair; using std::pair; +using std::string; using boost::shared_ptr; +using boost::lexical_cast; +using boost::dynamic_pointer_cast; void AudioMapping::add (Channel c, libdcp::Channel d) @@ -83,6 +88,40 @@ AudioMapping::content_to_dcp (Channel c) const return d; } +void +AudioMapping::as_xml (xmlpp::Node* node) const +{ + for (list<pair<Channel, libdcp::Channel> >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) { + xmlpp::Node* t = node->add_child ("Map"); + shared_ptr<const AudioContent> c = i->first.content.lock (); + t->add_child ("Content")->add_child_text (c->file().string ()); + t->add_child ("ContentIndex")->add_child_text (lexical_cast<string> (i->first.index)); + t->add_child ("DCP")->add_child_text (lexical_cast<string> (i->second)); + } +} + +void +AudioMapping::set_from_xml (ContentList const & content, shared_ptr<const cxml::Node> node) +{ + list<shared_ptr<cxml::Node> > const c = node->node_children ("Map"); + for (list<shared_ptr<cxml::Node> >::const_iterator i = c.begin(); i != c.end(); ++i) { + string const c = (*i)->string_child ("Content"); + ContentList::const_iterator j = content.begin (); + while (j != content.end() && (*j)->file().string() != c) { + ++j; + } + + if (j == content.end ()) { + continue; + } + + shared_ptr<const AudioContent> ac = dynamic_pointer_cast<AudioContent> (*j); + assert (ac); + + add (AudioMapping::Channel (ac, (*i)->number_child<int> ("ContentIndex")), static_cast<libdcp::Channel> ((*i)->number_child<int> ("DCP"))); + } +} + bool operator== (AudioMapping::Channel const & a, AudioMapping::Channel const & b) { @@ -90,6 +129,3 @@ operator== (AudioMapping::Channel const & a, AudioMapping::Channel const & b) shared_ptr<const AudioContent> sb = b.content.lock (); return sa == sb && a.index == b.index; } - - - diff --git a/src/lib/audio_mapping.h b/src/lib/audio_mapping.h index 10ac20b48..4f2cdb7f8 100644 --- a/src/lib/audio_mapping.h +++ b/src/lib/audio_mapping.h @@ -29,6 +29,9 @@ class AudioMapping { public: + void as_xml (xmlpp::Node *) const; + void set_from_xml (ContentList const &, boost::shared_ptr<const cxml::Node>); + struct Channel { Channel (boost::weak_ptr<const AudioContent> c, int i) : content (c) diff --git a/src/lib/film.cc b/src/lib/film.cc index b1f740ec2..b36dc8f9c 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -418,6 +418,7 @@ Film::write_metadata () const _dci_metadata.as_xml (root->add_child ("DCIMetadata")); 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")); @@ -502,6 +503,9 @@ Film::read_metadata () _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); diff --git a/src/lib/player.cc b/src/lib/player.cc index 60917ba09..d1f047851 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -26,6 +26,7 @@ #include "job.h" using std::list; +using std::cout; using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 08358c519..4bc5466bc 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -84,18 +84,18 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p) _play_button->Connect (wxID_ANY, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler (FilmViewer::play_clicked), 0, this); _timer.Connect (wxID_ANY, wxEVT_TIMER, wxTimerEventHandler (FilmViewer::timer), 0, this); - set_film (f); - - _player = _film->player (); + /* We need a player before we set_film() so that the first frame will be displayed */ + _player = f->player (); _player->disable_audio (); _player->disable_video_sync (); - /* Don't disable subtitles here as we may need them, and it's nice to be able to turn them on and off without needing obtain a new Player. */ _player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3)); + set_film (f); + JobManager::instance()->ActiveJobsChanged.connect ( bind (&FilmViewer::active_jobs_changed, this, _1) ); @@ -392,7 +392,7 @@ FilmViewer::get_frame () _display_frame.reset (); return; } - + try { _got_frame = false; while (!_got_frame) { |
