arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
VideoPlayerFull Class Reference

VideoPlayer subclass pre-registered with every video/audio codec this library ships a portable decoder for - H264/MJPEG/MPEG-1 video, MP3/AAC/MP2 audio - so it's the "just point it at a file, any common codec just works" player. Use instead of the base VideoPlayer unless you want to keep these dependencies out of your build (the base class's own multi-decoders start empty - see its class comment). More...

#include <VideoPlayerFull.h>

Inheritance diagram for VideoPlayerFull:
VideoPlayer

Public Member Functions

 VideoPlayerFull ()
 
 VideoPlayerFull (Demuxer &demuxer, VideoOutput &videoOutput)
 
 VideoPlayerFull (Demuxer &demuxer, VideoOutput &videoOutput, AudioOutput &audioOutput)
 
 VideoPlayerFull (Demuxer &demuxer, VideoOutput &videoOutput, AudioStream &audioOutput)
 
 VideoPlayerFull (Demuxer &demuxer, VideoOutput &videoOutput, Print &audioOutput)
 
void addAudioDecoder (AudioDecoder &decoder, const char *mime=nullptr)
 
void addDemuxer (Demuxer &demuxer)
 
void addVideoDecoder (VideoDecoder &decoder)
 
MultiDecoderaudioDecoder ()
 
bool begin (Stream &source)
 
size_t copy ()
 
size_t copyAll ()
 Copies until the source is exhausted (blocking).
 
MultiVideoDemuxerdemuxer ()
 
void end ()
 
StreamgetStream ()
 The Stream given to begin() - nullptr before the first begin() call.
 
bool isActive () const
 
 operator bool () const
 
void setActive (bool isActive)
 
void setAudioOutput (AudioOutput &out)
 
void setAudioOutput (AudioStream &out)
 
void setAudioOutput (Print &out)
 
void setBufferSize (int size)
 
void setUseAudioClock (bool active)
 
void setVideoOutput (VideoOutput &out)
 
bool useAudioClock () const
 
MultiVideoDecodervideoDecoder ()
 
PacedVideoOutputvideoSyncTask ()
 

Protected Member Functions

void registerAudioDecoders ()
 
void registerVideoDecoders ()
 

Protected Attributes

AACDecoderHelix aac_decoder
 
bool active = false
 
AudioTimeSourceStream audio_clock
 
EncodedAudioStream audio_out
 
int buffer_size = 1024
 
MultiDecoder default_audio_decoder
 
MultiVideoDemuxer default_demuxer
 
MultiVideoDecoder default_video_decoder
 
H264Decoder h264_decoder
 
MJPEGDecoder mjpeg_decoder
 
MP2Decoder mp2_decoder
 
MP3DecoderHelix mp3_decoder
 
MPGDecoder mpeg_decoder
 
Printp_audio_output = nullptr
 
AudioOutputp_audio_output_typed = nullptr
 
AudioStreamp_audio_stream = nullptr
 
Streamp_source = nullptr
 
VideoOutputp_video_output = nullptr
 
bool use_audio_clock = false
 
PacedVideoOutput video_sync {default_video_decoder}
 

Detailed Description

VideoPlayer subclass pre-registered with every video/audio codec this library ships a portable decoder for - H264/MJPEG/MPEG-1 video, MP3/AAC/MP2 audio - so it's the "just point it at a file, any common codec just works" player. Use instead of the base VideoPlayer unless you want to keep these dependencies out of your build (the base class's own multi-decoders start empty - see its class comment).

Pre-registers no container demuxer though - still supply one via the constructor/addDemuxer(), as the base VideoPlayer requires. Pass a MultiVideoDemuxerFull (Video/MultiVideoDemuxerFull.h) for the same "any format just works" convenience one layer down (AVI/MP4/MPG):

VideoPlayerFull player(demuxer, tftOutput, audioOut);
player.begin(file);
MultiVideoDemuxer pre-registered with every container format this library ships a demuxer for: Demuxe...
Definition MultiVideoDemuxerFull.h:35
VideoPlayer subclass pre-registered with every video/audio codec this library ships a portable decode...
Definition VideoPlayerFull.h:47
MultiVideoDemuxer & demuxer()
Definition VideoPlayer.h:375

WAV is deliberately not included (no external dependency to justify bundling it) - register it yourself if needed: addAudioDecoder(wavDecoder, "audio/vnd.wave").

