OpenShot Library | libopenshot  0.3.1
VideoPlaybackThread.cpp
Go to the documentation of this file.
1 
10 // Copyright (c) 2008-2019 OpenShot Studios, LLC
11 //
12 // SPDX-License-Identifier: LGPL-3.0-or-later
13 
14 #include "VideoPlaybackThread.h"
15 #include "ZmqLogger.h"
16 
17 #include "Frame.h"
18 #include "RendererBase.h"
19 #include "ZmqLogger.h"
20 
21 namespace openshot
22 {
23  // Constructor
24  VideoPlaybackThread::VideoPlaybackThread(RendererBase *rb)
25  : Thread("video-playback"), renderer(rb)
26  , render(), reset(false)
27  {
28  }
29 
30  // Destructor
31  VideoPlaybackThread::~VideoPlaybackThread()
32  {
33  }
34 
35  // Get the currently playing frame number (if any)
36  int64_t VideoPlaybackThread::getCurrentFramePosition()
37  {
38  if (frame)
39  return frame->number;
40  else
41  return 0;
42  }
43 
44  // Start the thread
45  void VideoPlaybackThread::run()
46  {
47  while (!threadShouldExit()) {
48  // Make other threads wait on the render event
49  bool need_render = render.wait(500);
50 
51  if (need_render && frame)
52  {
53  // Debug
54  ZmqLogger::Instance()->AppendDebugMethod(
55  "VideoPlaybackThread::run (before render)",
56  "frame->number", frame->number,
57  "need_render", need_render);
58 
59  // Render the frame to the screen
60  renderer->paint(frame);
61  }
62 
63  // Signal to other threads that the rendered event has completed
64  rendered.signal();
65  }
66 
67  return;
68  }
69 }
Header file for Frame class.
Header file for RendererBase class.
Source file for VideoPlaybackThread class.
Header file for ZeroMQ-based Logger class.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:29