-/* -*- 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)
{
+ if (p == ContentProperty::LENGTH && _sequence_video && !_sequencing_video) {
+ cout << "sequencing.\n";
+ _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;
+ }
+
+ (*i)->set_start (last);
+ cout << (*i)->file() << " -> " << last << "\n";
+ last = (*i)->end ();
+ }
+
+ _sequencing_video = false;
+ }
+
ContentChanged (c, p);
}
/** @param node <Playlist> node */
void
-Playlist::set_from_xml (shared_ptr<const cxml::Node> node)
+Playlist::set_from_xml (shared_ptr<const Film> film, shared_ptr<const cxml::Node> node)
{
list<shared_ptr<cxml::Node> > c = node->node_children ("Content");
for (list<shared_ptr<cxml::Node> >::iterator i = c.begin(); i != c.end(); ++i) {
boost::shared_ptr<Content> content;
if (type == "FFmpeg") {
- content.reset (new FFmpegContent (*i));
+ content.reset (new FFmpegContent (film, *i));
} else if (type == "ImageMagick") {
- content.reset (new ImageMagickContent (*i));
+ content.reset (new ImageMagickContent (film, *i));
} else if (type == "Sndfile") {
- content.reset (new SndfileContent (*i));
+ content.reset (new SndfileContent (film, *i));
}
+
+ _content.push_back (content);
}
+ 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::length (shared_ptr<const Film> film) const
+Playlist::length () const
{
Time len = 0;
for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
- Time const t = (*i)->time() + (*i)->length (film);
- len = max (len, t);
+ len = max (len, (*i)->end ());
}
return len;
}
}
+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();
+}