Gnash
0.8.11dev
|
The playback controller. More...
#include <PlayHead.h>
Public Types | |
enum | PlaybackStatus { PLAY_PLAYING = 1, PLAY_PAUSED = 2 } |
Flags for playback state. More... | |
Public Member Functions | |
PlayHead (VirtualClock *clockSource) | |
void | setVideoConsumerAvailable () |
Set a video consumer as available. More... | |
void | setAudioConsumerAvailable () |
Set an audio consumer as available. More... | |
std::uint64_t | getPosition () const |
Get current playhead position (milliseconds) More... | |
PlaybackStatus | getState () const |
Get current playback state. More... | |
PlaybackStatus | setState (PlaybackStatus newState) |
Set playback state, returning old state. More... | |
PlaybackStatus | toggleState () |
Toggle playback state, returning old state. More... | |
bool | isVideoConsumed () const |
Return true if video of current position have been consumed. More... | |
void | setVideoConsumed () |
Mark current position as being consumed by video consumer. More... | |
bool | isAudioConsumed () const |
Return true if audio of current position have been consumed. More... | |
void | setAudioConsumed () |
Mark current position as being consumed by audio consumer. More... | |
void | seekTo (std::uint64_t position) |
Change current position to the given time. More... | |
void | advanceIfConsumed () |
Advance position if all available consumers consumed the current one. More... | |
The playback controller.
gnash::PlayHead::PlayHead | ( | VirtualClock * | clockSource | ) |
Initialize playhead given a VirtualCock to use as clock source. The PlayHead will have initial state set to PAUSED and initial position set to 0.
clockSource | The VirtualClock to use as time source. Ownership left to caller (not necessarely a good thing). |
void gnash::PlayHead::advanceIfConsumed | ( | ) |
Advance position if all available consumers consumed the current one.
Clock source will be used to determine the amount of milliseconds to advance position to.
Consumer flags will be reset.
POSTCONDITIONS:
References gnash::VirtualClock::elapsed(), and gnash::log_debug().
Referenced by setAudioConsumed(), and gnash::NetStream_as::update().
|
inline |
Get current playhead position (milliseconds)
Referenced by gnash::NetStream_as::seek(), gnash::NetStream_as::time(), and gnash::NetStream_as::update().
|
inline |
Get current playback state.
References setState(), and toggleState().
Referenced by gnash::NetStream_as::pause(), gnash::NetStream_as::seek(), and gnash::NetStream_as::update().
|
inline |
Return true if audio of current position have been consumed.
Referenced by gnash::NetStream_as::seek().
|
inline |
Return true if video of current position have been consumed.
Referenced by gnash::NetStream_as::seek().
void gnash::PlayHead::seekTo | ( | std::uint64_t | position | ) |
Change current position to the given time.
Consume flag will be reset.
position | Position timestamp (milliseconds) |
POSTCONDITIONS:
References gnash::VirtualClock::elapsed(), and position.
Referenced by gnash::NetStream_as::play(), gnash::NetStream_as::seek(), setAudioConsumed(), and gnash::NetStream_as::update().
|
inline |
Mark current position as being consumed by audio consumer.
References advanceIfConsumed(), position, and seekTo().
Referenced by gnash::NetStream_as::seek().
|
inline |
Set an audio consumer as available.
This should be completely fine to do during PlayHead lifetime.
Referenced by gnash::NetStream_as::play().
PlayHead::PlaybackStatus gnash::PlayHead::setState | ( | PlaybackStatus | newState | ) |
Set playback state, returning old state.
References gnash::VirtualClock::elapsed(), PLAY_PAUSED, and PLAY_PLAYING.
Referenced by getState(), gnash::NetStream_as::play(), gnash::NetStream_as::time(), and toggleState().
|
inline |
Mark current position as being consumed by video consumer.
Referenced by gnash::NetStream_as::seek().
|
inline |
Set a video consumer as available.
This should be completely fine to do during PlayHead lifetime.
Referenced by gnash::NetStream_as::play().
PlayHead::PlaybackStatus gnash::PlayHead::toggleState | ( | ) |
Toggle playback state, returning old state.
References PLAY_PAUSED, PLAY_PLAYING, and setState().
Referenced by getState().