Merge pull request #1 from virinext/master

Merging last patches before refacto
This commit is contained in:
dabrain34 2018-12-02 10:24:17 +01:00 committed by GitHub
commit 4ef31416a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 23 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ pipeviz
*.o *.o
moc_* moc_*
src/version_info.h src/version_info.h
pipeviz.pro.user

51
gstreamer.prf Normal file
View 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
}

View file

@ -10,7 +10,7 @@ QT += xml
QT += core QT += core
INCLUDEPATH += . src INCLUDEPATH += . src
CONFIG += link_pkgconfig CONFIG += gstreamer
QMAKE_CXXFLAGS += -std=c++11 QMAKE_CXXFLAGS += -std=c++11

View file

@ -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) include(pipeviz.pri)
PKGCONFIG += gstreamer-1.0

View file

@ -38,7 +38,7 @@ Building:
cd pipeviz cd pipeviz
qmake pipeviz.pro QMAKEFEATURES=. qmake pipeviz.pro
make gitinfo make gitinfo

View file

@ -130,10 +130,11 @@ ElementProperties::addParamSimple (GParamSpec *param, GstElement *element,
QString propertyName = g_param_spec_get_name (param); QString propertyName = g_param_spec_get_name (param);
QString propertyValue; QString propertyValue;
GType type = G_VALUE_TYPE (&value);
bool skip = false; bool skip = false;
switch (G_VALUE_TYPE (&value)) { switch (type) {
case G_TYPE_STRING: { case G_TYPE_STRING: {
const char *string_val = g_value_get_string (&value); const char *string_val = g_value_get_string (&value);
propertyValue = string_val; propertyValue = string_val;
@ -186,6 +187,16 @@ ElementProperties::addParamSimple (GParamSpec *param, GstElement *element,
} }
default: { default: {
if (type == g_type_from_name("GstCaps")) {
GstCaps *gstcaps;
g_object_get (G_OBJECT (element), param->name, &gstcaps, NULL);
const char *string_val = gst_caps_to_string (gstcaps);
if (gstcaps == NULL)
string_val = "ANY";
propertyValue = string_val;
break;
}
skip = true; skip = true;
LOG_INFO("property %s not supported", propertyName.toStdString ().c_str ()); LOG_INFO("property %s not supported", propertyName.toStdString ().c_str ());
break; break;
@ -310,7 +321,8 @@ ElementProperties::applyClicked ()
} }
} }
else { else {
switch (param->value_type) { GType type = param->value_type;
switch (type) {
case G_TYPE_STRING: { case G_TYPE_STRING: {
g_object_set (G_OBJECT (element), propName, g_object_set (G_OBJECT (element), propName,
valStr.toStdString ().c_str (), NULL); valStr.toStdString ().c_str (), NULL);
@ -372,6 +384,20 @@ ElementProperties::applyClicked ()
break; break;
} }
default: { default: {
if (type == g_type_from_name("GstCaps")) {
GstCaps *oldval;
GstCaps *newval = gst_caps_from_string (valStr.toStdString ().c_str ());
g_object_get (G_OBJECT (element), propName, &oldval, NULL);
if (oldval != newval && oldval != NULL) {
/* Release old */
gst_caps_unref (oldval);
}
g_object_set (G_OBJECT (element), propName, newval, NULL);
break;
}
LOG_INFO("property %s not supported", itr.key ()); LOG_INFO("property %s not supported", itr.key ());
break; break;
} }

View file

@ -10,27 +10,26 @@
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#include <QTime>
#include <time.h>
#include <sys/time.h>
#include <assert.h> #include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <sys/syscall.h>
#include <thread> #include <thread>
G_LOCK_DEFINE_STATIC(logger); G_LOCK_DEFINE_STATIC(logger);
static long int getThreadID() { static long int getThreadID() {
return syscall(SYS_gettid); return quintptr(QThread::currentThreadId());
} }
void void
Logger::configure_logger () Logger::configure_logger ()
{ {
QString lastGstDebugString = CustomSettings::lastGstDebugString (); QString lastGstDebugString = CustomSettings::lastGstDebugString ();
setenv (lastGstDebugString.split ("=").at (0).toStdString ().c_str (), lastGstDebugString.split ("=").at (1).toStdString ().c_str (), 1); qputenv(lastGstDebugString.split("=").at(0).toStdString ().c_str(),
setenv ("GST_DEBUG_NO_COLOR", "1", 1); lastGstDebugString.split("=").at(1).toLocal8Bit());
setenv ("GST_DEBUG_FILE", "/tmp/gst_pipeviz.txt", 1); qputenv("GST_DEBUG_NO_COLOR", QByteArray("1"));
qputenv("GST_DEBUG_FILE", QByteArray("gst_pipeviz.txt"));
} }
Logger::Logger() 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 // first check if we should add the timestamp before the string
char* new_fmt = NULL; char* new_fmt = NULL;
if (flag == Logger::UseTimeStamp) { if (flag == Logger::UseTimeStamp) {
const char* fmt_template = "%02d:%02d:%02d:%06ld %d 0x%x %s"; QString szTimestamp(QTime::currentTime().toString("HH:mm:ss:zzz"));
struct timeval tv;
struct timezone tz; const char* fmt_template = "%s %d 0x%x %s";
struct tm t; int len = snprintf(NULL, 0, fmt_template, szTimestamp.toStdString().c_str(), getThreadID(), std::this_thread::get_id(), format);
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);
if (len < 0) { if (len < 0) {
// cannot parse the string // cannot parse the string
return; return;
} }
len++; // add 1 byte for the additional terminating null character len++; // add 1 byte for the additional terminating null character
new_fmt = static_cast<char*>(malloc(sizeof(char) * len)); 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...) // create the actual string (timestamp + format...)
@ -271,7 +267,7 @@ void Logger::run()
FILE* file; FILE* file;
gchar* line; gchar* line;
file = fopen("/tmp/gst_pipeviz.txt", "r"); file = fopen("gst_pipeviz.txt", "r");
if(!file) if(!file)
return; return;