Dependencies (install via Library Manager):

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ VideoPlayerFull() [1/5]

VideoPlayerFull ( )
inline

◆ VideoPlayerFull() [2/5]

VideoPlayerFull ( Demuxer demuxer,
VideoOutput videoOutput 
)
inline

demuxer is registered the same way VideoPlayer's own matching constructor does (see its class comment) - pass a MultiVideoDemuxerFull here instead of a single concrete demuxer if you want every container format supported too (see this class's own comment).

◆ VideoPlayerFull() [3/5]

VideoPlayerFull ( Demuxer demuxer,
VideoOutput videoOutput,
AudioOutput audioOutput 
)
inline

◆ VideoPlayerFull() [4/5]

VideoPlayerFull ( Demuxer demuxer,
VideoOutput videoOutput,
Print audioOutput 
)
inline

◆ VideoPlayerFull() [5/5]

VideoPlayerFull ( Demuxer demuxer,
VideoOutput videoOutput,
AudioStream audioOutput 
)
inline

Member Function Documentation

◆ addAudioDecoder()

void addAudioDecoder ( AudioDecoder decoder,
const char *  mime = nullptr 
)
inlineinherited

Registers an audio codec with the built-in (initially empty) MultiDecoder - see MultiDecoder::addDecoder() (the mime-only overload). Nothing is registered by default (see the class comment), so this needs at least one call per codec your content's audio track actually uses. Call before begin().

◆ addDemuxer()

void addDemuxer ( Demuxer demuxer)
inlineinherited

Registers a container demuxer (DemuxerAVI/DemuxerMP4/DemuxerMPG/...) with the built-in (initially empty) MultiVideoDemuxer, under its own Demuxer::mimeVideo() - see MultiVideoDemuxer::addDemuxer(). Nothing is registered by default (see the class comment), so this needs at least one call per container format your content actually uses. Call before begin().

◆ addVideoDecoder()

void addVideoDecoder ( VideoDecoder decoder)
inlineinherited

Registers a video codec with the built-in (initially empty) MultiVideoDecoder, under its own VideoDecoder::codecFormat() - see MultiVideoDecoder::addDecoder(). Nothing is registered by default (see the class comment), so this needs at least one call per codec your content's video track actually uses. Call before begin().

◆ audioDecoder()

MultiDecoder & audioDecoder ( )
inlineinherited

The built-in audio multi-decoder (empty until addAudioDecoder() is called - see the class comment) - also useful for diagnostics (e.g. selectedMime()).

◆ begin()

bool begin ( Stream source)
inlineinherited

Wires the full pipeline (video decoder -> output via PacedVideoOutput; audio decoder -> [audio clock ->] output, if an audio output was given) and starts the demuxer. source (e.g. an open File) is read from on every subsequent copy() call - the caller owns it and is responsible for closing it once copy()/copyAll() signal end of stream (return 0).

◆ copy()

size_t copy ( )
inlineinherited

