Skip to content

Commit

Permalink
Merge branch 'develop' into opencv
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph committed Oct 29, 2020
2 parents b48025c + 896b307 commit b74b3ea
Show file tree
Hide file tree
Showing 9 changed files with 603 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -35,7 +35,7 @@ if (POLICY CMP0057)
endif()

############### PROFILING #################
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
#set(PROFILER "/usr/lib//usr/lib/libprofiler.so.0.4.5")
#set(PROFILER "/usr/lib/libtcmalloc.so.4")

if(CMAKE_VERSION VERSION_LESS 3.3)
Expand Down Expand Up @@ -124,6 +124,7 @@ set(EFFECTS_SOURCES
effects/Bars.cpp
effects/Blur.cpp
effects/Brightness.cpp
effects/Caption.cpp
effects/ChromaKey.cpp
effects/ColorShift.cpp
effects/Crop.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/EffectInfo.cpp
Expand Up @@ -52,6 +52,9 @@ EffectBase* EffectInfo::CreateEffect(std::string effect_type) {
else if (effect_type == "Brightness")
return new Brightness();

else if (effect_type == "Caption")
return new Caption();

else if (effect_type == "ChromaKey")
return new ChromaKey();

Expand Down Expand Up @@ -109,6 +112,7 @@ Json::Value EffectInfo::JsonValue() {
root.append(Bars().JsonInfo());
root.append(Blur().JsonInfo());
root.append(Brightness().JsonInfo());
root.append(Caption().JsonInfo());
root.append(ChromaKey().JsonInfo());
root.append(ColorShift().JsonInfo());
root.append(Crop().JsonInfo());
Expand Down
1 change: 1 addition & 0 deletions src/Effects.h
Expand Up @@ -35,6 +35,7 @@
#include "effects/Bars.h"
#include "effects/Blur.h"
#include "effects/Brightness.h"
#include "effects/Caption.h"
#include "effects/ChromaKey.h"
#include "effects/ColorShift.h"
#include "effects/Crop.h"
Expand Down
7 changes: 4 additions & 3 deletions src/Settings.cpp
Expand Up @@ -34,14 +34,14 @@ using namespace std;
using namespace openshot;


// Global reference to logger
// Global reference to Settings
Settings *Settings::m_pInstance = NULL;

// Create or Get an instance of the logger singleton
// Create or Get an instance of the settings singleton
Settings *Settings::Instance()
{
if (!m_pInstance) {
// Create the actual instance of logger only once
// Create the actual instance of Settings only once
m_pInstance = new Settings;
m_pInstance->HARDWARE_DECODER = 0;
m_pInstance->HIGH_QUALITY_SCALING = false;
Expand All @@ -53,6 +53,7 @@ Settings *Settings::Instance()
m_pInstance->HW_DE_DEVICE_SET = 0;
m_pInstance->HW_EN_DEVICE_SET = 0;
m_pInstance->PLAYBACK_AUDIO_DEVICE_NAME = "";
m_pInstance->DEBUG_TO_STDERR = false;
}

return m_pInstance;
Expand Down
3 changes: 3 additions & 0 deletions src/Settings.h
Expand Up @@ -127,6 +127,9 @@ namespace openshot {
/// The current install path of OpenShot (needs to be set when using Timeline(path), since certain
/// paths depend on the location of OpenShot transitions and files)
std::string PATH_OPENSHOT_INSTALL = "";

/// Whether to dump ZeroMQ debug messages to stderr
bool DEBUG_TO_STDERR = false;

/// Create or get an instance of this logger singleton (invoke the class with this method)
static Settings * Instance();
Expand Down
28 changes: 17 additions & 11 deletions src/ZmqLogger.cpp
Expand Up @@ -34,8 +34,8 @@
#include "ResvgQt.h"
#endif

using namespace std;
using namespace openshot;

#include <sstream>
#include <iostream>
#include <iomanip>
Expand Down Expand Up @@ -70,7 +70,6 @@ ZmqLogger *ZmqLogger::Instance()
// This can only happen 1 time or it will crash
ResvgRenderer::initLog();
#endif

}

return m_pInstance;
Expand All @@ -80,7 +79,7 @@ ZmqLogger *ZmqLogger::Instance()
void ZmqLogger::Connection(std::string new_connection)
{
// Create a scoped lock, allowing only a single thread to run the following code at one time
const GenericScopedLock<CriticalSection> lock(loggerCriticalSection);
const juce::GenericScopedLock<juce::CriticalSection> lock(loggerCriticalSection);

// Does anything need to happen?
if (new_connection == connection)
Expand Down Expand Up @@ -124,7 +123,7 @@ void ZmqLogger::Log(std::string message)
return;

// Create a scoped lock, allowing only a single thread to run the following code at one time
const GenericScopedLock<CriticalSection> lock(loggerCriticalSection);
const juce::GenericScopedLock<juce::CriticalSection> lock(loggerCriticalSection);

// Send message over socket (ZeroMQ)
zmq::message_t reply (message.length());
Expand Down Expand Up @@ -195,19 +194,20 @@ void ZmqLogger::AppendDebugMethod(std::string method_name,
std::string arg5_name, float arg5_value,
std::string arg6_name, float arg6_value)
{
if (!enabled)
if (!enabled && !openshot::Settings::Instance()->DEBUG_TO_STDERR)
// Don't do anything
return;

{
// Create a scoped lock, allowing only a single thread to run the following code at one time
const GenericScopedLock<CriticalSection> lock(loggerCriticalSection);
const juce::GenericScopedLock<juce::CriticalSection> lock(loggerCriticalSection);

std::stringstream message;
message << std::fixed << std::setprecision(4);

// Construct message
message << method_name << " (";

// Add attributes to method JSON
if (arg1_name.length() > 0)
message << arg1_name << "=" << arg1_value;

Expand All @@ -226,10 +226,16 @@ void ZmqLogger::AppendDebugMethod(std::string method_name,
if (arg6_name.length() > 0)
message << ", " << arg6_name << "=" << arg6_value;

// Output to standard output
message << ")" << endl;
message << ")" << std::endl;

if (openshot::Settings::Instance()->DEBUG_TO_STDERR) {
// Print message to stderr
std::clog << message.str();
}

// Send message through ZMQ
Log(message.str());
if (enabled) {
// Send message through ZMQ
Log(message.str());
}
}
}
23 changes: 13 additions & 10 deletions src/ZmqLogger.h
Expand Up @@ -43,6 +43,7 @@
#include <zmq.hpp>
#include <unistd.h>
#include "JuceHeader.h"
#include "Settings.h"


namespace openshot {
Expand Down Expand Up @@ -70,17 +71,17 @@ namespace openshot {
zmq::socket_t *publisher;

/// Default constructor
ZmqLogger(){}; // Don't allow user to create an instance of this singleton
ZmqLogger(){}; // Don't allow user to create an instance of this singleton

#if __GNUC__ >=7
/// Default copy method
ZmqLogger(ZmqLogger const&) = delete; // Don't allow the user to assign this instance
ZmqLogger(ZmqLogger const&) = delete; // Don't allow the user to assign this instance

/// Default assignment operator
ZmqLogger & operator=(ZmqLogger const&) = delete; // Don't allow the user to assign this instance
#else
/// Default copy method
ZmqLogger(ZmqLogger const&) {}; // Don't allow the user to assign this instance
ZmqLogger(ZmqLogger const&) {}; // Don't allow the user to assign this instance

/// Default assignment operator
ZmqLogger & operator=(ZmqLogger const&); // Don't allow the user to assign this instance
Expand All @@ -94,13 +95,15 @@ namespace openshot {
static ZmqLogger * Instance();

/// Append debug information
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);
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
);

/// Close logger (sockets and/or files)
void Close();
Expand Down

0 comments on commit b74b3ea

Please sign in to comment.