OpenShot Library | libopenshot  0.2.5
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  std::shared_ptr<Frame> frame;
49  int speed;
50  bool is_playing;
51  int64_t position;
52  int64_t current_display_frame;
53  ReaderBase *reader;
54  int max_frames;
55 
56  /// Constructor
58  /// Destructor
60 
61  /// Get the currently playing frame number (if any)
62  int64_t getCurrentFramePosition();
63 
64  /// Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)
65  int getSpeed() const { return speed; }
66 
67  /// Play the video
68  void Play();
69 
70  /// Seek the reader to a particular frame number
71  void Seek(int64_t new_position);
72 
73  /// Set the currently displaying frame number
74  void setCurrentFramePosition(int64_t current_frame_number);
75 
76  /// Set Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)
77  void setSpeed(int new_speed) { speed = new_speed; }
78 
79  /// Stop the audio playback
80  void Stop();
81 
82  /// Start the thread
83  void run();
84 
85  /// Set the current thread's reader
86  void Reader(ReaderBase *new_reader) { reader=new_reader; Play(); };
87 
88  /// Parent class of VideoCacheThread
89  friend class PlayerPrivate;
90  friend class QtPlayer;
91  };
92 
93 }
94 
95 #endif // OPENSHOT_VIDEO_CACHE_THREAD_H
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AudioBufferSource.h:39
openshot::VideoCacheThread
The video cache class.
Definition: VideoCacheThread.h:47
openshot::PlayerPrivate
The private part of QtPlayer class, which contains an audio thread and video thread,...
Definition: PlayerPrivate.h:49
openshot::QtPlayer
This class is used to playback a video from a reader.
Definition: QtPlayer.h:48
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:98