X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.h;h=852e7243f1355546cab3a6dba2252c57bf635f86;hb=854f2e5bbb7ffb9758b823af87034033033f3cb8;hp=c8f6eecb87f9eba46d9d8bc6a3bb029803a39940;hpb=8c6fe8e1e8c8f6d5932606f2a5b6e1b87681ae38;p=dcpomatic.git diff --git a/src/lib/player.h b/src/lib/player.h index c8f6eecb8..852e7243f 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -1,7 +1,5 @@ -/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ - /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,70 +23,147 @@ #include #include #include -#include "video_source.h" -#include "audio_source.h" -#include "video_sink.h" -#include "audio_sink.h" #include "playlist.h" -#include "audio_buffers.h" +#include "content.h" +#include "film.h" +#include "rect.h" +#include "audio_content.h" +#include "dcpomatic_time.h" +#include "content_subtitle.h" +#include "position_image.h" class Job; class Film; class Playlist; class AudioContent; class Piece; +class Image; +class DCPVideo; +class Decoder; + +class PlayerStatistics +{ +public: + struct Video { + Video () + : black (0) + , repeat (0) + , good (0) + , skip (0) + {} + + int black; + int repeat; + int good; + int skip; + } video; + + struct Audio { + Audio () + : silence (0) + , good (0) + , skip (0) + {} + + DCPTime silence; + int64_t good; + int64_t skip; + } audio; + + void dump (boost::shared_ptr) const; +}; + +class Piece +{ +public: + Piece (boost::shared_ptr c, boost::shared_ptr d, FrameRateChange f) + : content (c) + , decoder (d) + , frc (f) + {} + + boost::shared_ptr content; + boost::shared_ptr decoder; + FrameRateChange frc; +}; /** @class Player - * @brief A class which can `play' a Playlist; emitting its audio and video. + * @brief A class which can `play' a Playlist. */ - -class Player : public VideoSource, public AudioSource, public boost::enable_shared_from_this +class Player : public boost::enable_shared_from_this, public boost::noncopyable { public: Player (boost::shared_ptr, boost::shared_ptr); - void disable_video (); - void disable_audio (); - void disable_subtitles (); + boost::shared_ptr get_video (DCPTime time, bool accurate); + boost::shared_ptr get_audio (DCPTime time, DCPTime length, bool accurate); - bool pass (); - void seek (Time); - void seek_back (); - void seek_forward (); - - Time last_video () const { - return _last_video; + void set_video_container_size (dcp::Size); + void set_approximate_size (); + void set_burn_subtitles (bool burn) { + _burn_subtitles = burn; } + PlayerStatistics const & statistics () const; + + /** Emitted when something has changed such that if we went back and emitted + * the last frame again it would look different. This is not emitted after + * a seek. + * + * The parameter is true if these signals are currently likely to be frequent. + */ + boost::signals2::signal Changed; + private: + friend class PlayerWrapper; + friend class Piece; - void process_video (boost::weak_ptr, boost::shared_ptr, bool, boost::shared_ptr, Time); - void process_audio (boost::weak_ptr, boost::shared_ptr, Time); void setup_pieces (); void playlist_changed (); - void content_changed (boost::weak_ptr, int); - + void content_changed (boost::weak_ptr, int, bool); + void flush (); + void film_changed (Film::Property); + std::list process_content_image_subtitles ( + boost::shared_ptr, std::list > + ); + std::list process_content_text_subtitles (std::list >); + void update_subtitle_from_text (); + VideoFrame dcp_to_content_video (boost::shared_ptr piece, DCPTime t) const; + AudioFrame dcp_to_content_audio (boost::shared_ptr piece, DCPTime t) const; + ContentTime dcp_to_content_subtitle (boost::shared_ptr piece, DCPTime t) const; + + template + std::list > + overlaps (DCPTime t) + { + std::list > overlaps; + for (typename std::list >::const_iterator i = _pieces.begin(); i != _pieces.end(); ++i) { + if (boost::dynamic_pointer_cast ((*i)->content) && (*i)->content->position() <= t && t < (*i)->content->end()) { + overlaps.push_back (*i); + } + } + + return overlaps; + } + boost::shared_ptr _film; boost::shared_ptr _playlist; - - bool _video; - bool _audio; - bool _subtitles; /** Our pieces are ready to go; if this is false the pieces must be (re-)created before they are used */ bool _have_valid_pieces; std::list > _pieces; - /** Time of the earliest thing not yet to have been emitted */ - Time _position; - Time _last_black; - Time _last_silence; + dcp::Size _video_container_size; + boost::shared_ptr _black_image; + + bool _approximate_size; + bool _burn_subtitles; + + PlayerStatistics _statistics; - /* XXX: position and last_video? Need both? */ - AudioBuffers _audio_buffers; - Time _last_video; - bool _last_was_black; - Time _next_audio; + boost::signals2::scoped_connection _playlist_changed_connection; + boost::signals2::scoped_connection _playlist_content_changed_connection; + boost::signals2::scoped_connection _film_changed_connection; }; #endif