X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.h;h=b004540935ef81f967ec2508184722a4b7be3548;hb=12074b64d64c1fe76a9cf07a46683b7db96fc56e;hp=afc856316cf48bee32cb4d560fe26dfba4432e4c;hpb=263eee639546964aaa57f5d2d3b24008ecfe8adb;p=dcpomatic.git diff --git a/src/lib/player.h b/src/lib/player.h index afc856316..b00454093 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,16 +29,20 @@ #include "audio_source.h" #include "video_sink.h" #include "audio_sink.h" +#include "playlist.h" +#include "audio_buffers.h" -class FFmpegDecoder; -class ImageMagickDecoder; -class SndfileDecoder; class Job; class Film; class Playlist; class AudioContent; +class Piece; -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); @@ -44,21 +50,28 @@ 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_to_last (); + void seek (Time); + void seek_back (); + void seek_forward (); - double last_video_time () const; + /** @return position that we are at; ie the time of the next thing we will emit on pass() */ + Time position () const { + return _position; + } private: - void process_video (boost::shared_ptr i, bool same, boost::shared_ptr s); - void process_audio (boost::weak_ptr, boost::shared_ptr); - void setup_decoders (); + + void process_video (boost::weak_ptr, boost::shared_ptr, bool, 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 do_seek (Time, bool); + void add_black_piece (Time, Time); + void add_silent_piece (Time, Time); + void flush (); boost::shared_ptr _film; boost::shared_ptr _playlist; @@ -66,17 +79,13 @@ private: bool _video; bool _audio; bool _subtitles; - - bool _have_valid_decoders; - boost::shared_ptr _ffmpeg_decoder; - bool _ffmpeg_decoder_done; - std::list > _imagemagick_decoders; - std::list >::iterator _imagemagick_decoder; - std::list > _sndfile_decoders; - - boost::shared_ptr _sndfile_buffers; - bool _video_sync; + /** 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 _position; + AudioBuffers _audio_buffers; + Time _next_audio; }; #endif