OpenShot Library | libopenshot 0.2.7
VideoPlaybackThread.cpp
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Source file for VideoPlaybackThread class
4 * @author Duzy Chan <code@duzy.info>
5 * @author Jonathan Thomas <jonathan@openshot.org>
6 *
7 * @ref License
8 */
9
10/* LICENSE
11 *
12 * Copyright (c) 2008-2019 OpenShot Studios, LLC
13 * <http://www.openshotstudios.com/>. This file is part of
14 * OpenShot Library (libopenshot), an open-source project dedicated to
15 * delivering high quality video editing and animation solutions to the
16 * world. For more information visit <http://www.openshot.org/>.
17 *
18 * OpenShot Library (libopenshot) is free software: you can redistribute it
19 * and/or modify it under the terms of the GNU Lesser General Public License
20 * as published by the Free Software Foundation, either version 3 of the
21 * License, or (at your option) any later version.
22 *
23 * OpenShot Library (libopenshot) is distributed in the hope that it will be
24 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public License
29 * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
30 */
31
32#include "VideoPlaybackThread.h"
33
34namespace openshot
35{
36 // Constructor
37 VideoPlaybackThread::VideoPlaybackThread(RendererBase *rb)
38 : Thread("video-playback"), renderer(rb)
39 , render(), reset(false)
40 {
41 }
42
43 // Destructor
44 VideoPlaybackThread::~VideoPlaybackThread()
45 {
46 }
47
48 // Get the currently playing frame number (if any)
49 int64_t VideoPlaybackThread::getCurrentFramePosition()
50 {
51 if (frame)
52 return frame->number;
53 else
54 return 0;
55 }
56
57 // Start the thread
58 void VideoPlaybackThread::run()
59 {
60 while (!threadShouldExit()) {
61 // Make other threads wait on the render event
62 bool need_render = render.wait(500);
63
64 if (need_render && frame)
65 {
66 // Debug
67 ZmqLogger::Instance()->AppendDebugMethod("VideoPlaybackThread::run (before render)", "frame->number", frame->number, "need_render", need_render);
68
69 // Render the frame to the screen
70 renderer->paint(frame);
71 }
72
73 // Signal to other threads that the rendered event has completed
74 rendered.signal();
75 }
76
77 return;
78 }
79}
Source file for VideoPlaybackThread class.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:47