diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-15 22:44:19 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-16 21:39:01 +0200 |
| commit | 194ec286939aba7b0cf24762d03ce6ebfe0b9a9f (patch) | |
| tree | 5b282afea0b90f6c53426de0550fdad21de5574f /src/lib | |
| parent | 1fca376d1000500d2450d936b42004ca69b086b6 (diff) | |
Split Empty into two separate classes, EmptyAudio and EmptyVideo.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/empty_audio.cc (renamed from src/lib/empty.cc) | 20 | ||||
| -rw-r--r-- | src/lib/empty_audio.h (renamed from src/lib/empty.h) | 30 | ||||
| -rw-r--r-- | src/lib/empty_video.cc | 101 | ||||
| -rw-r--r-- | src/lib/empty_video.h | 67 | ||||
| -rw-r--r-- | src/lib/player.cc | 18 | ||||
| -rw-r--r-- | src/lib/player.h | 7 | ||||
| -rw-r--r-- | src/lib/wscript | 3 |
7 files changed, 201 insertions, 45 deletions
diff --git a/src/lib/empty.cc b/src/lib/empty_audio.cc index 96d036463..a2d914bf9 100644 --- a/src/lib/empty.cc +++ b/src/lib/empty_audio.cc @@ -19,30 +19,30 @@ */ -#include "empty.h" -#include "film.h" -#include "playlist.h" #include "content.h" #include "content_part.h" #include "dcp_content.h" #include "dcpomatic_time_coalesce.h" +#include "empty_audio.h" +#include "film.h" #include "piece.h" +#include "playlist.h" #include <iostream> using std::cout; -using std::list; -using std::shared_ptr; using std::dynamic_pointer_cast; using std::function; +using std::list; +using std::shared_ptr; using namespace dcpomatic; -Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, function<bool (shared_ptr<const Content>)> part, DCPTime length) +EmptyAudio::EmptyAudio (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, DCPTime length) { list<DCPTimePeriod> full; for (auto i: playlist->content()) { - if (part(i) && i->paths_valid()) { + if (i->audio && i->paths_valid()) { full.push_back (DCPTimePeriod(i->position(), i->end(film))); } } @@ -56,7 +56,7 @@ Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, void -Empty::set_position (DCPTime position) +EmptyAudio::set_position (DCPTime position) { _position = position; @@ -76,7 +76,7 @@ Empty::set_position (DCPTime position) DCPTimePeriod -Empty::period_at_position () const +EmptyAudio::period_at_position () const { for (auto i: _periods) { if (i.contains(_position)) { @@ -89,7 +89,7 @@ Empty::period_at_position () const bool -Empty::done () const +EmptyAudio::done () const { DCPTime latest; for (auto i: _periods) { diff --git a/src/lib/empty.h b/src/lib/empty_audio.h index 145b84091..2aae7ca7e 100644 --- a/src/lib/empty.h +++ b/src/lib/empty_audio.h @@ -19,28 +19,28 @@ */ -#ifndef DCPOMATIC_EMPTY_H -#define DCPOMATIC_EMPTY_H +#ifndef DCPOMATIC_EMPTY_AUDIO_H +#define DCPOMATIC_EMPTY_AUDIO_H -#include "playlist.h" -#include "dcpomatic_time.h" #include "content_part.h" +#include "dcpomatic_time.h" +#include "playlist.h" #include <list> -struct empty_test1; -struct empty_test2; -struct empty_test3; -struct empty_test_with_overlapping_content; +struct empty_audio_test1; +struct empty_audio_test2; +struct empty_audio_test3; +struct empty_audio_test_with_overlapping_content; struct player_subframe_test; -class Empty +class EmptyAudio { public: - Empty () {} - Empty (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, std::function<bool (std::shared_ptr<const Content>)> part, dcpomatic::DCPTime length); + EmptyAudio () {} + EmptyAudio (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, dcpomatic::DCPTime length); dcpomatic::DCPTime position () const { return _position; @@ -53,10 +53,10 @@ public: void set_position (dcpomatic::DCPTime amount); private: - friend struct ::empty_test1; - friend struct ::empty_test2; - friend struct ::empty_test3; - friend struct ::empty_test_with_overlapping_content; + friend struct ::empty_audio_test1; + friend struct ::empty_audio_test2; + friend struct ::empty_audio_test3; + friend struct ::empty_audio_test_with_overlapping_content; friend struct ::player_subframe_test; std::list<dcpomatic::DCPTimePeriod> _periods; diff --git a/src/lib/empty_video.cc b/src/lib/empty_video.cc new file mode 100644 index 000000000..c578559e0 --- /dev/null +++ b/src/lib/empty_video.cc @@ -0,0 +1,101 @@ +/* + Copyright (C) 2017-2021 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 "content.h" +#include "content_part.h" +#include "dcp_content.h" +#include "dcpomatic_time_coalesce.h" +#include "empty_video.h" +#include "film.h" +#include "piece.h" +#include "playlist.h" +#include "video_content.h" +#include <iostream> + + +using std::cout; +using std::dynamic_pointer_cast; +using std::function; +using std::list; +using std::shared_ptr; +using namespace dcpomatic; + + +EmptyVideo::EmptyVideo (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, DCPTime length) +{ + list<DCPTimePeriod> full; + for (auto i: playlist->content()) { + if (i->video && i->video->use() && i->can_be_played() && i->paths_valid()) { + full.push_back (DCPTimePeriod(i->position(), i->end(film))); + } + } + + _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full)); + + if (!_periods.empty()) { + _position = _periods.front().from; + } +} + + +void +EmptyVideo::set_position (DCPTime position) +{ + _position = position; + + for (auto i: _periods) { + if (i.contains(_position)) { + return; + } + } + + for (auto i: _periods) { + if (i.from > _position) { + _position = i.from; + return; + } + } +} + + +DCPTimePeriod +EmptyVideo::period_at_position () const +{ + for (auto i: _periods) { + if (i.contains(_position)) { + return DCPTimePeriod (_position, i.to); + } + } + + DCPOMATIC_ASSERT (false); +} + + +bool +EmptyVideo::done () const +{ + DCPTime latest; + for (auto i: _periods) { + latest = max (latest, i.to); + } + + return _position >= latest; +} diff --git a/src/lib/empty_video.h b/src/lib/empty_video.h new file mode 100644 index 000000000..cf315bc44 --- /dev/null +++ b/src/lib/empty_video.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2018-2021 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/>. + +*/ + + +#ifndef DCPOMATIC_EMPTY_VIDEO_H +#define DCPOMATIC_EMPTY_VIDEO_H + + +#include "content_part.h" +#include "dcpomatic_time.h" +#include "playlist.h" +#include <list> + + +struct empty_video_test1; +struct empty_video_test2; +struct empty_video_test3; +struct empty_video_test_with_overlapping_content; +struct player_subframe_test; + + +class EmptyVideo +{ +public: + EmptyVideo () {} + EmptyVideo (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, dcpomatic::DCPTime length); + + dcpomatic::DCPTime position () const { + return _position; + } + + dcpomatic::DCPTimePeriod period_at_position () const; + + bool done () const; + + void set_position (dcpomatic::DCPTime amount); + +private: + friend struct ::empty_video_test1; + friend struct ::empty_video_test2; + friend struct ::empty_video_test3; + friend struct ::empty_video_test_with_overlapping_content; + friend struct ::player_subframe_test; + + std::list<dcpomatic::DCPTimePeriod> _periods; + dcpomatic::DCPTime _position; +}; + + +#endif diff --git a/src/lib/player.cc b/src/lib/player.cc index 94bb80779..cf286f4a5 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -144,20 +144,6 @@ Player::setup_pieces () } -bool -have_video (shared_ptr<const Content> content) -{ - return static_cast<bool>(content->video) && content->video->use() && content->can_be_played(); -} - - -bool -have_audio (shared_ptr<const Content> content) -{ - return static_cast<bool>(content->audio); -} - - void Player::setup_pieces_unlocked () { @@ -288,8 +274,8 @@ Player::setup_pieces_unlocked () } } - _black = Empty (_film, playlist(), bind(&have_video, _1), _playback_length); - _silent = Empty (_film, playlist(), bind(&have_audio, _1), _playback_length); + _black = EmptyVideo (_film, playlist(), _playback_length); + _silent = EmptyAudio (_film, playlist(), _playback_length); _next_video_time = boost::none; _next_video_eyes = Eyes::BOTH; diff --git a/src/lib/player.h b/src/lib/player.h index 7d99c22c6..9318cff5a 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -31,7 +31,8 @@ #include "content_audio.h" #include "content_text.h" #include "content_video.h" -#include "empty.h" +#include "empty_audio.h" +#include "empty_video.h" #include "film.h" #include "image.h" #include "player_text.h" @@ -225,8 +226,8 @@ private: }; std::map<AudioStreamPtr, StreamState> _stream_states; - Empty _black; - Empty _silent; + EmptyVideo _black; + EmptyAudio _silent; ActiveText _active_texts[static_cast<int>(TextType::COUNT)]; std::shared_ptr<AudioProcessor> _audio_processor; diff --git a/src/lib/wscript b/src/lib/wscript index 7400c5bf1..f83adedbd 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -85,7 +85,8 @@ sources = """ dkdm_wrapper.cc dolby_cp750.cc emailer.cc - empty.cc + empty_audio.cc + empty_video.cc encoder.cc encode_server.cc encode_server_finder.cc |
