xoreos  0.0.5
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Video::VideoDecoder Class Referenceabstract

A generic interface for video decoders. More...

#include <decoder.h>

Inheritance diagram for Video::VideoDecoder:
Inheritance graph
[legend]
Collaboration diagram for Video::VideoDecoder:
Collaboration graph
[legend]

Classes

class  AudioTrack
 An abstract representation of an audio track. More...
 
class  FixedRateVideoTrack
 A VideoTrack that is played at a constant rate. More...
 
class  Track
 An abstract representation of a track in a movie. More...
 
class  VideoTrack
 An abstract representation of a video track. More...
 

Public Types

enum  Scale { kScaleNone, kScaleUp, kScaleDown, kScaleUpDown }
 

Public Member Functions

 VideoDecoder ()
 
 ~VideoDecoder ()
 
void setScale (Scale scale)
 
bool isPlaying () const
 Is the video currently playing? More...
 
virtual uint32 getWidth () const
 Returns the width of the video's frames. More...
 
virtual uint32 getHeight () const
 Returns the height of the video's frames. More...
 
void start ()
 Start playing the video. More...
 
void abort ()
 Abort the playing of the video. More...
 
bool needsUpdate () const
 Check whether a new frame should be decoded, i.e. More...
 
bool endOfVideo () const
 Returns if the video has reached the end or not. More...
 
bool endOfVideoTracks () const
 Have all video tracks finished? More...
 
uint32 getTime () const
 Returns the time position (in ms) of the current video. More...
 
uint32 getTimeToNextFrame () const
 Return the time, in milliseconds, to the next frame. More...
 
void calculateDistance ()
 Calculate the object's distance. More...
 
void render (Graphics::RenderPass pass)
 Render the object. More...
 
virtual Common::Timestamp getDuration () const
 Get the duration of the video. More...
 
void pauseVideo (bool pause)
 Pause or resume the video. More...
 
bool isPaused () const
 Return whether the video is currently paused or not. More...
 
- Public Member Functions inherited from Graphics::GLContainer
 GLContainer ()
 
 ~GLContainer ()
 
void rebuild ()
 
void destroy ()
 
- Public Member Functions inherited from Graphics::Queueable
 Queueable ()
 
virtual ~Queueable ()
 
- Public Member Functions inherited from Graphics::Renderable
 Renderable (RenderableType type)
 
 ~Renderable ()
 
bool operator< (const Queueable &q) const
 
virtual void advanceTime (float dt)
 Advance time (used by renderables with animations). More...
 
virtual void renderImmediate (const glm::mat4 &parentTransform)
 For shader based systems, don't sort anything, render this right_now. More...
 
virtual void queueRender (const glm::mat4 &parentTransform)
 Queue the object for later rendering. More...
 
double getDistance () const
 Get the distance of the object from the viewer. More...
 
uint32 getID () const
 Get the object's unique ID. More...
 
bool isClickable () const
 Is the object clickable? More...
 
void setClickable (bool clickable)
 Set the object's clickable state. More...
 
const Common::UStringgetTag () const
 Get the object's tag. More...
 
void setTag (const Common::UString &tag)
 Set the object's tag. More...
 
bool isVisible () const
 Is the object visible? More...
 
virtual void show ()
 Show the object. More...
 
virtual void hide ()
 Hide the object. More...
 
virtual bool isIn (float x, float y) const
 Is that point within the object? More...
 
virtual bool isIn (float x, float y, float z) const
 Is that point within the object? More...
 
virtual bool isIn (float x1, float y1, float z1, float x2, float y2, float z2) const
 Does the line from x1.y1.z1 to x2.y2.z2 intersect with the object? More...
 

Protected Types

typedef boost::shared_ptr< TrackTrackPtr
 A Track pointer. More...
 
typedef boost::shared_ptr< const TrackConstTrackPtr
 A const Track pointer. More...
 
typedef boost::shared_ptr< AudioTrackAudioTrackPtr
 An AudioTrack pointer. More...
 
