From 4b0845e5c0178c45fedb6f2083ad7dd29e71c5c3 Mon Sep 17 00:00:00 2001 From: dabrain34 Date: Sat, 12 Nov 2016 19:21:26 +0100 Subject: [PATCH] Support gstreamer-0.10 Fixes #6. build with gstreamer-0.10 API. --- pipeviz-0.10.pro | 4 +++ pipeviz.pri | 42 +++++++++++++++++++++++++++++ pipeviz.pro | 40 +-------------------------- src/GraphManager.cpp | 63 +++++++++++++++++++++++++++++++++++++------ src/MainWindow.cpp | 9 ++++++- src/PadProperties.cpp | 10 ++++++- src/PipelineIE.cpp | 14 +++++++--- src/PluginsList.cpp | 30 +++++++++++++++++---- src/main.cpp | 6 ++++- 9 files changed, 160 insertions(+), 58 deletions(-) create mode 100644 pipeviz-0.10.pro create mode 100644 pipeviz.pri diff --git a/pipeviz-0.10.pro b/pipeviz-0.10.pro new file mode 100644 index 0000000..048bafd --- /dev/null +++ b/pipeviz-0.10.pro @@ -0,0 +1,4 @@ +include(pipeviz.pri) + +PKGCONFIG += gstreamer-0.10 + diff --git a/pipeviz.pri b/pipeviz.pri new file mode 100644 index 0000000..6a447ae --- /dev/null +++ b/pipeviz.pri @@ -0,0 +1,42 @@ +###################################################################### +# Automatically generated by qmake (3.0) ?? ???. 22 21:50:14 2014 +###################################################################### + +CONFIG += qt debug +TEMPLATE = app +TARGET = pipeviz +QT += widgets +QT += xml +QT += core +INCLUDEPATH += . src + +CONFIG += link_pkgconfig + + +gitinfo.commands = src/verinfo/verinfo.sh src/version src/version_info.h +gitinfo.target = gitinfo + +QMAKE_EXTRA_TARGETS += gitinfo + + +# Input +HEADERS += src/PluginsList.h \ + src/MainWindow.h \ + src/GraphManager.h \ + src/GraphDisplay.h \ + src/ElementProperties.h \ + src/PadProperties.h \ + src/PipelineIE.h \ + src/CustomSettings.h \ + src/SeekSlider.h + +SOURCES += src/main.cpp \ + src/PluginsList.cpp \ + src/MainWindow.cpp \ + src/GraphManager.cpp \ + src/GraphDisplay.cpp \ + src/ElementProperties.cpp \ + src/PadProperties.cpp \ + src/PipelineIE.cpp \ + src/CustomSettings.cpp \ + src/SeekSlider.cpp diff --git a/pipeviz.pro b/pipeviz.pro index cf90273..ae3077f 100644 --- a/pipeviz.pro +++ b/pipeviz.pro @@ -1,42 +1,4 @@ -###################################################################### -# Automatically generated by qmake (3.0) ?? ???. 22 21:50:14 2014 -###################################################################### +include(pipeviz.pri) -CONFIG += qt debug -TEMPLATE = app -TARGET = pipeviz -QT += widgets -QT += xml -QT += core -INCLUDEPATH += . src - -CONFIG += link_pkgconfig PKGCONFIG += gstreamer-1.0 -gitinfo.commands = src/verinfo/verinfo.sh src/version src/version_info.h -gitinfo.target = gitinfo - -QMAKE_EXTRA_TARGETS += gitinfo - - -# Input -HEADERS += src/PluginsList.h \ - src/MainWindow.h \ - src/GraphManager.h \ - src/GraphDisplay.h \ - src/ElementProperties.h \ - src/PadProperties.h \ - src/PipelineIE.h \ - src/CustomSettings.h \ - src/SeekSlider.h - -SOURCES += src/main.cpp \ - src/PluginsList.cpp \ - src/MainWindow.cpp \ - src/GraphManager.cpp \ - src/GraphDisplay.cpp \ - src/ElementProperties.cpp \ - src/PadProperties.cpp \ - src/PipelineIE.cpp \ - src/CustomSettings.cpp \ - src/SeekSlider.cpp diff --git a/src/GraphManager.cpp b/src/GraphManager.cpp index 85e7291..17268f4 100644 --- a/src/GraphManager.cpp +++ b/src/GraphManager.cpp @@ -59,7 +59,11 @@ bool GraphManager::AddPlugin(const char *plugin, const char *name) if(uri) { qDebug() << "Set uri: " << uri; +#if GST_VERSION_MAJOR >= 1 gst_uri_handler_set_uri(GST_URI_HANDLER(pel), uri, NULL); +#else + gst_uri_handler_set_uri(GST_URI_HANDLER(pel), uri); +#endif g_free(uri); QString dir = QFileInfo(path).absoluteDir().absolutePath(); @@ -74,7 +78,11 @@ bool GraphManager::AddPlugin(const char *plugin, const char *name) if(!uri.isEmpty()) { qDebug() << "Set uri: " << uri; +#if GST_VERSION_MAJOR >= 1 gst_uri_handler_set_uri(GST_URI_HANDLER(pel), uri.toStdString().c_str(), NULL); +#else + gst_uri_handler_set_uri(GST_URI_HANDLER(pel), uri.toStdString().c_str()); +#endif } } @@ -106,7 +114,11 @@ bool GraphManager::RemovePlugin(const char *name) bool GraphManager::OpenUri(const char *uri, const char *name) { +#if GST_VERSION_MAJOR >= 1 GstElement *element = gst_element_make_from_uri(GST_URI_SRC, uri, name, NULL); +#else + GstElement *element = gst_element_make_from_uri(GST_URI_SRC, uri, name); +#endif if(!element) return false; @@ -158,20 +170,28 @@ std::vector GraphManager::GetInfo() GstIterator *iter; iter = gst_bin_iterate_elements (GST_BIN (m_pGraph)); + GstElement* element = NULL; bool done = false; size_t id = 0; while (!done) { +#if GST_VERSION_MAJOR >= 1 GValue value = { 0 }; switch (gst_iterator_next (iter, &value)) { case GST_ITERATOR_OK: { + element = GST_ELEMENT(g_value_get_object(&value)); +#else + switch (gst_iterator_next (iter, (gpointer *)&element)) + { + case GST_ITERATOR_OK: + { +#endif ElementInfo elementInfo; - elementInfo.m_id = id; id++; - GstElement *element = GST_ELEMENT(g_value_get_object(&value)); + gchar *name = gst_element_get_name(element); elementInfo.m_name = name; @@ -186,15 +206,22 @@ std::vector GraphManager::GetInfo() GstIterator *padItr = gst_element_iterate_pads (element); bool padDone = FALSE; std::size_t padId = 0; + GstPad *pad; while (!padDone) { +#if GST_VERSION_MAJOR >= 1 GValue padVal = { 0 }; switch (gst_iterator_next (padItr, &padVal)) { case GST_ITERATOR_OK: { - GstPad *pad = GST_PAD(g_value_get_object(&padVal)); - + pad = GST_PAD(g_value_get_object(&padVal)); +#else + switch (gst_iterator_next (iter, (gpointer *)&pad)) + { + case GST_ITERATOR_OK: + { +#endif PadInfo padInfo; padInfo.m_id = padId; @@ -211,7 +238,9 @@ std::vector GraphManager::GetInfo() padInfo.m_type = PadInfo::None; elementInfo.m_pads.push_back(padInfo); +#if GST_VERSION_MAJOR >= 1 g_value_reset (&padVal); +#endif break; } case GST_ITERATOR_RESYNC: @@ -222,8 +251,9 @@ std::vector GraphManager::GetInfo() }; padId++; } - +#if GST_VERSION_MAJOR >= 1 g_value_reset (&value); +#endif res.push_back(elementInfo); break; } @@ -340,11 +370,22 @@ bool GraphManager::Stop() double GraphManager::GetPosition() { gint64 current, duration; - if(!gst_element_query_position(m_pGraph, GST_FORMAT_TIME, ¤t)) + GstFormat fmt = GST_FORMAT_TIME; +#if GST_VERSION_MAJOR >= 1 + if(!gst_element_query_position(m_pGraph, fmt, ¤t)) return 0; +#else + if(!gst_element_query_position(m_pGraph, &fmt, ¤t)) + return 0; +#endif - if(!gst_element_query_duration(m_pGraph, GST_FORMAT_TIME, &duration)) +#if GST_VERSION_MAJOR >= 1 + if(!gst_element_query_duration(m_pGraph, fmt, &duration)) return 0; +#else + if(!gst_element_query_duration(m_pGraph, &fmt, &duration)) + return 0; +#endif if(duration < 0 || current < 0) return 0; @@ -356,6 +397,7 @@ double GraphManager::GetPosition() bool GraphManager::SetPosition(double pos) { GstQuery *query = gst_query_new_seeking(GST_FORMAT_TIME); + GstFormat fmt = GST_FORMAT_TIME; if(!query) return false; @@ -372,8 +414,13 @@ bool GraphManager::SetPosition(double pos) gint64 duration; - if(!gst_element_query_duration(m_pGraph, GST_FORMAT_TIME, &duration)) +#if GST_VERSION_MAJOR >= 1 + if(!gst_element_query_duration(m_pGraph, fmt, &duration)) return 0; +#else + if(!gst_element_query_duration(m_pGraph, &fmt, &duration)) + return 0; +#endif if(duration < 0) return 0; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 49d743b..36ba2be 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -161,7 +161,6 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags): setStatusBar(m_pstatusBar); restoreGeometry(CustomSettings::mainWindowGeometry()); - startTimer(100); } @@ -253,7 +252,11 @@ void MainWindow::Flush() if(m_pGraph -> m_pGraph) { gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_start()); +#if GST_VERSION_MAJOR >= 1 gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_stop(true)); +#else + gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_stop()); +#endif } } @@ -362,5 +365,9 @@ void MainWindow::About() message = "
virinext@gmail.com

