summaryrefslogtreecommitdiff
path: root/src/lib/playlist.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/playlist.cc')
-rw-r--r--src/lib/playlist.cc58
1 files changed, 23 insertions, 35 deletions
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 172b6fbb9..e4494acb0 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -42,6 +42,7 @@ using std::min;
using std::max;
using std::string;
using std::stringstream;
+using std::pair;
using boost::optional;
using boost::shared_ptr;
using boost::weak_ptr;
@@ -49,8 +50,7 @@ using boost::dynamic_pointer_cast;
using boost::lexical_cast;
Playlist::Playlist ()
- : _loop (1)
- , _sequence_video (true)
+ : _sequence_video (true)
, _sequencing_video (false)
{
@@ -109,8 +109,6 @@ Playlist::video_identifier () const
}
}
- t += lexical_cast<string> (_loop);
-
return md5_digest (t.c_str(), t.length());
}
@@ -124,7 +122,6 @@ Playlist::set_from_xml (shared_ptr<const Film> film, shared_ptr<const cxml::Node
}
reconnect ();
- _loop = node->number_child<int> ("Loop");
_sequence_video = node->bool_child ("SequenceVideo");
}
@@ -136,7 +133,6 @@ Playlist::as_xml (xmlpp::Node* node)
(*i)->as_xml (node->add_child ("Content"));
}
- node->add_child("Loop")->add_child_text(lexical_cast<string> (_loop));
node->add_child("SequenceVideo")->add_child_text(_sequence_video ? "1" : "0");
}
@@ -162,13 +158,6 @@ Playlist::remove (shared_ptr<Content> c)
}
}
-void
-Playlist::set_loop (int l)
-{
- _loop = l;
- Changed ();
-}
-
bool
Playlist::has_subtitles () const
{
@@ -246,7 +235,7 @@ Playlist::best_dcp_frame_rate () const
}
Time
-Playlist::length_without_loop () const
+Playlist::length () const
{
Time len = 0;
for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
@@ -256,12 +245,6 @@ Playlist::length_without_loop () const
return len;
}
-Time
-Playlist::length_with_loop () const
-{
- return length_without_loop() * _loop;
-}
-
void
Playlist::reconnect ()
{
@@ -301,29 +284,34 @@ ContentSorter::operator() (shared_ptr<Content> a, shared_ptr<Content> b)
return a->start() < b->start();
}
-/** @return content in an undefined order, not taking looping into account */
+/** @return content in an undefined order */
Playlist::ContentList
-Playlist::content_without_loop () const
+Playlist::content () const
{
return _content;
}
-/** @return content in an undefined order, taking looping into account */
-Playlist::ContentList
-Playlist::content_with_loop () const
+void
+Playlist::repeat (list<shared_ptr<Content> > c, int n)
{
- ContentList looped = _content;
- Time const length = length_without_loop ();
+ pair<Time, Time> range (TIME_MAX, 0);
+ for (list<shared_ptr<Content> >::iterator i = c.begin(); i != c.end(); ++i) {
+ range.first = min (range.first, (*i)->start ());
+ range.second = max (range.second, (*i)->start ());
+ range.first = min (range.first, (*i)->end ());
+ range.second = max (range.second, (*i)->end ());
+ }
- Time offset = length;
- for (int i = 1; i < _loop; ++i) {
- for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
+ Time pos = range.second;
+ for (int i = 0; i < n; ++i) {
+ for (list<shared_ptr<Content> >::iterator i = c.begin(); i != c.end(); ++i) {
shared_ptr<Content> copy = (*i)->clone ();
- copy->set_start (copy->start() + offset);
- looped.push_back (copy);
+ copy->set_start (pos + copy->start() - range.first);
+ _content.push_back (copy);
}
- offset += length;
+ pos += range.second - range.first;
}
-
- return looped;
+
+ reconnect ();
+ Changed ();
}