Support gstreamer-0.10

Fixes #6.
build with gstreamer-0.10 API.
This commit is contained in:
dabrain34 2016-11-12 19:21:26 +01:00
parent 8a1759c547
commit 4b0845e5c0
9 changed files with 160 additions and 58 deletions

4
pipeviz-0.10.pro Normal file
View file

@ -0,0 +1,4 @@
include(pipeviz.pri)
PKGCONFIG += gstreamer-0.10

42
pipeviz.pri Normal file
View file

@ -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

View file

@ -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

View file

@ -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 <ElementInfo> 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 <ElementInfo> 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 <ElementInfo> 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 <ElementInfo> 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, &current))
GstFormat fmt = GST_FORMAT_TIME;
#if GST_VERSION_MAJOR >= 1
if(!gst_element_query_position(m_pGraph, fmt, &current))
return 0;
#else
if(!gst_element_query_position(m_pGraph, &fmt, &current))
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;

View file

@ -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 = "<center>virinext@gmail.com</center><br>";
message += QString("<center>Version: ") + VERSION_STR + "</center><br>";
message += "<center>GUI Based on Qt</center>";
message += "<center>using ";
message += gst_version_string();
message += "</center>";
QMessageBox::about(this, "About", message);
}

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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 += "<b>Name</b>: " + QString(gst_plugin_get_name(plugin)) + "<br>";

View file

@ -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();
}
}