typedef boost::shared_ptr< VideoTrackVideoTrackPtr
 A VideoTrack pointer. More...
 
typedef std::vector< TrackPtrTrackList
 A list of tracks. More...
 
typedef std::vector< ConstTrackPtrConstTrackList
 A list of const tracks. More...
 

Protected Member Functions

void initVideo ()
 Create a surface for video of these dimensions. More...
 
void deinit ()
 
void doRebuild ()
 
void doDestroy ()
 
virtual void decodeNextTrackFrame (VideoTrack &track)=0
 Decode enough data for the next frame. More...
 
virtual void checkAudioBuffer (AudioTrack &track, const Common::Timestamp &endTime)
 Ensure that there is enough audio buffered in the given track to reach the given timestamp. More...
 
void addTrack (Track *track, bool isExternal=false)
 Define a track to be used by this class. More...
 
TrackPtr getTrack (uint track)
 Get the given internal track based on its index. More...
 
ConstTrackPtr getTrack (uint track) const
 Get the given internal track based on its index. More...
 
VideoTrackPtr findNextVideoTrack ()
 Set _nextVideoTrack to the video track with the lowest start time for the next frame. More...
 
TrackList getInternalTracks ()
 Get a copy of the internal tracks. More...
 
ConstTrackList getInternalTracks () const
 Get a copy of the internal tracks. More...
 
- Protected Member Functions inherited from Graphics::Queueable
bool isInQueue (QueueType queue) const
 
void addToQueue (QueueType queue)
 
void removeFromQueue (QueueType queue)
 
void lockQueue (QueueType queue)
 
void unlockQueue (QueueType queue)
 
void sortQueue (QueueType queue)
 
- Protected Member Functions inherited from Graphics::Renderable
void resort ()
 
void lockFrame ()
 
void unlockFrame ()
 
void lockFrameIfVisible ()
 
void unlockFrameIfVisible ()
 

Protected Attributes

bool _needCopy
 Is new frame content available that needs to by copied? More...
 
Common::ScopedPtr< Graphics::Surface_surface
 The video's surface. More...
 
- Protected Attributes inherited from Graphics::Renderable
QueueType _queueExists
 
QueueType _queueVisible
 
uint32 _id
 
bool _clickable
 
Common::UString _tag
 
double _distance
 The distance of the object from the viewer. More...
 

Private Member Functions

void stopAudio ()
 Stop all audio tracks. More...
 
void startAudio ()
 Start the designated internal audio track and any external audio tracks. More...
 
bool hasAudio () const
 
void update ()
 Update the video, if necessary. More...
 
void copyData ()
 Copy the video image data to the texture. More...
 
void getQuadDimensions (float &width, float &height) const
 Get the dimensions of the quad to draw the texture on. More...
 

Private Attributes

TrackList _tracks
 Tracks owned by this VideoDecoder (both internal and external). More...
 
TrackList _internalTracks
 Tracks internal to this VideoDecoder. More...
 
TrackList _externalTracks
 Tracks loaded from externals files. More...
 
VideoTrackPtr _nextVideoTrack
 The next video track that needs to display. More...
 
Graphics::TextureID _texture
 
float _textureWidth
 
float _textureHeight
 
Scale _scale
 
uint32 _startTime
 The start time of the video, or -1 for not set. More...
 
uint32 _pauseLevel
 The pause level of the video; 0 for not paused. More...
 
uint32 _pauseStartTime
 The time when the track was first paused. More...
 

Detailed Description

A generic interface for video decoders.

Definition at line 55 of file decoder.h.

Member Typedef Documentation

◆ AudioTrackPtr

typedef boost::shared_ptr<AudioTrack> Video::VideoDecoder::AudioTrackPtr
protected

An AudioTrack pointer.

Definition at line 374 of file decoder.h.

◆ ConstTrackList

typedef std::vector<ConstTrackPtr> Video::VideoDecoder::ConstTrackList
protected

A list of const tracks.

Definition at line 389 of file decoder.h.

