UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMediaSampleCache Class Reference

#include <MediaSampleCache.h>

Public Member Functions

MEDIAUTILS_API FMediaSampleCache ()
 
MEDIAUTILS_API void Empty ()
 
MEDIAUTILS_API TSharedPtr< IMediaAudioSample, ESPMode::ThreadSafeGetAudioSample (FTimespan Time)
 
MEDIAUTILS_API void GetCachedAudioSampleRanges (TRangeSet< FTimespan > &OutTimeRanges) const
 
MEDIAUTILS_API void GetCachedVideoSampleRanges (TRangeSet< FTimespan > &OutTimeRanges) const
 
MEDIAUTILS_API void GetOverlaySamples (FTimespan Time, TArray< TSharedPtr< IMediaOverlaySample, ESPMode::ThreadSafe > > &OutSamples)
 
MEDIAUTILS_API TSharedPtr< IMediaTextureSample, ESPMode::ThreadSafeGetVideoSample (FTimespan Time, bool Forward)
 
void SetCacheWindow (FTimespan Ahead, FTimespan Behind)
 
MEDIAUTILS_API void Tick (FTimespan DeltaTime, float Rate, FTimespan Time)
 

Detailed Description

Implements a cache for media samples.

Constructor & Destructor Documentation

◆ FMediaSampleCache()

FMediaSampleCache::FMediaSampleCache ( )

Default constructor.

Member Function Documentation

◆ Empty()

void FMediaSampleCache::Empty ( )

Empty the cache.

See also
Update

◆ GetAudioSample()

TSharedPtr< IMediaAudioSample, ESPMode::ThreadSafe > FMediaSampleCache::GetAudioSample ( FTimespan  Time)

Get the audio sample for the specified play time.

This method returns the sample that contains the specified time code.

Parameters
TimeThe time to get the sample for (in the player's clock).
Returns
The sample, or nullptr if no sample available.
See also
GetAudioSamples, GetCachedVideoSampleRanges, GetOverlaySamples

◆ GetCachedAudioSampleRanges()

void FMediaSampleCache::GetCachedAudioSampleRanges ( TRangeSet< FTimespan > &  OutTimeRanges) const

Get the time ranges of audio samples currently in the cache.

Parameters
OutTimeRangesWill contain the set of cached sample time ranges.
See also
GetAudioSample, GetCachedVideoSampleRanges

◆ GetCachedVideoSampleRanges()

void FMediaSampleCache::GetCachedVideoSampleRanges ( TRangeSet< FTimespan > &  OutTimeRanges) const

Get the time ranges of video samples currently in the cache.

Parameters
OutTimeRangesWill contain the set of cached sample time ranges.
See also
GetCachedAudioSampleRanges, GetVideoSample

◆ GetOverlaySamples()

void FMediaSampleCache::GetOverlaySamples ( FTimespan  Time,
TArray< TSharedPtr< IMediaOverlaySample, ESPMode::ThreadSafe > > &  OutSamples 
)

Get the text overlay samples for the specified time.

Parameters
TimeThe time to get the sample for (in the player's clock).
OutSamplesWill contain the overlay samples.
See also
GetAudioSample, GetVideoSample

◆ GetVideoSample()

TSharedPtr< IMediaTextureSample, ESPMode::ThreadSafe > FMediaSampleCache::GetVideoSample ( FTimespan  Time,
bool  Forward 
)

Get the video sample for the specified play time.

This method will return the closest match for the given time code. If the current play rate is positive, the closest sample with an equal or older time is returned. If the current rate is negative, the closest sample with an equal or newer time is returned.

Parameters
TimeThe time to get the sample for (in the player's clock).
ForwardWhether the play direction is forward (true) or backward (false).
Returns
The sample, or nullptr if no sample available.
See also
GetAudioSample, GetCachedVideoSampleRanges, GetOverlaySamples

◆ SetCacheWindow()

void FMediaSampleCache::SetCacheWindow ( FTimespan  Ahead,
FTimespan  Behind 
)
inline

Set the time window of samples to cache.

Parameters
AheadMaximum time of samples to cache ahead of the play position.
BehindMaximum time of samples to cache behind the play position.

◆ Tick()

void FMediaSampleCache::Tick ( FTimespan  DeltaTime,
float  Rate,
FTimespan  Time 
)

Tick the cache.

This method fetches any unconsumed media samples from the player and removes expired samples from the cache.

Parameters
DeltaTimeTime since the last tick.
RateThe current play rate.
TimeThe current play time.
See also
Initialize, Shutdown

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