Theora Playback Library  1.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
TheoraVideoClip Class Referenceabstract

Public Member Functions

 TheoraVideoClip (TheoraDataSource *data_source, TheoraOutputMode output_mode, int nPrecachedFrames, bool usePower2Stride)
 
virtual ~TheoraVideoClip ()
 
std::string getName ()
 
virtual std::string getDecoderName ()=0
 Returns the string name of the decoder backend (eg. Theora, AVFoundation) More...
 
int getNumDisplayedFrames ()
 benchmark function More...
 
int getNumDroppedFrames ()
 benchmark function More...
 
int getWidth ()
 return width in pixels of the video clip More...
 
int getHeight ()
 return height in pixels of the video clip More...
 
bool hasAlphaChannel ()
 returns whether the clip has an alpha channel More...
 
int getSubFrameWidth ()
 Width of the actual picture inside a video frame (depending on implementation, this may be equal to mWidth or differ within a codec block size (usually 16)) More...
 
int getSubFrameHeight ()
 Height of the actual picture inside a video frame (depending on implementation, this may be equal to mHeight or differ within a codec block size (usually 16)) More...
 
int getSubFrameOffsetX ()
 X Offset of the actual picture inside a video frame (depending on implementation, this may be 0 or within a codec block size (usually 16)) More...
 
int getSubFrameOffsetY ()
 Y Offset of the actual picture inside a video frame (depending on implementation, this may be 0 or differ within a codec block size (usually 16)) More...
 
int getStride ()
 return stride in pixels More...
 
TheoraTimergetTimer ()
 retur the timer objet associated with this object More...
 
void setTimer (TheoraTimer *timer)
 replace the timer object with a new one More...
 
virtual bool decodeNextFrame ()=0
 used by TheoraWorkerThread, do not call directly More...
 
void update (float timeDelta)
 advance time. TheoraVideoManager calls this More...
 
float updateToNextFrame ()
 update timer to the display time of the next frame More...
 
TheoraFrameQueuegetFrameQueue ()
 
void popFrame ()
 pop the frame from the front of the FrameQueue More...
 
TheoraVideoFramegetNextFrame ()
 Returns the first available frame in the queue or NULL if no frames are available. More...
 
virtual void decodedAudioCheck ()=0
 
void setAudioInterface (TheoraAudioInterface *iface)
 
TheoraAudioInterfacegetAudioInterface ()
 
void setNumPrecachedFrames (int n)
 resize the frame queues More...
 
int getNumPrecachedFrames ()
 returns the size of the frame queue More...
 
int getNumReadyFrames ()
 returns the number of ready frames in the frame queue More...
 
void setAudioGain (float gain)
 if you want to adjust the audio gain. range [0,1] More...
 
float getAudioGain ()
 
void setAutoRestart (bool value)
 if you want the video to automatically and smoothly restart when the last frame is reached More...
 
bool getAutoRestart ()
 
void setPriority (float priority)
 
float getPriority ()
 
float getPriorityIndex ()
 Used by TheoraVideoManager to schedule work. More...
 
float getTimePosition ()
 get the current time index from the timer object More...
 
float getDuration ()
 get the duration of the movie in seconds More...
 
float getFPS ()
 return the clips' frame rate, warning, fps can be a non integer number! More...
 
int getNumFrames ()
 get the number of frames in this movie More...
 
TheoraOutputMode getOutputMode ()
 return the current output mode for this video object More...
 
void setOutputMode (TheoraOutputMode mode)
 
bool isDone ()
 
void play ()
 
void pause ()
 
void restart ()
 
bool isPaused ()
 
void stop ()
 
void setPlaybackSpeed (float speed)
 
float getPlaybackSpeed ()
 
void seek (float time)
 seek to a given time position More...
 
void seekToFrame (int frame)
 seek to a given frame number More...
 
float waitForCache (float desired_cache_factor=0.5f, float max_wait_time=1.0f)
 wait max_time for the clip to cache a given percentage of frames, factor in range [0,1]. Returns actual precache factor More...
 

Protected Member Functions

int calculatePriority ()
 