◆ ConstTrackPtr

typedef boost::shared_ptr<const Track> Video::VideoDecoder::ConstTrackPtr
protected

A const Track pointer.

Definition at line 369 of file decoder.h.

◆ TrackList

typedef std::vector<TrackPtr> Video::VideoDecoder::TrackList
protected

A list of tracks.

Definition at line 384 of file decoder.h.

◆ TrackPtr

typedef boost::shared_ptr<Track> Video::VideoDecoder::TrackPtr
protected

A Track pointer.

Definition at line 364 of file decoder.h.

◆ VideoTrackPtr

typedef boost::shared_ptr<VideoTrack> Video::VideoDecoder::VideoTrackPtr
protected

A VideoTrack pointer.

Definition at line 379 of file decoder.h.

Member Enumeration Documentation

◆ Scale

Enumerator
kScaleNone 

Don't scale the video.

kScaleUp 

Only scale the video up, if necessary.

kScaleDown 

Only scale the video down, if necessary.

kScaleUpDown 

Scale the video up and down, if necessary.

Definition at line 57 of file decoder.h.

Constructor & Destructor Documentation

◆ VideoDecoder()

Video::VideoDecoder::VideoDecoder ( )

Definition at line 48 of file decoder.cpp.

◆ ~VideoDecoder()

Video::VideoDecoder::~VideoDecoder ( )

Definition at line 56 of file decoder.cpp.

References _texture, deinit(), GfxMan, and stopAudio().

Here is the call graph for this function:

Member Function Documentation

◆ abort()

void Video::VideoDecoder::abort ( )

Abort the playing of the video.

Definition at line 405 of file decoder.cpp.

References Graphics::Renderable::hide(), and stopAudio().

Here is the call graph for this function:

◆ addTrack()

void Video::VideoDecoder::addTrack ( Track track,
bool  isExternal = false 
)
protected

Define a track to be used by this class.

The pointer is then owned by this base class.

Parameters
trackThe track to add
isExternalIs this an external track not found by loadStream()?

Definition at line 152 of file decoder.cpp.

References _externalTracks, _internalTracks, _nextVideoTrack, _tracks, Video::VideoDecoder::Track::getTrackType(), isPaused(), isPlaying(), Video::VideoDecoder::Track::kTrackTypeAudio, Video::VideoDecoder::Track::kTrackTypeVideo, and Video::VideoDecoder::Track::pause().

Referenced by Video::Fader::Fader(), Video::Bink::load(), Video::XboxMediaVideo::load(), and Video::QuickTimeDecoder::load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateDistance()

void Video::VideoDecoder::calculateDistance ( )
virtual

Calculate the object's distance.

Implements Graphics::Renderable.

Definition at line 362 of file decoder.cpp.

◆ checkAudioBuffer()

void Video::VideoDecoder::checkAudioBuffer ( AudioTrack track,
const Common::Timestamp endTime 
)
protectedvirtual

Ensure that there is enough audio buffered in the given track to reach the given timestamp.

Reimplemented in Video::QuickTimeDecoder, and Video::Bink.

Definition at line 436 of file decoder.cpp.

Referenced by update().

Here is the caller graph for this function:

◆ copyData()

void Video::VideoDecoder::copyData ( )
private

Copy the video image data to the texture.

Definition at line 273 of file decoder.cpp.

References _needCopy, _surface, and _texture.

Referenced by update().

Here is the caller graph for this function:

◆ decodeNextTrackFrame()

virtual void Video::VideoDecoder::decodeNextTrackFrame ( VideoTrack track)
protectedpure virtual

Decode enough data for the next frame.

Currently, audio may be buffered here at the same time. This is deprecated in favor of using checkAudioBuffer().

Implemented in Video::Bink, Video::QuickTimeDecoder, Video::XboxMediaVideo, Video::ActimagineDecoder, and Video::Fader.

Referenced by update().

Here is the caller graph for this function:

◆ deinit()

void Video::VideoDecoder::deinit ( )
protected

