#include <stdint.h>
#include <algorithm>
+#include "i18n.h"
+
#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
using std::list;
, _playlist (p)
, _have_valid_pieces (false)
, _approximate_size (false)
+ , _ignore_video (false)
{
_playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this));
_playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3));
shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (*i);
if (dc) {
- decoder.reset (new DCPDecoder (dc, _film->log ()));
+ decoder.reset (new DCPDecoder (dc));
frc = FrameRateChange (dc->video_frame_rate(), _film->video_frame_rate());
}
frc = best_overlap_frc;
}
+ shared_ptr<VideoDecoder> vd = dynamic_pointer_cast<VideoDecoder> (decoder);
+ if (vd && _ignore_video) {
+ vd->set_ignore_video ();
+ }
+
_pieces.push_back (shared_ptr<Piece> (new Piece (*i, decoder, frc.get ())));
}
{
return shared_ptr<PlayerVideo> (
new PlayerVideo (
- shared_ptr<const ImageProxy> (new RawImageProxy (_black_image, _film->log ())),
+ shared_ptr<const ImageProxy> (new RawImageProxy (_black_image)),
time,
Crop (),
optional<float> (),
if (!_have_valid_pieces) {
setup_pieces ();
}
-
+
list<shared_ptr<Piece> > ov = overlaps<VideoContent> (
time,
time + DCPTime::from_frames (1, _film->video_frame_rate ())
shared_ptr<Piece> piece = ov.back ();
shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
- assert (decoder);
+ DCPOMATIC_ASSERT (decoder);
shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
- assert (content);
+ DCPOMATIC_ASSERT (content);
list<ContentVideo> content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate);
if (content_video.empty ()) {
for (list<shared_ptr<Piece> >::iterator i = ov.begin(); i != ov.end(); ++i) {
shared_ptr<AudioContent> content = dynamic_pointer_cast<AudioContent> ((*i)->content);
- assert (content);
+ DCPOMATIC_ASSERT (content);
shared_ptr<AudioDecoder> decoder = dynamic_pointer_cast<AudioDecoder> ((*i)->decoder);
- assert (decoder);
+ DCPOMATIC_ASSERT (decoder);
if (content->audio_frame_rate() == 0) {
/* This AudioContent has no audio (e.g. if it is an FFmpegContent with no
s = DCPTime (min (piece->content->length_after_trim().get(), s.get()));
/* Convert this to the content frame */
- return DCPTime (s + piece->content->trim_start()).frames (_film->video_frame_rate()) * piece->frc.factor ();
+ return DCPTime (s + piece->content->trim_start()).frames (_film->video_frame_rate()) / piece->frc.factor ();
}
DCPTime
Player::content_video_to_dcp (shared_ptr<const Piece> piece, VideoFrame f) const
{
- DCPTime t = DCPTime::from_frames (f / piece->frc.factor (), _film->video_frame_rate()) - piece->content->trim_start () + piece->content->position ();
+ DCPTime t = DCPTime::from_frames (f * piece->frc.factor (), _film->video_frame_rate()) - piece->content->trim_start () + piece->content->position ();
if (t < DCPTime ()) {
t = DCPTime ();
}
return ps;
}
+
+list<shared_ptr<Font> >
+Player::get_subtitle_fonts ()
+{
+ if (!_have_valid_pieces) {
+ setup_pieces ();
+ }
+
+ list<shared_ptr<Font> > fonts;
+ BOOST_FOREACH (shared_ptr<Piece>& p, _pieces) {
+ shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (p->content);
+ if (sc) {
+ /* XXX: things may go wrong if there are duplicate font IDs
+ with different font files.
+ */
+ list<shared_ptr<Font> > f = sc->fonts ();
+ copy (f.begin(), f.end(), back_inserter (fonts));
+ }
+ }
+
+ return fonts;
+}
+
+/** Set this player never to produce any video data */
+void
+Player::set_ignore_video ()
+{
+ _ignore_video = true;
+}