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

This clip does the actual work of composing images into a video. More...

#include <foleys_ComposedClip.h>

+ Inheritance diagram for ComposedClip:

Classes

struct  ClipPosition
 

Public Member Functions

 ComposedClip (VideoEngine &videoEngine)
 
juce::String getClipType () const override
 Used to identify the clip type to the user.
 
void invalidateVideo ()
 Forces the video to re-render, e.g.
 
juce::String getDescription () const override
 returns a string describing the clip.
 
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.
 
Size getVideoSize () const override
 returns the pixel size of the media as a tuple.
 
double getCurrentTimeInSeconds () const override
 Return the clip's read position in seconds.
 
juce::Image getStillImage (double seconds, Size size) override
 This returns a still frame on the selected position.
 
double getLengthInSeconds () const override
 Returns the length of the clip in seconds.
 
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
 
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.
 
void parameterAutomationChanged (const ParameterAutomation *) override
 
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.
 
int getDefaultBufferSize () const
 
void readPluginStatesIntoValueTree ()
 Read all plugins getStateInformation() and save it into the statusTree as BLOB.
 
juce::ValueTree & getStatusTree ()
 The ValueTree describes the media and positions of the individual clips.
 
std::shared_ptr< ClipDescriptoraddClip (std::shared_ptr< AVClip > clip, ClipPosition position, int zPosition=-1)
 Add an existing clip to the ComposedClip.
 
void removeClip (std::shared_ptr< ClipDescriptor > descriptor)
 remove a ClipDescriptor from the clips vector
 
std::vector< std::shared_ptr< ClipDescriptor > > getClips () const
 allows safe access to the clips list.
 
std::shared_ptr< ClipDescriptorgetClip (int index)
 
void valueTreePropertyChanged (juce::ValueTree &treeWhosePropertyHasChanged, const juce::Identifier &property) override
 
void valueTreeChildAdded (juce::ValueTree &parentTree, juce::ValueTree &childWhichHasBeenAdded) override
 
void valueTreeChildRemoved (juce::ValueTree &parentTree, juce::ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved) override
 
void valueTreeChildOrderChanged (juce::ValueTree &, int oldIndex, int newIndex) override
 
void valueTreeParentChanged (juce::ValueTree &) override
 
juce::UndoManager * getUndoManager ()
 
juce::CriticalSection & getCallbackLock ()
 This lock is used, when the vector of clips is changed, or when a clip is altered in a way, that it cannot render correctly, e.g.
 
juce::String makeUniqueDescription (const juce::String &description) const
 Create a unique description by appending or incrementing a number.
 
- Public Member Functions inherited from AVClip
 AVClip (VideoEngine &videoEngine)
 
virtual ~AVClip ()=default
 
virtual juce::URL getMediaFile () const
 returns the original media file to restore
 
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)
 
virtual bool waitForFrameReady (double pts, int timeout=1000)
 When rendering non realtime (bounce), use this to wait for background threads to read ahead.
 
const ParameterMapgetVideoParameters ()
 
const ParameterMapgetAudioParameters ()
 
virtual juce::TimeSliceClient * getBackgroundJob ()
 
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

This clip does the actual work of composing images into a video.

It is assembled by a number of ComposedClip::ClipDescriptor instances. ComposedClip does audio mixing as well as video compositing. While the video is done on a background thread ahead of time, the audio is pulled in realtime to allow low latency processing.

When you created a shared_ptr of an ComposedClip, 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

◆ ComposedClip()

Member Function Documentation

◆ getClipType()

juce::String getClipType ( ) const
overridevirtual

Used to identify the clip type to the user.

Implements AVClip.

◆ invalidateVideo()

void invalidateVideo ( )

Forces the video to re-render, e.g.

if a parameter was changed

Referenced by ComposedClip::parameterAutomationChanged(), and ProcessorController::setActive().

◆ getDescription()

juce::String getDescription ( ) const
overridevirtual

returns a string describing the clip.

This could be the filename of the original media file

Implements AVClip.

◆ getFrame()

VideoFrame & getFrame ( double  pts)
overridevirtual

◆ isFrameAvailable()

bool isFrameAvailable ( double  pts) const
overridevirtual

Checks, if a frame is available.

Implements AVClip.

References ComposedClip::getClips(), and ComposedClip::getSampleRate().

◆ 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

◆ 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.

References VideoStreamSettings::frameSize.

◆ getCurrentTimeInSeconds()

double getCurrentTimeInSeconds ( ) const
overridevirtual

Return the clip's read position in seconds.

Implements TimeCodeAware.

Referenced by ComposedClip::getNextAudioBlock().

