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; 55 int64_t current_display_frame; 56 ReaderBase *reader; 57 int max_concurrent_frames; 58 59 /// Constructor 60 VideoCacheThread(); 61 /// Destructor 62 ~VideoCacheThread(); 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...) getSpeed()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...) setSpeed(int new_speed)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 Reader(ReaderBase * new_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 99