Definition at line 65 of file decoder.cpp.

References Graphics::Renderable::hide(), and Graphics::kQueueGLContainer.

Referenced by ~VideoDecoder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doDestroy()

void Video::VideoDecoder::doDestroy ( )
protectedvirtual

Implements Graphics::GLContainer.

Definition at line 264 of file decoder.cpp.

References _texture.

◆ doRebuild()

void Video::VideoDecoder::doRebuild ( )
protectedvirtual

Implements Graphics::GLContainer.

Definition at line 243 of file decoder.cpp.

References _surface, and _texture.

◆ endOfVideo()

bool Video::VideoDecoder::endOfVideo ( ) const

Returns if the video has reached the end or not.

Returns
true if the video has finished playing, false otherwise

Definition at line 106 of file decoder.cpp.

References _tracks.

Referenced by getTimeToNextFrame().

Here is the caller graph for this function:

◆ endOfVideoTracks()

bool Video::VideoDecoder::endOfVideoTracks ( ) const

Have all video tracks finished?

Definition at line 114 of file decoder.cpp.

References _tracks, and Video::VideoDecoder::Track::kTrackTypeVideo.

Referenced by needsUpdate().

Here is the caller graph for this function:

◆ findNextVideoTrack()

VideoDecoder::VideoTrackPtr Video::VideoDecoder::findNextVideoTrack ( )
protected

Set _nextVideoTrack to the video track with the lowest start time for the next frame.

Returns
_nextVideoTrack

Definition at line 195 of file decoder.cpp.

References _nextVideoTrack, _tracks, and Video::VideoDecoder::Track::kTrackTypeVideo.

Referenced by update().

Here is the caller graph for this function:

◆ getDuration()

Common::Timestamp Video::VideoDecoder::getDuration ( ) const
virtual

Get the duration of the video.

If the duration is unknown, this will return 0. If this is not overriden, it will take the length of the longest track.

Definition at line 439 of file decoder.cpp.

References _tracks.

◆ getHeight()

uint32 Video::VideoDecoder::getHeight ( ) const
virtual

Returns the height of the video's frames.

By default, this finds the largest height between all of the loaded tracks. However, a subclass may override this if it does any kind of post-processing on it.

Returns
the height of the video's frames

Definition at line 98 of file decoder.cpp.

References _tracks, and Video::VideoDecoder::Track::kTrackTypeVideo.

Referenced by getQuadDimensions(), and initVideo().

Here is the caller graph for this function:

◆ getInternalTracks() [1/2]

TrackList Video::VideoDecoder::getInternalTracks ( )
inlineprotected

Get a copy of the internal tracks.

Definition at line 461 of file decoder.h.

References _internalTracks.

◆ getInternalTracks() [2/2]

VideoDecoder::ConstTrackList Video::VideoDecoder::getInternalTracks ( ) const
protected

Get a copy of the internal tracks.

Definition at line 214 of file decoder.cpp.

References _internalTracks.

◆ getQuadDimensions()

void Video::VideoDecoder::getQuadDimensions ( float &  width,
float &  height 
) const
private

Get the dimensions of the quad to draw the texture on.

Definition at line 332 of file decoder.cpp.

References _scale, getHeight(), getWidth(), kScaleDown, kScaleNone, kScaleUp, and WindowMan.

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTime()

uint32 Video::VideoDecoder::getTime ( ) const

Returns the time position (in ms) of the current video.

Definition at line 411 of file decoder.cpp.

References _pauseStartTime, _startTime, EventMan, isPaused(), and isPlaying().

Referenced by getTimeToNextFrame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTimeToNextFrame()

uint32 Video::VideoDecoder::getTimeToNextFrame ( ) const

Return the time, in milliseconds, to the next frame.

Definition at line 423 of file decoder.cpp.

References _nextVideoTrack, endOfVideo(), and getTime().

Referenced by needsUpdate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTrack() [1/2]

VideoDecoder::TrackPtr Video::VideoDecoder::getTrack ( uint  track)
protected

Get the given internal track based on its index.

