From: Carl Hetherington Date: Fri, 28 Sep 2018 23:13:49 +0000 (+0100) Subject: swaroop: Disable play/stop/pause and slider during ad content. X-Git-Tag: v2.13.58~10 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=92f024ea58c7279b8096e5e9f60f9cb2613e8a91 swaroop: Disable play/stop/pause and slider during ad content. --- diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 3498cc961..7301e5373 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -133,6 +133,11 @@ DCPContent::DCPContent (shared_ptr film, cxml::ConstNodePtr node, in } } _three_d = node->optional_bool_child("ThreeD").get_value_or (false); + + optional ck = node->optional_string_child("ContentKind"); + if (ck) { + _content_kind = dcp::content_kind_from_string (*ck); + } _cpl = node->optional_string_child("CPL"); BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("ReelLength")) { _reel_lengths.push_back (raw_convert (i->content ())); @@ -209,6 +214,7 @@ DCPContent::examine (shared_ptr job) _kdm_valid = examiner->kdm_valid (); _standard = examiner->standard (); _three_d = examiner->three_d (); + _content_kind = examiner->content_kind (); _cpl = examiner->cpl (); _reel_lengths = examiner->reel_lengths (); } @@ -301,6 +307,9 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const } } node->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0"); + if (_content_kind) { + node->add_child("ContentKind")->add_child_text(dcp::content_kind_to_string(*_content_kind)); + } if (_cpl) { node->add_child("CPL")->add_child_text (_cpl.get ()); } diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index db617afa2..2a3ef46e8 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -138,6 +138,11 @@ public: return _three_d; } + boost::optional content_kind () const { + boost::mutex::scoped_lock lm (_mutex); + return _content_kind; + } + bool kdm_timing_window_valid () const; private: @@ -176,6 +181,7 @@ private: bool _reference_text[TEXT_COUNT]; boost::optional _standard; + boost::optional _content_kind; bool _three_d; /** ID of the CPL to use; older metadata might not specify this: in that case * just use the only CPL. diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 1785669dd..dfb47f2eb 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -108,6 +108,7 @@ DCPExaminer::DCPExaminer (shared_ptr content) _cpl = cpl->id (); _name = cpl->content_title_text (); + _content_kind = cpl->content_kind (); BOOST_FOREACH (shared_ptr i, cpl->reels()) { diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index 4b93bfa42..f54f02c36 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -99,6 +99,10 @@ public: return _three_d; } + dcp::ContentKind content_kind () const { + return _content_kind; + } + std::string cpl () const { return _cpl; } @@ -125,6 +129,7 @@ private: bool _kdm_valid; boost::optional _standard; bool _three_d; + dcp::ContentKind _content_kind; std::string _cpl; std::list _reel_lengths; }; diff --git a/src/lib/player_video.h b/src/lib/player_video.h index cd904af06..11b2c8833 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -100,6 +100,10 @@ public: size_t memory_used () const; + boost::weak_ptr content () const { + return _content; + } + private: boost::shared_ptr _in; Crop _crop; @@ -110,7 +114,9 @@ private: Part _part; boost::optional _colour_conversion; boost::optional _text; - /** Content that we came from. This is so that reset_metadata() can work */ + /** Content that we came from. This is so that reset_metadata() can work, and also + * for variant:swaroop's non-skippable ads. + */ boost::weak_ptr _content; /** Video frame that we came from. Again, this is for reset_metadata() */ boost::optional _video_frame; diff --git a/src/wx/controls.cc b/src/wx/controls.cc index a5cc1dcc4..0c9a27518 100644 --- a/src/wx/controls.cc +++ b/src/wx/controls.cc @@ -24,6 +24,8 @@ #include "playhead_to_timecode_dialog.h" #include "playhead_to_frame_dialog.h" #include "lib/job_manager.h" +#include "lib/player_video.h" +#include "lib/dcp_content.h" #include #include #include @@ -38,6 +40,7 @@ using std::make_pair; using boost::optional; using boost::shared_ptr; using boost::weak_ptr; +using boost::dynamic_pointer_cast; Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor_controls) : wxPanel (parent) @@ -170,6 +173,7 @@ Controls::Controls (wxWindow* parent, shared_ptr viewer, bool editor _viewer->Started.connect (boost::bind(&Controls::started, this)); _viewer->Stopped.connect (boost::bind(&Controls::stopped, this)); _viewer->FilmChanged.connect (boost::bind(&Controls::film_changed, this)); + _viewer->ImageChanged.connect (boost::bind(&Controls::image_changed, this, _1)); film_changed (); @@ -420,8 +424,9 @@ Controls::setup_sensitivity () _forward_button->Enable (c); #ifdef DCPOMATIC_VARIANT_SWAROOP _play_button->Enable (c && !_viewer->playing()); - _pause_button->Enable (c && _viewer->playing()); - _stop_button->Enable (c); + _pause_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT) && _viewer->playing()); + _stop_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT)); + _slider->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT)); #else _play_button->Enable (c); #endif @@ -610,3 +615,29 @@ Controls::log (wxString s) wxString ts = std_to_wx(string(buffer)) + N_(": "); _log->SetValue(_log->GetValue() + ts + s + "\n"); } + +void +Controls::image_changed (boost::weak_ptr weak_pv) +{ +#ifdef DCPOMATIC_VARIANT_SWAROOP + shared_ptr pv = weak_pv.lock (); + if (!pv) { + return; + } + + shared_ptr c = pv->content().lock(); + if (!c) { + return; + } + + shared_ptr dc = dynamic_pointer_cast (c); + if (!dc) { + return; + } + + if (!_current_kind || *_current_kind != dc->content_kind()) { + _current_kind = dc->content_kind (); + setup_sensitivity (); + } +#endif +} diff --git a/src/wx/controls.h b/src/wx/controls.h index a49f16595..ba7c46fcc 100644 --- a/src/wx/controls.h +++ b/src/wx/controls.h @@ -129,5 +129,9 @@ private: ClosedCaptionsDialog* _closed_captions_dialog; +#ifdef DCPOMATIC_VARIANT_SWAROOP + boost::optional _current_kind; +#endif + boost::signals2::scoped_connection _config_changed_connection; };