X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.h;h=44b95e07643a9599586bcd7e89a926a3be5a28b3;hb=2255aedd15f985796d2e6f7fcc7fb412a5d98812;hp=7a99d656190bd25c23faddcd08f61e218942c884;hpb=7fb622a18582f18fcc6cfe140a262fd6cc8cad88;p=dcpomatic.git diff --git a/src/lib/player.h b/src/lib/player.h index 7a99d6561..44b95e076 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -1,3 +1,5 @@ +/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ + /* Copyright (C) 2013 Carl Hetherington @@ -17,8 +19,8 @@ */ -#ifndef DVDOMATIC_PLAYER_H -#define DVDOMATIC_PLAYER_H +#ifndef DCPOMATIC_PLAYER_H +#define DCPOMATIC_PLAYER_H #include #include @@ -27,15 +29,20 @@ #include "audio_source.h" #include "video_sink.h" #include "audio_sink.h" +#include "playlist.h" +#include "audio_buffers.h" -class VideoDecoder; -class SndfileDecoder; class Job; class Film; class Playlist; class AudioContent; +class Decoder; -class Player : public VideoSource, public AudioSource, public VideoSink, public boost::enable_shared_from_this +/** @class Player + * @brief A class which can `play' a Playlist; emitting its audio and video. + */ + +class Player : public VideoSource, public AudioSource, public boost::enable_shared_from_this { public: Player (boost::shared_ptr, boost::shared_ptr); @@ -43,20 +50,36 @@ public: void disable_video (); void disable_audio (); void disable_subtitles (); - void disable_video_sync (); bool pass (); - void set_progress (boost::shared_ptr); - bool seek (double); + bool seek (Time); + void seek_back (); + void seek_forward (); - double last_video_time () const; + Time last_video () const { + return _last_video; + } private: - void process_video (boost::shared_ptr i, bool same, boost::shared_ptr s); - void process_audio (boost::weak_ptr, boost::shared_ptr); + + struct DecoderRecord + { + DecoderRecord () + : last (0) + {} + + boost::shared_ptr content; + boost::shared_ptr decoder; + Time last; + }; + + void process_video (boost::shared_ptr, boost::shared_ptr, bool, boost::shared_ptr, Time); + void process_audio (boost::shared_ptr, boost::shared_ptr, Time); void setup_decoders (); void playlist_changed (); void content_changed (boost::weak_ptr, int); + void emit_black_frame (); + void emit_silence (Time); boost::shared_ptr _film; boost::shared_ptr _playlist; @@ -64,15 +87,16 @@ private: bool _video; bool _audio; bool _subtitles; - - bool _have_valid_decoders; - std::list > _video_decoders; - std::list >::iterator _video_decoder; - std::list > _sndfile_decoders; - boost::shared_ptr _audio_buffers; + /** Our decoders are ready to go; if this is false the decoders must be (re-)created before they are used */ + bool _have_valid_decoders; + std::list > _decoders; - bool _video_sync; + Time _position; + AudioBuffers _audio_buffers; + Time _last_video; + bool _last_was_black; + Time _last_audio; }; #endif