◆ 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.

◆ getLengthInSeconds()

double getLengthInSeconds ( ) const
overridevirtual

Returns the length of the clip in seconds.

Implements AVClip.

References ComposedClip::getTotalLength().

◆ 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

◆ hasVideo()

bool hasVideo ( ) const
overridevirtual

Returns true, if this clip will produce visual frames.

Implements AVClip.

References ComposedClip::getClips(), and ComposedClip::hasVideo().

Referenced by ComposedClip::hasVideo().

◆ hasAudio()

bool hasAudio ( ) const
overridevirtual

Returns true, if this clip will produce audio.

Implements AVClip.

References ComposedClip::hasAudio().

Referenced by ComposedClip::hasAudio().

◆ getFrameDurationInSeconds()

double getFrameDurationInSeconds ( ) const
overridevirtual

Returns the duration of a frame in seconds.

This is the inverse of frame rate.

Reimplemented from AVClip.

References VideoStreamSettings::defaultDuration, and VideoStreamSettings::timebase.

◆ parameterAutomationChanged()

void parameterAutomationChanged ( const ParameterAutomation )
overridevirtual

◆ 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 ComposedClip::getStatusTree(), 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.

References AudioStreamSettings::timebase.

Referenced by ClipDescriptor::addAudioProcessor(), ComposedClip::isFrameAvailable(), and ComposedClip::valueTreeChildAdded().

◆ 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 ComposedClip::getClips().

◆ getDefaultBufferSize()

◆ readPluginStatesIntoValueTree()

void readPluginStatesIntoValueTree ( )

Read all plugins getStateInformation() and save it into the statusTree as BLOB.

References ComposedClip::getClips().

◆ getStatusTree()

juce::ValueTree & getStatusTree ( )

The ValueTree describes the media and positions of the individual clips.

You can use this to listen to changes or to serialise a clip / project

Referenced by ComposedClip::createCopy().

◆ addClip()

std::shared_ptr< ClipDescriptor > addClip ( std::shared_ptr< AVClip clip,
ClipPosition  position,
int  zPosition = -1 
)

Add an existing clip to the ComposedClip.

Parameters
clipis the clip you want to add
positionis a struct containing start, length and offset
zPositionis the position in the clips vector. This value determins the drawing order of the clip. -1 will add at the end.
Returns
a descriptor that holds the clip as well as the information like position, plugins etc.

References AudioStreamSettings::defaultNumSamples, ComposedClip::getUndoManager(), ComposedClip::ClipPosition::length, ComposedClip::makeUniqueDescription(), ComposedClip::ClipPosition::offset, ComposedClip::ClipPosition::start, and AudioStreamSettings::timebase.

◆ removeClip()

void removeClip ( std::shared_ptr< ClipDescriptor descriptor)

remove a ClipDescriptor from the clips vector

References ComposedClip::getUndoManager().

◆ getClips()

◆ getClip()

std::shared_ptr< ClipDescriptor > getClip ( int  index)

◆ valueTreePropertyChanged()

void valueTreePropertyChanged ( juce::ValueTree &  treeWhosePropertyHasChanged,
const juce::Identifier &  property 
)
override

◆ valueTreeChildAdded()

void valueTreeChildAdded ( juce::ValueTree &  parentTree,
juce::ValueTree &  childWhichHasBeenAdded 
)
override

◆ valueTreeChildRemoved()

void valueTreeChildRemoved ( juce::ValueTree &  parentTree,
juce::ValueTree &  childWhichHasBeenRemoved,
int  indexFromWhichChildWasRemoved 
)
override

◆ valueTreeChildOrderChanged()

void valueTreeChildOrderChanged ( juce::ValueTree &  ,
int  oldIndex,
int  newIndex 
)
override

◆ valueTreeParentChanged()

void valueTreeParentChanged ( juce::ValueTree &  )
override

◆ getUndoManager()

◆ getCallbackLock()

juce::CriticalSection & getCallbackLock ( )

This lock is used, when the vector of clips is changed, or when a clip is altered in a way, that it cannot render correctly, e.g.

when adding or removing an audio plugin

Referenced by ClipDescriptor::addAudioProcessor(), ClipDescriptor::addVideoProcessor(), ClipDescriptor::removeAudioProcessor(), ClipDescriptor::removeProcessor(), and ClipDescriptor::removeVideoProcessor().

◆ makeUniqueDescription()

juce::String makeUniqueDescription ( const juce::String &  description) const

Create a unique description by appending or incrementing a number.

References ComposedClip::getClips().

Referenced by ComposedClip::addClip().


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