Move _player_video into VideoView.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Oct 2019 21:03:27 +0000 (23:03 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2020 20:56:47 +0000 (21:56 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/simple_video_view.cc
src/wx/video_view.cc [new file with mode: 0644]
src/wx/video_view.h
src/wx/wscript

index 178311a..8b90cd9 100644 (file)
@@ -157,8 +157,7 @@ FilmViewer::set_film (shared_ptr<Film> film)
 
        _film = film;
        _video_position = DCPTime ();
-       _player_video.first.reset ();
-       _player_video.second = DCPTime ();
+       _video_view->clear ();
 
        _video_view->set_image (shared_ptr<Image>());
        _closed_captions_dialog->clear ();
@@ -406,11 +405,11 @@ FilmViewer::slow_refresh ()
 bool
 FilmViewer::quick_refresh ()
 {
-       if (!_player_video.first) {
+       if (!_video_view->_player_video.first) {
                return false;
        }
 
-       if (!_player_video.first->reset_metadata (_film, _player->video_container_size(), _film->frame_size())) {
+       if (!_video_view->_player_video.first->reset_metadata (_film, _player->video_container_size(), _film->frame_size())) {
                return false;
        }
 
index 916491d..e98fbe1 100644 (file)
@@ -173,7 +173,6 @@ private:
        bool _coalesce_player_changes;
        std::list<int> _pending_player_changes;
 
-       std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> _player_video;
        dcpomatic::DCPTime _video_position;
        Position<int> _inter_position;
        dcp::Size _inter_size;
index 456d8cd..91f7df5 100644 (file)
@@ -185,8 +185,8 @@ SimpleVideoView::get (bool lazy)
 
        do {
                Butler::Error e;
-               _viewer->_player_video = _viewer->_butler->get_video (!lazy, &e);
-               if (!_viewer->_player_video.first && e == Butler::AGAIN) {
+               _player_video = _viewer->_butler->get_video (!lazy, &e);
+               if (!_player_video.first && e == Butler::AGAIN) {
                        if (lazy) {
                                /* No video available; return saying we failed */
                                return false;
@@ -197,10 +197,10 @@ SimpleVideoView::get (bool lazy)
                        }
                }
        } while (
-               _viewer->_player_video.first &&
+               _player_video.first &&
                _viewer->film()->three_d() &&
-               _viewer->_eyes != _viewer->_player_video.first->eyes() &&
-               _viewer->_player_video.first->eyes() != EYES_BOTH
+               _viewer->_eyes != _player_video.first->eyes() &&
+               _player_video.first->eyes() != EYES_BOTH
                );
 
        try {
@@ -218,17 +218,17 @@ SimpleVideoView::get (bool lazy)
 void
 SimpleVideoView::display_player_video ()
 {
-       if (!_viewer->_player_video.first) {
+       if (!_player_video.first) {
                set_image (shared_ptr<Image>());
                _viewer->refresh_view ();
                return;
        }
 
-       if (_viewer->playing() && (_viewer->time() - _viewer->_player_video.second) > _viewer->one_video_frame()) {
+       if (_viewer->playing() && (_viewer->time() - _player_video.second) > _viewer->one_video_frame()) {
                /* Too late; just drop this frame before we try to get its image (which will be the time-consuming
                   part if this frame is J2K).
                */
-               _viewer->_video_position = _viewer->_player_video.second;
+               _viewer->_video_position = _player_video.second;
                ++_viewer->_dropped;
                return;
        }
@@ -254,16 +254,16 @@ SimpleVideoView::display_player_video ()
        _viewer->_state_timer.set ("get image");
 
        set_image (
-               _viewer->_player_video.first->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true)
+               _player_video.first->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true)
                );
 
        _viewer->_state_timer.set ("ImageChanged");
-       _viewer->ImageChanged (_viewer->_player_video.first);
+       _viewer->ImageChanged (_player_video.first);
        _viewer->_state_timer.unset ();
 
-       _viewer->_video_position = _viewer->_player_video.second;
-       _viewer->_inter_position = _viewer->_player_video.first->inter_position ();
-       _viewer->_inter_size = _viewer->_player_video.first->inter_size ();
+       _viewer->_video_position = _player_video.second;
+       _viewer->_inter_position = _player_video.first->inter_position ();
+       _viewer->_inter_size = _player_video.first->inter_size ();
 
        _viewer->refresh_view ();
 
diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc
new file mode 100644 (file)
index 0000000..eb85079
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "video_view.h"
+
+void
+VideoView::clear ()
+{
+       _player_video.first.reset ();
+       _player_video.second = dcpomatic::DCPTime ();
+}
index 873df16..f4a8ea2 100644 (file)
 #ifndef DCPOMATIC_VIDEO_VIEW_H
 #define DCPOMATIC_VIDEO_VIEW_H
 
+#include "lib/dcpomatic_time.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 
 class Image;
 class wxWindow;
 class FilmViewer;
+class PlayerVideo;
 
 class VideoView
 {
@@ -47,6 +49,8 @@ public:
        /* XXX_b: make pure */
        virtual void start () {}
 
+       void clear ();
+
        boost::signals2::signal<void()> Sized;
 
        /* XXX_b: to remove */
@@ -57,7 +61,11 @@ public:
        virtual void display_player_video () {}
 
 protected:
+       /* XXX_b: to remove */
+       friend class FilmViewer;
+
        FilmViewer* _viewer;
+       std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> _player_video;
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        bool _in_watermark;
index f4fc492..5dbf75e 100644 (file)
@@ -145,6 +145,7 @@ sources = """
           update_dialog.cc
           verify_dcp_dialog.cc
           video_panel.cc
+          video_view.cc
           video_waveform_dialog.cc
           video_waveform_plot.cc
           wx_util.cc