OpenShot Library | libopenshot  0.2.7
VideoCacheThread.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Source file for VideoCacheThread class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @ref License
7  */
8 
9 /* LICENSE
10  *
11  * Copyright (c) 2008-2019 OpenShot Studios, LLC
12  * <http://www.openshotstudios.com/>. This file is part of
13  * OpenShot Library (libopenshot), an open-source project dedicated to
14  * delivering high quality video editing and animation solutions to the
15  * world. For more information visit <http://www.openshot.org/>.
16  *
17  * OpenShot Library (libopenshot) is free software: you can redistribute it
18  * and/or modify it under the terms of the GNU Lesser General Public License
19  * as published by the Free Software Foundation, either version 3 of the
20  * License, or (at your option) any later version.
21  *
22  * OpenShot Library (libopenshot) is distributed in the hope that it will be
23  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public License
28  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
31 #ifndef OPENSHOT_VIDEO_CACHE_THREAD_H
32 #define OPENSHOT_VIDEO_CACHE_THREAD_H
33 
34 #include "../OpenMPUtilities.h"
35 #include "../ReaderBase.h"
36 #include "../RendererBase.h"
37 
38 namespace openshot
39 {
40  using juce::Thread;
41  using juce::WaitableEvent;
42 
43  /**
44  * @brief The video cache class.
45  */
46  class VideoCacheThread : Thread
47  {
48  private:
49  std::atomic_int position;
50 
51  protected:
52  std::shared_ptr<Frame> frame;
53  int speed;
54  bool is_playing;
58 
59  /// Constructor
61  /// Destructor
63 
64  /// Get the currently playing frame number (if any)
65  int64_t getCurrentFramePosition();
66 
67  /// Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)
68  int getSpeed() const { return speed; }
69 
70  /// Play the video
71  void Play();
72 
73  /// Seek the reader to a particular frame number
74  void Seek(int64_t new_position);
75 
76  /// Set the currently displaying frame number
77  void setCurrentFramePosition(int64_t current_frame_number);
78 
79  /// Set Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)
80  void setSpeed(int new_speed) { speed = new_speed; }
81 
82  /// Stop the audio playback
83  void Stop();
84 
85  /// Start the thread
86  void run();
87 
88  /// Set the current thread's reader
89  void Reader(ReaderBase *new_reader) { reader=new_reader; Play(); };
90 
91  /// Parent class of VideoCacheThread
92  friend class PlayerPrivate;
93  friend class QtPlayer;
94  };
95 
96 }
97 
98 #endif // OPENSHOT_VIDEO_CACHE_THREAD_H
void setSpeed(int new_speed)
Set Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)
The video cache class.
void Play()
Play the video.
This class is used to playback a video from a reader.
Definition: QtPlayer.h:47
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:97
std::shared_ptr< Frame > frame
void Reader(ReaderBase *new_reader)
Set the current thread&#39;s reader.
void Stop()
Stop the audio playback.
The private part of QtPlayer class, which contains an audio thread and video thread, and controls the video timing and audio synchronization code.
Definition: PlayerPrivate.h:48
void run()
Start the thread.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:46
void Seek(int64_t new_position)
Seek the reader to a particular frame number.
void setCurrentFramePosition(int64_t current_frame_number)
Set the currently displaying frame number.
int64_t getCurrentFramePosition()
Get the currently playing frame number (if any)
int getSpeed() const
Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)