void readTheoraVorbisHeaders ()
 
virtual void doSeek ()=0
 
virtual bool _readData ()=0
 called by WorkerThread to seek to mSeekFrame More...
 
bool isBusy ()
 
virtual float decodeAudio ()=0
 
int _getNumReadyFrames ()
 
void resetFrameQueue ()
 
int discardOutdatedFrames (float absTime)
 
float getAbsPlaybackTime ()
 
virtual void load (TheoraDataSource *source)=0
 
virtual void _restart ()=0
 

Protected Attributes

TheoraFrameQueuemFrameQueue
 
TheoraAudioInterfacemAudioInterface
 
TheoraDataSourcemStream
 
TheoraTimermTimer
 
TheoraTimermDefaultTimer
 
TheoraWorkerThreadmAssignedWorkerThread
 
bool mUseAlpha
 
bool mWaitingForCache
 
int mNumDroppedFrames
 
int mNumDisplayedFrames
 
int mNumPrecachedFrames
 
int mThreadAccessCount
 
int mSeekFrame
 counter used by TheoraVideoManager to schedule workload More...
 
float mDuration
 stores desired seek position as a frame number. next worker thread will do the seeking and reset this var to -1 More...
 
float mFrameDuration
 
float mPriority
 
std::string mName
 User assigned priority. Default value is 1. More...
 
int mWidth
 
int mHeight
 
int mStride
 
int mNumFrames
 
float mFPS
 
int mSubFrameWidth
 
int mSubFrameHeight
 
int mSubFrameOffsetX
 
int mSubFrameOffsetY
 
float mAudioGain
 
TheoraOutputMode mOutputMode
 multiplier for audio samples. between 0 and 1 More...
 
TheoraOutputMode mRequestedOutputMode
 
bool mFirstFrameDisplayed
 
bool mAutoRestart
 
bool mEndOfFile
 
bool mRestarted
 
int mIteration
 
int mPlaybackIteration
 
TheoraMutexmAudioMutex
 used to ensure smooth playback of looping videos More...
 
TheoraMutexmThreadAccessMutex
 syncs audio decoding and extraction More...
 

Friends

class TheoraWorkerThread
 
class TheoraVideoFrame
 
class TheoraVideoManager
 

Detailed Description

This object contains all data related to video playback, eg. the open source file, the frame queue etc.

Constructor & Destructor Documentation

TheoraVideoClip::TheoraVideoClip ( TheoraDataSource data_source,
TheoraOutputMode  output_mode,
int  nPrecachedFrames,
bool  usePower2Stride 
)
virtual TheoraVideoClip::~TheoraVideoClip ( )
virtual

Member Function Documentation

int TheoraVideoClip::_getNumReadyFrames ( )
protected
virtual bool TheoraVideoClip::_readData ( )
protectedpure virtual

called by WorkerThread to seek to mSeekFrame

virtual void TheoraVideoClip::_restart ( )
protectedpure virtual
int TheoraVideoClip::calculatePriority ( )
protected

Get the priority of a video clip. based on a forumula that includes user priority factor, whether the video is paused or not, how many precached frames it has etc. This function is used in TheoraVideoManager to efficiently distribute job assignments among worker threads

Returns
priority number of this video clip
virtual float TheoraVideoClip::decodeAudio ( )
protectedpure virtual

decodes audio from the vorbis stream and stores it in audio packets This is an internal function of TheoraVideoClip, called regularly if playing an audio enabled video clip.