"; message += QString("
Version: ") + VERSION_STR + "

"; message += "
GUI Based on Qt
"; + message += "
using "; + message += gst_version_string(); + message += "
"; + QMessageBox::about(this, "About", message); } diff --git a/src/PadProperties.cpp b/src/PadProperties.cpp index dc2309c..666cb95 100644 --- a/src/PadProperties.cpp +++ b/src/PadProperties.cpp @@ -29,7 +29,11 @@ QWidget(parent, flags) play -> addWidget(plbl, 0, 1); play -> addWidget(new QLabel("All caps:"), 1, 0); +#if GST_VERSION_MAJOR >= 1 GstCaps *caps = gst_pad_query_caps(pad, NULL); +#else + GstCaps *caps = gst_pad_get_caps(pad); +#endif gchar *str; gchar *noSpecified = (gchar *)"not specified"; if(caps) @@ -64,7 +68,11 @@ QWidget(parent, flags) } play -> addWidget(new QLabel("Current caps"), 3, 0); +#if GST_VERSION_MAJOR >= 1 caps = gst_pad_get_current_caps(pad); +#else + caps = gst_pad_get_negotiated_caps(pad); +#endif str = NULL; if(caps) str = gst_caps_to_string(caps); @@ -92,4 +100,4 @@ QWidget(parent, flags) pvblay -> addWidget(pscroll); setLayout(pvblay); -} \ No newline at end of file +} diff --git a/src/PipelineIE.cpp b/src/PipelineIE.cpp index 56e0f5a..e704851 100644 --- a/src/PipelineIE.cpp +++ b/src/PipelineIE.cpp @@ -16,19 +16,27 @@ static void clearPipeline(GstElement *pipeline) GstIterator *iter; iter = gst_bin_iterate_elements (GST_BIN (pipeline)); - + GstElement *element = NULL; bool done = false; while (!done) { +#if GST_VERSION_MAJOR >= 1 GValue value = { 0 }; switch (gst_iterator_next (iter, &value)) { case GST_ITERATOR_OK: { - GstElement *element = GST_ELEMENT(g_value_get_object(&value)); + element = GST_ELEMENT(g_value_get_object(&value)); +#else + switch (gst_iterator_next (iter, (gpointer *)&element)) + { + case GST_ITERATOR_OK: + { +#endif gst_bin_remove(GST_BIN(pipeline), element); +#if GST_VERSION_MAJOR >= 1 g_value_reset (&value); - +#endif iter = gst_bin_iterate_elements (GST_BIN (pipeline)); if(!iter) done = true; diff --git a/src/PluginsList.cpp b/src/PluginsList.cpp index e152624..18ee790 100644 --- a/src/PluginsList.cpp +++ b/src/PluginsList.cpp @@ -20,14 +20,24 @@ namespace { std::size_t num = 0; GList *plugins; - plugins = gst_registry_get_plugin_list(gst_registry_get()); + GstRegistry *registry; +#if GST_VERSION_MAJOR >= 1 + registry = gst_registry_get(); +#else + registry = gst_registry_get_default(); +#endif + plugins = gst_registry_get_plugin_list(registry); while(plugins) { GstPlugin *plugin; plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); - - GList *features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), +#if GST_VERSION_MAJOR >= 1 + registry = gst_registry_get(); +#else + registry = gst_registry_get_default(); +#endif + GList *features = gst_registry_get_feature_list_by_plugin (registry, gst_plugin_get_name (plugin)); while(features) @@ -116,16 +126,26 @@ void PluginsList::showInfo(QListWidgetItem *pitem, QListWidgetItem *previous) qDebug() << "warning: " << pitem -> text() << " Not Found"; return; } - +#if GST_VERSION_MAJOR >= 1 GstPlugin *plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory)); +#else + const gchar* plugin_name = GST_PLUGIN_FEATURE(factory)->plugin_name; + if (!plugin_name) { + return; + } + GstPlugin* plugin = gst_default_registry_find_plugin(plugin_name); +#endif if(!plugin) { qDebug() << "warning: " << pitem -> text() << " Not Found"; return; } - +#if GST_VERSION_MAJOR >= 1 const gchar *release_date = gst_plugin_get_release_date_string (plugin); +#else + const gchar *release_date = (plugin->desc.release_datetime) ? plugin->desc.release_datetime : ""; +#endif const gchar *filename = gst_plugin_get_filename(plugin); descr += "Name: " + QString(gst_plugin_get_name(plugin)) + "
"; diff --git a/src/main.cpp b/src/main.cpp index 2e36c3a..d6c6831 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,11 @@ int main(int argc, char **argv) gst_init (&argc, &argv); GstRegistry *registry; +#if GST_VERSION_MAJOR >= 1 registry = gst_registry_get(); +#else + registry = gst_registry_get_default(); +#endif gst_registry_scan_path(registry, "./plugins"); QApplication app(argc, argv); @@ -17,4 +21,4 @@ int main(int argc, char **argv) wgt.show(); return app.exec(); -} \ No newline at end of file +}