summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-27 21:54:50 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-27 21:54:50 +0100
commit6166c045a8de42edd09924fdd995a77a3b753e54 (patch)
tree91da3177d9802c0b9da84607eb3c3831ffc975b5 /src/lib
parenta4642b6463430175d0f4e1ca284a4bf08bcf4de9 (diff)
Support for keeping video in sequence when changing lengths; tie selection in timeline with that in the editor.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.cc1
-rw-r--r--src/lib/content.h1
-rw-r--r--src/lib/ffmpeg_content.cc2
-rw-r--r--src/lib/film.cc6
-rw-r--r--src/lib/film.h2
-rw-r--r--src/lib/imagemagick_content.cc11
-rw-r--r--src/lib/player.cc10
-rw-r--r--src/lib/playlist.cc38
-rw-r--r--src/lib/playlist.h9
-rw-r--r--src/lib/video_content.cc7
-rw-r--r--src/lib/video_content.h1
11 files changed, 62 insertions, 26 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index aaf2e4f9c..6a33e9f7e 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -28,6 +28,7 @@ using boost::shared_ptr;
using boost::lexical_cast;
int const ContentProperty::START = 400;
+int const ContentProperty::LENGTH = 401;
Content::Content (shared_ptr<const Film> f, Time s)
: _film (f)
diff --git a/src/lib/content.h b/src/lib/content.h
index 321252c02..5e8f98428 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -40,6 +40,7 @@ class ContentProperty
{
public:
static int const START;
+ static int const LENGTH;
};
class Content : public boost::enable_shared_from_this<Content>
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index d912ee418..7a67ee5b8 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -156,7 +156,7 @@ FFmpegContent::examine (shared_ptr<Job> job)
take_from_video_decoder (decoder);
- signal_changed (VideoContentProperty::VIDEO_LENGTH);
+ signal_changed (ContentProperty::LENGTH);
signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
signal_changed (FFmpegContentProperty::AUDIO_STREAMS);
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 26b3962a1..8eeb4fec5 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -905,3 +905,9 @@ Film::dcp_audio_frame_rate () const
/* XXX */
return 48000;
}
+
+void
+Film::set_sequence_video (bool s)
+{
+ _playlist->set_sequence_video (s);
+}
diff --git a/src/lib/film.h b/src/lib/film.h
index 9d1b86374..cb970da4d 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -119,6 +119,8 @@ public:
void set_loop (int);
int loop () const;
+ void set_sequence_video (bool);
+
/** Identifiers for the parts of our state;
used for signalling changes.
*/
diff --git a/src/lib/imagemagick_content.cc b/src/lib/imagemagick_content.cc
index ac04fb15b..a4777e3cd 100644
--- a/src/lib/imagemagick_content.cc
+++ b/src/lib/imagemagick_content.cc
@@ -75,15 +75,8 @@ ImageMagickContent::examine (shared_ptr<Job> job)
shared_ptr<ImageMagickDecoder> decoder (new ImageMagickDecoder (film, shared_from_this()));
- {
- boost::mutex::scoped_lock lm (_mutex);
- /* Initial length */
- _video_length = Config::instance()->default_still_length() * 24;
- }
-
+ set_video_length (Config::instance()->default_still_length() * 24);
take_from_video_decoder (decoder);
-
- signal_changed (VideoContentProperty::VIDEO_LENGTH);
}
shared_ptr<Content>
@@ -100,7 +93,7 @@ ImageMagickContent::set_video_length (ContentVideoFrame len)
_video_length = len;
}
- signal_changed (VideoContentProperty::VIDEO_LENGTH);
+ signal_changed (ContentProperty::LENGTH);
}
Time
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 786180a6a..34894ff0e 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -251,14 +251,6 @@ Player::add_silent_piece (Time s, Time len)
}
-struct ContentSorter
-{
- bool operator() (shared_ptr<Content> a, shared_ptr<Content> b)
- {
- return a->start() < b->start();
- }
-};
-
void
Player::setup_pieces ()
{
@@ -358,7 +350,7 @@ Player::content_changed (weak_ptr<Content> w, int p)
return;
}
- if (p == ContentProperty::START || p == VideoContentProperty::VIDEO_LENGTH) {
+ if (p == ContentProperty::START || p == ContentProperty::LENGTH) {
_have_valid_pieces = false;
}
}
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index d2df75a09..d32ec6ba8 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -1,5 +1,3 @@
-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
@@ -51,6 +49,8 @@ using boost::lexical_cast;
Playlist::Playlist ()
: _loop (1)
+ , _sequence_video (true)
+ , _sequencing_video (false)
{
}
@@ -72,6 +72,26 @@ Playlist::~Playlist ()
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);
}
@@ -143,6 +163,7 @@ 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");
}
/** @param node <Playlist> node */
@@ -154,6 +175,7 @@ Playlist::as_xml (xmlpp::Node* node)
}
node->add_child("Loop")->add_child_text(lexical_cast<string> (_loop));
+ node->add_child("SequenceVideo")->add_child_text(_sequence_video ? "1" : "0");
}
void
@@ -297,3 +319,15 @@ Playlist::video_end () const
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();
+}
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index f75b4ba63..3a7ca73bf 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -51,6 +51,11 @@ class Region;
* are played simultaneously (i.e. they can be split up into multiple files for different channels)
*/
+struct ContentSorter
+{
+ bool operator() (boost::shared_ptr<Content> a, boost::shared_ptr<Content> b);
+};
+
class Playlist
{
public:
@@ -85,6 +90,8 @@ public:
int best_dcp_frame_rate () const;
Time video_end () const;
+ void set_sequence_video (bool);
+
mutable boost::signals2::signal<void ()> Changed;
mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
@@ -94,6 +101,8 @@ private:
ContentList _content;
int _loop;
+ bool _sequence_video;
+ bool _sequencing_video;
std::list<boost::signals2::connection> _content_connections;
};
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index 2e413678f..ae799dad3 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -23,10 +23,9 @@
#include "i18n.h"
-int const VideoContentProperty::VIDEO_LENGTH = 0;
-int const VideoContentProperty::VIDEO_SIZE = 1;
-int const VideoContentProperty::VIDEO_FRAME_RATE = 2;
-int const VideoContentProperty::VIDEO_CROP = 3;
+int const VideoContentProperty::VIDEO_SIZE = 0;
+int const VideoContentProperty::VIDEO_FRAME_RATE = 1;
+int const VideoContentProperty::VIDEO_CROP = 2;
using std::string;
using std::stringstream;
diff --git a/src/lib/video_content.h b/src/lib/video_content.h
index 7dde927af..ce2550d12 100644
--- a/src/lib/video_content.h
+++ b/src/lib/video_content.h
@@ -28,7 +28,6 @@ class VideoDecoder;
class VideoContentProperty
{
public:
- static int const VIDEO_LENGTH;
static int const VIDEO_SIZE;
static int const VIDEO_FRAME_RATE;
static int const VIDEO_CROP;