BitmapToolkit Scol plugin
|
This class provides media playback functionality. More...
#include <MediaPlayer.h>
Public Types | |
enum | AudioFormats { AUDIO_8BIT_MONO , AUDIO_8BIT_STEREO , AUDIO_16BIT_MONO , AUDIO_16BIT_STEREO } |
enum | State { STOPPED , PLAYING , PAUSED } |
Public Member Functions | |
MediaPlayer () | |
Create an empty player. | |
virtual | ~MediaPlayer () |
void | Open (std::string path) |
Open the media file at the given path. If a media was already loaded, it will be replaced by the new one. | |
void | OpenUrl (std::string url) |
Open the media at the given URL. | |
void | Close () |
Close the current media file, if any. | |
bool | IsReady () |
Check whether the player has a media ready to play. | |
State | GetState () |
Get the current state of this player. | |
bool | HasAudio () |
Check whether the player has an audio track selected and ready to play. | |
bool | HasVideo () |
Check whether the player has a video track selected and ready to play. | |
long | GetLength () |
Get the length of the current media stream. | |
bool | IsSeekable () |
Check whether the file or stream is seekable. | |
bool | IsLiveStream () |
Check whether the current media is a live stream. | |
void | GetSize (int &width, int &height) |
Get the current size of the video (after resize) | |
void | GetSourceSize (int &width, int &height) |
Get the original size of the video (before resize) | |
void | SetSize (int width, int height) |
Set the target size for the video. | |
void | SetAudioFormat (AudioFormats format, int sampleRate) |
Set the output format for audio. | |
void | Play (long startPosition=0) |
Play/resume the currently loaded media. | |
void | Pause () |
Pause the current media playback. | |
void | Stop () |
Stop media playback. | |
void | SetLoop (bool loop) |
Set whether media playback should loop or not. | |
void | SetCurrentTime (long time) |
Set the current playback time of the media. | |
long | GetCurrentTime () |
Get the current playback time of the media. | |
bool | GetFrame (ObjBitmap *scolBitmap) |
Get the current decoded video frame. | |
bool | GetFrame (cv::Mat &buffer) |
Get the current decoded video frame. | |
cv::Mat | GetFrame () |
Get the current decoded video frame. | |
int | GetAudioThreaded (char *destBuffer, size_t length) |
Get decoded audio data from the media (using the dedicated audio thread). | |
int | SetVideoStream (int streamIndex=-1) |
Select the video stream to play from the current file. | |
int | SetAudioStream (int streamIndex=-1) |
Select the audio stream to play from the current file. | |
std::vector< std::string > | ListStreams (AVMediaType type) |
Static Public Member Functions | |
static void | InitFFmpeg () |
Init FFmpeg functionalities. Call this before any other MediaPlayer functions. | |
static void | DeInitFFmpeg () |
Free resources allocated by init. Call this when you're done with MediaPlayer. | |
static void | SetGlobalPause (bool pause) |
Pause/unpause every MediaPlayer. | |
static bool | IsValidPlayer (MediaPlayer *player) |
Check whether a media player is still valid. | |
Static Public Attributes | |
static const int | VIDEO_SIZE_AUTO = 0 |
static const int | STREAM_UNDEFINED = -1 |
static const int | BUFFER_COUNT = 2 |
static const AVPixelFormat | DEST_PIXEL_FORMAT = AV_PIX_FMT_BGR24 |
static const AVRational | TIME_BASE = { 1, 1000 } |
static const AVRational | FF_AV_TIME_BASE_Q = { 1, AV_TIME_BASE } |
static const int | AV_SYNC_THRESHOLD = 16 |
static const int | MAX_READ_ERRORS = 30 |
This class provides media playback functionality.
Definition at line 52 of file MediaPlayer.h.
Enumerator | |
---|---|
AUDIO_8BIT_MONO | |
AUDIO_8BIT_STEREO | |
AUDIO_16BIT_MONO | |
AUDIO_16BIT_STEREO |
Definition at line 71 of file MediaPlayer.h.
enum MediaPlayer::State |
Enumerator | |
---|---|
STOPPED | |
PLAYING | |
PAUSED |
Definition at line 79 of file MediaPlayer.h.
MediaPlayer::MediaPlayer | ( | ) |
Create an empty player.
Definition at line 110 of file MediaPlayer.cpp.
|
virtual |
Definition at line 161 of file MediaPlayer.cpp.
void MediaPlayer::Close | ( | ) |
Close the current media file, if any.
Definition at line 329 of file MediaPlayer.cpp.
|
static |
Free resources allocated by init. Call this when you're done with MediaPlayer.
Definition at line 76 of file MediaPlayer.cpp.
int MediaPlayer::GetAudioThreaded | ( | char * | destBuffer, |
size_t | length | ||
) |
Get decoded audio data from the media (using the dedicated audio thread).
destBuffer | Buffer where the audio data will be stored. |
length | How much data to retrieve, in bytes. |
Definition at line 1481 of file MediaPlayer.cpp.
long MediaPlayer::GetCurrentTime | ( | ) |
Get the current playback time of the media.
Definition at line 590 of file MediaPlayer.cpp.
cv::Mat MediaPlayer::GetFrame | ( | ) |
Get the current decoded video frame.
Definition at line 648 of file MediaPlayer.cpp.
bool MediaPlayer::GetFrame | ( | cv::Mat & | buffer | ) |
Get the current decoded video frame.
cv::Mat | buffer where the frame will be copied. |
Definition at line 624 of file MediaPlayer.cpp.
bool MediaPlayer::GetFrame | ( | ObjBitmap * | scolBitmap | ) |
Get the current decoded video frame.
scolBitmap | Bitmap where the frame will be copied. |
Definition at line 595 of file MediaPlayer.cpp.
long MediaPlayer::GetLength | ( | ) |
Get the length of the current media stream.
Definition at line 370 of file MediaPlayer.cpp.
void MediaPlayer::GetSize | ( | int & | width, |
int & | height | ||
) |
Get the current size of the video (after resize)
[out] | width | Width of the video in pixels |
[out] | height | Height of the video in pixels |
Definition at line 398 of file MediaPlayer.cpp.
void MediaPlayer::GetSourceSize | ( | int & | width, |
int & | height | ||
) |
Get the original size of the video (before resize)
[out] | width | Width of the video in pixels |
[out] | height | Height of the video in pixels |
Definition at line 409 of file MediaPlayer.cpp.
MediaPlayer::State MediaPlayer::GetState | ( | ) |
Get the current state of this player.
Definition at line 350 of file MediaPlayer.cpp.
bool MediaPlayer::HasAudio | ( | ) |
Check whether the player has an audio track selected and ready to play.
Definition at line 360 of file MediaPlayer.cpp.
bool MediaPlayer::HasVideo | ( | ) |
Check whether the player has a video track selected and ready to play.
Definition at line 365 of file MediaPlayer.cpp.
|
static |
Init FFmpeg functionalities. Call this before any other MediaPlayer functions.
Definition at line 69 of file MediaPlayer.cpp.
bool MediaPlayer::IsLiveStream | ( | ) |
Check whether the current media is a live stream.
Definition at line 392 of file MediaPlayer.cpp.
bool MediaPlayer::IsReady | ( | ) |
Check whether the player has a media ready to play.
Definition at line 345 of file MediaPlayer.cpp.
bool MediaPlayer::IsSeekable | ( | ) |
Check whether the file or stream is seekable.
Definition at line 380 of file MediaPlayer.cpp.
|
static |
Check whether a media player is still valid.
player | Pointer to the MediaPlayer object to be checked. |
Definition at line 99 of file MediaPlayer.cpp.
std::vector< std::string > MediaPlayer::ListStreams | ( | AVMediaType | type | ) |
Definition at line 788 of file MediaPlayer.cpp.
void MediaPlayer::Open | ( | std::string | path | ) |
Open the media file at the given path. If a media was already loaded, it will be replaced by the new one.
path | Path to the media file. |
Definition at line 239 of file MediaPlayer.cpp.
void MediaPlayer::OpenUrl | ( | std::string | url | ) |
Open the media at the given URL.
url | Url of the media. |
close | Whether to close the currently open file or not (used internally). Should be left to true. |
Definition at line 321 of file MediaPlayer.cpp.
void MediaPlayer::Pause | ( | ) |
Pause the current media playback.
Definition at line 514 of file MediaPlayer.cpp.
void MediaPlayer::Play | ( | long | startPosition = 0 | ) |
Play/resume the currently loaded media.
startPosition | In case the player is stopped, the position in milliseconds at which we want it to start. Defaults to 0 (beginning). |
Definition at line 487 of file MediaPlayer.cpp.
void MediaPlayer::SetAudioFormat | ( | AudioFormats | format, |
int | sampleRate | ||
) |
Set the output format for audio.
format | Sample format with channel layout (one of AUDIO_*) |
sampleRate | Frequency in Hz |
Definition at line 432 of file MediaPlayer.cpp.
int MediaPlayer::SetAudioStream | ( | int | streamIndex = -1 | ) |
Select the audio stream to play from the current file.
streamIndex | Index of the desired stream. Leave to -1 for default stream. |
Definition at line 703 of file MediaPlayer.cpp.
void MediaPlayer::SetCurrentTime | ( | long | time | ) |
Set the current playback time of the media.
time | Time in milliseconds to seek to. |
Definition at line 561 of file MediaPlayer.cpp.
|
static |
Pause/unpause every MediaPlayer.
pause | True to pause, false to unpause. |
Definition at line 81 of file MediaPlayer.cpp.
void MediaPlayer::SetLoop | ( | bool | loop | ) |
Set whether media playback should loop or not.
loop | true to loop playback, false to stop on media end. |
Definition at line 556 of file MediaPlayer.cpp.
void MediaPlayer::SetSize | ( | int | width, |
int | height | ||
) |
Set the target size for the video.
width | Desired width in pixels |
height | Desired height in pixels |
Definition at line 420 of file MediaPlayer.cpp.
int MediaPlayer::SetVideoStream | ( | int | streamIndex = -1 | ) |
Select the video stream to play from the current file.
streamIndex | Index of the desired stream. Leave to -1 for default stream. |
Definition at line 662 of file MediaPlayer.cpp.
void MediaPlayer::Stop | ( | ) |
Stop media playback.
Definition at line 533 of file MediaPlayer.cpp.
|
static |
Definition at line 66 of file MediaPlayer.h.
|
static |
Definition at line 57 of file MediaPlayer.h.
|
static |
Definition at line 58 of file MediaPlayer.h.
|
static |
Definition at line 53 of file MediaPlayer.h.
|
static |
Definition at line 69 of file MediaPlayer.h.
|
static |
Definition at line 56 of file MediaPlayer.h.
|
static |
Definition at line 51 of file MediaPlayer.h.
|
static |
Definition at line 55 of file MediaPlayer.h.