summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-15 16:36:49 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-15 16:36:49 +0100
commit1bb4bd728a445de0728c897211bf079c714d4f41 (patch)
treeb4d606dafac8a3fc99d8ce362238c0e14bc9459b /src/lib
parent49c7639efbd0c7e014e9ddf3380b6d7f1fed9285 (diff)
Add some player tests. Fix seek with content at non-DCP frame rate. A few other small fixes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/player.cc24
-rw-r--r--src/lib/player.h5
-rw-r--r--src/lib/playlist.cc40
-rw-r--r--src/lib/playlist.h1
4 files changed, 51 insertions, 19 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc
index c8c206424..6ee8c5029 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -138,7 +138,7 @@ Player::pass ()
continue;
}
- if (dynamic_pointer_cast<VideoDecoder> ((*i)->decoder)) {
+ if (_video && dynamic_pointer_cast<VideoDecoder> ((*i)->decoder)) {
if ((*i)->video_position < earliest_t) {
earliest_t = (*i)->video_position;
earliest = *i;
@@ -146,7 +146,7 @@ Player::pass ()
}
}
- if (dynamic_pointer_cast<AudioDecoder> ((*i)->decoder)) {
+ if (_audio && dynamic_pointer_cast<AudioDecoder> ((*i)->decoder)) {
if ((*i)->audio_position < earliest_t) {
earliest_t = (*i)->audio_position;
earliest = *i;
@@ -238,6 +238,10 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image
work_image = im;
}
+#ifdef DCPOMATIC_DEBUG
+ _last_video = piece->content;
+#endif
+
Video (work_image, same, time);
time += TIME_HZ / _film->dcp_video_frame_rate();
@@ -348,7 +352,10 @@ Player::flush ()
}
-/** @return true on error */
+/** Seek so that the next pass() will yield (approximately) the requested frame.
+ * Pass accurate = true to try harder to get close to the request.
+ * @return true on error
+ */
void
Player::seek (Time t, bool accurate)
{
@@ -374,11 +381,16 @@ Player::seek (Time t, bool accurate)
(*i)->video_position = (*i)->audio_position = vc->start() + s;
FrameRateConversion frc (vc->video_frame_rate(), _film->dcp_video_frame_rate());
- VideoContent::Frame f = s * vc->video_frame_rate() / (frc.factor() * TIME_HZ);
+ /* Here we are converting from time (in the DCP) to a frame number in the content.
+ Hence we need to use the DCP's frame rate and the double/skip correction, not
+ the source's rate.
+ */
+ VideoContent::Frame f = s * _film->dcp_video_frame_rate() / (frc.factor() * TIME_HZ);
dynamic_pointer_cast<VideoDecoder>((*i)->decoder)->seek (f, accurate);
}
_video_position = _audio_position = t;
+
/* XXX: don't seek audio because we don't need to... */
}
@@ -501,6 +513,10 @@ Player::resampler (shared_ptr<AudioContent> c)
void
Player::emit_black ()
{
+#ifdef DCPOMATIC_DEBUG
+ _last_video.reset ();
+#endif
+
/* XXX: use same here */
Video (_black_frame, false, _video_position);
_video_position += _film->video_frames_to_time (1);
diff --git a/src/lib/player.h b/src/lib/player.h
index b3eadd7c0..92a358043 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -75,6 +75,7 @@ public:
boost::signals2::signal<void ()> Changed;
private:
+ friend class PlayerWrapper;
void process_video (boost::weak_ptr<Piece>, boost::shared_ptr<const Image>, bool, VideoContent::Frame);
void process_audio (boost::weak_ptr<Piece>, boost::shared_ptr<const AudioBuffers>, AudioContent::Frame);
@@ -126,6 +127,10 @@ private:
Time from;
Time to;
} _out_subtitle;
+
+#ifdef DCPOMATIC_DEBUG
+ boost::shared_ptr<Content> _last_video;
+#endif
};
#endif
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 703a14663..0d6462f6c 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -72,25 +72,35 @@ Playlist::~Playlist ()
void
Playlist::content_changed (weak_ptr<Content> c, int 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;
- }
+ if (p == ContentProperty::LENGTH) {
+ maybe_sequence_video ();
+ }
- (*i)->set_start (last);
- last = (*i)->end ();
- }
+ ContentChanged (c, p);
+}
- _sequencing_video = false;
+void
+Playlist::maybe_sequence_video ()
+{
+ if (!_sequence_video || _sequencing_video) {
+ return;
}
- ContentChanged (c, p);
+ _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);
+ last = (*i)->end ();
+ }
+
+ _sequencing_video = false;
}
string
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index cf0f09b31..805df4d70 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -86,6 +86,7 @@ public:
Time video_end () const;
void set_sequence_video (bool);
+ void maybe_sequence_video ();
mutable boost::signals2::signal<void ()> Changed;
mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;