Reads and demuxes one chunk (setBufferSize(), default 1024 bytes) from the source given to begin() - call this every loop() iteration. Also keeps the video schedule's fps in sync with the demuxer's own parsed rate, since VideoInfo::fps only becomes known partway through (once the container's header has been parsed) - no separate polling needed in the caller's loop(), unlike the *.ino examples this class replaces.

Returns
bytes actually copied - 0 once the source is exhausted (or playback is inactive/not begin()'d), matching CodecCopy::copy()'s own "0 means stop" convention every current *.ino example already checks for.

◆ copyAll()

size_t copyAll ( )
inlineinherited

Copies until the source is exhausted (blocking).

◆ demuxer()

MultiVideoDemuxer & demuxer ( )
inlineinherited

The built-in demuxer multi-selector (empty until addDemuxer() is called - see the class comment) - also useful for diagnostics (e.g. selectedDemuxer()/mimeVideo()).

◆ end()

void end ( )
inlineinherited

Stops playback and releases the video/audio decoders + the sync task's background render thread. The Stream given to begin() is left for the caller to close.

◆ getStream()

Stream * getStream ( )
inlineinherited

The Stream given to begin() - nullptr before the first begin() call.

◆ isActive()

bool isActive ( ) const
inlineinherited

True between a successful begin() and end()/setActive(false)/source exhaustion.

◆ operator bool()

operator bool ( ) const
inlineinherited

◆ registerAudioDecoders()

void registerAudioDecoders ( )
inlineprotected

◆ registerVideoDecoders()

void registerVideoDecoders ( )
inlineprotected

◆ setActive()

void setActive ( bool  isActive)
inlineinherited

Halts copy()/copyAll() without tearing down the pipeline (unlike end()) - resume with setActive(true).

◆ setAudioOutput() [1/3]

void setAudioOutput ( AudioOutput out)
inlineinherited

◆ setAudioOutput() [2/3]

void setAudioOutput ( AudioStream out)
inlineinherited

◆ setAudioOutput() [3/3]

void setAudioOutput ( Print out)
inlineinherited

Defines the final audio output target and enables the audio path - leave unset entirely for video-only content. Must already be configured/begin()'d. Call before begin(). See the class comment's "Audio clock" section for setUseAudioClock()'s default.

Three overloads, mirroring AudioPlayer::setOutput() - AudioOutput and AudioStream are unrelated types (both derive from Print, neither from the other - see AudioOutput.h's own class comment), so the most specific one actually available should be used: it lets begin() wire the audio clock/EncodedAudioStream via the matching setOutput( AudioOutput&)/setStream(AudioStream&) overload instead of falling back to the generic Print& one, which is what makes e.g. audio-info change notifications reach the real output.

◆ setBufferSize()

void setBufferSize ( int  size)
inlineinherited

Sets the read-buffer size (bytes) copy() uses per call (default 1024, same as CodecCopy's own default). Call before begin().

◆ setUseAudioClock()

void setUseAudioClock ( bool  active)
inlineinherited

See the class comment's "Audio clock" section. Off by default; setAudioOutput() does not change it - opt in explicitly once you know the content has a real audio track. Call before begin().

◆ setVideoOutput()

void setVideoOutput ( VideoOutput out)
inlineinherited

Defines the final video display target (e.g. OutputTinyGPU, OutputOpenCV) - must already be configured/begin()'d (board/panel init is outside this class's scope, same as AudioPlayer's AudioOutput& argument). Call before begin().

◆ useAudioClock()

bool useAudioClock ( ) const
inlineinherited

◆ videoDecoder()

MultiVideoDecoder & videoDecoder ( )
inlineinherited

The built-in video multi-decoder (empty until addVideoDecoder() is called - see the class comment) - also useful for diagnostics (e.g. selectedFormat()).

◆ videoSyncTask()

PacedVideoOutput & videoSyncTask ( )
inlineinherited

Escape hatch for tuning beyond this class's own surface - e.g. setTaskParameters()/setQueueBytes()/setMaxQueuedIFrames()/ setIgnorePFrames()/setSchedulingDelayMs(), or the frameCount()/ avgFrameMs()/outputFPS() family of diagnostics.

Member Data Documentation

◆ aac_decoder

AACDecoderHelix aac_decoder
protected

◆ active

bool active = false
protectedinherited

◆ audio_clock

AudioTimeSourceStream audio_clock
protectedinherited

◆ audio_out

EncodedAudioStream audio_out
protectedinherited

◆ buffer_size

int buffer_size = 1024
protectedinherited

◆ default_audio_decoder

MultiDecoder default_audio_decoder
protectedinherited

◆ default_demuxer

MultiVideoDemuxer default_demuxer
protectedinherited

◆ default_video_decoder

MultiVideoDecoder default_video_decoder
protectedinherited

◆ h264_decoder

H264Decoder h264_decoder
protected

◆ mjpeg_decoder

MJPEGDecoder mjpeg_decoder
protected

◆ mp2_decoder

MP2Decoder mp2_decoder
protected

◆ mp3_decoder

MP3DecoderHelix mp3_decoder
protected

◆ mpeg_decoder

MPGDecoder mpeg_decoder
protected

◆ p_audio_output

Print* p_audio_output = nullptr
protectedinherited

◆ p_audio_output_typed

AudioOutput* p_audio_output_typed = nullptr
protectedinherited

◆ p_audio_stream

AudioStream* p_audio_stream = nullptr
protectedinherited

◆ p_source

Stream* p_source = nullptr
protectedinherited

◆ p_video_output

VideoOutput* p_video_output = nullptr
protectedinherited

◆ use_audio_clock

bool use_audio_clock = false
protectedinherited

◆ video_sync

PacedVideoOutput video_sync {default_video_decoder}
protectedinherited

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