CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Public Member Functions | List of all members
movie_player Class Reference

#include <th_movie.h>

Public Member Functions

 movie_player ()
 Construct a new movie_player.
 
 ~movie_player ()
 Destroy the movie_player.
 
void set_renderer (SDL_Renderer *pRenderer)
 
bool movies_enabled () const
 Return whether movies were compiled into CorsixTH.
 
bool load (const char *szFilepath)
 Load the movie with the given file name.
 
void unload ()
 
void play (int requested_audio_channel)
 
void stop ()
 Stop the currently playing movie.
 
void togglePause ()
 
int get_native_height () const
 Return the original height of the movie.
 
int get_native_width () const
 Return the original width of the movie.
 
bool has_audio_track () const
 Return whether the movie has an audio stream.
 
double get_movie_length () const
 Return the length of the movie in milliseconds.
 
const charget_last_error () const
 Return a text description of the last error encountered.
 
void clear_last_error ()
 
double refresh (const SDL_Rect &destination_rect)
 
void deallocate_picture_buffer ()
 
void allocate_picture_buffer ()
 Allocate the picture buffer for the current renderer.
 
void read_streams ()
 
void run_video ()
 
void copy_audio_to_stream (uint8_t *pbStream, int iStreamSize)
 

Detailed Description

Movie player for CorsixTH

The movie player is designed to be preinitialized and used for multiple movies. After initializing the movie player, call movie_player::set_renderer to assign the current SDL renderer to the movie player. Then movie_player::load the desired movie and finally movie_player::play it.

Constructor & Destructor Documentation

◆ movie_player()

movie_player::movie_player ( )

Construct a new movie_player.

◆ ~movie_player()

movie_player::~movie_player ( )

Destroy the movie_player.

Member Function Documentation

◆ allocate_picture_buffer()

void movie_player::allocate_picture_buffer ( )

Allocate the picture buffer for the current renderer.

◆ clear_last_error()

void movie_player::clear_last_error ( )

Clear the last error so that if there is no more errors before the next call to movie_player::get_last_error() it will return an empty string.

◆ copy_audio_to_stream()

void movie_player::copy_audio_to_stream ( uint8_t *  pbStream,
int  iStreamSize 
)

Read audio from the audio packet queue, and copy it into the audio buffer for playback

◆ deallocate_picture_buffer()

void movie_player::deallocate_picture_buffer ( )

Deallocate the picture buffer and free any resources associated with it.

Remarks
This destroys the textures and other resources that may lock the renderer from being deleted. If the target changes you would call this, then free and switch renderers in the outside program, then call movie_player::set_renderer and finally movie_player::allocate_picture_buffer.
Up to the size of the picture buffer frames may be lost during this process.

◆ get_last_error()

const char * movie_player::get_last_error ( ) const

Return a text description of the last error encountered.

◆ get_movie_length()

double movie_player::get_movie_length ( ) const

Return the length of the movie in milliseconds.

◆ get_native_height()

int movie_player::get_native_height ( ) const

Return the original height of the movie.

◆ get_native_width()

int movie_player::get_native_width ( ) const

Return the original width of the movie.

◆ has_audio_track()

bool movie_player::has_audio_track ( ) const

Return whether the movie has an audio stream.

◆ load()

bool movie_player::load ( const char szFilepath)

Load the movie with the given file name.

◆ movies_enabled()

bool movie_player::movies_enabled ( ) const

Return whether movies were compiled into CorsixTH.

◆ play()

void movie_player::play ( int  requested_audio_channel)

Play the currently loaded movie

Parameters
requested_audio_channelThe audio channel to use

◆ read_streams()

void movie_player::read_streams ( )

Read packets from the movie and allocate them to the appropriate stream packet queues. Signal if we have reached the end of the movie.

Remarks
This should not be called externally. It is public as it is the entry point of a thread.

◆ refresh()

double movie_player::refresh ( const SDL_Rect &  destination_rect)

Draw the next frame if it is time to do so

Parameters
destination_rectThe location and dimensions in the renderer on which to draw the movie
Returns
The current presentation time stamp of the movie in milliseconds

◆ run_video()

void movie_player::run_video ( )

Read video frames from the video packet queue and write them to the picture queue.

Remarks
This should not be called externally. It is public as it is the entry point of a thread.

◆ set_renderer()

void movie_player::set_renderer ( SDL_Renderer pRenderer)

Assign the renderer on which to draw the movie.

movie_player does not take ownership of the render, it is up to the caller to delete it, after deleting movie_player or setting a different renderer.

◆ stop()

void movie_player::stop ( )

Stop the currently playing movie.

◆ togglePause()

void movie_player::togglePause ( )

Pause the currently playing movie

This method is not thread safe, it should only be called from the event thread.

◆ unload()

void movie_player::unload ( )

Unload and free the currently loaded movie.

Remarks
This is called by load before loading a new movie so it is unnecessary to explicitly call this method. There is no harm either.

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