From: Carl Hetherington Date: Thu, 25 Oct 2018 23:25:00 +0000 (+0100) Subject: Basics of MP4 support in the player. X-Git-Tag: v2.13.65~8 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=ee2cf80b14e8e78eb46280ba30cdb2f0c10c90a0 Basics of MP4 support in the player. --- diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 860181477..844d92bc8 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -444,11 +444,8 @@ public: _film->set_container (Ratio::from_id("185")); BOOST_FOREACH (shared_ptr i, _film->content()) { - /* This DCP has been examined and loaded */ - shared_ptr dcp = dynamic_pointer_cast(i); - DCPOMATIC_ASSERT (dcp); - if (dcp->needs_kdm()) { + if (dcp && dcp->needs_kdm()) { optional kdm; #ifdef DCPOMATIC_VARIANT_SWAROOP kdm = get_kdm_from_url (dcp); @@ -463,12 +460,12 @@ public: } } - BOOST_FOREACH (shared_ptr j, dcp->text) { + BOOST_FOREACH (shared_ptr j, i->text) { j->set_use (true); } - if (dcp->video) { - Ratio const * r = Ratio::nearest_from_ratio(dcp->video->size().ratio()); + if (i->video) { + Ratio const * r = Ratio::nearest_from_ratio(i->video->size().ratio()); if (r->id() == "239") { /* Any scope content means we use scope */ _film->set_container(r); @@ -476,7 +473,7 @@ public: } /* Any 3D content means we use 3D mode */ - if (dcp->three_d()) { + if (i->video && i->video->frame_type() != VIDEO_FRAME_TYPE_2D) { _film->set_three_d (true); } } @@ -494,16 +491,17 @@ public: if (_film->content().size() == 1) { /* Offer a CPL menu */ shared_ptr first = dynamic_pointer_cast(_film->content().front()); - DCPOMATIC_ASSERT (first); - DCPExaminer ex (first); - int id = ID_view_cpl; - BOOST_FOREACH (shared_ptr i, ex.cpls()) { - wxMenuItem* j = _cpl_menu->AppendRadioItem( - id, - wxString::Format("%s (%s)", std_to_wx(i->annotation_text()).data(), std_to_wx(i->id()).data()) - ); - j->Check(!first->cpl() || i->id() == *first->cpl()); - ++id; + if (first) { + DCPExaminer ex (first); + int id = ID_view_cpl; + BOOST_FOREACH (shared_ptr i, ex.cpls()) { + wxMenuItem* j = _cpl_menu->AppendRadioItem( + id, + wxString::Format("%s (%s)", std_to_wx(i->annotation_text()).data(), std_to_wx(i->id()).data()) + ); + j->Check(!first->cpl() || i->id() == *first->cpl()); + ++id; + } } } } diff --git a/src/wx/controls.cc b/src/wx/controls.cc index 8c24a0da3..9540b8586 100644 --- a/src/wx/controls.cc +++ b/src/wx/controls.cc @@ -28,6 +28,7 @@ #include "lib/dcp_content.h" #include "lib/job.h" #include "lib/examine_content_job.h" +#include "lib/content_factory.h" #include "lib/cross.h" #include #include @@ -190,7 +191,7 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor film_changed (); setup_sensitivity (); - update_dcp_directory (); + update_content_directory (); JobManager::instance()->ActiveJobsChanged.connect ( bind (&Controls::active_jobs_changed, this, _2) @@ -256,7 +257,7 @@ void Controls::config_changed (int property) { if (property == Config::PLAYER_CONTENT_DIRECTORY) { - update_dcp_directory (); + update_content_directory (); } else { setup_sensitivity (); } @@ -573,7 +574,7 @@ Controls::show_extended_player_controls (bool s) { _content_view->Show (s); if (s) { - update_dcp_directory (); + update_content_directory (); } _spl_view->Show (s); _log->Show (s); @@ -615,7 +616,7 @@ Controls::add_content_to_list (shared_ptr content, wxListCtrl* ctrl) } void -Controls::update_dcp_directory () +Controls::update_content_directory () { if (!_content_view->IsShown()) { return; @@ -630,13 +631,19 @@ Controls::update_dcp_directory () return; } - wxProgressDialog progress (_("DCP-o-matic"), _("Reading DCP directory")); + wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory")); JobManager* jm = JobManager::instance (); for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) { try { + shared_ptr content; if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) { - shared_ptr content (new DCPContent(_film, *i)); + content.reset (new DCPContent(_film, *i)); + } else if (i->path().extension() == ".mp4") { + content = content_factory(_film, *i).front(); + } + + if (content) { jm->add (shared_ptr(new ExamineContentJob(_film, content))); while (jm->work_to_do()) { if (!progress.Pulse()) { diff --git a/src/wx/controls.h b/src/wx/controls.h index dba981d14..6e9b684a6 100644 --- a/src/wx/controls.h +++ b/src/wx/controls.h @@ -79,8 +79,7 @@ private: void started (); void stopped (); void film_changed (); - void update_dcp_directory (); - void dcp_directory_changed (); + void update_content_directory (); void config_changed (int property); typedef std::pair, boost::filesystem::path> CPL;