#include "content_part.h"
#include "dcp_content.h"
#include "dcpomatic_time_coalesce.h"
+#include "piece.h"
#include <boost/foreach.hpp>
#include <iostream>
using boost::dynamic_pointer_cast;
using boost::function;
-Empty::Empty (ContentList content, DCPTime length, function<shared_ptr<ContentPart> (Content *)> part)
+Empty::Empty (list<shared_ptr<Piece> > pieces, DCPTime length, function<bool (shared_ptr<Piece>)> part)
{
list<DCPTimePeriod> full;
- BOOST_FOREACH (shared_ptr<Content> i, content) {
- if (part (i.get())) {
- full.push_back (DCPTimePeriod (i->position(), i->end()));
+ BOOST_FOREACH (shared_ptr<Piece> i, pieces) {
+ if (part(i)) {
+ full.push_back (DCPTimePeriod (i->content->position(), i->content->end()));
}
}
/*
- Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+#ifndef DCPOMATIC_EMPTY_H
+#define DCPOMATIC_EMPTY_H
+
#include "playlist.h"
#include "dcpomatic_time.h"
#include "content_part.h"
struct empty_test1;
struct empty_test2;
struct player_subframe_test;
+class Piece;
class Empty
{
public:
Empty () {}
- Empty (ContentList content, DCPTime length, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
+ Empty (std::list<boost::shared_ptr<Piece> > pieces, DCPTime length, boost::function<bool (boost::shared_ptr<Piece>)> part);
DCPTime position () const {
return _position;
std::list<DCPTimePeriod> _periods;
DCPTime _position;
};
+
+#endif
setup_pieces_unlocked ();
}
+bool
+have_video (shared_ptr<Piece> piece)
+{
+ return piece->decoder && piece->decoder->video;
+}
+
+bool
+have_audio (shared_ptr<Piece> piece)
+{
+ return piece->decoder && piece->decoder->audio;
+}
+
void
Player::setup_pieces_unlocked ()
{
}
}
- _black = Empty (_film->content(), _film->length(), bind(&Content::video, _1));
- _silent = Empty (_film->content(), _film->length(), bind(&Content::audio, _1));
+ _black = Empty (_pieces, _film->length(), bind(&have_video, _1));
+ _silent = Empty (_pieces, _film->length(), bind(&have_audio, _1));
_last_video_time = DCPTime ();
_last_video_eyes = EYES_BOTH;
/* A change in our content has gone through. Re-build our pieces. */
setup_pieces ();
} else if (type == CHANGE_TYPE_CANCELLED) {
+ boost::mutex::scoped_lock lm (_mutex);
_suspended = false;
}
boost::signals2::signal<void (ChangeType, int, bool)> Change;
- /** The change suggested by a MayChange did not happen */
- boost::signals2::signal<void ()> NotChanged;
-
/** Emitted when a video frame is ready. These emissions happen in the correct order. */
boost::signals2::signal<void (boost::shared_ptr<PlayerVideo>, DCPTime)> Video;
boost::signals2::signal<void (boost::shared_ptr<AudioBuffers>, DCPTime)> Audio;
friend struct player_time_calculation_test2;
friend struct player_time_calculation_test3;
friend struct player_subframe_test;
+ friend struct empty_test1;
+ friend struct empty_test2;
void setup_pieces ();
void setup_pieces_unlocked ();
boost::shared_ptr<const Film> _film;
boost::shared_ptr<const Playlist> _playlist;
- /** true if we are suspended (i.e. pass() and seek() do nothing */
+ /** true if we are suspended (i.e. pass() and seek() do nothing) */
bool _suspended;
std::list<boost::shared_ptr<Piece> > _pieces;
#include "lib/video_content.h"
#include "lib/image_content.h"
#include "lib/empty.h"
+#include "lib/player.h"
+#include "lib/decoder.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
using boost::shared_ptr;
+bool
+has_video (shared_ptr<Piece> piece)
+{
+ return piece->decoder && piece->decoder->video;
+}
+
BOOST_AUTO_TEST_CASE (empty_test1)
{
shared_ptr<Film> film = new_test_film ("empty_test1");
contentB->video->set_length (1);
contentB->set_position (DCPTime::from_frames (7, vfr));
- Empty black (film->content(), film->length(), bind(&Content::video, _1));
+ shared_ptr<Player> player (new Player(film, film->playlist()));
+ Empty black (player->_pieces, film->length(), bind(&has_video, _1));
BOOST_REQUIRE_EQUAL (black._periods.size(), 2);
BOOST_CHECK (black._periods.front().from == DCPTime());
BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(2, vfr));
contentB->video->set_length (1);
contentB->set_position (DCPTime::from_frames (7, vfr));
- Empty black (film->content(), film->length(), bind(&Content::video, _1));
+ shared_ptr<Player> player (new Player(film, film->playlist()));
+ Empty black (player->_pieces, film->length(), bind(&has_video, _1));
BOOST_REQUIRE_EQUAL (black._periods.size(), 1);
BOOST_CHECK (black._periods.front().from == DCPTime::from_frames(3, vfr));
BOOST_CHECK (black._periods.front().to == DCPTime::from_frames(7, vfr));