Returns
A valid track pointer on success, 0 otherwise

Definition at line 181 of file decoder.cpp.

References _internalTracks.

◆ getTrack() [2/2]

VideoDecoder::ConstTrackPtr Video::VideoDecoder::getTrack ( uint  track) const
protected

Get the given internal track based on its index.

Returns
A valid track pointer on success, 0 otherwise

Definition at line 188 of file decoder.cpp.

References _internalTracks.

◆ getWidth()

uint32 Video::VideoDecoder::getWidth ( ) const
virtual

Returns the width of the video's frames.

By default, this finds the largest width between all of the loaded tracks. However, a subclass may override this if it does any kind of post-processing on it.

Returns
the width of the video's frames

Definition at line 90 of file decoder.cpp.

References _tracks, and Video::VideoDecoder::Track::kTrackTypeVideo.

Referenced by getQuadDimensions(), and initVideo().

Here is the caller graph for this function:

◆ hasAudio()

bool Video::VideoDecoder::hasAudio ( ) const
private

Definition at line 235 of file decoder.cpp.

References _tracks, and Video::VideoDecoder::Track::kTrackTypeAudio.

◆ initVideo()

void Video::VideoDecoder::initVideo ( )
protected

Create a surface for video of these dimensions.

Since the data will be copied into the graphics card memory, the surface's actual dimensions will be rounded up to the next power of two values.

The surface's width and height is taken from getWidth() and getHeight().

The surface's pixel format is always BGRA8888.

Definition at line 71 of file decoder.cpp.

References _surface, _textureHeight, _textureWidth, getHeight(), getWidth(), NEXTPOWER2(), Graphics::GLContainer::rebuild(), and Common::ScopedPtrBase< T, Deallocator >::reset().

Referenced by Video::Fader::Fader(), Video::Bink::load(), Video::XboxMediaVideo::load(), and Video::QuickTimeDecoder::load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPaused()

bool Video::VideoDecoder::isPaused ( ) const
inline

Return whether the video is currently paused or not.

Definition at line 152 of file decoder.h.

References _pauseLevel.

Referenced by addTrack(), getTime(), and Video::VideoDecoder::AudioTrack::start().

Here is the caller graph for this function:

◆ isPlaying()

bool Video::VideoDecoder::isPlaying ( ) const

Is the video currently playing?

Definition at line 293 of file decoder.cpp.

References _startTime, and _tracks.

Referenced by addTrack(), getTime(), and render().

Here is the caller graph for this function:

◆ needsUpdate()

bool Video::VideoDecoder::needsUpdate ( ) const

Check whether a new frame should be decoded, i.e.

because enough time has elapsed since the last frame was decoded.

Returns
whether a new frame should be decoded or not

Definition at line 122 of file decoder.cpp.

References endOfVideoTracks(), and getTimeToNextFrame().

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pauseVideo()

void Video::VideoDecoder::pauseVideo ( bool  pause)

Pause or resume the video.

This should stop/resume any audio playback and other stuff. The initial pause time is kept so that any timing variables can be updated appropriately.

This is a convenience method which automatically keeps track on how often the video has been paused, ensuring that after pausing an video e.g. twice, it has to be unpaused twice before actuallying resuming.

Parameters
pausetrue to pause the video, false to resume it

Definition at line 126 of file decoder.cpp.

References _pauseLevel, _pauseStartTime, _startTime, _tracks, and EventMan.

◆ render()

void Video::VideoDecoder::render ( Graphics::RenderPass  pass)
virtual

Render the object.

Implements Graphics::Renderable.

Definition at line 365 of file decoder.cpp.

References _texture, _textureHeight, _textureWidth, getQuadDimensions(), isPlaying(), Graphics::kRenderPassTransparent, pass, and update().

Here is the call graph for this function:

◆ setScale()

void Video::VideoDecoder::setScale ( Scale  scale)

Definition at line 289 of file decoder.cpp.

References _scale.

◆ start()

void Video::VideoDecoder::start ( )

