Video display and composing engine for JUCE
Loading...
Searching...
No Matches
MovieClip Class Reference

The MovieClip plays back a video file. More...

#include <foleys_MovieClip.h>

+ Inheritance diagram for MovieClip:

Public Member Functions

 MovieClip (VideoEngine &videoEngine)
 
juce::String getClipType () const override
 Used to identify the clip type to the user.
 
juce::String getDescription () const override
 returns a string describing the clip.
 
bool openFromFile (const juce::File file)
 
juce::URL getMediaFile () const override
 returns the original media file to restore
 
void setReader (std::unique_ptr< AVReader > reader)
 
void setThumbnailReader (std::unique_ptr< AVReader > reader)
 
Size getVideoSize () const override
 returns the pixel size of the media as a tuple.
 
double getLengthInSeconds () const override
 Returns the length of the clip in seconds.
 
double getCurrentTimeInSeconds () const override
 Return the clip's read position in seconds.
 
VideoFramegetFrame (double pts) override
 Returns the frame for a certain timecode.
 
bool isFrameAvailable (double pts) const override
 Checks, if a frame is available.
 
void render (juce::Graphics &view, juce::Rectangle< float > area, double pts, float rotation=0.0f, float zoom=100.0f, juce::Point< float > translation=juce::Point< float >(), float alpha=1.0f) override
 This is the virtual render() method for OpenGL rendering.
 
void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override
 
void releaseResources () override
 
void getNextAudioBlock (const juce::AudioSourceChannelInfo &) override
 
void setNextReadPosition (juce::int64 samples) override
 
juce::int64 getNextReadPosition () const override
 
juce::int64 getTotalLength () const override
 
bool isLooping () const override
 
void setLooping (bool shouldLoop) override
 
juce::Image getStillImage (double seconds, Size size) override
 This returns a still frame on the selected position.
 
juce::TimeSliceClient * getBackgroundJob () override
 
bool hasVideo () const override
 Returns true, if this clip will produce visual frames.
 
bool hasAudio () const override
 Returns true, if this clip will produce audio.
 
double getFrameDurationInSeconds () const override
 Returns the duration of a frame in seconds.
 
std::shared_ptr< AVClipcreateCopy (StreamTypes types) override
 This returns a copy of the clip.
 
double getSampleRate () const override
 This is the samplerate supplied from prepareToPlay and the sample rate this clip will produce audio and use as clock source.
 
bool waitForSamplesReady (int samples, int timeout=1000) override
 When rendering non realtime (bounce), use this to wait for background threads to read ahead.
 
bool waitForFrameReady (double pts, int timeout=1000) override
 When rendering non realtime (bounce), use this to wait for background threads to read ahead.
 
- Public Member Functions inherited from AVClip
 AVClip (VideoEngine &videoEngine)
 
virtual ~AVClip ()=default
 
void renderFrame (juce::Graphics &g, juce::Rectangle< float > area, VideoFrame &frame, float rotation, float zoom, juce::Point< float > translation, float alpha)
 Renders a frame on the OpenGLView.
 
void setAspectType (Aspect type)
 
const ParameterMapgetVideoParameters ()
 
const ParameterMapgetAudioParameters ()
 
VideoEnginegetVideoEngine () const
 
- Public Member Functions inherited from TimeCodeAware
 TimeCodeAware ()=default
 
virtual ~TimeCodeAware ()=default
 
void addTimecodeListener (Listener *listener)
 Register a TimecodeListener to be notified, when the visual frame changes.
 
void removeTimecodeListener (Listener *listener)
 Unregister a TimecodeListener.
 

Additional Inherited Members

- Static Public Member Functions inherited from AVClip
static void addDefaultAudioParameters (AVClip &clip)
 
static void addDefaultVideoParameters (AVClip &clip)
 
- Protected Member Functions inherited from AVClip
void addAudioParameter (std::unique_ptr< ProcessorParameter > parameter)
 
void addVideoParameter (std::unique_ptr< ProcessorParameter > parameter)
 
- Protected Member Functions inherited from TimeCodeAware
void sendTimecode (int64_t count, double seconds, juce::NotificationType nt)
 Subclasses can call this to notify displays, that the time code has changed, e.g.
 

Detailed Description

The MovieClip plays back a video file.

It buffers an amount of audio and video frames ahead of time. To check, you can call isFrameAvailable(), in case you need to wait for the frame, e.g. for offline bouncing.

When you created a shared_ptr of an MovieClip, call manageLifeTime() on the VideoEngine, that will add it to the auto release pool and register possible background jobs with the TimeSliceThreads.

Constructor & Destructor Documentation

◆ MovieClip()

Member Function Documentation

◆ getClipType()

juce::String getClipType ( ) const
overridevirtual