Returns
last decoded timestamp (if found in decoded packet's granule position)
virtual void TheoraVideoClip::decodedAudioCheck ( )
pure virtual

check if there is enough audio data decoded to submit to the audio interface

TheoraWorkerThread calls this

virtual bool TheoraVideoClip::decodeNextFrame ( )
pure virtual

used by TheoraWorkerThread, do not call directly

int TheoraVideoClip::discardOutdatedFrames ( float  absTime)
protected
virtual void TheoraVideoClip::doSeek ( )
protectedpure virtual
float TheoraVideoClip::getAbsPlaybackTime ( )
protected
float TheoraVideoClip::getAudioGain ( )
TheoraAudioInterface* TheoraVideoClip::getAudioInterface ( )
bool TheoraVideoClip::getAutoRestart ( )
inline
virtual std::string TheoraVideoClip::getDecoderName ( )
pure virtual

Returns the string name of the decoder backend (eg. Theora, AVFoundation)

float TheoraVideoClip::getDuration ( )

get the duration of the movie in seconds

float TheoraVideoClip::getFPS ( )

return the clips' frame rate, warning, fps can be a non integer number!

TheoraFrameQueue* TheoraVideoClip::getFrameQueue ( )
int TheoraVideoClip::getHeight ( )

return height in pixels of the video clip

std::string TheoraVideoClip::getName ( )
TheoraVideoFrame* TheoraVideoClip::getNextFrame ( )

Returns the first available frame in the queue or NULL if no frames are available.

see TheoraFrameQueue::getFirstAvailableFrame() for more details

int TheoraVideoClip::getNumDisplayedFrames ( )
inline

benchmark function

int TheoraVideoClip::getNumDroppedFrames ( )
inline

benchmark function

int TheoraVideoClip::getNumFrames ( )
inline

get the number of frames in this movie

int TheoraVideoClip::getNumPrecachedFrames ( )

returns the size of the frame queue

int TheoraVideoClip::getNumReadyFrames ( )

returns the number of ready frames in the frame queue

TheoraOutputMode TheoraVideoClip::getOutputMode ( )

return the current output mode for this video object

float TheoraVideoClip::getPlaybackSpeed ( )
float TheoraVideoClip::getPriority ( )
float TheoraVideoClip::getPriorityIndex ( )

Used by TheoraVideoManager to schedule work.

int TheoraVideoClip::getStride ( )
inline

return stride in pixels

If you've specified usePower2Stride when creating the TheoraVideoClip object then this value will be the next power of two size compared to width, eg: w=376, stride=512.

Otherwise, stride will be equal to width

int TheoraVideoClip::getSubFrameHeight ( )

Height of the actual picture inside a video frame (depending on implementation, this may be equal to mHeight or differ within a codec block size (usually 16))

int TheoraVideoClip::getSubFrameOffsetX ( )

X Offset of the actual picture inside a video frame (depending on implementation, this may be 0 or within a codec block size (usually 16))

int TheoraVideoClip::getSubFrameOffsetY ( )

Y Offset of the actual picture inside a video frame (depending on implementation, this may be 0 or differ within a codec block size (usually 16))

int TheoraVideoClip::getSubFrameWidth ( )

Width of the actual picture inside a video frame (depending on implementation, this may be equal to mWidth or differ within a codec block size (usually 16))

float TheoraVideoClip::getTimePosition ( )

get the current time index from the timer object

TheoraTimer* TheoraVideoClip::getTimer ( )

retur the timer objet associated with this object

int TheoraVideoClip::getWidth ( )

return width in pixels of the video clip

bool TheoraVideoClip::hasAlphaChannel ( )
inline

returns whether the clip has an alpha channel

bool TheoraVideoClip::isBusy ( )
protected
bool TheoraVideoClip::isDone ( )
bool TheoraVideoClip::isPaused ( )
virtual void TheoraVideoClip::load ( TheoraDataSource source)
protectedpure virtual
void TheoraVideoClip::pause ( )
void TheoraVideoClip::play ( )
void TheoraVideoClip::popFrame ( )

pop the frame from the front of the FrameQueue

see TheoraFrameQueue::pop() for more details

void TheoraVideoClip::readTheoraVorbisHeaders ( )
protected
void TheoraVideoClip::resetFrameQueue ( )
protected
void TheoraVideoClip::restart ( )
void TheoraVideoClip::seek ( float  time)

seek to a given time position

void TheoraVideoClip::seekToFrame ( int  frame)

seek to a given frame number

void TheoraVideoClip::setAudioGain ( float  gain)

if you want to adjust the audio gain. range [0,1]

void TheoraVideoClip::setAudioInterface ( TheoraAudioInterface iface)
void TheoraVideoClip::setAutoRestart ( bool  value)

if you want the video to automatically and smoothly restart when the last frame is reached

void TheoraVideoClip::setNumPrecachedFrames ( int  n)

resize the frame queues

Warning: this call discards ready frames in the frame queue

void TheoraVideoClip::setOutputMode ( TheoraOutputMode  mode)

set a new output mode

Warning: this discards the frame queue. ready frames will be lost.

void TheoraVideoClip::setPlaybackSpeed ( float  speed)
void TheoraVideoClip::setPriority ( float  priority)

TODO: user priority. Useful only when more than one video is being decoded

void TheoraVideoClip::setTimer ( TheoraTimer timer)

replace the timer object with a new one

void TheoraVideoClip::stop ( )
void TheoraVideoClip::update ( float  timeDelta)

advance time. TheoraVideoManager calls this

float TheoraVideoClip::updateToNextFrame ( )

update timer to the display time of the next frame

useful if you want to grab frames instead of regular display

Returns
time advanced. 0 if no frames are ready
float TheoraVideoClip::waitForCache ( float  desired_cache_factor = 0.5f,
float  max_wait_time = 1.0f 
)

wait max_time for the clip to cache a given percentage of frames, factor in range [0,1]. Returns actual precache factor

Friends And Related Function Documentation

friend class TheoraVideoFrame
friend
friend class TheoraVideoManager
friend
friend class TheoraWorkerThread
friend

Member Data Documentation

TheoraWorkerThread* TheoraVideoClip::mAssignedWorkerThread
protected
float TheoraVideoClip::mAudioGain
protected
TheoraAudioInterface* TheoraVideoClip::mAudioInterface
protected
TheoraMutex* TheoraVideoClip::mAudioMutex
protected

used to ensure smooth playback of looping videos

bool TheoraVideoClip::mAutoRestart
protected
TheoraTimer * TheoraVideoClip::mDefaultTimer
protected
float TheoraVideoClip::mDuration
protected

stores desired seek position as a frame number. next worker thread will do the seeking and reset this var to -1

bool TheoraVideoClip::mEndOfFile
protected
bool TheoraVideoClip::mFirstFrameDisplayed
protected
float TheoraVideoClip::mFPS
protected
float TheoraVideoClip::mFrameDuration
protected
TheoraFrameQueue* TheoraVideoClip::mFrameQueue
protected
int TheoraVideoClip::mHeight
protected
int TheoraVideoClip::mIteration
protected
std::string TheoraVideoClip::mName
protected

User assigned priority. Default value is 1.

int TheoraVideoClip::mNumDisplayedFrames
protected
int TheoraVideoClip::mNumDroppedFrames
protected
int TheoraVideoClip::mNumFrames
protected
int TheoraVideoClip::mNumPrecachedFrames
protected
TheoraOutputMode TheoraVideoClip::mOutputMode
protected

multiplier for audio samples. between 0 and 1

int TheoraVideoClip::mPlaybackIteration
protected
float TheoraVideoClip::mPriority
protected
TheoraOutputMode TheoraVideoClip::mRequestedOutputMode
protected
bool TheoraVideoClip::mRestarted
protected
int TheoraVideoClip::mSeekFrame
protected

counter used by TheoraVideoManager to schedule workload

TheoraDataSource* TheoraVideoClip::mStream
protected
int TheoraVideoClip::mStride
protected
int TheoraVideoClip::mSubFrameHeight
protected
int TheoraVideoClip::mSubFrameOffsetX
protected
int TheoraVideoClip::mSubFrameOffsetY
protected
int TheoraVideoClip::mSubFrameWidth
protected
int TheoraVideoClip::mThreadAccessCount
protected
TheoraMutex* TheoraVideoClip::mThreadAccessMutex
protected

syncs audio decoding and extraction

TheoraTimer* TheoraVideoClip::mTimer
protected
bool TheoraVideoClip::mUseAlpha
protected
bool TheoraVideoClip::mWaitingForCache
protected
int TheoraVideoClip::mWidth
protected

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