Start playing the video.

Definition at line 397 of file decoder.cpp.

References _startTime, EventMan, Graphics::Renderable::show(), and startAudio().

Here is the call graph for this function:

◆ startAudio()

void Video::VideoDecoder::startAudio ( )
private

Start the designated internal audio track and any external audio tracks.

Definition at line 223 of file decoder.cpp.

References _tracks, and Video::VideoDecoder::Track::kTrackTypeAudio.

Referenced by start().

Here is the caller graph for this function:

◆ stopAudio()

void Video::VideoDecoder::stopAudio ( )
private

Stop all audio tracks.

Definition at line 229 of file decoder.cpp.

References _tracks, and Video::VideoDecoder::Track::kTrackTypeAudio.

Referenced by abort(), and ~VideoDecoder().

Here is the caller graph for this function:

◆ update()

void Video::VideoDecoder::update ( )
private

Update the video, if necessary.

Definition at line 304 of file decoder.cpp.

References _internalTracks, _nextVideoTrack, Video::VideoDecoder::AudioTrack::canBufferData(), checkAudioBuffer(), copyData(), debugC(), decodeNextTrackFrame(), findNextVideoTrack(), Common::kDebugVideo, Video::VideoDecoder::Track::kTrackTypeAudio, and needsUpdate().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _externalTracks

TrackList Video::VideoDecoder::_externalTracks
private

Tracks loaded from externals files.

Definition at line 471 of file decoder.h.

Referenced by addTrack().

◆ _internalTracks

TrackList Video::VideoDecoder::_internalTracks
private

Tracks internal to this VideoDecoder.

Definition at line 470 of file decoder.h.

Referenced by addTrack(), getInternalTracks(), getTrack(), and update().

◆ _needCopy

bool Video::VideoDecoder::_needCopy
protected

◆ _nextVideoTrack

VideoTrackPtr Video::VideoDecoder::_nextVideoTrack
private

The next video track that needs to display.

Definition at line 473 of file decoder.h.

Referenced by addTrack(), findNextVideoTrack(), getTimeToNextFrame(), and update().

◆ _pauseLevel

uint32 Video::VideoDecoder::_pauseLevel
private

The pause level of the video; 0 for not paused.

Definition at line 491 of file decoder.h.

Referenced by isPaused(), and pauseVideo().

◆ _pauseStartTime

uint32 Video::VideoDecoder::_pauseStartTime
private

The time when the track was first paused.

Definition at line 494 of file decoder.h.

Referenced by getTime(), and pauseVideo().

◆ _scale

Scale Video::VideoDecoder::_scale
private

Definition at line 484 of file decoder.h.

Referenced by getQuadDimensions(), and setScale().

◆ _startTime

uint32 Video::VideoDecoder::_startTime
private

The start time of the video, or -1 for not set.

Definition at line 488 of file decoder.h.

Referenced by getTime(), isPlaying(), pauseVideo(), and start().

◆ _surface

Common::ScopedPtr<Graphics::Surface> Video::VideoDecoder::_surface
protected

◆ _texture

Graphics::TextureID Video::VideoDecoder::_texture
private

Definition at line 479 of file decoder.h.

Referenced by copyData(), doDestroy(), doRebuild(), render(), and ~VideoDecoder().

◆ _textureHeight

float Video::VideoDecoder::_textureHeight
private

Definition at line 482 of file decoder.h.

Referenced by initVideo(), and render().

◆ _textureWidth

float Video::VideoDecoder::_textureWidth
private

Definition at line 481 of file decoder.h.

Referenced by initVideo(), and render().

◆ _tracks

TrackList Video::VideoDecoder::_tracks
private

Tracks owned by this VideoDecoder (both internal and external).

Definition at line 469 of file decoder.h.

Referenced by addTrack(), endOfVideo(), endOfVideoTracks(), findNextVideoTrack(), getDuration(), getHeight(), getWidth(), hasAudio(), isPlaying(), pauseVideo(), startAudio(), and stopAudio().


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