X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.h;h=8d95816ca4d249a014338344c9ed7502d1a32831;hb=d132400792c831bca8a43b46547ee6ef7a5e6fa5;hp=e52ca3ffee2e5bc463f923bec9c1cb9f9cd31019;hpb=64a27cef84b97edd665d4891efb8ba5c9d78b70f;p=dcpomatic.git diff --git a/src/lib/player.h b/src/lib/player.h index e52ca3ffe..8d95816ca 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -32,6 +32,7 @@ #include "content_text.h" #include "content_video.h" #include "empty.h" +#include "enum_indexed_vector.h" #include "film.h" #include "image.h" #include "player_text.h" @@ -62,26 +63,34 @@ public: static int const FILM_VIDEO_FRAME_RATE; static int const DCP_DECODE_REDUCTION; static int const PLAYBACK_LENGTH; + static int const IGNORE_VIDEO; + static int const IGNORE_AUDIO; + static int const IGNORE_TEXT; + static int const ALWAYS_BURN_OPEN_SUBTITLES; + static int const PLAY_REFERENCED; }; /** @class Player * @brief A class which can play a Playlist. */ -class Player : public std::enable_shared_from_this +class Player { public: Player (std::shared_ptr, Image::Alignment subtitle_alignment); Player (std::shared_ptr, std::shared_ptr playlist); - Player (Player const& Player) = delete; - Player& operator= (Player const& Player) = delete; + Player (Player const&) = delete; + Player& operator= (Player const&) = delete; + + Player(Player&& other); + Player& operator=(Player&& other); bool pass (); void seek (dcpomatic::DCPTime time, bool accurate); std::vector> get_subtitle_fonts (); - std::list get_reel_assets (); + dcp::Size video_container_size () const { return _video_container_size; } @@ -95,9 +104,15 @@ public: void set_play_referenced (); void set_dcp_decode_reduction (boost::optional reduction); - boost::optional content_time_to_dcp (std::shared_ptr content, dcpomatic::ContentTime t); - boost::optional dcp_to_content_time (std::shared_ptr content, dcpomatic::DCPTime t); + boost::optional content_time_to_dcp (std::shared_ptr content, dcpomatic::ContentTime t) const; + boost::optional dcp_to_content_time (std::shared_ptr content, dcpomatic::DCPTime t) const; + + void signal_change(ChangeType type, int property); + /** First parameter is PENDING, DONE or CANCELLED. + * Second parameter is the property. + * Third parameter is true if these signals are currently likely to be frequent. + */ boost::signals2::signal Change; /** Emitted when a video frame is ready. These emissions happen in the correct order. */ @@ -125,6 +140,7 @@ private: friend struct overlap_video_test1; void construct (); + void connect(); void setup_pieces (); void film_change (ChangeType, Film::Property); void playlist_change (ChangeType); @@ -136,6 +152,8 @@ private: dcpomatic::ContentTime dcp_to_content_time (std::shared_ptr piece, dcpomatic::DCPTime t) const; dcpomatic::DCPTime content_time_to_dcp (std::shared_ptr piece, dcpomatic::ContentTime t) const; std::shared_ptr black_player_video_frame (Eyes eyes) const; + void emit_video_until(dcpomatic::DCPTime time); + void insert_video(std::shared_ptr pv, dcpomatic::DCPTime time, dcpomatic::DCPTime end); void video (std::weak_ptr, ContentVideo); void audio (std::weak_ptr, AudioStreamPtr, ContentAudio); @@ -150,20 +168,20 @@ private: std::shared_ptr audio, dcpomatic::DCPTime time, dcpomatic::DCPTime discard_to ) const; boost::optional open_subtitles_for_frame (dcpomatic::DCPTime time) const; - void emit_video (std::shared_ptr pv, dcpomatic::DCPTime time); - void do_emit_video (std::shared_ptr pv, dcpomatic::DCPTime time); + void emit_video(std::shared_ptr pv, dcpomatic::DCPTime time); + void use_video(std::shared_ptr pv, dcpomatic::DCPTime time, dcpomatic::DCPTime end); void emit_audio (std::shared_ptr data, dcpomatic::DCPTime time); std::shared_ptr playlist () const; - /** Mutex to protect the whole Player state. When it's used for the preview we have + /** Mutex to protect the most of the Player state. When it's used for the preview we have seek() and pass() called from the Butler thread and lots of other stuff called from the GUI thread. */ mutable boost::mutex _mutex; - std::shared_ptr const _film; + std::weak_ptr _film; /** Playlist, or 0 if we are using the one from the _film */ - std::shared_ptr const _playlist; + std::shared_ptr _playlist; /** > 0 if we are suspended (i.e. pass() and seek() do nothing) */ boost::atomic _suspended; @@ -173,6 +191,8 @@ private: * the size of preview in a window. */ boost::atomic _video_container_size; + + mutable boost::mutex _black_image_mutex; std::shared_ptr _black_image; /** true if the player should ignore all video; i.e. never produce any */ @@ -184,21 +204,18 @@ private: /** true if we should try to be fast rather than high quality */ boost::atomic _fast; /** true if we should keep going in the face of `survivable' errors */ - bool const _tolerant; + bool _tolerant; /** true if we should `play' (i.e output) referenced DCP data (e.g. for preview) */ boost::atomic _play_referenced; /** Time of the next video that we will emit, or the time of the last accurate seek */ boost::optional _next_video_time; - /** Eyes of the next video that we will emit */ - boost::optional _next_video_eyes; /** Time of the next audio that we will emit, or the time of the last accurate seek */ boost::optional _next_audio_time; boost::atomic> _dcp_decode_reduction; - typedef std::map, std::shared_ptr, std::owner_less>> LastVideoMap; - LastVideoMap _last_video; + EnumIndexedVector, dcpomatic::DCPTime>, Eyes> _last_video; AudioMerger _audio_merger; std::unique_ptr _shuffler; @@ -209,26 +226,25 @@ private: public: StreamState () {} - StreamState (std::shared_ptr p, dcpomatic::DCPTime l) + explicit StreamState(std::shared_ptr p) : piece(p) - , last_push_end(l) {} std::shared_ptr piece; - dcpomatic::DCPTime last_push_end; + boost::optional last_push_end; }; std::map _stream_states; Empty _black; Empty _silent; - ActiveText _active_texts[static_cast(TextType::COUNT)]; + EnumIndexedVector _active_texts; std::shared_ptr _audio_processor; - dcpomatic::DCPTime _playback_length; + boost::atomic _playback_length; /** Alignment for subtitle images that we create */ - Image::Alignment const _subtitle_alignment = Image::Alignment::PADDED; + Image::Alignment _subtitle_alignment = Image::Alignment::PADDED; boost::signals2::scoped_connection _film_changed_connection; boost::signals2::scoped_connection _playlist_change_connection;