OpenShot Library | libopenshot  0.3.3
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
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 }
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
VideoPlaybackThread.h
Source file for VideoPlaybackThread class.
ZmqLogger.h
Header file for ZeroMQ-based Logger class.
openshot::RendererBase::paint
void paint(const std::shared_ptr< openshot::Frame > &frame)
Paint(render) a video Frame.
Definition: RendererBase.cpp:24
Frame.h
Header file for Frame class.
openshot::ZmqLogger::Instance
static ZmqLogger * Instance()
Create or get an instance of this logger singleton (invoke the class with this method)
Definition: ZmqLogger.cpp:35
openshot::ZmqLogger::AppendDebugMethod
void AppendDebugMethod(std::string method_name, std::string arg1_name="", float arg1_value=-1.0, std::string arg2_name="", float arg2_value=-1.0, std::string arg3_name="", float arg3_value=-1.0, std::string arg4_name="", float arg4_value=-1.0, std::string arg5_name="", float arg5_value=-1.0, std::string arg6_name="", float arg6_value=-1.0)
Append debug information.
Definition: ZmqLogger.cpp:178
RendererBase.h
Header file for RendererBase class.