OpenShot Library | libopenshot
0.4.0
|
Go to the documentation of this file.
13 #ifndef OPENSHOT_VIDEO_CACHE_THREAD_H
14 #define OPENSHOT_VIDEO_CACHE_THREAD_H
18 #include <AppConfig.h>
19 #include <juce_audio_basics/juce_audio_basics.h>
62 void Seek(int64_t new_position);
69 void Seek(int64_t new_position,
bool start_preroll);
90 int64_t
getBytes(
int width,
int height,
int sample_rate,
int channels,
float fps);
129 int64_t timeline_end,
130 int64_t& window_begin,
131 int64_t& window_end)
const;
147 int64_t window_begin,
179 #endif // OPENSHOT_VIDEO_CACHE_THREAD_H
VideoCacheThread()
Constructor: initializes member variables and assumes forward direction on first launch.
bool prefetchWindow(CacheBase *cache, int64_t window_begin, int64_t window_end, int dir, ReaderBase *reader)
Prefetch all missing frames in [window_begin ... window_end] or [window_end ... window_begin].
This namespace is the default namespace for all code in the openshot library.
int64_t min_frames_ahead
Minimum number of frames considered “ready” (pre-roll).
int computeDirection() const
ReaderBase * reader
The source reader (e.g., Timeline, FFmpegReader).
void handleUserSeek(int64_t playhead, int dir)
If userSeeked is true, reset last_cached_index just behind the playhead.
std::shared_ptr< Frame > last_cached_frame
Last frame pointer added to cache.
All cache managers in libopenshot are based on this CacheBase class.
void Play()
Set is_playing = true, so run() will begin caching/playback.
~VideoCacheThread() override
int64_t timeline_max_frame
Highest valid frame index in the timeline.
Handles prefetching and caching of video/audio frames for smooth playback.
int last_speed
Last non-zero speed (for tracking).
void setSpeed(int new_speed)
Set playback speed/direction. Positive = forward, negative = rewind, zero = pause.
bool userSeeked
True if Seek(..., true) was called (forces a cache reset).
int speed
Current playback speed (0=paused, >0 forward, <0 backward).
void Reader(ReaderBase *new_reader)
Attach a ReaderBase (e.g. Timeline, FFmpegReader) and begin caching.
void Stop()
Set is_playing = false, effectively pausing playback (caching still runs).
void run() override
Thread entry point: loops until threadShouldExit() is true.
int64_t last_cached_index
Index of the most recently cached frame.
int64_t getBytes(int width, int height, int sample_rate, int channels, float fps)
Estimate memory usage for a single frame (video + audio).
Header file for ReaderBase class.
bool clearCacheIfPaused(int64_t playhead, bool paused, CacheBase *cache)
When paused and playhead is outside current cache, clear all frames.
int64_t max_frames_ahead
Maximum frames to attempt to cache (mem capped).
int64_t current_display_frame
Currently displayed frame (unused here, reserved).
int last_dir
Last direction sign (+1 forward, –1 backward).
int64_t cached_frame_count
Count of frames currently added to cache.
bool force_directional_cache
(Reserved for future use).
This abstract class is the base class, used by all readers in libopenshot.
void computeWindowBounds(int64_t playhead, int dir, int64_t ahead_count, int64_t timeline_end, int64_t &window_begin, int64_t &window_end) const
Compute the “window” of frames to cache around playhead.
bool is_playing
True if playback is “running” (affects thread loop, not caching).
void Seek(int64_t new_position)
Seek to a specific frame (no preroll).
int64_t requested_display_frame
Frame index the user requested.