*/
#include "empty.h"
+#include "film.h"
#include "playlist.h"
#include "content.h"
#include "content_part.h"
using boost::dynamic_pointer_cast;
using boost::function;
-Empty::Empty (shared_ptr<const Playlist> playlist, function<shared_ptr<ContentPart> (Content *)> part)
+Empty::Empty (shared_ptr<const Film> film, function<shared_ptr<ContentPart> (Content *)> part)
{
list<DCPTimePeriod> full;
- BOOST_FOREACH (shared_ptr<Content> i, playlist->content()) {
+ BOOST_FOREACH (shared_ptr<Content> i, film->content()) {
if (part (i.get())) {
full.push_back (DCPTimePeriod (i->position(), i->end()));
}
}
- _periods = subtract (DCPTimePeriod(DCPTime(), playlist->length()), coalesce(full));
+ _periods = subtract (DCPTimePeriod(DCPTime(), film->length()), coalesce(full));
+
+ if (!_periods.empty ()) {
+ _position = _periods.front().from;
+ }
}
void
bool
Empty::done () const
{
+ DCPTime latest;
BOOST_FOREACH (DCPTimePeriod i, _periods) {
- if (i.contains(_position)) {
- return false;
- }
+ latest = max (latest, i.to);
}
- return true;
+ return _position >= latest;
}
#include <list>
struct empty_test1;
+struct empty_test2;
+struct player_subframe_test;
class Empty
{
public:
Empty () {}
- Empty (boost::shared_ptr<const Playlist> playlist, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
+ Empty (boost::shared_ptr<const Film> film, boost::function<boost::shared_ptr<ContentPart> (Content *)> part);
DCPTime position () const {
return _position;
private:
friend struct ::empty_test1;
+ friend struct ::empty_test2;
+ friend struct ::player_subframe_test;
std::list<DCPTimePeriod> _periods;
DCPTime _position;