Gnash  0.8.11dev
Public Types | Public Member Functions | List of all members
gnash::PlayHead Class Reference

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...
 

Detailed Description

The playback controller.

Member Enumeration Documentation

§ PlaybackStatus

Flags for playback state.

Enumerator
PLAY_PLAYING 
PLAY_PAUSED 

Constructor & Destructor Documentation

§ PlayHead()

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.

Parameters
clockSourceThe VirtualClock to use as time source. Ownership left to caller (not necessarely a good thing).

Member Function Documentation

§ advanceIfConsumed()

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().

§ getPosition()

std::uint64_t gnash::PlayHead::getPosition ( ) const
inline

Get current playhead position (milliseconds)

Referenced by gnash::NetStream_as::seek(), gnash::NetStream_as::time(), and gnash::NetStream_as::update().

§ getState()

PlaybackStatus gnash::PlayHead::getState ( ) const
inline

Get current playback state.

References setState(), and toggleState().

Referenced by gnash::NetStream_as::pause(), gnash::NetStream_as::seek(), and gnash::NetStream_as::update().

§ isAudioConsumed()

bool gnash::PlayHead::isAudioConsumed ( ) const
inline

Return true if audio of current position have been consumed.

Referenced by gnash::NetStream_as::seek().

§ isVideoConsumed()

bool gnash::PlayHead::isVideoConsumed ( ) const
inline

Return true if video of current position have been consumed.

Referenced by gnash::NetStream_as::seek().

§ seekTo()

void gnash::PlayHead::seekTo ( std::uint64_t  position)

Change current position to the given time.

Consume flag will be reset.

Parameters
positionPosition 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().

§ setAudioConsumed()

void gnash::PlayHead::setAudioConsumed ( )
inline

Mark current position as being consumed by audio consumer.

References advanceIfConsumed(), position, and seekTo().

Referenced by gnash::NetStream_as::seek().

§ setAudioConsumerAvailable()

void gnash::PlayHead::setAudioConsumerAvailable ( )
inline

Set an audio consumer as available.

This should be completely fine to do during PlayHead lifetime.

Referenced by gnash::NetStream_as::play().

§ setState()

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().

§ setVideoConsumed()

void gnash::PlayHead::setVideoConsumed ( )
inline

Mark current position as being consumed by video consumer.

Referenced by gnash::NetStream_as::seek().

§ setVideoConsumerAvailable()

void gnash::PlayHead::setVideoConsumerAvailable ( )
inline

Set a video consumer as available.

This should be completely fine to do during PlayHead lifetime.

Referenced by gnash::NetStream_as::play().

§ toggleState()

PlayHead::PlaybackStatus gnash::PlayHead::toggleState ( )

Toggle playback state, returning old state.

References PLAY_PAUSED, PLAY_PLAYING, and setState().

Referenced by getState().


The documentation for this class was generated from the following files: