#ifndef DCPOMATIC_CONTENT_VIDEO_H
#define DCPOMATIC_CONTENT_VIDEO_H
+#include "types.h"
+
class ImageProxy;
/** @class ContentVideo
--- /dev/null
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "delay.h"
+#include "content_video.h"
+#include "dcpomatic_assert.h"
+#include <boost/foreach.hpp>
+#include <iostream>
+
+using std::make_pair;
+using boost::weak_ptr;
+using boost::shared_ptr;
+using boost::optional;
+
+void
+Delay::video (weak_ptr<Piece> weak_piece, ContentVideo video)
+{
+ _store.push_back (make_pair (weak_piece, video));
+ /* Delay by 2 frames */
+ while (_store.size() > 2) {
+ Video (_store.front().first, _store.front().second);
+ _store.pop_front ();
+ }
+}
--- /dev/null
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_DELAY_H
+#define DCPOMATIC_DELAY_H
+
+#include "types.h"
+#include "video_adjuster.h"
+#include "content_video.h"
+#include <boost/signals2.hpp>
+
+class Piece;
+
+/** A class which `delays' received video by 2 frames; i.e. when it receives
+ * a video frame it emits the last-but-one it received.
+ */
+class Delay : public VideoAdjuster
+{
+public:
+ void video (boost::weak_ptr<Piece>, ContentVideo video);
+
+private:
+ boost::optional<ContentVideo> _last;
+};
+
+#endif
#include "image_decoder.h"
#include "compose.hpp"
#include "shuffler.h"
+#include "delay.h"
#include <dcp/reel.h>
#include <dcp/reel_sound_asset.h>
#include <dcp/reel_subtitle_asset.h>
, _play_referenced (false)
, _audio_merger (_film->audio_frame_rate())
, _shuffler (0)
+ , _delay (0)
{
_film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1));
_playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this));
Player::~Player ()
{
delete _shuffler;
+ delete _delay;
}
void
_shuffler = new Shuffler();
_shuffler->Video.connect(bind(&Player::video, this, _1, _2));
+ delete _delay;
+ _delay = new Delay();
+ _delay->Video.connect(bind(&Player::video, this, _1, _2));
+
BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) {
if (!i->paths_valid ()) {
if (decoder->video) {
if (i->video->frame_type() == VIDEO_FRAME_TYPE_3D_LEFT || i->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) {
+ /* We need a Shuffler to cope with 3D L/R video data arriving out of sequence */
decoder->video->Data.connect (bind (&Shuffler::video, _shuffler, weak_ptr<Piece>(piece), _1));
} else {
- decoder->video->Data.connect (bind (&Player::video, this, weak_ptr<Piece>(piece), _1));
+ /* We need a Delay to give a little wiggle room to ensure that relevent subtitles arrive at the
+ player before the video that requires them.
+ */
+ decoder->video->Data.connect (bind (&Delay::video, _delay, weak_ptr<Piece>(piece), _1));
}
}
if (done) {
_shuffler->flush ();
+ _delay->flush ();
}
return done;
}
_shuffler->clear ();
}
+ if (_delay) {
+ _delay->clear ();
+ }
+
if (_audio_processor) {
_audio_processor->flush ();
}
#include "audio_stream.h"
#include "audio_merger.h"
#include "empty.h"
+#include "delay.h"
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <list>
AudioMerger _audio_merger;
Shuffler* _shuffler;
+ Delay* _delay;
class StreamState
{
void
Shuffler::clear ()
{
+ VideoAdjuster::clear ();
_last = optional<ContentVideo>();
}
-
-void
-Shuffler::flush ()
-{
- BOOST_FOREACH (Store i, _store) {
- Video (i.first, i.second);
- }
-}
#include "types.h"
#include "content_video.h"
+#include "video_adjuster.h"
#include <boost/signals2.hpp>
class Piece;
-class Shuffler
+class Shuffler : public VideoAdjuster
{
public:
void clear ();
- void flush ();
void video (boost::weak_ptr<Piece>, ContentVideo video);
- boost::signals2::signal<void (boost::weak_ptr<Piece>, ContentVideo)> Video;
-
- typedef std::pair<boost::weak_ptr<Piece>, ContentVideo> Store;
private:
-
boost::optional<ContentVideo> _last;
- std::list<Store> _store;
};
--- /dev/null
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "video_adjuster.h"
+#include "content_video.h"
+#include <boost/foreach.hpp>
+
+void
+VideoAdjuster::flush ()
+{
+ BOOST_FOREACH (Store i, _store) {
+ Video (i.first, i.second);
+ }
+}
+
+void
+VideoAdjuster::clear ()
+{
+ _store.clear ();
+}
--- /dev/null
+/*
+ Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_VIDEO_ADJUSTER_H
+#define DCPOMATIC_VIDEO_ADJUSTER_H
+
+#include <boost/signals2.hpp>
+
+class Piece;
+class ContentVideo;
+
+/** Parent class for short delays of video content done by the Player
+ * to work around various problems.
+ */
+class VideoAdjuster
+{
+public:
+ virtual ~VideoAdjuster() {}
+
+ virtual void clear ();
+ void flush ();
+
+ boost::signals2::signal<void (boost::weak_ptr<Piece>, ContentVideo)> Video;
+
+ typedef std::pair<boost::weak_ptr<Piece>, ContentVideo> Store;
+
+protected:
+ std::list<Store> _store;
+};
+
+#endif
decoder.cc
decoder_factory.cc
decoder_part.cc
+ delay.cc
digester.cc
dkdm_wrapper.cc
dolby_cp750.cc
upmixer_a.cc
upmixer_b.cc
util.cc
+ video_adjuster.cc
video_content.cc
video_content_scale.cc
video_decoder.cc