-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
Playlist::Playlist ()
: _loop (1)
+ , _sequence_video (true)
+ , _sequencing_video (false)
{
}
void
Playlist::content_changed (weak_ptr<Content> c, int p)
{
- ContentChanged (c, p);
-}
+ if (p == ContentProperty::LENGTH && _sequence_video && !_sequencing_video) {
+ _sequencing_video = true;
+
+ ContentList cl = _content;
+ sort (cl.begin(), cl.end(), ContentSorter ());
+ Time last = 0;
+ for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) {
+ if (!dynamic_pointer_cast<VideoContent> (*i)) {
+ continue;
+ }
-string
-Playlist::audio_digest () const
-{
- string t;
-
- for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
- if (!dynamic_pointer_cast<const AudioContent> (*i)) {
- continue;
+ (*i)->set_start (last);
+ last = (*i)->end ();
}
-
- t += (*i)->digest ();
- shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
- if (fc) {
- t += lexical_cast<string> (fc->audio_stream()->id);
- }
+ _sequencing_video = false;
}
-
- t += lexical_cast<string> (_loop);
-
- return md5_digest (t.c_str(), t.length());
+
+ ContentChanged (c, p);
}
string
reconnect ();
_loop = node->number_child<int> ("Loop");
+ _sequence_video = node->bool_child ("SequenceVideo");
}
/** @param node <Playlist> node */
}
node->add_child("Loop")->add_child_text(lexical_cast<string> (_loop));
+ node->add_child("SequenceVideo")->add_child_text(_sequence_video ? "1" : "0");
}
void
}
}
+Time
+Playlist::video_end () const
+{
+ Time end = 0;
+ for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
+ if (dynamic_pointer_cast<const VideoContent> (*i)) {
+ end = max (end, (*i)->end ());
+ }
+ }
+
+ return end;
+}
+
+void
+Playlist::set_sequence_video (bool s)
+{
+ _sequence_video = s;
+}
+
+bool
+ContentSorter::operator() (shared_ptr<Content> a, shared_ptr<Content> b)
+{
+ return a->start() < b->start();
+}