Used to identify the clip type to the user.

Implements AVClip.

◆ getDescription()

juce::String getDescription ( ) const
overridevirtual

returns a string describing the clip.

This could be the filename of the original media file

Implements AVClip.

◆ openFromFile()

bool openFromFile ( const juce::File  file)

◆ getMediaFile()

juce::URL getMediaFile ( ) const
overridevirtual

returns the original media file to restore

Reimplemented from AVClip.

Referenced by MovieClip::createCopy().

◆ setReader()

◆ setThumbnailReader()

void setThumbnailReader ( std::unique_ptr< AVReader reader)

Referenced by MovieClip::openFromFile().

◆ getVideoSize()

Size getVideoSize ( ) const
overridevirtual

returns the pixel size of the media as a tuple.

In some video files this can change at any frame.

Implements AVClip.

◆ getLengthInSeconds()

double getLengthInSeconds ( ) const
overridevirtual

Returns the length of the clip in seconds.

Implements AVClip.

◆ getCurrentTimeInSeconds()

double getCurrentTimeInSeconds ( ) const
overridevirtual

Return the clip's read position in seconds.

Implements TimeCodeAware.

◆ getFrame()

VideoFrame & getFrame ( double  pts)
overridevirtual

Returns the frame for a certain timecode.

Implements AVClip.

References VideoFifo::getFrameSeconds().

Referenced by MovieClip::render().

◆ isFrameAvailable()

bool isFrameAvailable ( double  pts) const
overridevirtual

Checks, if a frame is available.

Implements AVClip.

References VideoFifo::isFrameAvailable().

◆ render()

void render ( juce::Graphics &  g,
juce::Rectangle< float >  area,
double  pts,
float  rotation = 0.0f,
float  zoom = 100.0f,
juce::Point< float >  translation = juce::Point< float >(),
float  alpha = 1.0f 
)
overridevirtual

This is the virtual render() method for OpenGL rendering.

Implements AVClip.

References MovieClip::getFrame(), and AVClip::renderFrame().

◆ prepareToPlay()

void prepareToPlay ( int  samplesPerBlockExpected,
double  sampleRate 
)
override

◆ releaseResources()

void releaseResources ( )
override

◆ getNextAudioBlock()

void getNextAudioBlock ( const juce::AudioSourceChannelInfo &  info)
override

◆ setNextReadPosition()

void setNextReadPosition ( juce::int64  samples)
override

◆ getNextReadPosition()

juce::int64 getNextReadPosition ( ) const
override

◆ getTotalLength()

juce::int64 getTotalLength ( ) const
override

◆ isLooping()

bool isLooping ( ) const
override

◆ setLooping()

void setLooping ( bool  shouldLoop)
override

◆ getStillImage()

juce::Image getStillImage ( double  seconds,
Size  size 
)
overridevirtual

This returns a still frame on the selected position.

Don't use this method for streaming a video, because it will be slow

Implements AVClip.

◆ getBackgroundJob()

juce::TimeSliceClient * getBackgroundJob ( )
overridevirtual

Reimplemented from AVClip.

◆ hasVideo()

bool hasVideo ( ) const
overridevirtual

Returns true, if this clip will produce visual frames.

Implements AVClip.

Referenced by MovieClip::setReader().

◆ hasAudio()

bool hasAudio ( ) const
overridevirtual

Returns true, if this clip will produce audio.

Implements AVClip.

◆ getFrameDurationInSeconds()

double getFrameDurationInSeconds ( ) const
overridevirtual

Returns the duration of a frame in seconds.

This is the inverse of frame rate.

Reimplemented from AVClip.

◆ createCopy()

std::shared_ptr< AVClip > createCopy ( StreamTypes  types)
overridevirtual

This returns a copy of the clip.

Note that this will not work properly if the clip is not properly registered in the engine, because the copy will automatically be registered with the engine as well.

Implements AVClip.

References MovieClip::getMediaFile(), and AVClip::getVideoEngine().

◆ getSampleRate()

double getSampleRate ( ) const
overridevirtual

This is the samplerate supplied from prepareToPlay and the sample rate this clip will produce audio and use as clock source.

Implements AVClip.

◆ waitForSamplesReady()

bool waitForSamplesReady ( int  samples,
int  timeout = 1000 
)
overridevirtual

When rendering non realtime (bounce), use this to wait for background threads to read ahead.

Reimplemented from AVClip.

References AudioFifo::getAvailableSamples().

◆ waitForFrameReady()

bool waitForFrameReady ( double  pts,
int  timeout = 1000 
)
overridevirtual

When rendering non realtime (bounce), use this to wait for background threads to read ahead.

Reimplemented from AVClip.

References VideoFifo::isFrameAvailable().


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