swaroop: Disable play/stop/pause and slider during ad content.
authorCarl Hetherington <cth@carlh.net>
Fri, 28 Sep 2018 23:13:49 +0000 (00:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 28 Sep 2018 23:13:49 +0000 (00:13 +0100)
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcp_examiner.cc
src/lib/dcp_examiner.h
src/lib/player_video.h
src/wx/controls.cc
src/wx/controls.h

index 3498cc96119940bbd2a25a4546c0c1fc0bc56662..7301e537393e43eb1097cb806f6506b87727754c 100644 (file)
@@ -133,6 +133,11 @@ DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
                }
        }
        _three_d = node->optional_bool_child("ThreeD").get_value_or (false);
+
+       optional<string> 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<int64_t> (i->content ()));
@@ -209,6 +214,7 @@ DCPContent::examine (shared_ptr<Job> 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 ());
        }
index db617afa2c52f8d8e53faf9cbeb6308a46f47fd9..2a3ef46e80092db8b2fd4288211eccac18975163 100644 (file)
@@ -138,6 +138,11 @@ public:
                return _three_d;
        }
 
+       boost::optional<dcp::ContentKind> 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<dcp::Standard> _standard;
+       boost::optional<dcp::ContentKind> _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.
index 1785669dd56ceefdf93f33cbf29465ea49eaad1c..dfb47f2ebf6d1f009e9476620e4c708ea84591c4 100644 (file)
@@ -108,6 +108,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content)
 
        _cpl = cpl->id ();
        _name = cpl->content_title_text ();
+       _content_kind = cpl->content_kind ();
 
        BOOST_FOREACH (shared_ptr<dcp::Reel> i, cpl->reels()) {
 
index 4b93bfa4298e99606f9d61f4e14923221065f268..f54f02c36c005f607de6b8b3720beac8b4a3f2df 100644 (file)
@@ -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<dcp::Standard> _standard;
        bool _three_d;
+       dcp::ContentKind _content_kind;
        std::string _cpl;
        std::list<int64_t> _reel_lengths;
 };
index cd904af0613d5b9aa842e07cdbacad89e4e24466..11b2c88330512b96ddc205ee104fc87237eab5cc 100644 (file)
@@ -100,6 +100,10 @@ public:
 
        size_t memory_used () const;
 
+       boost::weak_ptr<Content> content () const {
+               return _content;
+       }
+
 private:
        boost::shared_ptr<const ImageProxy> _in;
        Crop _crop;
@@ -110,7 +114,9 @@ private:
        Part _part;
        boost::optional<ColourConversion> _colour_conversion;
        boost::optional<PositionImage> _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> _content;
        /** Video frame that we came from.  Again, this is for reset_metadata() */
        boost::optional<Frame> _video_frame;
index a5cc1dcc4f7a8cd5cf5e3b49c20c927a1d338284..0c9a27518635f70dde4b120ca111d8eb1e71deec 100644 (file)
@@ -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 <dcp/dcp.h>
 #include <dcp/cpl.h>
 #include <dcp/reel.h>
@@ -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<FilmViewer> viewer, bool editor_controls)
        : wxPanel (parent)
@@ -170,6 +173,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> 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<PlayerVideo> weak_pv)
+{
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       shared_ptr<PlayerVideo> pv = weak_pv.lock ();
+       if (!pv) {
+               return;
+       }
+
+       shared_ptr<Content> c = pv->content().lock();
+       if (!c) {
+               return;
+       }
+
+       shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (c);
+       if (!dc) {
+               return;
+       }
+
+       if (!_current_kind || *_current_kind != dc->content_kind()) {
+               _current_kind = dc->content_kind ();
+               setup_sensitivity ();
+       }
+#endif
+}
index a49f16595d43b93f17435fee8ac3377c8cfacb40..ba7c46fcc50a7ff724c6df6768cd09360b3bbcc0 100644 (file)
@@ -129,5 +129,9 @@ private:
 
        ClosedCaptionsDialog* _closed_captions_dialog;
 
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       boost::optional<dcp::ContentKind> _current_kind;
+#endif
+
        boost::signals2::scoped_connection _config_changed_connection;
 };