diff --git a/.gitignore b/.gitignore index 62ab9d9..5f8fee5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pipeviz *.o moc_* src/version_info.h +pipeviz.pro.user diff --git a/gstreamer.prf b/gstreamer.prf new file mode 100644 index 0000000..8197b85 --- /dev/null +++ b/gstreamer.prf @@ -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 +} diff --git a/pipeviz.pri b/pipeviz.pri index 352de7f..ec7d79a 100644 --- a/pipeviz.pri +++ b/pipeviz.pri @@ -10,7 +10,7 @@ QT += xml QT += core INCLUDEPATH += . src -CONFIG += link_pkgconfig +CONFIG += gstreamer QMAKE_CXXFLAGS += -std=c++11 diff --git a/pipeviz.pro b/pipeviz.pro index ae3077f..521857e 100644 --- a/pipeviz.pro +++ b/pipeviz.pro @@ -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 - diff --git a/readme.md b/readme.md index 3407a69..838fde4 100644 --- a/readme.md +++ b/readme.md @@ -38,7 +38,7 @@ Building: cd pipeviz -qmake pipeviz.pro +QMAKEFEATURES=. qmake pipeviz.pro make gitinfo diff --git a/src/ElementProperties.cpp b/src/ElementProperties.cpp index 18fab7d..ec4a0b5 100644 --- a/src/ElementProperties.cpp +++ b/src/ElementProperties.cpp @@ -130,10 +130,11 @@ ElementProperties::addParamSimple (GParamSpec *param, GstElement *element, QString propertyName = g_param_spec_get_name (param); QString propertyValue; + GType type = G_VALUE_TYPE (&value); bool skip = false; - switch (G_VALUE_TYPE (&value)) { + switch (type) { case G_TYPE_STRING: { const char *string_val = g_value_get_string (&value); propertyValue = string_val; @@ -186,6 +187,16 @@ ElementProperties::addParamSimple (GParamSpec *param, GstElement *element, } 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; LOG_INFO("property %s not supported", propertyName.toStdString ().c_str ()); break; @@ -310,7 +321,8 @@ ElementProperties::applyClicked () } } else { - switch (param->value_type) { + GType type = param->value_type; + switch (type) { case G_TYPE_STRING: { g_object_set (G_OBJECT (element), propName, valStr.toStdString ().c_str (), NULL); @@ -372,6 +384,20 @@ ElementProperties::applyClicked () break; } 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 ()); break; } diff --git a/src/Logger.cpp b/src/Logger.cpp index e46a5f6..5195b88 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -10,27 +10,26 @@ #include #include +#include -#include -#include #include #include -#include #include G_LOCK_DEFINE_STATIC(logger); static long int getThreadID() { - return syscall(SYS_gettid); + return quintptr(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(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;