mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-09-27 22:11:57 +00:00
Merge pull request #45 from philippefoubert/portability
Fix some portability issues on Windows
This commit is contained in:
commit
2852a99fa1
5 changed files with 69 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ pipeviz
|
|||
*.o
|
||||
moc_*
|
||||
src/version_info.h
|
||||
pipeviz.pro.user
|
||||
|
|
51
gstreamer.prf
Normal file
51
gstreamer.prf
Normal file
|
@ -0,0 +1,51 @@
|
|||
# =============================================================
|
||||
# This optional feature file adds GStreamer dependencies
|
||||
# =============================================================
|
||||
unix {
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += gstreamer-1.0
|
||||
} else {
|
||||
|
||||
GSTREAMER_PATH = $$clean_path($$(GSTREAMER_1_0_ROOT_X86))
|
||||
if(isEmpty(GSTREAMER_PATH)) {
|
||||
GSTREAMER_PATH = $$clean_path($$(GSTREAMER_1_0_ROOT_X86_64))
|
||||
}
|
||||
|
||||
if(isEmpty(GSTREAMER_PATH)|!exists($${GSTREAMER_PATH})) {
|
||||
|
||||
text = "\"GStreamer\" not found: to be able to use the debugger, don't forget to add"
|
||||
text = "$${text} \"%GSTREAMER_1_0_ROOT_X86_64%\bin\" in your PATH"
|
||||
!build:warning("$${text}")
|
||||
|
||||
} else {
|
||||
|
||||
DEFINES += GST_USE_UNSTABLE_API
|
||||
|
||||
GST_INCLUDEPATH = \
|
||||
$$clean_path($$GSTREAMER_PATH/include/gstreamer-1.0) \
|
||||
$$clean_path($$GSTREAMER_PATH/include/glib-2.0) \
|
||||
$$clean_path($$GSTREAMER_PATH/lib/glib-2.0/include)
|
||||
*-g++ {
|
||||
# To avoid warnings due to GStreamer, use -isystem automatically for any GStreamer system header:
|
||||
for(somelib, $$list($$GST_INCLUDEPATH)) {
|
||||
QMAKE_CXXFLAGS += -isystem $${somelib}
|
||||
}
|
||||
} else {
|
||||
INCLUDEPATH += $${GST_INCLUDEPATH}
|
||||
}
|
||||
unset(GST_INCLUDEPATH)
|
||||
|
||||
win32-g++ {
|
||||
LIBS += \
|
||||
$${GSTREAMER_PATH}/lib/glib-2.0.lib \
|
||||
$${GSTREAMER_PATH}/lib/gobject-2.0.lib \
|
||||
$${GSTREAMER_PATH}/lib/gstreamer-1.0.lib
|
||||
} else {
|
||||
LIBS += \
|
||||
-L$$GSTREAMER_PATH/lib \
|
||||
-lglib-2.0 \
|
||||
-lgobject-2.0 \
|
||||
-lgstreamer-1.0
|
||||
}
|
||||
} # GStreamer found
|
||||
}
|
|
@ -10,7 +10,7 @@ QT += xml
|
|||
QT += core
|
||||
INCLUDEPATH += . src
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
CONFIG += gstreamer
|
||||
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Location of our own features:
|
||||
command = $$[QT_INSTALL_BINS]/qmake -set QMAKEFEATURES $$_PRO_FILE_PWD_
|
||||
system($$command)|error("Failed to run: $$command")
|
||||
|
||||
include(pipeviz.pri)
|
||||
|
||||
PKGCONFIG += gstreamer-1.0
|
||||
|
||||
|
|
|
@ -10,27 +10,26 @@
|
|||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QTime>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <thread>
|
||||
|
||||
G_LOCK_DEFINE_STATIC(logger);
|
||||
|
||||
static long int getThreadID() {
|
||||
return syscall(SYS_gettid);
|
||||
return qintptr(QThread::currentThreadId());
|
||||
}
|
||||
|
||||
void
|
||||
Logger::configure_logger ()
|
||||
{
|
||||
QString lastGstDebugString = CustomSettings::lastGstDebugString ();
|
||||
setenv (lastGstDebugString.split ("=").at (0).toStdString ().c_str (), lastGstDebugString.split ("=").at (1).toStdString ().c_str (), 1);
|
||||
setenv ("GST_DEBUG_NO_COLOR", "1", 1);
|
||||
setenv ("GST_DEBUG_FILE", "/tmp/gst_pipeviz.txt", 1);
|
||||
qputenv(lastGstDebugString.split("=").at(0).toStdString ().c_str(),
|
||||
lastGstDebugString.split("=").at(1).toLocal8Bit());
|
||||
qputenv("GST_DEBUG_NO_COLOR", QByteArray("1"));
|
||||
qputenv("GST_DEBUG_FILE", QByteArray("gst_pipeviz.txt"));
|
||||
}
|
||||
|
||||
Logger::Logger()
|
||||
|
@ -57,20 +56,17 @@ void Logger::createLog(TimeStampFlag flag, const char* format, ...)
|
|||
// first check if we should add the timestamp before the string
|
||||
char* new_fmt = NULL;
|
||||
if (flag == Logger::UseTimeStamp) {
|
||||
const char* fmt_template = "%02d:%02d:%02d:%06ld %d 0x%x %s";
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
struct tm t;
|
||||
gettimeofday(&tv, &tz);
|
||||
localtime_r(&(tv.tv_sec), &t);
|
||||
int len = snprintf(NULL, 0, fmt_template, t.tm_hour,t.tm_min,t.tm_sec, tv.tv_usec, getThreadID(), std::this_thread::get_id(), format);
|
||||
QString szTimestamp(QTime::currentTime().toString("HH:mm:ss:zzz"));
|
||||
|
||||
const char* fmt_template = "%s %d 0x%x %s";
|
||||
int len = snprintf(NULL, 0, fmt_template, szTimestamp.toStdString().c_str(), getThreadID(), std::this_thread::get_id(), format);
|
||||
if (len < 0) {
|
||||
// cannot parse the string
|
||||
return;
|
||||
}
|
||||
len++; // add 1 byte for the additional terminating null character
|
||||
new_fmt = static_cast<char*>(malloc(sizeof(char) * len));
|
||||
snprintf(new_fmt, len, fmt_template, t.tm_hour,t.tm_min,t.tm_sec, tv.tv_usec, getThreadID(), std::this_thread::get_id(), format);
|
||||
snprintf(new_fmt, len, fmt_template, szTimestamp.toStdString().c_str(), getThreadID(), std::this_thread::get_id(), format);
|
||||
}
|
||||
|
||||
// create the actual string (timestamp + format...)
|
||||
|
@ -271,7 +267,7 @@ void Logger::run()
|
|||
FILE* file;
|
||||
gchar* line;
|
||||
|
||||
file = fopen("/tmp/gst_pipeviz.txt", "r");
|
||||
file = fopen("gst_pipeviz.txt", "r");
|
||||
if(!file)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue