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