OpenShot Library | libopenshot  0.3.3
VideoCacheThread.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_VIDEO_CACHE_THREAD_H
14 #define OPENSHOT_VIDEO_CACHE_THREAD_H
15 
16 #include "ReaderBase.h"
17 
18 #include <AppConfig.h>
19 #include <juce_audio_basics/juce_audio_basics.h>
20 
21 namespace openshot
22 {
23  using juce::Thread;
24  using juce::WaitableEvent;
25 
29  class VideoCacheThread : Thread
30  {
31  protected:
32  std::shared_ptr<Frame> last_cached_frame;
33  int speed;
35  bool is_playing;
38  int64_t cached_frame_count = 0;
45 
50 
52  int64_t getBytes(int width, int height, int sample_rate, int channels, float fps);
53 
55  int getSpeed() const { return speed; }
56 
58  void Play();
59 
61  void Seek(int64_t new_position);
62 
64  void Seek(int64_t new_position, bool start_preroll);
65 
67  void setSpeed(int new_speed);
68 
70  void Stop();
71 
73  void run();
74 
76  void Reader(ReaderBase *new_reader) { reader=new_reader; Play(); };
77 
79  friend class PlayerPrivate;
80  friend class QtPlayer;
81 
82  public:
84  bool isReady();
85  };
86 }
87 
88 #endif // OPENSHOT_VIDEO_CACHE_THREAD_H
openshot::VideoCacheThread::VideoCacheThread
VideoCacheThread()
Constructor.
Definition: VideoCacheThread.cpp:29
openshot::VideoCacheThread::should_break
bool should_break
Definition: VideoCacheThread.h:44
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::VideoCacheThread::min_frames_ahead
int64_t min_frames_ahead
Definition: VideoCacheThread.h:40
openshot::VideoCacheThread::reader
ReaderBase * reader
Definition: VideoCacheThread.h:39
openshot::VideoCacheThread::last_cached_frame
std::shared_ptr< Frame > last_cached_frame
Definition: VideoCacheThread.h:32
openshot::VideoCacheThread::Play
void Play()
Play the video.
Definition: VideoCacheThread.cpp:123
openshot::VideoCacheThread::timeline_max_frame
int64_t timeline_max_frame
Definition: VideoCacheThread.h:42
openshot::VideoCacheThread
The video cache class.
Definition: VideoCacheThread.h:29
openshot::PlayerPrivate
The private part of QtPlayer class, which contains an audio thread and video thread,...
Definition: PlayerPrivate.h:30
openshot::VideoCacheThread::last_speed
int last_speed
Definition: VideoCacheThread.h:34
openshot::VideoCacheThread::~VideoCacheThread
~VideoCacheThread()
Destructor.
Definition: VideoCacheThread.cpp:38
openshot::VideoCacheThread::setSpeed
void setSpeed(int new_speed)
Set Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster,...
Definition: VideoCacheThread.cpp:101
openshot::VideoCacheThread::should_pause_cache
bool should_pause_cache
Definition: VideoCacheThread.h:43
openshot::VideoCacheThread::speed
int speed
Definition: VideoCacheThread.h:33
openshot::VideoCacheThread::Reader
void Reader(ReaderBase *new_reader)
Set the current thread's reader.
Definition: VideoCacheThread.h:76
openshot::VideoCacheThread::Stop
void Stop()
Stop the audio playback.
Definition: VideoCacheThread.cpp:129
openshot::VideoCacheThread::run
void run()
Start the thread.
Definition: VideoCacheThread.cpp:140
openshot::VideoCacheThread::getBytes
int64_t getBytes(int width, int height, int sample_rate, int channels, float fps)
Get the size in bytes of a frame (rough estimate)
Definition: VideoCacheThread.cpp:110
ReaderBase.h
Header file for ReaderBase class.
openshot::QtPlayer
This class is used to playback a video from a reader.
Definition: QtPlayer.h:32
openshot::VideoCacheThread::getSpeed
int getSpeed() const
Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster,...
Definition: VideoCacheThread.h:55
openshot::VideoCacheThread::max_frames_ahead
int64_t max_frames_ahead
Definition: VideoCacheThread.h:41
openshot::VideoCacheThread::current_display_frame
int64_t current_display_frame
Definition: VideoCacheThread.h:37
openshot::VideoCacheThread::cached_frame_count
int64_t cached_frame_count
Definition: VideoCacheThread.h:38
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
openshot::VideoCacheThread::is_playing
bool is_playing
Definition: VideoCacheThread.h:35
openshot::VideoCacheThread::Seek
void Seek(int64_t new_position)
Seek the reader to a particular frame number.
Definition: VideoCacheThread.cpp:43
openshot::VideoCacheThread::requested_display_frame
int64_t requested_display_frame
Definition: VideoCacheThread.h:36
openshot::VideoCacheThread::isReady
bool isReady()
Is cache ready for video/audio playback.
Definition: VideoCacheThread.cpp:135