2 Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "video_ring_buffers.h"
23 #include "player_video.h"
24 #include "compose.hpp"
34 using std::shared_ptr;
35 using boost::optional;
36 using namespace dcpomatic;
40 VideoRingBuffers::put (shared_ptr<PlayerVideo> frame, DCPTime time)
42 boost::mutex::scoped_lock lm (_mutex);
43 _data.push_back (make_pair(frame, time));
47 pair<shared_ptr<PlayerVideo>, DCPTime>
48 VideoRingBuffers::get ()
50 boost::mutex::scoped_lock lm (_mutex);
54 auto const r = _data.front();
61 VideoRingBuffers::size () const
63 boost::mutex::scoped_lock lm (_mutex);
69 VideoRingBuffers::empty () const
71 boost::mutex::scoped_lock lm (_mutex);
72 return _data.empty ();
77 VideoRingBuffers::clear ()
79 boost::mutex::scoped_lock lm (_mutex);
85 VideoRingBuffers::memory_used () const
87 boost::mutex::scoped_lock lm (_mutex);
89 for (auto const& i: _data) {
90 m += i.first->memory_used();
92 return make_pair(m, String::compose("%1 frames", _data.size()));
97 VideoRingBuffers::reset_metadata (shared_ptr<const Film> film, dcp::Size player_video_container_size)
99 boost::mutex::scoped_lock lm (_mutex);
100 for (auto const& i: _data) {
101 i.first->reset_metadata (film, player_video_container_size);