mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2025-01-26 08:38:18 +00:00
Code cleanup
Use GNU formatter from Eclipse.
This commit is contained in:
parent
606b1bb3eb
commit
2d75a32dd0
21 changed files with 2718 additions and 2812 deletions
|
@ -1,13 +1,15 @@
|
|||
#include "CustomMenuAction.h"
|
||||
|
||||
CustomMenuAction::CustomMenuAction(const QString& displayName, QObject * parent)
|
||||
:QAction(displayName, parent)
|
||||
, m_name(displayName)
|
||||
CustomMenuAction::CustomMenuAction (const QString& displayName,
|
||||
QObject * parent)
|
||||
: QAction (displayName, parent),
|
||||
m_name (displayName)
|
||||
{
|
||||
}
|
||||
|
||||
CustomMenuAction::CustomMenuAction(const QString& displayName, const QString& name, QObject * parent)
|
||||
:QAction(displayName, parent)
|
||||
, m_name(name)
|
||||
CustomMenuAction::CustomMenuAction (const QString& displayName,
|
||||
const QString& name, QObject * parent)
|
||||
: QAction (displayName, parent),
|
||||
m_name (name)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
#ifndef CUSTOM_MENU_ACTION_H_
|
||||
#define CUSTOM_MENU_ACTION_H_
|
||||
|
||||
|
||||
#include <QAction>
|
||||
|
||||
class CustomMenuAction: public QAction
|
||||
{
|
||||
public:
|
||||
CustomMenuAction(const QString& displayName, QObject * parent);
|
||||
|
||||
CustomMenuAction(const QString& displayName, const QString& name, QObject * parent);
|
||||
|
||||
QString getName() { return m_name;}
|
||||
QString getName() {return m_name;}
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //CUSTOM_MENU_ACTION_H_
|
||||
|
|
|
@ -5,34 +5,35 @@
|
|||
#define COMPANY_NAME "virinext"
|
||||
#define APPLICATION_NAME "pipeviz"
|
||||
|
||||
void CustomSettings::saveLastIODirectory(const QString &name)
|
||||
void
|
||||
CustomSettings::saveLastIODirectory (const QString &name)
|
||||
{
|
||||
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
|
||||
settings.setValue("last_directory", name);
|
||||
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
|
||||
settings.setValue ("last_directory", name);
|
||||
}
|
||||
|
||||
|
||||
QString CustomSettings::lastIODirectory()
|
||||
QString
|
||||
CustomSettings::lastIODirectory ()
|
||||
{
|
||||
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
|
||||
QString res = settings.value("last_directory").toString();
|
||||
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
|
||||
QString res = settings.value ("last_directory").toString ();
|
||||
|
||||
if(res.isEmpty())
|
||||
if (res.isEmpty ())
|
||||
res = "./";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void CustomSettings::saveMainWindowGeometry(const QByteArray &geometry)
|
||||
void
|
||||
CustomSettings::saveMainWindowGeometry (const QByteArray &geometry)
|
||||
{
|
||||
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
|
||||
settings.setValue("geometry", geometry);
|
||||
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
|
||||
settings.setValue ("geometry", geometry);
|
||||
}
|
||||
|
||||
|
||||
QByteArray CustomSettings::mainWindowGeometry()
|
||||
QByteArray
|
||||
CustomSettings::mainWindowGeometry ()
|
||||
{
|
||||
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
|
||||
return settings.value("geometry").toByteArray();
|
||||
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
|
||||
return settings.value ("geometry").toByteArray ();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
|
||||
namespace CustomSettings
|
||||
{
|
||||
void saveLastIODirectory(const QString &name);
|
||||
|
@ -14,6 +13,4 @@ namespace CustomSettings
|
|||
QByteArray mainWindowGeometry();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,231 +11,208 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
ElementProperties::ElementProperties(QSharedPointer<GraphManager> pGraph, const char *name,
|
||||
QWidget *parent, Qt::WindowFlags flags):
|
||||
QWidget(parent, flags),
|
||||
m_pGraphManager(pGraph),
|
||||
m_name(name)
|
||||
ElementProperties::ElementProperties (QSharedPointer<GraphManager> pGraph,
|
||||
const char *name, QWidget *parent,
|
||||
Qt::WindowFlags flags)
|
||||
: QWidget (parent, flags),
|
||||
m_pGraphManager (pGraph),
|
||||
m_name (name)
|
||||
{
|
||||
setWindowTitle(QString(name) + " properties");
|
||||
setWindowTitle (QString (name) + " properties");
|
||||
|
||||
create();
|
||||
create ();
|
||||
}
|
||||
|
||||
|
||||
void ElementProperties::addParamEnum(GParamSpec *param, GstElement *element, QGridLayout *play)
|
||||
void
|
||||
ElementProperties::addParamEnum (GParamSpec *param, GstElement *element,
|
||||
QGridLayout *play)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
|
||||
g_value_init (&value, param -> value_type);
|
||||
if(param -> flags & G_PARAM_READABLE)
|
||||
g_object_get_property (G_OBJECT(element), param -> name, &value);
|
||||
else
|
||||
{
|
||||
const GValue *valueDef = g_param_spec_get_default_value(param);
|
||||
g_value_copy(valueDef, &value);
|
||||
g_value_init (&value, param->value_type);
|
||||
if (param->flags & G_PARAM_READABLE)
|
||||
g_object_get_property (G_OBJECT (element), param->name, &value);
|
||||
else {
|
||||
const GValue *valueDef = g_param_spec_get_default_value (param);
|
||||
g_value_copy (valueDef, &value);
|
||||
}
|
||||
|
||||
|
||||
QString propertyName = g_param_spec_get_name (param);
|
||||
int propertyValue;
|
||||
|
||||
propertyValue = g_value_get_enum(&value);
|
||||
propertyValue = g_value_get_enum (&value);
|
||||
|
||||
GParamSpecEnum *penumSpec = G_PARAM_SPEC_ENUM(param);
|
||||
GParamSpecEnum *penumSpec = G_PARAM_SPEC_ENUM (param);
|
||||
|
||||
if(!penumSpec)
|
||||
if (!penumSpec)
|
||||
return;
|
||||
|
||||
QComboBox *pcomBox = new QComboBox;
|
||||
|
||||
for(std::size_t i=0; i<penumSpec -> enum_class -> n_values; i++)
|
||||
{
|
||||
QVariant var(penumSpec -> enum_class -> values[i].value);
|
||||
QString valueName = penumSpec -> enum_class -> values[i].value_name;
|
||||
for (std::size_t i = 0; i < penumSpec->enum_class->n_values; i++) {
|
||||
QVariant var (penumSpec->enum_class->values[i].value);
|
||||
QString valueName = penumSpec->enum_class->values[i].value_name;
|
||||
|
||||
pcomBox -> addItem(valueName, var);
|
||||
pcomBox->addItem (valueName, var);
|
||||
|
||||
if(penumSpec -> enum_class -> values[i].value == propertyValue)
|
||||
pcomBox -> setCurrentIndex(i);
|
||||
if (penumSpec->enum_class->values[i].value == propertyValue)
|
||||
pcomBox->setCurrentIndex (i);
|
||||
}
|
||||
|
||||
|
||||
int row = play -> rowCount();
|
||||
|
||||
play -> addWidget(new QLabel(propertyName), row, 0);
|
||||
|
||||
play -> addWidget(pcomBox, row, 1);
|
||||
|
||||
m_values.insert(propertyName, pcomBox);
|
||||
int row = play->rowCount ();
|
||||
play->addWidget (new QLabel (propertyName), row, 0);
|
||||
play->addWidget (pcomBox, row, 1);
|
||||
m_values.insert (propertyName, pcomBox);
|
||||
}
|
||||
|
||||
|
||||
void ElementProperties::addParamFlags(GParamSpec *param, GstElement *element, QGridLayout *play)
|
||||
void
|
||||
ElementProperties::addParamFlags (GParamSpec *param, GstElement *element,
|
||||
QGridLayout *play)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
|
||||
g_value_init (&value, param -> value_type);
|
||||
if(param -> flags & G_PARAM_READABLE)
|
||||
g_object_get_property (G_OBJECT(element), param -> name, &value);
|
||||
else
|
||||
{
|
||||
const GValue *valueDef = g_param_spec_get_default_value(param);
|
||||
g_value_copy(valueDef, &value);
|
||||
g_value_init (&value, param->value_type);
|
||||
if (param->flags & G_PARAM_READABLE)
|
||||
g_object_get_property (G_OBJECT (element), param->name, &value);
|
||||
else {
|
||||
const GValue *valueDef = g_param_spec_get_default_value (param);
|
||||
g_value_copy (valueDef, &value);
|
||||
}
|
||||
|
||||
|
||||
QString propertyName = g_param_spec_get_name (param);
|
||||
int propertyValue;
|
||||
|
||||
propertyValue = g_value_get_flags(&value);
|
||||
propertyValue = g_value_get_flags (&value);
|
||||
|
||||
GParamSpecFlags *pflagsSpec = G_PARAM_SPEC_FLAGS(param);
|
||||
GParamSpecFlags *pflagsSpec = G_PARAM_SPEC_FLAGS (param);
|
||||
|
||||
if(!pflagsSpec)
|
||||
if (!pflagsSpec)
|
||||
return;
|
||||
|
||||
QComboBox *pcomBox = new QComboBox;
|
||||
|
||||
for(std::size_t i=0; i<pflagsSpec -> flags_class -> n_values; i++)
|
||||
{
|
||||
QVariant var(pflagsSpec -> flags_class -> values[i].value);
|
||||
QString valueName = pflagsSpec -> flags_class -> values[i].value_name;
|
||||
for (std::size_t i = 0; i < pflagsSpec->flags_class->n_values; i++) {
|
||||
QVariant var (pflagsSpec->flags_class->values[i].value);
|
||||
QString valueName = pflagsSpec->flags_class->values[i].value_name;
|
||||
|
||||
pcomBox -> addItem(valueName, var);
|
||||
pcomBox->addItem (valueName, var);
|
||||
|
||||
if(pflagsSpec -> flags_class -> values[i].value == propertyValue)
|
||||
pcomBox -> setCurrentIndex(i);
|
||||
if (pflagsSpec->flags_class->values[i].value == propertyValue)
|
||||
pcomBox->setCurrentIndex (i);
|
||||
}
|
||||
|
||||
int row = play->rowCount ();
|
||||
|
||||
int row = play -> rowCount();
|
||||
play->addWidget (new QLabel (propertyName), row, 0);
|
||||
|
||||
play -> addWidget(new QLabel(propertyName), row, 0);
|
||||
play->addWidget (pcomBox, row, 1);
|
||||
|
||||
play -> addWidget(pcomBox, row, 1);
|
||||
|
||||
m_values.insert(propertyName, pcomBox);
|
||||
m_values.insert (propertyName, pcomBox);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ElementProperties::addParamSimple(GParamSpec *param, GstElement *element, QGridLayout *play)
|
||||
void
|
||||
ElementProperties::addParamSimple (GParamSpec *param, GstElement *element,
|
||||
QGridLayout *play)
|
||||
{
|
||||
bool readOnly = true;
|
||||
|
||||
if(param->flags & G_PARAM_WRITABLE)
|
||||
if (param->flags & G_PARAM_WRITABLE)
|
||||
readOnly = false;
|
||||
|
||||
GValue value = { 0 };
|
||||
|
||||
g_value_init (&value, param -> value_type);
|
||||
if(param -> flags & G_PARAM_READABLE)
|
||||
g_object_get_property (G_OBJECT(element), param -> name, &value);
|
||||
else
|
||||
{
|
||||
const GValue *valueDef = g_param_spec_get_default_value(param);
|
||||
g_value_copy(valueDef, &value);
|
||||
g_value_init (&value, param->value_type);
|
||||
if (param->flags & G_PARAM_READABLE)
|
||||
g_object_get_property (G_OBJECT (element), param->name, &value);
|
||||
else {
|
||||
const GValue *valueDef = g_param_spec_get_default_value (param);
|
||||
g_value_copy (valueDef, &value);
|
||||
}
|
||||
|
||||
|
||||
QString propertyName = g_param_spec_get_name (param);
|
||||
QString propertyValue;
|
||||
|
||||
bool skip = false;
|
||||
|
||||
switch (G_VALUE_TYPE (&value))
|
||||
{
|
||||
case G_TYPE_STRING:
|
||||
{
|
||||
switch (G_VALUE_TYPE (&value)) {
|
||||
case G_TYPE_STRING: {
|
||||
const char *string_val = g_value_get_string (&value);
|
||||
propertyValue = string_val;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_BOOLEAN:
|
||||
{
|
||||
case G_TYPE_BOOLEAN: {
|
||||
gboolean bool_val = g_value_get_boolean (&value);
|
||||
propertyValue = QString::number(bool_val);
|
||||
propertyValue = QString::number (bool_val);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_ULONG:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_ulong(&value));
|
||||
case G_TYPE_ULONG: {
|
||||
propertyValue = QString::number (g_value_get_ulong (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_LONG:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_long(&value));
|
||||
case G_TYPE_LONG: {
|
||||
propertyValue = QString::number (g_value_get_long (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_uint(&value));
|
||||
case G_TYPE_UINT: {
|
||||
propertyValue = QString::number (g_value_get_uint (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_int(&value));
|
||||
case G_TYPE_INT: {
|
||||
propertyValue = QString::number (g_value_get_int (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT64:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_uint64(&value));
|
||||
case G_TYPE_UINT64: {
|
||||
propertyValue = QString::number (g_value_get_uint64 (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT64:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_int64(&value));
|
||||
case G_TYPE_INT64: {
|
||||
propertyValue = QString::number (g_value_get_int64 (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_FLOAT:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_float(&value));
|
||||
case G_TYPE_FLOAT: {
|
||||
propertyValue = QString::number (g_value_get_float (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_DOUBLE:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_double(&value));
|
||||
case G_TYPE_DOUBLE: {
|
||||
propertyValue = QString::number (g_value_get_double (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_CHAR:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_char(&value));
|
||||
case G_TYPE_CHAR: {
|
||||
propertyValue = QString::number (g_value_get_char (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UCHAR:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_uchar(&value));
|
||||
case G_TYPE_UCHAR: {
|
||||
propertyValue = QString::number (g_value_get_uchar (&value));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
skip = true;
|
||||
qDebug() << "property " << propertyName << " not supported";
|
||||
qDebug () << "property " << propertyName << " not supported";
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
int row = play -> rowCount();
|
||||
int row = play->rowCount ();
|
||||
|
||||
play -> addWidget(new QLabel(propertyName), row, 0);
|
||||
play->addWidget (new QLabel (propertyName), row, 0);
|
||||
|
||||
QLineEdit *ple = new QLineEdit(propertyValue);
|
||||
ple -> setReadOnly(readOnly);
|
||||
play -> addWidget(ple, row, 1);
|
||||
if(!skip)
|
||||
m_values.insert(propertyName, ple);
|
||||
QLineEdit *ple = new QLineEdit (propertyValue);
|
||||
ple->setReadOnly (readOnly);
|
||||
play->addWidget (ple, row, 1);
|
||||
if (!skip)
|
||||
m_values.insert (propertyName, ple);
|
||||
else
|
||||
ple -> setReadOnly(true);
|
||||
ple->setReadOnly (true);
|
||||
}
|
||||
|
||||
|
||||
void ElementProperties::create()
|
||||
void
|
||||
ElementProperties::create ()
|
||||
{
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraphManager -> m_pGraph), m_name.toStdString().c_str());
|
||||
GstElement *element = gst_bin_get_by_name (
|
||||
GST_BIN (m_pGraphManager->m_pGraph), m_name.toStdString ().c_str ());
|
||||
|
||||
if(!element)
|
||||
if (!element)
|
||||
return;
|
||||
|
||||
QGridLayout *play = new QGridLayout;
|
||||
|
@ -243,196 +220,178 @@ void ElementProperties::create()
|
|||
GParamSpec **prop_specs;
|
||||
guint num_props;
|
||||
|
||||
prop_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element),
|
||||
prop_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
|
||||
&num_props);
|
||||
|
||||
for(std::size_t i = 0; i<num_props; i++)
|
||||
{
|
||||
for (std::size_t i = 0; i < num_props; i++) {
|
||||
GParamSpec *param = prop_specs[i];
|
||||
|
||||
if(G_IS_PARAM_SPEC_ENUM(param))
|
||||
addParamEnum(param, element, play);
|
||||
else if(G_IS_PARAM_SPEC_FLAGS(param))
|
||||
addParamFlags(param, element, play);
|
||||
if (G_IS_PARAM_SPEC_ENUM (param))
|
||||
addParamEnum (param, element, play);
|
||||
else if (G_IS_PARAM_SPEC_FLAGS (param))
|
||||
addParamFlags (param, element, play);
|
||||
else
|
||||
addParamSimple(param, element, play);
|
||||
addParamSimple (param, element, play);
|
||||
}
|
||||
|
||||
QVBoxLayout *pvblay = new QVBoxLayout;
|
||||
QWidget *pwgt = new QWidget(this);
|
||||
pwgt -> setLayout(play);
|
||||
QScrollArea *pscroll = new QScrollArea(this);
|
||||
pscroll -> setWidget(pwgt);
|
||||
QWidget *pwgt = new QWidget (this);
|
||||
pwgt->setLayout (play);
|
||||
QScrollArea *pscroll = new QScrollArea (this);
|
||||
pscroll->setWidget (pwgt);
|
||||
|
||||
pvblay -> addWidget(pscroll);
|
||||
pvblay->addWidget (pscroll);
|
||||
|
||||
QHBoxLayout *phblay = new QHBoxLayout;
|
||||
|
||||
QPushButton *pcmdApply = new QPushButton("Apply");
|
||||
QPushButton *pcmdOk = new QPushButton("OK");
|
||||
QPushButton *pcmdCancel = new QPushButton("Cancel");
|
||||
QPushButton *pcmdApply = new QPushButton ("Apply");
|
||||
QPushButton *pcmdOk = new QPushButton ("OK");
|
||||
QPushButton *pcmdCancel = new QPushButton ("Cancel");
|
||||
|
||||
phblay->addStretch (1);
|
||||
phblay->addWidget (pcmdApply);
|
||||
phblay->addWidget (pcmdCancel);
|
||||
phblay->addWidget (pcmdOk);
|
||||
|
||||
phblay -> addStretch(1);
|
||||
phblay -> addWidget(pcmdApply);
|
||||
phblay -> addWidget(pcmdCancel);
|
||||
phblay -> addWidget(pcmdOk);
|
||||
pvblay->addLayout (phblay);
|
||||
|
||||
pvblay -> addLayout(phblay);
|
||||
QObject::connect (pcmdApply, SIGNAL (clicked ()), this,
|
||||
SLOT (applyClicked ()));
|
||||
QObject::connect (pcmdCancel, SIGNAL (clicked ()), this, SLOT (close ()));
|
||||
QObject::connect (pcmdOk, SIGNAL (clicked ()), this, SLOT (okClicked ()));
|
||||
|
||||
QObject::connect(pcmdApply, SIGNAL(clicked()), this, SLOT(applyClicked()));
|
||||
QObject::connect(pcmdCancel, SIGNAL(clicked()), this, SLOT(close()));
|
||||
QObject::connect(pcmdOk, SIGNAL(clicked()), this, SLOT(okClicked()));
|
||||
setLayout (pvblay);
|
||||
|
||||
setLayout(pvblay);
|
||||
|
||||
g_free(prop_specs);
|
||||
gst_object_unref(element);
|
||||
g_free (prop_specs);
|
||||
gst_object_unref (element);
|
||||
|
||||
}
|
||||
|
||||
void ElementProperties::applyClicked()
|
||||
void
|
||||
ElementProperties::applyClicked ()
|
||||
{
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraphManager -> m_pGraph),
|
||||
m_name.toStdString().c_str());
|
||||
GstElement *element = gst_bin_get_by_name (
|
||||
GST_BIN (m_pGraphManager->m_pGraph), m_name.toStdString ().c_str ());
|
||||
|
||||
if(!element)
|
||||
if (!element)
|
||||
return;
|
||||
|
||||
QMap<QString, QWidget *>::iterator itr = m_values.begin();
|
||||
QMap<QString, QWidget *>::iterator itr = m_values.begin ();
|
||||
|
||||
for(;itr != m_values.end(); itr++)
|
||||
{
|
||||
GParamSpec *param = g_object_class_find_property(G_OBJECT_GET_CLASS (element),
|
||||
itr.key().toStdString().c_str());
|
||||
for (; itr != m_values.end (); itr++) {
|
||||
GParamSpec *param = g_object_class_find_property (
|
||||
G_OBJECT_GET_CLASS (element), itr.key ().toStdString ().c_str ());
|
||||
|
||||
if(!param)
|
||||
{
|
||||
qDebug() << "problem with setting " << itr.key() << " property";
|
||||
if (!param) {
|
||||
qDebug () << "problem with setting " << itr.key () << " property";
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!(param -> flags & G_PARAM_WRITABLE))
|
||||
if (!(param->flags & G_PARAM_WRITABLE))
|
||||
continue;
|
||||
|
||||
QString valStr;
|
||||
|
||||
if(dynamic_cast<QLineEdit *>(itr.value()))
|
||||
valStr = ((QLineEdit *) itr.value()) -> text();
|
||||
else if(dynamic_cast<QComboBox *>(itr.value()))
|
||||
{
|
||||
QComboBox *pcomBox = (QComboBox *) itr.value();
|
||||
int val = pcomBox -> itemData(pcomBox -> currentIndex()).toInt();
|
||||
valStr = QString::number(val);
|
||||
if (dynamic_cast<QLineEdit *> (itr.value ()))
|
||||
valStr = ((QLineEdit *) itr.value ())->text ();
|
||||
else if (dynamic_cast<QComboBox *> (itr.value ())) {
|
||||
QComboBox *pcomBox = (QComboBox *) itr.value ();
|
||||
int val = pcomBox->itemData (pcomBox->currentIndex ()).toInt ();
|
||||
valStr = QString::number (val);
|
||||
}
|
||||
|
||||
std::string tmpStr = itr.key().toStdString();
|
||||
const char *propName = tmpStr.c_str();
|
||||
std::string tmpStr = itr.key ().toStdString ();
|
||||
const char *propName = tmpStr.c_str ();
|
||||
|
||||
if(G_IS_PARAM_SPEC_ENUM(param) || G_IS_PARAM_SPEC_FLAGS(param))
|
||||
{
|
||||
if(dynamic_cast<QComboBox *>(itr.value()))
|
||||
{
|
||||
QComboBox *pcomBox = (QComboBox *) itr.value();
|
||||
int val = pcomBox -> itemData(pcomBox -> currentIndex()).toInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
if (G_IS_PARAM_SPEC_ENUM (param) || G_IS_PARAM_SPEC_FLAGS (param)) {
|
||||
if (dynamic_cast<QComboBox *> (itr.value ())) {
|
||||
QComboBox *pcomBox = (QComboBox *) itr.value ();
|
||||
int val = pcomBox->itemData (pcomBox->currentIndex ()).toInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (param -> value_type)
|
||||
{
|
||||
case G_TYPE_STRING:
|
||||
{
|
||||
g_object_set(G_OBJECT(element), propName, valStr.toStdString().c_str(), NULL);
|
||||
else {
|
||||
switch (param->value_type) {
|
||||
case G_TYPE_STRING: {
|
||||
g_object_set (G_OBJECT (element), propName,
|
||||
valStr.toStdString ().c_str (), NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_BOOLEAN:
|
||||
{
|
||||
gboolean val = valStr.toInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_BOOLEAN: {
|
||||
gboolean val = valStr.toInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_ULONG:
|
||||
{
|
||||
gulong val = valStr.toULong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_ULONG: {
|
||||
gulong val = valStr.toULong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_LONG:
|
||||
{
|
||||
glong val = valStr.toLong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_LONG: {
|
||||
glong val = valStr.toLong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT:
|
||||
{
|
||||
guint val = valStr.toUInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_UINT: {
|
||||
guint val = valStr.toUInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT:
|
||||
{
|
||||
gint val = valStr.toInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_INT: {
|
||||
gint val = valStr.toInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT64:
|
||||
{
|
||||
guint64 val = valStr.toULongLong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_UINT64: {
|
||||
guint64 val = valStr.toULongLong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT64:
|
||||
{
|
||||
gint64 val = valStr.toLongLong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_INT64: {
|
||||
gint64 val = valStr.toLongLong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_FLOAT:
|
||||
{
|
||||
gfloat val = valStr.toFloat();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_FLOAT: {
|
||||
gfloat val = valStr.toFloat ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_DOUBLE:
|
||||
{
|
||||
gdouble val = valStr.toDouble();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_DOUBLE: {
|
||||
gdouble val = valStr.toDouble ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_CHAR:
|
||||
{
|
||||
gchar val = valStr.toInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_CHAR: {
|
||||
gchar val = valStr.toInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UCHAR:
|
||||
{
|
||||
guchar val = valStr.toUInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_UCHAR: {
|
||||
guchar val = valStr.toUInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
qDebug() << "property " << itr.key() << " not supported";
|
||||
default: {
|
||||
qDebug () << "property " << itr.key () << " not supported";
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
gst_object_unref(element);
|
||||
gst_object_unref (element);
|
||||
|
||||
delete layout();
|
||||
qDeleteAll(children());
|
||||
delete layout ();
|
||||
qDeleteAll (
|
||||
children ());
|
||||
|
||||
|
||||
create();
|
||||
create ();
|
||||
}
|
||||
|
||||
void ElementProperties::okClicked()
|
||||
void
|
||||
ElementProperties::okClicked ()
|
||||
{
|
||||
applyClicked();
|
||||
close();
|
||||
applyClicked ();
|
||||
close ();
|
||||
}
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
|
||||
class ElementProperties: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
ElementProperties(QSharedPointer<GraphManager> pGraphManager, const char *name,
|
||||
QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
|
||||
private slots:
|
||||
void applyClicked();
|
||||
void okClicked();
|
||||
|
@ -33,5 +32,4 @@ private:
|
|||
void addParamFlags(GParamSpec *value, GstElement *element, QGridLayout *play);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,16 +7,12 @@
|
|||
#include <QSharedPointer>
|
||||
#include <QPoint>
|
||||
|
||||
|
||||
#include "GraphManager.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
|
||||
class GraphDisplay: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphDisplay(QWidget *parent=0, Qt::WindowFlags f=0);
|
||||
|
@ -28,7 +24,6 @@ public:
|
|||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
|
||||
QSharedPointer<GraphManager> m_pGraph;
|
||||
|
||||
private slots:
|
||||
|
@ -57,7 +52,6 @@ private:
|
|||
QPoint m_startPosition;
|
||||
};
|
||||
|
||||
|
||||
struct ElementDisplayInfo
|
||||
{
|
||||
QRect m_rect;
|
||||
|
@ -90,5 +84,4 @@ private:
|
|||
MoveInfo m_moveInfo;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,65 +10,71 @@
|
|||
#include "CustomSettings.h"
|
||||
|
||||
#define MAX_STR_CAPS_SIZE 150
|
||||
gchar* get_str_caps_limited(gchar* str)
|
||||
gchar*
|
||||
get_str_caps_limited (gchar* str)
|
||||
{
|
||||
gchar* result;
|
||||
if(strlen(str) > MAX_STR_CAPS_SIZE) {
|
||||
result = g_strndup(str, MAX_STR_CAPS_SIZE);
|
||||
for(int i = strlen(result)-1;i > strlen(result)-4 ;i--)
|
||||
if (strlen (str) > MAX_STR_CAPS_SIZE) {
|
||||
result = g_strndup (str, MAX_STR_CAPS_SIZE);
|
||||
for (int i = strlen (result) - 1; i > strlen (result) - 4; i--)
|
||||
result[i] = '.';
|
||||
} else
|
||||
result = g_strdup(str);
|
||||
}
|
||||
else
|
||||
result = g_strdup (str);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
typefind_have_type_callback (GstElement * typefind,
|
||||
guint probability, GstCaps * caps, GraphManager * thiz)
|
||||
typefind_have_type_callback (GstElement * typefind, guint probability,
|
||||
GstCaps * caps, GraphManager * thiz)
|
||||
{
|
||||
gchar *caps_description = gst_caps_to_string (caps);
|
||||
qDebug() << "Found caps " << caps_description << " with probability " << probability;
|
||||
g_free(caps_description);
|
||||
thiz->Pause();
|
||||
qDebug () << "Found caps " << caps_description << " with probability "
|
||||
<< probability;
|
||||
g_free (caps_description);
|
||||
thiz->Pause ();
|
||||
}
|
||||
|
||||
GraphManager::GraphManager()
|
||||
GraphManager::GraphManager ()
|
||||
{
|
||||
m_pGraph = gst_pipeline_new ("pipeline");
|
||||
m_pluginsList = new PluginsList();
|
||||
m_pluginsList = new PluginsList ();
|
||||
}
|
||||
|
||||
GraphManager::~GraphManager()
|
||||
GraphManager::~GraphManager ()
|
||||
{
|
||||
delete m_pluginsList;
|
||||
}
|
||||
|
||||
QString GraphManager::getPadCaps(ElementInfo* elementInfo, PadInfo* padInfo, ePadCapsSubset subset, bool afTruncated)
|
||||
QString
|
||||
GraphManager::getPadCaps (ElementInfo* elementInfo, PadInfo* padInfo,
|
||||
ePadCapsSubset subset, bool afTruncated)
|
||||
{
|
||||
QString padCaps = "";
|
||||
if(!elementInfo || !padInfo)
|
||||
if (!elementInfo || !padInfo)
|
||||
return padCaps;
|
||||
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraph), elementInfo->m_name.c_str());
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN (m_pGraph),
|
||||
elementInfo->m_name.c_str ());
|
||||
|
||||
if(!element)
|
||||
if (!element)
|
||||
return padCaps;
|
||||
GstPad *pad = gst_element_get_static_pad(GST_ELEMENT(element), padInfo->m_name.c_str());
|
||||
if(!pad) {
|
||||
gst_object_unref(element);
|
||||
GstPad *pad = gst_element_get_static_pad (GST_ELEMENT (element),
|
||||
padInfo->m_name.c_str ());
|
||||
if (!pad) {
|
||||
gst_object_unref (element);
|
||||
return padCaps;
|
||||
}
|
||||
GstCaps *caps;
|
||||
switch(subset)
|
||||
{
|
||||
switch (subset) {
|
||||
case PAD_CAPS_ALLOWED:
|
||||
caps = gst_pad_get_allowed_caps(pad);
|
||||
caps = gst_pad_get_allowed_caps (pad);
|
||||
break;
|
||||
case PAD_CAPS_NEGOCIATED:
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
caps = gst_pad_get_current_caps(pad);
|
||||
#else
|
||||
caps = gst_pad_get_negotiated_caps(pad);
|
||||
caps = gst_pad_get_negotiated_caps (pad);
|
||||
#endif
|
||||
break;
|
||||
case PAD_CAPS_ALL:
|
||||
|
@ -76,269 +82,265 @@ QString GraphManager::getPadCaps(ElementInfo* elementInfo, PadInfo* padInfo, ePa
|
|||
#if GST_VERSION_MAJOR >= 1
|
||||
caps = gst_pad_query_caps(pad, NULL);
|
||||
#else
|
||||
caps = gst_pad_get_caps(pad);
|
||||
caps = gst_pad_get_caps (pad);
|
||||
#endif
|
||||
}
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
caps = gst_pad_query_caps(pad, NULL);
|
||||
#else
|
||||
caps = gst_pad_get_caps(pad);
|
||||
caps = gst_pad_get_caps (pad);
|
||||
#endif
|
||||
if(caps) {
|
||||
gchar* str = gst_caps_to_string(caps);
|
||||
if (caps) {
|
||||
gchar* str = gst_caps_to_string (caps);
|
||||
if (afTruncated) {
|
||||
gchar* str_limited = get_str_caps_limited(str);
|
||||
g_free(str);
|
||||
gchar* str_limited = get_str_caps_limited (str);
|
||||
g_free (str);
|
||||
padCaps = str_limited;
|
||||
g_free(str_limited);
|
||||
} else {
|
||||
g_free (str_limited);
|
||||
}
|
||||
else {
|
||||
padCaps = str;
|
||||
g_free(str);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gst_object_unref(element);
|
||||
gst_object_unref (element);
|
||||
gst_object_unref (pad);
|
||||
return padCaps;
|
||||
}
|
||||
|
||||
gchar* GraphManager::AddPlugin(const char *plugin, const char *name)
|
||||
gchar*
|
||||
GraphManager::AddPlugin (const char *plugin, const char *name)
|
||||
{
|
||||
GstElement *pel = gst_element_factory_make(plugin, name);
|
||||
if(!pel)
|
||||
GstElement *pel = gst_element_factory_make (plugin, name);
|
||||
if (!pel)
|
||||
return NULL;
|
||||
|
||||
if(GST_IS_URI_HANDLER(pel))
|
||||
{
|
||||
static const gchar *const *protocols;
|
||||
protocols = gst_uri_handler_get_protocols(GST_URI_HANDLER(pel));
|
||||
if (GST_IS_URI_HANDLER (pel)) {
|
||||
static const gchar * const *protocols;
|
||||
protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (pel));
|
||||
|
||||
bool isFile = false;
|
||||
|
||||
for(std::size_t i=0; protocols[i] != NULL; i++)
|
||||
{
|
||||
if(strcmp("file", protocols[i]) == 0)
|
||||
{
|
||||
for (std::size_t i = 0; protocols[i] != NULL; i++) {
|
||||
if (strcmp ("file", protocols[i]) == 0) {
|
||||
isFile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isFile)
|
||||
{
|
||||
if (isFile) {
|
||||
QString path;
|
||||
QString dir = CustomSettings::lastIODirectory();
|
||||
QString dir = CustomSettings::lastIODirectory ();
|
||||
|
||||
if(gst_uri_handler_get_uri_type(GST_URI_HANDLER(pel)) == GST_URI_SRC)
|
||||
path = QFileDialog::getOpenFileName(NULL, "Open Media Source File...", dir);
|
||||
if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (pel)) == GST_URI_SRC)
|
||||
path = QFileDialog::getOpenFileName (NULL, "Open Media Source File...",
|
||||
dir);
|
||||
else
|
||||
path = QFileDialog::getSaveFileName(NULL, "Open Sink File...", dir);
|
||||
path = QFileDialog::getSaveFileName (NULL, "Open Sink File...", dir);
|
||||
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
gchar *uri = gst_filename_to_uri(path.toStdString().c_str(), NULL);
|
||||
if(uri)
|
||||
{
|
||||
qDebug() << "Set uri: " << uri;
|
||||
if (!path.isEmpty ()) {
|
||||
gchar *uri = gst_filename_to_uri (path.toStdString ().c_str (),
|
||||
NULL);
|
||||
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);
|
||||
gst_uri_handler_set_uri (GST_URI_HANDLER (pel), uri);
|
||||
#endif
|
||||
g_free(uri);
|
||||
g_free (uri);
|
||||
|
||||
QString dir = QFileInfo(path).absoluteDir().absolutePath();
|
||||
CustomSettings::saveLastIODirectory(dir);
|
||||
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
|
||||
CustomSettings::saveLastIODirectory (dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QString uri = QInputDialog::getText(NULL, "Uri...", "Uri:");
|
||||
else {
|
||||
QString uri = QInputDialog::getText (NULL, "Uri...", "Uri:");
|
||||
|
||||
if(!uri.isEmpty())
|
||||
{
|
||||
qDebug() << "Set uri: " << uri;
|
||||
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());
|
||||
gst_uri_handler_set_uri (GST_URI_HANDLER (pel),
|
||||
uri.toStdString ().c_str ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool res = gst_bin_add(GST_BIN(m_pGraph), pel);
|
||||
bool res = gst_bin_add (GST_BIN (m_pGraph), pel);
|
||||
if (res)
|
||||
gst_element_sync_state_with_parent(pel);
|
||||
gst_element_sync_state_with_parent (pel);
|
||||
else {
|
||||
gst_object_unref(pel);
|
||||
gst_object_unref (pel);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return gst_element_get_name(pel);
|
||||
return gst_element_get_name (pel);
|
||||
}
|
||||
|
||||
|
||||
bool GraphManager::RemovePlugin(const char *name)
|
||||
bool
|
||||
GraphManager::RemovePlugin (const char *name)
|
||||
{
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraph), name);
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN (m_pGraph), name);
|
||||
|
||||
if(!element)
|
||||
if (!element)
|
||||
return false;
|
||||
|
||||
bool res = gst_bin_remove (GST_BIN(m_pGraph), element);
|
||||
gst_object_unref(element);
|
||||
bool res = gst_bin_remove (GST_BIN (m_pGraph), element);
|
||||
gst_object_unref (element);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool GraphManager::OpenUri(const char *uri, 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);
|
||||
GstElement *element = gst_element_make_from_uri (GST_URI_SRC, uri, name);
|
||||
#endif
|
||||
if(!element)
|
||||
if (!element)
|
||||
return false;
|
||||
|
||||
bool res = gst_bin_add(GST_BIN(m_pGraph), element);
|
||||
if(res)
|
||||
gst_element_sync_state_with_parent(element);
|
||||
bool res = gst_bin_add (GST_BIN (m_pGraph), element);
|
||||
if (res)
|
||||
gst_element_sync_state_with_parent (element);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GraphManager::Connect(const char *srcElement, const char *srcPad,
|
||||
bool
|
||||
GraphManager::Connect (const char *srcElement, const char *srcPad,
|
||||
const char *dstElement, const char *dstPad)
|
||||
{
|
||||
GstElement *src = gst_bin_get_by_name (GST_BIN(m_pGraph), srcElement);
|
||||
GstElement *dst = gst_bin_get_by_name (GST_BIN(m_pGraph), dstElement);
|
||||
GstElement *src = gst_bin_get_by_name (GST_BIN (m_pGraph), srcElement);
|
||||
GstElement *dst = gst_bin_get_by_name (GST_BIN (m_pGraph), dstElement);
|
||||
|
||||
bool res = gst_element_link_pads(src, srcPad, dst, dstPad);
|
||||
bool res = gst_element_link_pads (src, srcPad, dst, dstPad);
|
||||
|
||||
gboolean seekRes = gst_element_seek_simple(m_pGraph, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 0);
|
||||
gboolean seekRes = gst_element_seek_simple (m_pGraph, GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH, 0);
|
||||
|
||||
gst_object_unref(src);
|
||||
gst_object_unref(dst);
|
||||
gst_object_unref (src);
|
||||
gst_object_unref (dst);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GraphManager::Connect(const char *srcElement, const char *dstElement)
|
||||
bool
|
||||
GraphManager::Connect (const char *srcElement, const char *dstElement)
|
||||
{
|
||||
GstElement *src = gst_bin_get_by_name (GST_BIN(m_pGraph), srcElement);
|
||||
GstElement *dst = gst_bin_get_by_name (GST_BIN(m_pGraph), dstElement);
|
||||
GstElement *src = gst_bin_get_by_name (GST_BIN (m_pGraph), srcElement);
|
||||
GstElement *dst = gst_bin_get_by_name (GST_BIN (m_pGraph), dstElement);
|
||||
|
||||
bool res = gst_element_link(src, dst);
|
||||
bool res = gst_element_link (src, dst);
|
||||
|
||||
gboolean seekRes = gst_element_seek_simple(m_pGraph, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 0);
|
||||
gboolean seekRes = gst_element_seek_simple (m_pGraph, GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH, 0);
|
||||
|
||||
/* add a callback to handle have-type signal */
|
||||
if (g_str_has_prefix(dstElement,"typefindelement")) {
|
||||
if (g_str_has_prefix (dstElement, "typefindelement")) {
|
||||
g_signal_connect (dst, "have-type",
|
||||
G_CALLBACK (typefind_have_type_callback),
|
||||
this);
|
||||
Play();
|
||||
G_CALLBACK (typefind_have_type_callback), this);
|
||||
Play ();
|
||||
}
|
||||
|
||||
gst_object_unref(src);
|
||||
gst_object_unref(dst);
|
||||
gst_object_unref (src);
|
||||
gst_object_unref (dst);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GraphManager::Disconnect(const char *srcElement, const char *srcPad,
|
||||
bool
|
||||
GraphManager::Disconnect (const char *srcElement, const char *srcPad,
|
||||
const char *dstElement, const char *dstPad)
|
||||
{
|
||||
GstElement *src = gst_bin_get_by_name (GST_BIN(m_pGraph), srcElement);
|
||||
GstElement *dst = gst_bin_get_by_name (GST_BIN(m_pGraph), dstElement);
|
||||
GstElement *src = gst_bin_get_by_name (GST_BIN (m_pGraph), srcElement);
|
||||
GstElement *dst = gst_bin_get_by_name (GST_BIN (m_pGraph), dstElement);
|
||||
|
||||
gst_element_unlink_pads (src, srcPad, dst, dstPad);
|
||||
|
||||
gst_element_unlink_pads(src, srcPad, dst, dstPad);
|
||||
|
||||
gst_object_unref(src);
|
||||
gst_object_unref(dst);
|
||||
gst_object_unref (src);
|
||||
gst_object_unref (dst);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector <ElementInfo> GraphManager::GetInfo()
|
||||
std::vector<ElementInfo>
|
||||
GraphManager::GetInfo ()
|
||||
{
|
||||
std::vector <ElementInfo> res;
|
||||
std::vector<ElementInfo> res;
|
||||
|
||||
GstIterator *iter;
|
||||
iter = gst_bin_iterate_elements (GST_BIN (m_pGraph));
|
||||
GstElement* element = NULL;
|
||||
bool done = false;
|
||||
size_t id = 0;
|
||||
while (!done)
|
||||
{
|
||||
while (!done) {
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
GValue value = { 0 };
|
||||
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:
|
||||
{
|
||||
switch (gst_iterator_next (iter, (gpointer *) &element)) {
|
||||
case GST_ITERATOR_OK: {
|
||||
#endif
|
||||
ElementInfo elementInfo;
|
||||
elementInfo.m_id = id;
|
||||
id++;
|
||||
|
||||
gchar *name = gst_element_get_name(element);
|
||||
gchar *name = gst_element_get_name (element);
|
||||
elementInfo.m_name = name;
|
||||
g_free(name);
|
||||
g_free (name);
|
||||
|
||||
GstElementFactory *pfactory =
|
||||
gst_element_get_factory(element);
|
||||
GstElementFactory *pfactory = gst_element_get_factory (element);
|
||||
|
||||
elementInfo.m_pluginName =
|
||||
gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(pfactory));
|
||||
elementInfo.m_pluginName = gst_plugin_feature_get_name (
|
||||
GST_PLUGIN_FEATURE (pfactory));
|
||||
|
||||
GstIterator *padItr = gst_element_iterate_pads (element);
|
||||
bool padDone = FALSE;
|
||||
std::size_t padId = 0;
|
||||
GstPad *pad;
|
||||
while (!padDone)
|
||||
{
|
||||
while (!padDone) {
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
GValue padVal = { 0 };
|
||||
GValue padVal =
|
||||
{ 0};
|
||||
switch (gst_iterator_next (padItr, &padVal))
|
||||
{
|
||||
case GST_ITERATOR_OK:
|
||||
{
|
||||
pad = GST_PAD(g_value_get_object(&padVal));
|
||||
#else
|
||||
switch (gst_iterator_next (padItr, (gpointer *)&pad))
|
||||
{
|
||||
case GST_ITERATOR_OK:
|
||||
{
|
||||
switch (gst_iterator_next (padItr, (gpointer *) &pad)) {
|
||||
case GST_ITERATOR_OK: {
|
||||
#endif
|
||||
PadInfo padInfo;
|
||||
padInfo.m_id = padId;
|
||||
|
||||
gchar *pad_name = gst_pad_get_name(pad);
|
||||
gchar *pad_name = gst_pad_get_name (pad);
|
||||
padInfo.m_name = pad_name;
|
||||
g_free(pad_name);
|
||||
g_free (pad_name);
|
||||
|
||||
GstPadDirection direction = gst_pad_get_direction(pad);
|
||||
if(direction == GST_PAD_SRC)
|
||||
GstPadDirection direction = gst_pad_get_direction (pad);
|
||||
if (direction == GST_PAD_SRC)
|
||||
padInfo.m_type = PadInfo::Out;
|
||||
else if(direction == GST_PAD_SINK)
|
||||
else if (direction == GST_PAD_SINK)
|
||||
padInfo.m_type = PadInfo::In;
|
||||
else
|
||||
padInfo.m_type = PadInfo::None;
|
||||
|
||||
elementInfo.m_pads.push_back(padInfo);
|
||||
elementInfo.m_pads.push_back (padInfo);
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
g_value_reset (&padVal);
|
||||
#endif
|
||||
|
@ -355,13 +357,12 @@ std::vector <ElementInfo> GraphManager::GetInfo()
|
|||
#if GST_VERSION_MAJOR >= 1
|
||||
g_value_reset (&value);
|
||||
#endif
|
||||
res.push_back(elementInfo);
|
||||
res.push_back (elementInfo);
|
||||
break;
|
||||
}
|
||||
case GST_ITERATOR_DONE:
|
||||
case GST_ITERATOR_RESYNC:
|
||||
case GST_ITERATOR_ERROR:
|
||||
{
|
||||
case GST_ITERATOR_ERROR: {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
@ -370,35 +371,30 @@ std::vector <ElementInfo> GraphManager::GetInfo()
|
|||
|
||||
gst_iterator_free (iter);
|
||||
|
||||
for(std::size_t i=0; i<res.size(); i++)
|
||||
{
|
||||
res[i].m_connections.resize(res[i].m_pads.size());
|
||||
for (std::size_t i = 0; i < res.size (); i++) {
|
||||
res[i].m_connections.resize (res[i].m_pads.size ());
|
||||
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraph), res[i].m_name.c_str());
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN (m_pGraph),
|
||||
res[i].m_name.c_str ());
|
||||
|
||||
for(std::size_t j=0; j<res[i].m_pads.size(); j++)
|
||||
{
|
||||
for (std::size_t j = 0; j < res[i].m_pads.size (); j++) {
|
||||
res[i].m_connections[j].m_elementId = -1;
|
||||
res[i].m_connections[j].m_padId = -1;
|
||||
|
||||
GstPad *pad = gst_element_get_static_pad (element, res[i].m_pads[j].m_name.c_str());
|
||||
GstPad *peerPad = gst_pad_get_peer(pad);
|
||||
GstPad *pad = gst_element_get_static_pad (
|
||||
element, res[i].m_pads[j].m_name.c_str ());
|
||||
GstPad *peerPad = gst_pad_get_peer (pad);
|
||||
|
||||
if(peerPad)
|
||||
{
|
||||
GstElement *peerElement = GST_ELEMENT(gst_pad_get_parent(peerPad));
|
||||
if (peerPad) {
|
||||
GstElement *peerElement = GST_ELEMENT (gst_pad_get_parent (peerPad));
|
||||
|
||||
gchar *peerName = gst_element_get_name(peerElement);
|
||||
gchar *peerPadName = gst_pad_get_name(peerPad);
|
||||
gchar *peerName = gst_element_get_name (peerElement);
|
||||
gchar *peerPadName = gst_pad_get_name (peerPad);
|
||||
|
||||
for(std::size_t k=0; k<res.size(); k++)
|
||||
{
|
||||
if(res[k].m_name == peerName)
|
||||
{
|
||||
for(std::size_t l=0; l<res[k].m_pads.size(); l++)
|
||||
{
|
||||
if(res[k].m_pads[l].m_name == peerPadName)
|
||||
{
|
||||
for (std::size_t k = 0; k < res.size (); k++) {
|
||||
if (res[k].m_name == peerName) {
|
||||
for (std::size_t l = 0; l < res[k].m_pads.size (); l++) {
|
||||
if (res[k].m_pads[l].m_name == peerPadName) {
|
||||
res[i].m_connections[j].m_elementId = res[k].m_id;
|
||||
res[i].m_connections[j].m_padId = res[k].m_pads[l].m_id;
|
||||
break;
|
||||
|
@ -407,64 +403,64 @@ std::vector <ElementInfo> GraphManager::GetInfo()
|
|||
}
|
||||
}
|
||||
|
||||
g_free(peerName);
|
||||
g_free(peerPadName);
|
||||
g_free (peerName);
|
||||
g_free (peerPadName);
|
||||
|
||||
gst_object_unref(peerPad);
|
||||
gst_object_unref(peerElement);
|
||||
gst_object_unref (peerPad);
|
||||
gst_object_unref (peerElement);
|
||||
}
|
||||
|
||||
gst_object_unref(pad);
|
||||
gst_object_unref (pad);
|
||||
}
|
||||
gst_object_unref(element);
|
||||
gst_object_unref (element);
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool GraphManager::Play()
|
||||
bool
|
||||
GraphManager::Play ()
|
||||
{
|
||||
GstStateChangeReturn res;
|
||||
gst_element_set_state(m_pGraph, GST_STATE_PLAYING);
|
||||
gst_element_set_state (m_pGraph, GST_STATE_PLAYING);
|
||||
|
||||
GstState state;
|
||||
res = gst_element_get_state (m_pGraph, &state, NULL, GST_SECOND);
|
||||
|
||||
if(res != GST_STATE_CHANGE_SUCCESS)
|
||||
{
|
||||
gst_element_abort_state(m_pGraph);
|
||||
qDebug() << "state changing to Play was FAILED";
|
||||
if (res != GST_STATE_CHANGE_SUCCESS) {
|
||||
gst_element_abort_state (m_pGraph);
|
||||
qDebug () << "state changing to Play was FAILED";
|
||||
}
|
||||
|
||||
return state == GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
|
||||
bool GraphManager::Pause()
|
||||
bool
|
||||
GraphManager::Pause ()
|
||||
{
|
||||
GstStateChangeReturn res;
|
||||
|
||||
GstState state;
|
||||
gst_element_set_state(m_pGraph, GST_STATE_PAUSED);
|
||||
gst_element_set_state (m_pGraph, GST_STATE_PAUSED);
|
||||
res = gst_element_get_state (m_pGraph, &state, NULL, GST_SECOND);
|
||||
if(res != GST_STATE_CHANGE_SUCCESS)
|
||||
{
|
||||
gst_element_abort_state(m_pGraph);
|
||||
qDebug() << "state changing to Pause was FAILED";
|
||||
if (res != GST_STATE_CHANGE_SUCCESS) {
|
||||
gst_element_abort_state (m_pGraph);
|
||||
qDebug () << "state changing to Pause was FAILED";
|
||||
}
|
||||
|
||||
return state == GST_STATE_PAUSED;
|
||||
}
|
||||
|
||||
bool GraphManager::Stop()
|
||||
bool
|
||||
GraphManager::Stop ()
|
||||
{
|
||||
GstStateChangeReturn res = gst_element_set_state(m_pGraph, GST_STATE_READY);
|
||||
GstStateChangeReturn res = gst_element_set_state (m_pGraph, GST_STATE_READY);
|
||||
return res == GST_STATE_CHANGE_SUCCESS;
|
||||
}
|
||||
|
||||
double GraphManager::GetPosition()
|
||||
double
|
||||
GraphManager::GetPosition ()
|
||||
{
|
||||
gint64 current, duration;
|
||||
GstFormat fmt = GST_FORMAT_TIME;
|
||||
|
@ -472,7 +468,7 @@ double GraphManager::GetPosition()
|
|||
if(!gst_element_query_position(m_pGraph, fmt, ¤t))
|
||||
return 0;
|
||||
#else
|
||||
if(!gst_element_query_position(m_pGraph, &fmt, ¤t))
|
||||
if (!gst_element_query_position (m_pGraph, &fmt, ¤t))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
@ -480,33 +476,33 @@ double GraphManager::GetPosition()
|
|||
if(!gst_element_query_duration(m_pGraph, fmt, &duration))
|
||||
return 0;
|
||||
#else
|
||||
if(!gst_element_query_duration(m_pGraph, &fmt, &duration))
|
||||
if (!gst_element_query_duration (m_pGraph, &fmt, &duration))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if(duration < 0 || current < 0)
|
||||
if (duration < 0 || current < 0)
|
||||
return 0;
|
||||
|
||||
return (double) current / duration;
|
||||
}
|
||||
|
||||
|
||||
bool GraphManager::SetPosition(double pos)
|
||||
bool
|
||||
GraphManager::SetPosition (double pos)
|
||||
{
|
||||
GstQuery *query = gst_query_new_seeking(GST_FORMAT_TIME);
|
||||
GstQuery *query = gst_query_new_seeking (GST_FORMAT_TIME);
|
||||
GstFormat fmt = GST_FORMAT_TIME;
|
||||
if(!query)
|
||||
if (!query)
|
||||
return false;
|
||||
|
||||
if(!gst_element_query(m_pGraph, query))
|
||||
if (!gst_element_query (m_pGraph, query))
|
||||
return false;
|
||||
|
||||
gboolean seekable;
|
||||
gst_query_parse_seeking(query, NULL, &seekable, NULL, NULL);
|
||||
gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
|
||||
|
||||
gst_query_unref(query);
|
||||
gst_query_unref (query);
|
||||
|
||||
if(!seekable)
|
||||
if (!seekable)
|
||||
return false;
|
||||
|
||||
gint64 duration;
|
||||
|
@ -515,19 +511,23 @@ bool GraphManager::SetPosition(double pos)
|
|||
if(!gst_element_query_duration(m_pGraph, fmt, &duration))
|
||||
return 0;
|
||||
#else
|
||||
if(!gst_element_query_duration(m_pGraph, &fmt, &duration))
|
||||
if (!gst_element_query_duration (m_pGraph, &fmt, &duration))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if(duration < 0)
|
||||
if (duration < 0)
|
||||
return 0;
|
||||
|
||||
gboolean seekRes = gst_element_seek_simple(m_pGraph, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, duration * pos);
|
||||
gboolean seekRes = gst_element_seek_simple (m_pGraph, GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH,
|
||||
duration * pos);
|
||||
|
||||
return seekRes;
|
||||
}
|
||||
|
||||
bool GraphManager::CanConnect(const char *srcName, const char *srcPadName, const char *destName, bool noANY)
|
||||
bool
|
||||
GraphManager::CanConnect (const char *srcName, const char *srcPadName,
|
||||
const char *destName, bool noANY)
|
||||
{
|
||||
bool ret = false;
|
||||
bool added = false;
|
||||
|
@ -537,73 +537,74 @@ bool GraphManager::CanConnect(const char *srcName, const char *srcPadName, const
|
|||
GstCaps* srcCaps = NULL;
|
||||
GstElementFactory *destFactory = NULL;
|
||||
|
||||
src = gst_bin_get_by_name (GST_BIN(m_pGraph), srcName);
|
||||
src = gst_bin_get_by_name (GST_BIN (m_pGraph), srcName);
|
||||
if (!src) {
|
||||
qDebug() << "Unable to get the src element: " << srcName;
|
||||
qDebug () << "Unable to get the src element: " << srcName;
|
||||
goto done;
|
||||
}
|
||||
|
||||
srcPad = gst_element_get_static_pad(src, srcPadName);
|
||||
srcPad = gst_element_get_static_pad (src, srcPadName);
|
||||
if (!srcPad) {
|
||||
qDebug() << "Unable to get the src pad";
|
||||
qDebug () << "Unable to get the src pad";
|
||||
goto done;
|
||||
}
|
||||
|
||||
srcCaps = gst_pad_get_current_caps(srcPad);
|
||||
srcCaps = gst_pad_get_current_caps (srcPad);
|
||||
if (!srcCaps) {
|
||||
qDebug() << "Unable to get the current caps for pad:" << srcPadName;
|
||||
srcCaps =gst_pad_get_pad_template_caps(srcPad);
|
||||
qDebug () << "Unable to get the current caps for pad:" << srcPadName;
|
||||
srcCaps = gst_pad_get_pad_template_caps (srcPad);
|
||||
if (!srcCaps) {
|
||||
qDebug() << "Unable to get the template caps for pad:" << srcPadName;
|
||||
qDebug () << "Unable to get the template caps for pad:" << srcPadName;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
dest = gst_element_factory_make(destName, NULL);
|
||||
dest = gst_element_factory_make (destName, NULL);
|
||||
if (!dest) {
|
||||
qDebug() << "Unable to get the dest element: " << destName;
|
||||
qDebug () << "Unable to get the dest element: " << destName;
|
||||
goto done;
|
||||
}
|
||||
|
||||
destFactory = gst_element_get_factory(dest);
|
||||
destFactory = gst_element_get_factory (dest);
|
||||
if (!destFactory) {
|
||||
qDebug() << "Unable to get the dest factory";
|
||||
qDebug () << "Unable to get the dest factory";
|
||||
goto done;
|
||||
}
|
||||
if (noANY && gst_element_factory_can_sink_any_caps(destFactory, srcCaps)) {
|
||||
qDebug() << "The dest element " << destName << " can sink any caps";
|
||||
if (noANY && gst_element_factory_can_sink_any_caps (destFactory, srcCaps)) {
|
||||
qDebug () << "The dest element " << destName << " can sink any caps";
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(!gst_element_factory_can_sink_all_caps(destFactory, srcCaps)) {
|
||||
gchar* caps_string = gst_caps_to_string(srcCaps);
|
||||
qDebug() << "The dest element " << destName << " can not sink this caps: " << caps_string;
|
||||
if (!gst_element_factory_can_sink_all_caps (destFactory, srcCaps)) {
|
||||
gchar* caps_string = gst_caps_to_string (srcCaps);
|
||||
qDebug () << "The dest element " << destName << " can not sink this caps: "
|
||||
<< caps_string;
|
||||
g_free (caps_string);
|
||||
goto done;
|
||||
}
|
||||
|
||||
added = gst_bin_add(GST_BIN(m_pGraph), dest);
|
||||
added = gst_bin_add (GST_BIN (m_pGraph), dest);
|
||||
if (!added) {
|
||||
qDebug() << "Unable to add element to the bin";
|
||||
qDebug () << "Unable to add element to the bin";
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = gst_element_link(src,dest);
|
||||
ret = gst_element_link (src, dest);
|
||||
if (ret) {
|
||||
qDebug() << "Can link elements src " << GST_OBJECT_NAME(src) << " with dest " << GST_OBJECT_NAME(dest);
|
||||
gst_element_unlink(src,dest);
|
||||
qDebug () << "Can link elements src " << GST_OBJECT_NAME (src)
|
||||
<< " with dest " << GST_OBJECT_NAME (dest);
|
||||
gst_element_unlink (src, dest);
|
||||
}
|
||||
|
||||
done:
|
||||
if (added) {
|
||||
gst_bin_remove(GST_BIN(m_pGraph), dest);
|
||||
done: if (added) {
|
||||
gst_bin_remove (GST_BIN (m_pGraph), dest);
|
||||
dest = NULL;
|
||||
}
|
||||
if (src)
|
||||
gst_object_unref(src);
|
||||
gst_object_unref (src);
|
||||
if (srcPad)
|
||||
gst_object_unref(srcPad);
|
||||
gst_object_unref (srcPad);
|
||||
if (dest)
|
||||
gst_object_unref(dest);
|
||||
gst_object_unref (dest);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ struct ElementInfo
|
|||
|
||||
class GraphManager
|
||||
{
|
||||
|
||||
public:
|
||||
GraphManager();
|
||||
~GraphManager();
|
||||
|
@ -111,8 +112,6 @@ public:
|
|||
|
||||
GstElement *m_pGraph;
|
||||
PluginsList *m_pluginsList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,255 +33,263 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags):
|
||||
QMainWindow(parent, flags)
|
||||
,m_pGraph(new GraphManager)
|
||||
MainWindow::MainWindow (QWidget *parent, Qt::WindowFlags flags)
|
||||
: QMainWindow (parent, flags),
|
||||
m_pGraph (new GraphManager)
|
||||
{
|
||||
QToolBar *ptb = addToolBar("Menu");
|
||||
QToolBar *ptb = addToolBar ("Menu");
|
||||
|
||||
QAction *pactAdd = ptb -> addAction("Add...");
|
||||
pactAdd -> setShortcut(QKeySequence("Ctrl+F"));
|
||||
connect(pactAdd, SIGNAL(triggered()), SLOT(AddPlugin()));
|
||||
QAction *pactAdd = ptb->addAction ("Add...");
|
||||
pactAdd->setShortcut (QKeySequence ("Ctrl+F"));
|
||||
connect (pactAdd, SIGNAL (triggered ()), SLOT (AddPlugin ()));
|
||||
|
||||
QAction *pactOpenFile = ptb->addAction ("Open Media File...");
|
||||
connect (pactOpenFile, SIGNAL (triggered ()), SLOT (OpenMediaFile ()));
|
||||
|
||||
QAction *pactOpenFile = ptb -> addAction("Open Media File...");
|
||||
connect(pactOpenFile, SIGNAL(triggered()), SLOT(OpenMediaFile()));
|
||||
ptb->addSeparator ();
|
||||
|
||||
ptb -> addSeparator();
|
||||
QPixmap pxPlay (24, 24);
|
||||
pxPlay.fill (QColor (0, 0, 0, 0));
|
||||
QPainter pntrPlay (&pxPlay);
|
||||
pntrPlay.setPen (Qt::darkGreen);
|
||||
pntrPlay.setBrush (QBrush (Qt::darkGreen));
|
||||
|
||||
QPixmap pxPlay(24, 24);
|
||||
pxPlay.fill(QColor(0, 0, 0, 0));
|
||||
QPainter pntrPlay(&pxPlay);
|
||||
pntrPlay.setPen(Qt::darkGreen);
|
||||
pntrPlay.setBrush(QBrush(Qt::darkGreen));
|
||||
QPolygon polygon (3);
|
||||
polygon.setPoint (0, 4, 4);
|
||||
polygon.setPoint (1, 4, 20);
|
||||
polygon.setPoint (2, 20, 12);
|
||||
|
||||
QPolygon polygon(3);
|
||||
polygon.setPoint(0, 4, 4);
|
||||
polygon.setPoint(1, 4, 20);
|
||||
polygon.setPoint(2, 20, 12);
|
||||
pntrPlay.drawPolygon (polygon, Qt::WindingFill);
|
||||
|
||||
pntrPlay.drawPolygon(polygon, Qt::WindingFill);
|
||||
QAction *pactPlay = ptb->addAction (QIcon (pxPlay), "Play");
|
||||
connect (pactPlay, SIGNAL (triggered ()), SLOT (Play ()));
|
||||
|
||||
QAction *pactPlay = ptb -> addAction(QIcon(pxPlay), "Play");
|
||||
connect(pactPlay, SIGNAL(triggered()), SLOT(Play()));
|
||||
QPixmap pxPause (24, 24);
|
||||
pxPause.fill (QColor (0, 0, 0, 0));
|
||||
QPainter pntrPause (&pxPause);
|
||||
pntrPause.setPen (Qt::darkGray);
|
||||
pntrPause.setBrush (QBrush (Qt::darkGray));
|
||||
|
||||
QPixmap pxPause(24, 24);
|
||||
pxPause.fill(QColor(0, 0, 0, 0));
|
||||
QPainter pntrPause(&pxPause);
|
||||
pntrPause.setPen(Qt::darkGray);
|
||||
pntrPause.setBrush(QBrush(Qt::darkGray));
|
||||
pntrPause.drawRect (8, 4, 3, 16);
|
||||
pntrPause.drawRect (13, 4, 3, 16);
|
||||
|
||||
pntrPause.drawRect(8, 4, 3, 16);
|
||||
pntrPause.drawRect(13, 4, 3, 16);
|
||||
QAction *pactPause = ptb->addAction (QIcon (pxPause), "Pause");
|
||||
connect (pactPause, SIGNAL (triggered ()), SLOT (Pause ()));
|
||||
|
||||
QAction *pactPause = ptb -> addAction(QIcon(pxPause), "Pause");
|
||||
connect(pactPause, SIGNAL(triggered()), SLOT(Pause()));
|
||||
QPixmap pxStop (24, 24);
|
||||
pxStop.fill (QColor (0, 0, 0, 0));
|
||||
QPainter pntrStop (&pxStop);
|
||||
pntrStop.setPen (Qt::darkRed);
|
||||
pntrStop.setBrush (QBrush (Qt::darkRed));
|
||||
|
||||
QPixmap pxStop(24, 24);
|
||||
pxStop.fill(QColor(0, 0, 0, 0));
|
||||
QPainter pntrStop(&pxStop);
|
||||
pntrStop.setPen(Qt::darkRed);
|
||||
pntrStop.setBrush(QBrush(Qt::darkRed));
|
||||
pntrStop.drawRect (6, 6, 12, 12);
|
||||
|
||||
pntrStop.drawRect(6, 6, 12, 12);
|
||||
QAction *pactStop = ptb->addAction (QIcon (pxStop), "Stop");
|
||||
connect (pactStop, SIGNAL (triggered ()), SLOT (Stop ()));
|
||||
|
||||
QAction *pactStop = ptb -> addAction(QIcon(pxStop), "Stop");
|
||||
connect(pactStop, SIGNAL(triggered()), SLOT(Stop()));
|
||||
QPixmap pxFulsh (24, 24);
|
||||
pxFulsh.fill (QColor (0, 0, 0, 0));
|
||||
QPainter pntrFlush (&pxFulsh);
|
||||
pntrFlush.setPen (Qt::darkGreen);
|
||||
pntrFlush.setBrush (QBrush (Qt::darkGreen));
|
||||
|
||||
QPixmap pxFulsh(24, 24);
|
||||
pxFulsh.fill(QColor(0, 0, 0, 0));
|
||||
QPainter pntrFlush(&pxFulsh);
|
||||
pntrFlush.setPen(Qt::darkGreen);
|
||||
pntrFlush.setBrush(QBrush(Qt::darkGreen));
|
||||
pntrFlush.drawRect (3, 4, 3, 16);
|
||||
|
||||
pntrFlush.drawRect(3, 4, 3, 16);
|
||||
polygon = QPolygon (3);
|
||||
polygon.setPoint (0, 9, 4);
|
||||
polygon.setPoint (1, 9, 20);
|
||||
polygon.setPoint (2, 21, 12);
|
||||
|
||||
polygon = QPolygon(3);
|
||||
polygon.setPoint(0, 9, 4);
|
||||
polygon.setPoint(1, 9, 20);
|
||||
polygon.setPoint(2, 21, 12);
|
||||
pntrFlush.drawPolygon (polygon, Qt::WindingFill);
|
||||
|
||||
pntrFlush.drawPolygon(polygon, Qt::WindingFill);
|
||||
QAction *pactFlush = ptb->addAction (QIcon (pxFulsh), "Flush");
|
||||
connect (pactFlush, SIGNAL (triggered ()), SLOT (Flush ()));
|
||||
|
||||
QAction *pactFlush = ptb -> addAction(QIcon(pxFulsh), "Flush");
|
||||
connect(pactFlush, SIGNAL(triggered()), SLOT(Flush()));
|
||||
QAction *pactClear = ptb->addAction ("Clear");
|
||||
connect (pactClear, SIGNAL (triggered ()), SLOT (ClearGraph ()));
|
||||
ptb->addSeparator ();
|
||||
|
||||
QAction *pactClear = ptb -> addAction("Clear");
|
||||
connect(pactClear, SIGNAL(triggered()), SLOT(ClearGraph()));
|
||||
ptb -> addSeparator();
|
||||
|
||||
m_pslider = new SeekSlider();
|
||||
m_pslider -> setOrientation(Qt::Horizontal);
|
||||
m_pslider -> setRange(0, 10000);
|
||||
m_pslider -> setTracking(false);
|
||||
m_pslider = new SeekSlider ();
|
||||
m_pslider->setOrientation (Qt::Horizontal);
|
||||
m_pslider->setRange (0, 10000);
|
||||
m_pslider->setTracking (false);
|
||||
|
||||
connect(m_pslider, SIGNAL(valueChanged(int)), SLOT(Seek(int)));
|
||||
ptb -> addWidget(m_pslider);
|
||||
ptb->addWidget (m_pslider);
|
||||
|
||||
QMenu *pmenu = menuBar() -> addMenu("&File");
|
||||
QMenu *pmenu = menuBar ()->addMenu ("&File");
|
||||
|
||||
QAction *pactOpen = pmenu -> addAction ("Open...", this, SLOT(Open()), QKeySequence::Open);
|
||||
QAction *pactOpen = pmenu->addAction ("Open...", this, SLOT (Open ()),
|
||||
QKeySequence::Open);
|
||||
addAction (pactOpen);
|
||||
|
||||
QAction *pactOpenMediaFile = pmenu -> addAction ("Open Media File...", this, SLOT(OpenMediaFile()), QKeySequence::Open);
|
||||
QAction *pactOpenMediaFile = pmenu->addAction ("Open Media File...", this,
|
||||
SLOT (OpenMediaFile ()),
|
||||
QKeySequence::Open);
|
||||
addAction (pactOpenMediaFile);
|
||||
|
||||
QAction *pactSave = pmenu -> addAction ("Save", this, SLOT(Save()), QKeySequence::Save);
|
||||
QAction *pactSave = pmenu->addAction ("Save", this, SLOT (Save ()),
|
||||
QKeySequence::Save);
|
||||
addAction (pactSave);
|
||||
|
||||
QAction *pactSaveAs = pmenu -> addAction ("Save As...", this, SLOT(SaveAs()), QKeySequence::SaveAs);
|
||||
QAction *pactSaveAs = pmenu->addAction ("Save As...", this, SLOT (SaveAs ()),
|
||||
QKeySequence::SaveAs);
|
||||
addAction (pactSaveAs);
|
||||
|
||||
pmenu -> addSeparator();
|
||||
pmenu -> addAction("Exit", this, SLOT(close()));
|
||||
pmenu->addSeparator ();
|
||||
pmenu->addAction ("Exit", this, SLOT (close ()));
|
||||
|
||||
pmenu = menuBar ()->addMenu ("&Graph");
|
||||
|
||||
pmenu = menuBar() -> addMenu("&Graph");
|
||||
pmenu->addAction (pactAdd);
|
||||
pmenu->addAction (pactOpenMediaFile);
|
||||
pmenu->addAction ("Open Media Uri...", this, SLOT (OpenMediaUri ()));
|
||||
pmenu->addSeparator ();
|
||||
pmenu->addAction (pactPlay);
|
||||
pmenu->addAction (pactPause);
|
||||
pmenu->addAction (pactStop);
|
||||
pmenu->addAction (pactFlush);
|
||||
pmenu->addSeparator ();
|
||||
pmenu->addAction (pactClear);
|
||||
|
||||
pmenu -> addAction(pactAdd);
|
||||
pmenu -> addAction(pactOpenMediaFile);
|
||||
pmenu -> addAction ("Open Media Uri...", this, SLOT(OpenMediaUri()));
|
||||
pmenu -> addSeparator();
|
||||
pmenu -> addAction(pactPlay);
|
||||
pmenu -> addAction(pactPause);
|
||||
pmenu -> addAction(pactStop);
|
||||
pmenu -> addAction(pactFlush);
|
||||
pmenu -> addSeparator();
|
||||
pmenu -> addAction(pactClear);
|
||||
|
||||
|
||||
pmenu = menuBar() -> addMenu("&Help");
|
||||
|
||||
pmenu -> addAction ("About pipeviz...", this, SLOT(About()));
|
||||
pmenu = menuBar ()->addMenu ("&Help");
|
||||
|
||||
pmenu->addAction ("About pipeviz...", this, SLOT (About ()));
|
||||
|
||||
m_pGraphDisplay = new GraphDisplay;
|
||||
|
||||
QScrollArea *pscroll = new QScrollArea;
|
||||
pscroll -> setWidget(m_pGraphDisplay);
|
||||
pscroll -> setWidgetResizable(false);
|
||||
m_pGraphDisplay -> resize(10000, 10000);
|
||||
m_pGraphDisplay -> m_pGraph = m_pGraph;
|
||||
setCentralWidget(pscroll);
|
||||
pscroll->setWidget (m_pGraphDisplay);
|
||||
pscroll->setWidgetResizable (false);
|
||||
m_pGraphDisplay->resize (10000, 10000);
|
||||
m_pGraphDisplay->m_pGraph = m_pGraph;
|
||||
setCentralWidget (pscroll);
|
||||
m_pstatusBar = new QStatusBar;
|
||||
setStatusBar(m_pstatusBar);
|
||||
m_pluginListDlg = new PluginsListDialog(m_pGraph->getPluginsList(), this);
|
||||
m_pluginListDlg->setModal(false);
|
||||
restoreGeometry(CustomSettings::mainWindowGeometry());
|
||||
startTimer(100);
|
||||
setStatusBar (m_pstatusBar);
|
||||
m_pluginListDlg = new PluginsListDialog (m_pGraph->getPluginsList (), this);
|
||||
m_pluginListDlg->setModal (false);
|
||||
restoreGeometry (CustomSettings::mainWindowGeometry ());
|
||||
startTimer (100);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
MainWindow::~MainWindow ()
|
||||
{
|
||||
CustomSettings::saveMainWindowGeometry(saveGeometry());
|
||||
CustomSettings::saveMainWindowGeometry (saveGeometry ());
|
||||
delete m_pluginListDlg;
|
||||
}
|
||||
|
||||
void MainWindow::AddPlugin()
|
||||
void
|
||||
MainWindow::AddPlugin ()
|
||||
{
|
||||
m_pluginListDlg->setGraph(m_pGraph.data());
|
||||
m_pluginListDlg->show();
|
||||
std::vector<ElementInfo> info = m_pGraph -> GetInfo();
|
||||
m_pGraphDisplay -> update(info);
|
||||
m_pluginListDlg->setGraph (m_pGraph.data ());
|
||||
m_pluginListDlg->show ();
|
||||
std::vector<ElementInfo> info = m_pGraph->GetInfo ();
|
||||
m_pGraphDisplay->update (info);
|
||||
}
|
||||
|
||||
void MainWindow::OpenMediaFile()
|
||||
void
|
||||
MainWindow::OpenMediaFile ()
|
||||
{
|
||||
QString dir = CustomSettings::lastIODirectory();
|
||||
QString dir = CustomSettings::lastIODirectory ();
|
||||
|
||||
QString path = QFileDialog::getOpenFileName(this, "Open File...", dir);
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
gchar *uri = gst_filename_to_uri(path.toStdString().c_str(), NULL);
|
||||
if(uri)
|
||||
{
|
||||
qDebug() << "Open Source file: " << path;
|
||||
QString path = QFileDialog::getOpenFileName (this, "Open File...", dir);
|
||||
if (!path.isEmpty ()) {
|
||||
gchar *uri = gst_filename_to_uri (path.toStdString ().c_str (), NULL);
|
||||
if (uri) {
|
||||
qDebug () << "Open Source file: " << path;
|
||||
|
||||
m_pGraph -> OpenUri(uri, NULL);
|
||||
g_free(uri);
|
||||
m_pGraph->OpenUri (uri, NULL);
|
||||
g_free (uri);
|
||||
|
||||
std::vector<ElementInfo> info = m_pGraph -> GetInfo();
|
||||
m_pGraphDisplay -> update(info);
|
||||
std::vector<ElementInfo> info = m_pGraph->GetInfo ();
|
||||
m_pGraphDisplay->update (info);
|
||||
|
||||
QString dir = QFileInfo(path).absoluteDir().absolutePath();
|
||||
CustomSettings::saveLastIODirectory(dir);
|
||||
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
|
||||
CustomSettings::saveLastIODirectory (dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::OpenMediaUri()
|
||||
void
|
||||
MainWindow::OpenMediaUri ()
|
||||
{
|
||||
QString uri = QInputDialog::getText(this, "Open Uri...", "Uri:");
|
||||
QString uri = QInputDialog::getText (this, "Open Uri...", "Uri:");
|
||||
|
||||
if(!uri.isEmpty())
|
||||
{
|
||||
qDebug() << "Open uri: " << uri;
|
||||
m_pGraph -> OpenUri(uri.toStdString().c_str(), NULL);
|
||||
if (!uri.isEmpty ()) {
|
||||
qDebug () << "Open uri: " << uri;
|
||||
m_pGraph->OpenUri (uri.toStdString ().c_str (), NULL);
|
||||
|
||||
std::vector<ElementInfo> info = m_pGraph -> GetInfo();
|
||||
m_pGraphDisplay -> update(info);
|
||||
std::vector<ElementInfo> info = m_pGraph->GetInfo ();
|
||||
m_pGraphDisplay->update (info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::Play()
|
||||
void
|
||||
MainWindow::Play ()
|
||||
{
|
||||
qDebug() << "Play";
|
||||
m_pGraph -> Play();
|
||||
qDebug () << "Play";
|
||||
m_pGraph->Play ();
|
||||
}
|
||||
|
||||
void MainWindow::Pause()
|
||||
void
|
||||
MainWindow::Pause ()
|
||||
{
|
||||
qDebug() << "Pause";
|
||||
m_pGraph -> Pause();
|
||||
qDebug () << "Pause";
|
||||
m_pGraph->Pause ();
|
||||
}
|
||||
|
||||
void MainWindow::Stop()
|
||||
void
|
||||
MainWindow::Stop ()
|
||||
{
|
||||
qDebug() << "Stop";
|
||||
m_pGraph -> Stop();
|
||||
qDebug () << "Stop";
|
||||
m_pGraph->Stop ();
|
||||
}
|
||||
|
||||
void MainWindow::Flush()
|
||||
void
|
||||
MainWindow::Flush ()
|
||||
{
|
||||
qDebug() << "Flush";
|
||||
qDebug () << "Flush";
|
||||
|
||||
if(m_pGraph -> m_pGraph)
|
||||
{
|
||||
gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_start());
|
||||
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());
|
||||
gst_element_send_event (GST_ELEMENT (m_pGraph->m_pGraph),
|
||||
gst_event_new_flush_stop ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ClearGraph()
|
||||
void
|
||||
MainWindow::ClearGraph ()
|
||||
{
|
||||
qDebug() << "ClearGraph";
|
||||
PipelineIE::Clear(m_pGraph);
|
||||
qDebug () << "ClearGraph";
|
||||
PipelineIE::Clear (m_pGraph);
|
||||
}
|
||||
|
||||
void MainWindow::Seek(int val)
|
||||
void
|
||||
MainWindow::Seek (int val)
|
||||
{
|
||||
if(m_pGraph -> SetPosition((double)(val) / m_pslider -> maximum()))
|
||||
qDebug() << "Seek to" << val;
|
||||
if (m_pGraph->SetPosition ((double) (val) / m_pslider->maximum ()))
|
||||
qDebug () << "Seek to" << val;
|
||||
else
|
||||
qDebug() << "Seek to" << val << "was FAILED";
|
||||
qDebug () << "Seek to" << val << "was FAILED";
|
||||
}
|
||||
|
||||
void MainWindow::timerEvent(QTimerEvent *)
|
||||
void
|
||||
MainWindow::timerEvent (QTimerEvent *)
|
||||
{
|
||||
GstState state;
|
||||
GstStateChangeReturn res = gst_element_get_state (m_pGraph -> m_pGraph, &state, NULL, GST_MSECOND);
|
||||
GstStateChangeReturn res = gst_element_get_state (m_pGraph->m_pGraph, &state,
|
||||
NULL,
|
||||
GST_MSECOND);
|
||||
|
||||
if(res == GST_STATE_CHANGE_SUCCESS)
|
||||
{
|
||||
if (res == GST_STATE_CHANGE_SUCCESS) {
|
||||
QString str;
|
||||
switch(state)
|
||||
{
|
||||
switch (state) {
|
||||
case GST_STATE_VOID_PENDING:
|
||||
str = "Pending";
|
||||
break;
|
||||
|
@ -299,79 +307,82 @@ void MainWindow::timerEvent(QTimerEvent *)
|
|||
break;
|
||||
};
|
||||
|
||||
m_pstatusBar -> showMessage(str);
|
||||
m_pstatusBar->showMessage (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pstatusBar -> showMessage(QString(gst_element_state_change_return_get_name(res)));
|
||||
else {
|
||||
m_pstatusBar->showMessage (
|
||||
QString (gst_element_state_change_return_get_name (res)));
|
||||
}
|
||||
|
||||
double pos = m_pGraph -> GetPosition();
|
||||
double pos = m_pGraph->GetPosition ();
|
||||
|
||||
if(m_pslider -> value() != (int)(m_pslider -> maximum() * pos))
|
||||
m_pslider -> setSliderPosition(m_pslider -> maximum() * pos);
|
||||
if (m_pslider->value () != (int) (m_pslider->maximum () * pos))
|
||||
m_pslider->setSliderPosition (m_pslider->maximum () * pos);
|
||||
|
||||
|
||||
m_pGraphDisplay -> update(m_pGraph -> GetInfo());
|
||||
m_pGraphDisplay->update (m_pGraph->GetInfo ());
|
||||
}
|
||||
|
||||
void MainWindow::Save()
|
||||
void
|
||||
MainWindow::Save ()
|
||||
{
|
||||
if(m_fileName.isEmpty())
|
||||
SaveAs();
|
||||
if (m_fileName.isEmpty ())
|
||||
SaveAs ();
|
||||
else {
|
||||
QFileInfo fileInfo(m_fileName);
|
||||
if (fileInfo.completeSuffix().isEmpty() || fileInfo.completeSuffix() != "gpi")
|
||||
QFileInfo fileInfo (m_fileName);
|
||||
if (fileInfo.completeSuffix ().isEmpty ()
|
||||
|| fileInfo.completeSuffix () != "gpi")
|
||||
m_fileName = m_fileName + ".gpi";
|
||||
|
||||
|
||||
PipelineIE::Export(m_pGraph, m_fileName);
|
||||
PipelineIE::Export (m_pGraph, m_fileName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SaveAs()
|
||||
void
|
||||
MainWindow::SaveAs ()
|
||||
{
|
||||
QString dir = CustomSettings::lastIODirectory();
|
||||
QString dir = CustomSettings::lastIODirectory ();
|
||||
|
||||
QString path = QFileDialog::getSaveFileName(this, "Save As...", dir, tr("*.gpi"));
|
||||
QString path = QFileDialog::getSaveFileName (this, "Save As...", dir,
|
||||
tr ("*.gpi"));
|
||||
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
if (!path.isEmpty ()) {
|
||||
m_fileName = path;
|
||||
Save();
|
||||
Save ();
|
||||
|
||||
QString dir = QFileInfo(path).absoluteDir().absolutePath();
|
||||
CustomSettings::saveLastIODirectory(dir);
|
||||
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
|
||||
CustomSettings::saveLastIODirectory (dir);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::Open()
|
||||
void
|
||||
MainWindow::Open ()
|
||||
{
|
||||
QString dir = CustomSettings::lastIODirectory();
|
||||
QString dir = CustomSettings::lastIODirectory ();
|
||||
|
||||
QString path = QFileDialog::getOpenFileName(this, "Open...", dir, tr("GPI (*.gpi *.xpm);;All files (*.*)"));
|
||||
QString path = QFileDialog::getOpenFileName (
|
||||
this, "Open...", dir, tr ("GPI (*.gpi *.xpm);;All files (*.*)"));
|
||||
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
if(PipelineIE::Import(m_pGraph, path))
|
||||
if (!path.isEmpty ()) {
|
||||
if (PipelineIE::Import (m_pGraph, path))
|
||||
m_fileName = path;
|
||||
|
||||
QString dir = QFileInfo(path).absoluteDir().absolutePath();
|
||||
CustomSettings::saveLastIODirectory(dir);
|
||||
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
|
||||
CustomSettings::saveLastIODirectory (dir);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::About()
|
||||
void
|
||||
MainWindow::About ()
|
||||
{
|
||||
QString message;
|
||||
message = "<center><b>pipeviz</b></center><br>";
|
||||
message = "<center>virinext@gmail.com</center><br>";
|
||||
message += QString("<center>Version: ") + VERSION_STR + "</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 += gst_version_string ();
|
||||
message += "</center>";
|
||||
|
||||
QMessageBox::about(this, "About", message);
|
||||
QMessageBox::about (this, "About", message);
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ class PluginsListDialog;
|
|||
class MainWindow: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void AddPlugin();
|
||||
void OpenMediaFile();
|
||||
void OpenMediaUri();
|
||||
|
@ -44,7 +44,7 @@ class MainWindow: public QMainWindow
|
|||
void ClearGraph();
|
||||
void About();
|
||||
|
||||
private:
|
||||
private:
|
||||
QSharedPointer<GraphManager> m_pGraph;
|
||||
GraphDisplay *m_pGraphDisplay;
|
||||
|
||||
|
@ -55,5 +55,4 @@ class MainWindow: public QMainWindow
|
|||
PluginsListDialog *m_pluginListDlg;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,96 +8,99 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
PadProperties::PadProperties(QSharedPointer<GraphManager> pGraphManager, const char *elementName, const char *padName,
|
||||
QWidget *parent, Qt::WindowFlags flags):
|
||||
QWidget(parent, flags)
|
||||
PadProperties::PadProperties (QSharedPointer<GraphManager> pGraphManager,
|
||||
const char *elementName, const char *padName,
|
||||
QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget (parent, flags)
|
||||
{
|
||||
setWindowTitle(QString(elementName) + "::" + padName + " properties");
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(pGraphManager -> m_pGraph), elementName);
|
||||
setWindowTitle (QString (elementName) + "::" + padName + " properties");
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN (pGraphManager->m_pGraph),
|
||||
elementName);
|
||||
|
||||
if(!element)
|
||||
if (!element)
|
||||
return;
|
||||
|
||||
GstPad *pad = gst_element_get_static_pad(GST_ELEMENT(element), padName);
|
||||
GstPad *pad = gst_element_get_static_pad (GST_ELEMENT (element), padName);
|
||||
|
||||
QGridLayout *play = new QGridLayout;
|
||||
|
||||
play -> addWidget(new QLabel("Name"), 0, 0);
|
||||
play->addWidget (new QLabel ("Name"), 0, 0);
|
||||
|
||||
QLabel *plbl = new QLabel(padName);
|
||||
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play -> addWidget(plbl, 0, 1);
|
||||
QLabel *plbl = new QLabel (padName);
|
||||
plbl->setTextInteractionFlags (
|
||||
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play->addWidget (plbl, 0, 1);
|
||||
|
||||
play -> addWidget(new QLabel("All caps:"), 1, 0);
|
||||
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);
|
||||
GstCaps *caps = gst_pad_get_caps (pad);
|
||||
#endif
|
||||
gchar *str;
|
||||
gchar *noSpecified = (gchar *)"not specified";
|
||||
if(caps)
|
||||
str = gst_caps_to_string(caps);
|
||||
gchar *noSpecified = (gchar *) "not specified";
|
||||
if (caps)
|
||||
str = gst_caps_to_string (caps);
|
||||
else
|
||||
str = noSpecified;
|
||||
|
||||
plbl = new QLabel(QString(str));
|
||||
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play -> addWidget(plbl, 1, 1);
|
||||
if(caps)
|
||||
{
|
||||
g_free(str);
|
||||
gst_caps_unref(caps);
|
||||
plbl = new QLabel (QString (str));
|
||||
plbl->setTextInteractionFlags (
|
||||
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play->addWidget (plbl, 1, 1);
|
||||
if (caps) {
|
||||
g_free (str);
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
play -> addWidget(new QLabel("Allowed caps:"), 2, 0);
|
||||
caps = gst_pad_get_allowed_caps(pad);
|
||||
play->addWidget (new QLabel ("Allowed caps:"), 2, 0);
|
||||
caps = gst_pad_get_allowed_caps (pad);
|
||||
str = NULL;
|
||||
if(caps)
|
||||
str = gst_caps_to_string(caps);
|
||||
if (caps)
|
||||
str = gst_caps_to_string (caps);
|
||||
else
|
||||
str = noSpecified;
|
||||
|
||||
plbl = new QLabel(QString(str));
|
||||
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play -> addWidget(plbl, 2, 1);
|
||||
if(caps)
|
||||
{
|
||||
g_free(str);
|
||||
gst_caps_unref(caps);
|
||||
plbl = new QLabel (QString (str));
|
||||
plbl->setTextInteractionFlags (
|
||||
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play->addWidget (plbl, 2, 1);
|
||||
if (caps) {
|
||||
g_free (str);
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
play -> addWidget(new QLabel("Current caps"), 3, 0);
|
||||
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);
|
||||
caps = gst_pad_get_negotiated_caps (pad);
|
||||
#endif
|
||||
str = NULL;
|
||||
if(caps)
|
||||
str = gst_caps_to_string(caps);
|
||||
if (caps)
|
||||
str = gst_caps_to_string (caps);
|
||||
else
|
||||
str = noSpecified;
|
||||
|
||||
plbl = new QLabel(QString(str));
|
||||
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play -> addWidget(plbl, 3, 1);
|
||||
if(caps)
|
||||
{
|
||||
g_free(str);
|
||||
gst_caps_unref(caps);
|
||||
plbl = new QLabel (QString (str));
|
||||
plbl->setTextInteractionFlags (
|
||||
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||
play->addWidget (plbl, 3, 1);
|
||||
if (caps) {
|
||||
g_free (str);
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
gst_object_unref(element);
|
||||
gst_object_unref (element);
|
||||
gst_object_unref (pad);
|
||||
|
||||
QVBoxLayout *pvblay = new QVBoxLayout;
|
||||
QWidget *pwgt = new QWidget(this);
|
||||
pwgt -> setLayout(play);
|
||||
QScrollArea *pscroll = new QScrollArea(this);
|
||||
pscroll -> setWidget(pwgt);
|
||||
QWidget *pwgt = new QWidget (this);
|
||||
pwgt->setLayout (play);
|
||||
QScrollArea *pscroll = new QScrollArea (this);
|
||||
pscroll->setWidget (pwgt);
|
||||
|
||||
pvblay -> addWidget(pscroll);
|
||||
pvblay->addWidget (pscroll);
|
||||
|
||||
setLayout(pvblay);
|
||||
setLayout (pvblay);
|
||||
}
|
||||
|
|
|
@ -13,5 +13,4 @@ public:
|
|||
, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,44 +9,42 @@
|
|||
|
||||
#include <QDebug>
|
||||
|
||||
static void clearPipeline(GstElement *pipeline)
|
||||
static void
|
||||
clearPipeline (GstElement *pipeline)
|
||||
{
|
||||
if(!pipeline)
|
||||
if (!pipeline)
|
||||
return;
|
||||
|
||||
GstIterator *iter;
|
||||
iter = gst_bin_iterate_elements (GST_BIN (pipeline));
|
||||
GstElement *element = NULL;
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
while (!done) {
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
GValue value = { 0 };
|
||||
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:
|
||||
{
|
||||
switch (gst_iterator_next (iter, (gpointer *) &element)) {
|
||||
case GST_ITERATOR_OK: {
|
||||
#endif
|
||||
gst_bin_remove(GST_BIN(pipeline), element);
|
||||
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)
|
||||
if (!iter)
|
||||
done = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case GST_ITERATOR_DONE:
|
||||
case GST_ITERATOR_RESYNC:
|
||||
case GST_ITERATOR_ERROR:
|
||||
{
|
||||
case GST_ITERATOR_ERROR: {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
@ -67,280 +65,254 @@ namespace
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
static void writeProperties(QXmlStreamWriter &xmlWriter, const GstElement *element)
|
||||
static void
|
||||
writeProperties (QXmlStreamWriter &xmlWriter, const GstElement *element)
|
||||
{
|
||||
GParamSpec **prop_specs;
|
||||
guint num_props;
|
||||
|
||||
prop_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element),
|
||||
prop_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
|
||||
&num_props);
|
||||
|
||||
if(!num_props)
|
||||
if (!num_props)
|
||||
return;
|
||||
|
||||
xmlWriter.writeStartElement("properties");
|
||||
xmlWriter.writeStartElement ("properties");
|
||||
|
||||
for(std::size_t i = 0; i<num_props; i++)
|
||||
{
|
||||
for (std::size_t i = 0; i < num_props; i++) {
|
||||
GParamSpec *param = prop_specs[i];
|
||||
|
||||
if((param -> flags & G_PARAM_READABLE) && (param -> flags & G_PARAM_WRITABLE))
|
||||
{
|
||||
if ((param->flags & G_PARAM_READABLE)
|
||||
&& (param->flags & G_PARAM_WRITABLE)) {
|
||||
GValue value = { 0 };
|
||||
g_value_init (&value, param -> value_type);
|
||||
g_value_init (&value, param->value_type);
|
||||
|
||||
g_object_get_property (G_OBJECT(element), param -> name, &value);
|
||||
g_object_get_property (G_OBJECT (element), param->name, &value);
|
||||
|
||||
if(!g_param_value_defaults(param, &value))
|
||||
{
|
||||
if (!g_param_value_defaults (param, &value)) {
|
||||
bool skip = false;
|
||||
QString propertyName = g_param_spec_get_name (param);
|
||||
QString propertyValue;
|
||||
|
||||
|
||||
switch (G_VALUE_TYPE (&value))
|
||||
{
|
||||
case G_TYPE_STRING:
|
||||
{
|
||||
switch (G_VALUE_TYPE (&value)) {
|
||||
case G_TYPE_STRING: {
|
||||
|
||||
const char *string_val = g_value_get_string (&value);
|
||||
if(string_val)
|
||||
if (string_val)
|
||||
propertyValue = string_val;
|
||||
else
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
case G_TYPE_BOOLEAN:
|
||||
{
|
||||
case G_TYPE_BOOLEAN: {
|
||||
gboolean bool_val = g_value_get_boolean (&value);
|
||||
propertyValue = QString::number(bool_val);
|
||||
propertyValue = QString::number (bool_val);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_ULONG:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_ulong(&value));
|
||||
case G_TYPE_ULONG: {
|
||||
propertyValue = QString::number (g_value_get_ulong (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_LONG:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_long(&value));
|
||||
case G_TYPE_LONG: {
|
||||
propertyValue = QString::number (g_value_get_long (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_uint(&value));
|
||||
case G_TYPE_UINT: {
|
||||
propertyValue = QString::number (g_value_get_uint (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_int(&value));
|
||||
case G_TYPE_INT: {
|
||||
propertyValue = QString::number (g_value_get_int (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT64:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_uint64(&value));
|
||||
case G_TYPE_UINT64: {
|
||||
propertyValue = QString::number (g_value_get_uint64 (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT64:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_int64(&value));
|
||||
case G_TYPE_INT64: {
|
||||
propertyValue = QString::number (g_value_get_int64 (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_FLOAT:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_float(&value));
|
||||
case G_TYPE_FLOAT: {
|
||||
propertyValue = QString::number (g_value_get_float (&value));
|
||||
break;
|
||||
}
|
||||
case G_TYPE_DOUBLE:
|
||||
{
|
||||
propertyValue = QString::number(g_value_get_double(&value));
|
||||
case G_TYPE_DOUBLE: {
|
||||
propertyValue = QString::number (g_value_get_double (&value));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
gchar *elementName = gst_element_get_name(element);
|
||||
default: {
|
||||
gchar *elementName = gst_element_get_name (element);
|
||||
|
||||
qDebug() << "property `" << propertyName << "` for `"
|
||||
qDebug () << "property `" << propertyName << "` for `"
|
||||
<< elementName << "` not supported";
|
||||
g_free(elementName);
|
||||
g_free (elementName);
|
||||
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
if(!skip)
|
||||
{
|
||||
xmlWriter.writeStartElement("property");
|
||||
xmlWriter.writeAttribute("name", propertyName);
|
||||
xmlWriter.writeAttribute("value", propertyValue);
|
||||
xmlWriter.writeEndElement();
|
||||
if (!skip) {
|
||||
xmlWriter.writeStartElement ("property");
|
||||
xmlWriter.writeAttribute ("name", propertyName);
|
||||
xmlWriter.writeAttribute ("value", propertyValue);
|
||||
xmlWriter.writeEndElement ();
|
||||
}
|
||||
g_value_reset(&value);
|
||||
g_value_reset (&value);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement ();
|
||||
|
||||
g_free(prop_specs);
|
||||
g_free (prop_specs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void loadProperties(QDomElement node, GstElement *element)
|
||||
static void
|
||||
loadProperties (QDomElement node, GstElement *element)
|
||||
{
|
||||
QDomNode child = node.firstChild();
|
||||
while(!child.isNull())
|
||||
{
|
||||
if(child.toElement().tagName() == "property")
|
||||
{
|
||||
QString name = child.toElement().attribute("name");
|
||||
QString value = child.toElement().attribute("value");
|
||||
QDomNode child = node.firstChild ();
|
||||
while (!child.isNull ()) {
|
||||
if (child.toElement ().tagName () == "property") {
|
||||
QString name = child.toElement ().attribute ("name");
|
||||
QString value = child.toElement ().attribute ("value");
|
||||
|
||||
GParamSpec *param = g_object_class_find_property(G_OBJECT_GET_CLASS (element),
|
||||
name.toStdString().c_str());
|
||||
GParamSpec *param = g_object_class_find_property (
|
||||
G_OBJECT_GET_CLASS (element), name.toStdString ().c_str ());
|
||||
|
||||
if(!param)
|
||||
{
|
||||
gchar *elementName = gst_element_get_name(element);
|
||||
qDebug() << "problem with setting property `" << name << "` for `" << elementName << "`";
|
||||
g_free(elementName);
|
||||
if (!param) {
|
||||
gchar *elementName = gst_element_get_name (element);
|
||||
qDebug () << "problem with setting property `" << name << "` for `"
|
||||
<< elementName << "`";
|
||||
g_free (elementName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!(param -> flags & G_PARAM_WRITABLE))
|
||||
if (!(param->flags & G_PARAM_WRITABLE))
|
||||
continue;
|
||||
|
||||
std::string tmpStr = name.toStdString();
|
||||
const char *propName = tmpStr.c_str();
|
||||
switch (param -> value_type)
|
||||
{
|
||||
case G_TYPE_STRING:
|
||||
{
|
||||
g_object_set(G_OBJECT(element), propName, value.toStdString().c_str(), NULL);
|
||||
std::string tmpStr = name.toStdString ();
|
||||
const char *propName = tmpStr.c_str ();
|
||||
switch (param->value_type) {
|
||||
case G_TYPE_STRING: {
|
||||
g_object_set (G_OBJECT (element), propName,
|
||||
value.toStdString ().c_str (), NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_BOOLEAN:
|
||||
{
|
||||
gboolean val = value.toInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_BOOLEAN: {
|
||||
gboolean val = value.toInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_ULONG:
|
||||
{
|
||||
gulong val = value.toULong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_ULONG: {
|
||||
gulong val = value.toULong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_LONG:
|
||||
{
|
||||
glong val = value.toLong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_LONG: {
|
||||
glong val = value.toLong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT:
|
||||
{
|
||||
guint val = value.toUInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_UINT: {
|
||||
guint val = value.toUInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT:
|
||||
{
|
||||
gint val = value.toInt();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_INT: {
|
||||
gint val = value.toInt ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_UINT64:
|
||||
{
|
||||
guint64 val = value.toULongLong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_UINT64: {
|
||||
guint64 val = value.toULongLong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_INT64:
|
||||
{
|
||||
gint64 val = value.toLongLong();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_INT64: {
|
||||
gint64 val = value.toLongLong ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_FLOAT:
|
||||
{
|
||||
gfloat val = value.toFloat();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_FLOAT: {
|
||||
gfloat val = value.toFloat ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
case G_TYPE_DOUBLE:
|
||||
{
|
||||
gdouble val = value.toDouble();
|
||||
g_object_set(G_OBJECT(element), propName, val, NULL);
|
||||
case G_TYPE_DOUBLE: {
|
||||
gdouble val = value.toDouble ();
|
||||
g_object_set (G_OBJECT (element), propName, val, NULL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
gchar *elementName = gst_element_get_name(element);
|
||||
qDebug() << "property `" << name << "` for `" << QString(elementName) << "` not supported";
|
||||
g_free(elementName);
|
||||
default: {
|
||||
gchar *elementName = gst_element_get_name (element);
|
||||
qDebug () << "property `" << name << "` for `"
|
||||
<< QString (elementName) << "` not supported";
|
||||
g_free (elementName);
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
child = child.nextSibling();
|
||||
child = child.nextSibling ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void create_requst_pad(GstElement *element, const QString &templateName, const QString &padName)
|
||||
static void
|
||||
create_requst_pad (GstElement *element, const QString &templateName,
|
||||
const QString &padName)
|
||||
{
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS(element);
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
||||
|
||||
GstPadTemplate *templ = gst_element_class_get_pad_template(klass, templateName.toStdString().c_str());
|
||||
GstPadTemplate *templ = gst_element_class_get_pad_template (
|
||||
klass, templateName.toStdString ().c_str ());
|
||||
|
||||
gst_element_request_pad(element, templ, padName.toStdString().c_str(), NULL);
|
||||
gst_element_request_pad (element, templ, padName.toStdString ().c_str (),
|
||||
NULL);
|
||||
}
|
||||
|
||||
bool PipelineIE::Export(QSharedPointer<GraphManager> pgraph, const QString &fileName)
|
||||
bool
|
||||
PipelineIE::Export (QSharedPointer<GraphManager> pgraph,
|
||||
const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
QFile file (fileName);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::warning(0, "Read only", "The file is in read only mode");
|
||||
if (!file.open (QIODevice::WriteOnly)) {
|
||||
QMessageBox::warning (0, "Read only", "The file is in read only mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector <ElementInfo> info = pgraph -> GetInfo();
|
||||
std::vector<ElementInfo> info = pgraph->GetInfo ();
|
||||
|
||||
QXmlStreamWriter xmlWriter;
|
||||
xmlWriter.setDevice(&file);
|
||||
xmlWriter.writeStartDocument();
|
||||
xmlWriter.writeStartElement("pipeline");
|
||||
xmlWriter.setDevice (&file);
|
||||
xmlWriter.writeStartDocument ();
|
||||
xmlWriter.writeStartElement ("pipeline");
|
||||
|
||||
for(std::size_t i=0; i<info.size(); i++)
|
||||
{
|
||||
xmlWriter.writeStartElement("element");
|
||||
for (std::size_t i = 0; i < info.size (); i++) {
|
||||
xmlWriter.writeStartElement ("element");
|
||||
|
||||
xmlWriter.writeAttribute("name", info[i].m_name.c_str());
|
||||
xmlWriter.writeAttribute("plugin-name", info[i].m_pluginName.c_str());
|
||||
xmlWriter.writeAttribute ("name", info[i].m_name.c_str ());
|
||||
xmlWriter.writeAttribute ("plugin-name", info[i].m_pluginName.c_str ());
|
||||
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(pgraph -> m_pGraph), info[i].m_name.c_str());
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN (pgraph->m_pGraph),
|
||||
info[i].m_name.c_str ());
|
||||
|
||||
for(std::size_t j=0; j<info[i].m_pads.size(); j++)
|
||||
{
|
||||
xmlWriter.writeStartElement("pad");
|
||||
for (std::size_t j = 0; j < info[i].m_pads.size (); j++) {
|
||||
xmlWriter.writeStartElement ("pad");
|
||||
|
||||
xmlWriter.writeAttribute("name", info[i].m_pads[j].m_name.c_str());
|
||||
xmlWriter.writeAttribute ("name", info[i].m_pads[j].m_name.c_str ());
|
||||
|
||||
GstPad *pad = gst_element_get_static_pad(element, info[i].m_pads[j].m_name.c_str());
|
||||
GstPad *pad = gst_element_get_static_pad (
|
||||
element, info[i].m_pads[j].m_name.c_str ());
|
||||
|
||||
GstPadTemplate *templ = gst_pad_get_pad_template(pad);
|
||||
GstPadTemplate *templ = gst_pad_get_pad_template (pad);
|
||||
if (templ) {
|
||||
QString presence;
|
||||
switch(GST_PAD_TEMPLATE_PRESENCE(templ))
|
||||
{
|
||||
switch (GST_PAD_TEMPLATE_PRESENCE (templ)) {
|
||||
case GST_PAD_ALWAYS:
|
||||
presence = "always";
|
||||
break;
|
||||
|
@ -354,65 +326,68 @@ bool PipelineIE::Export(QSharedPointer<GraphManager> pgraph, const QString &file
|
|||
break;
|
||||
};
|
||||
|
||||
xmlWriter.writeAttribute("presence", presence);
|
||||
xmlWriter.writeAttribute("template-name", GST_PAD_TEMPLATE_NAME_TEMPLATE(templ));
|
||||
} else {
|
||||
qDebug() << "Unable to find a template for" << info[i].m_pads[j].m_name.c_str();
|
||||
xmlWriter.writeAttribute("presence", "always");
|
||||
xmlWriter.writeAttribute("template-name", "");
|
||||
xmlWriter.writeAttribute ("presence", presence);
|
||||
xmlWriter.writeAttribute ("template-name",
|
||||
GST_PAD_TEMPLATE_NAME_TEMPLATE (templ));
|
||||
}
|
||||
gst_object_unref(pad);
|
||||
else {
|
||||
qDebug () << "Unable to find a template for"
|
||||
<< info[i].m_pads[j].m_name.c_str ();
|
||||
xmlWriter.writeAttribute ("presence", "always");
|
||||
xmlWriter.writeAttribute ("template-name", "");
|
||||
}
|
||||
gst_object_unref (pad);
|
||||
|
||||
if(info[i].m_connections[j].m_elementId != (size_t)-1 &&
|
||||
info[i].m_connections[j].m_padId != (size_t)-1)
|
||||
{
|
||||
if (info[i].m_connections[j].m_elementId != (size_t) -1
|
||||
&& info[i].m_connections[j].m_padId != (size_t) -1) {
|
||||
std::size_t elementPos, padPos;
|
||||
for(elementPos = 0; elementPos < info.size(); elementPos++)
|
||||
{
|
||||
if(info[elementPos].m_id == info[i].m_connections[j].m_elementId)
|
||||
{
|
||||
for(padPos = 0; padPos < info[elementPos].m_pads.size(); padPos++)
|
||||
if(info[elementPos].m_pads[padPos].m_id == info[i].m_connections[j].m_padId)
|
||||
for (elementPos = 0; elementPos < info.size (); elementPos++) {
|
||||
if (info[elementPos].m_id == info[i].m_connections[j].m_elementId) {
|
||||
for (padPos = 0; padPos < info[elementPos].m_pads.size (); padPos++)
|
||||
if (info[elementPos].m_pads[padPos].m_id
|
||||
== info[i].m_connections[j].m_padId)
|
||||
break;
|
||||
|
||||
if(padPos < info[elementPos].m_pads.size())
|
||||
if (padPos < info[elementPos].m_pads.size ())
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(elementPos < info.size() && padPos < info[elementPos].m_pads.size())
|
||||
{
|
||||
xmlWriter.writeStartElement("connected-to");
|
||||
xmlWriter.writeAttribute("element-name", info[elementPos].m_name.c_str());
|
||||
xmlWriter.writeAttribute("pad-name", info[elementPos].m_pads[padPos].m_name.c_str());
|
||||
xmlWriter.writeEndElement();
|
||||
if (elementPos < info.size ()
|
||||
&& padPos < info[elementPos].m_pads.size ()) {
|
||||
xmlWriter.writeStartElement ("connected-to");
|
||||
xmlWriter.writeAttribute ("element-name",
|
||||
info[elementPos].m_name.c_str ());
|
||||
xmlWriter.writeAttribute (
|
||||
"pad-name", info[elementPos].m_pads[padPos].m_name.c_str ());
|
||||
xmlWriter.writeEndElement ();
|
||||
}
|
||||
}
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement ();
|
||||
}
|
||||
|
||||
writeProperties(xmlWriter, element);
|
||||
gst_object_unref(element);
|
||||
writeProperties (xmlWriter, element);
|
||||
gst_object_unref (element);
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement ();
|
||||
}
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndDocument();
|
||||
xmlWriter.writeEndElement ();
|
||||
xmlWriter.writeEndDocument ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool PipelineIE::Import(QSharedPointer<GraphManager> pgraph, const QString &fileName)
|
||||
bool
|
||||
PipelineIE::Import (QSharedPointer<GraphManager> pgraph,
|
||||
const QString &fileName)
|
||||
{
|
||||
GstElement *pipeline = pgraph -> m_pGraph;
|
||||
QFile file(fileName);
|
||||
if(!file.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QMessageBox::warning(0, "Open failed",
|
||||
QString("Cannot read file ") + fileName +
|
||||
": " + file.errorString());
|
||||
GstElement *pipeline = pgraph->m_pGraph;
|
||||
QFile file (fileName);
|
||||
if (!file.open (QFile::ReadOnly | QFile::Text)) {
|
||||
QMessageBox::warning (
|
||||
0, "Open failed",
|
||||
QString ("Cannot read file ") + fileName + ": " + file.errorString ());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -422,192 +397,195 @@ bool PipelineIE::Import(QSharedPointer<GraphManager> pgraph, const QString &file
|
|||
int errorColumn;
|
||||
|
||||
QDomDocument doc;
|
||||
if(!doc.setContent(&file, false, &errorStr, &errorLine, &errorColumn))
|
||||
{
|
||||
QMessageBox::warning(0, "Xml parsing failed",
|
||||
QString("Parse error at line ") + QString::number(errorLine) + ", "
|
||||
"column " + QString::number(errorColumn) + ": " + errorStr);
|
||||
if (!doc.setContent (&file, false, &errorStr, &errorLine, &errorColumn)) {
|
||||
QMessageBox::warning (
|
||||
0, "Xml parsing failed",
|
||||
QString ("Parse error at line ") + QString::number (errorLine) + ", "
|
||||
"column " + QString::number (errorColumn) + ": " + errorStr);
|
||||
return false;
|
||||
}
|
||||
|
||||
clearPipeline(pipeline);
|
||||
clearPipeline (pipeline);
|
||||
|
||||
QDomElement root = doc.documentElement();
|
||||
QDomElement root = doc.documentElement ();
|
||||
|
||||
if(root.tagName() != "pipeline")
|
||||
{
|
||||
QMessageBox::warning(0, "Parsing failed", "Is invalid pipeline file");
|
||||
if (root.tagName () != "pipeline") {
|
||||
QMessageBox::warning (0, "Parsing failed", "Is invalid pipeline file");
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomNode child = root.firstChild();
|
||||
QDomNode child = root.firstChild ();
|
||||
|
||||
std::vector<Connection> connections;
|
||||
while(!child.isNull())
|
||||
{
|
||||
if(child.toElement().tagName() == "element")
|
||||
{
|
||||
QDomElement elNode = child.toElement();
|
||||
while (!child.isNull ()) {
|
||||
if (child.toElement ().tagName () == "element") {
|
||||
QDomElement elNode = child.toElement ();
|
||||
|
||||
GstElement *pel = gst_element_factory_make (
|
||||
elNode.attribute ("plugin-name").toStdString ().c_str (),
|
||||
elNode.attribute ("name").toStdString ().c_str ());
|
||||
|
||||
GstElement *pel = gst_element_factory_make(elNode.attribute("plugin-name").toStdString().c_str(),
|
||||
elNode.attribute("name").toStdString().c_str());
|
||||
if (!pel) {
|
||||
QMessageBox::warning (
|
||||
0,
|
||||
"Element creation failed",
|
||||
QString ("Could not create element of `")
|
||||
+ elNode.attribute ("plugin-name") + "` with name `"
|
||||
+ elNode.attribute ("name") + "`");
|
||||
|
||||
if(!pel)
|
||||
{
|
||||
QMessageBox::warning(0, "Element creation failed",
|
||||
QString("Could not create element of `") +
|
||||
elNode.attribute("plugin-name") + "` with name `" +
|
||||
elNode.attribute("name") + "`");
|
||||
|
||||
child = child.nextSibling();
|
||||
child = child.nextSibling ();
|
||||
continue;
|
||||
}
|
||||
|
||||
bool res = gst_bin_add(GST_BIN(pipeline), pel);
|
||||
bool res = gst_bin_add (GST_BIN (pipeline), pel);
|
||||
|
||||
if(!res)
|
||||
{
|
||||
QMessageBox::warning(0, "Element insertion failed",
|
||||
QString("Could not insert element `") +
|
||||
elNode.attribute("name") + "` to pipeline");
|
||||
if (!res) {
|
||||
QMessageBox::warning (
|
||||
0,
|
||||
"Element insertion failed",
|
||||
QString ("Could not insert element `") + elNode.attribute ("name")
|
||||
+ "` to pipeline");
|
||||
|
||||
child = child.nextSibling();
|
||||
child = child.nextSibling ();
|
||||
continue;
|
||||
}
|
||||
|
||||
gst_element_sync_state_with_parent(pel);
|
||||
gst_element_sync_state_with_parent (pel);
|
||||
|
||||
|
||||
QDomNode elementChild = elNode.firstChild();
|
||||
while(!elementChild.isNull())
|
||||
{
|
||||
if(elementChild.toElement().tagName() == "pad")
|
||||
{
|
||||
QDomNode padChild = elementChild.firstChild();
|
||||
QDomElement elPad = elementChild.toElement();
|
||||
QDomNode elementChild = elNode.firstChild ();
|
||||
while (!elementChild.isNull ()) {
|
||||
if (elementChild.toElement ().tagName () == "pad") {
|
||||
QDomNode padChild = elementChild.firstChild ();
|
||||
QDomElement elPad = elementChild.toElement ();
|
||||
// GstPadPresence presence = GST_PAD_ALWAYS;
|
||||
|
||||
QString templaneName;
|
||||
if(elPad.attribute("presence") == "request")
|
||||
create_requst_pad(pel, elPad.attribute("template-name"), elPad.attribute("name"));
|
||||
if (elPad.attribute ("presence") == "request")
|
||||
create_requst_pad (pel, elPad.attribute ("template-name"),
|
||||
elPad.attribute ("name"));
|
||||
|
||||
while(!padChild.isNull())
|
||||
{
|
||||
if(padChild.toElement().tagName() == "connected-to")
|
||||
{
|
||||
while (!padChild.isNull ()) {
|
||||
if (padChild.toElement ().tagName () == "connected-to") {
|
||||
bool isExists = false;
|
||||
QDomElement elCoonnectedTo = padChild.toElement();
|
||||
QDomElement elCoonnectedTo = padChild.toElement ();
|
||||
|
||||
for(std::size_t i=0; i<connections.size(); i++)
|
||||
{
|
||||
if((connections[i].element1 == elNode.attribute("name").toStdString() &&
|
||||
connections[i].element2 == elCoonnectedTo.attribute("element-name").toStdString() &&
|
||||
connections[i].pad1 == elPad.attribute("name").toStdString() &&
|
||||
connections[i].pad2 == elCoonnectedTo.attribute("pad-name").toStdString())
|
||||
||
|
||||
(connections[i].element2 == elNode.attribute("name").toStdString() &&
|
||||
connections[i].element1 == elCoonnectedTo.attribute("element-name").toStdString() &&
|
||||
connections[i].pad2 == elPad.attribute("name").toStdString() &&
|
||||
connections[i].pad1 ==elCoonnectedTo.attribute("pad-name").toStdString())
|
||||
)
|
||||
{
|
||||
for (std::size_t i = 0; i < connections.size (); i++) {
|
||||
if ((connections[i].element1
|
||||
== elNode.attribute ("name").toStdString ()
|
||||
&& connections[i].element2
|
||||
== elCoonnectedTo.attribute ("element-name").toStdString ()
|
||||
&& connections[i].pad1
|
||||
== elPad.attribute ("name").toStdString ()
|
||||
&& connections[i].pad2
|
||||
== elCoonnectedTo.attribute ("pad-name").toStdString ())
|
||||
|| (connections[i].element2
|
||||
== elNode.attribute ("name").toStdString ()
|
||||
&& connections[i].element1
|
||||
== elCoonnectedTo.attribute ("element-name").toStdString ()
|
||||
&& connections[i].pad2
|
||||
== elPad.attribute ("name").toStdString ()
|
||||
&& connections[i].pad1
|
||||
== elCoonnectedTo.attribute ("pad-name").toStdString ())) {
|
||||
isExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isExists)
|
||||
{
|
||||
if (!isExists) {
|
||||
Connection newConnetion;
|
||||
newConnetion.element1 = elNode.attribute("name").toStdString();
|
||||
newConnetion.element2 = padChild.toElement().attribute("element-name").toStdString();
|
||||
newConnetion.pad1 = elementChild.toElement().attribute("name").toStdString();
|
||||
newConnetion.pad2 = padChild.toElement().attribute("pad-name").toStdString();
|
||||
newConnetion.element1 =
|
||||
elNode.attribute ("name").toStdString ();
|
||||
newConnetion.element2 = padChild.toElement ().attribute (
|
||||
"element-name").toStdString ();
|
||||
newConnetion.pad1 =
|
||||
elementChild.toElement ().attribute ("name").toStdString ();
|
||||
newConnetion.pad2 =
|
||||
padChild.toElement ().attribute ("pad-name").toStdString ();
|
||||
|
||||
connections.push_back(newConnetion);
|
||||
connections.push_back (newConnetion);
|
||||
}
|
||||
}
|
||||
padChild = padChild.nextSibling();
|
||||
padChild = padChild.nextSibling ();
|
||||
}
|
||||
}
|
||||
else if(elementChild.toElement().tagName() == "properties")
|
||||
{
|
||||
loadProperties(elementChild.toElement(), pel);
|
||||
else if (elementChild.toElement ().tagName () == "properties") {
|
||||
loadProperties (elementChild.toElement (), pel);
|
||||
}
|
||||
elementChild = elementChild.nextSibling();
|
||||
elementChild = elementChild.nextSibling ();
|
||||
}
|
||||
}
|
||||
child = child.nextSibling();
|
||||
child = child.nextSibling ();
|
||||
}
|
||||
|
||||
std::size_t maxStarts = 5;
|
||||
bool setReady = true;
|
||||
for(std::size_t k=0; k<maxStarts; k++)
|
||||
{
|
||||
if(connections.empty())
|
||||
for (std::size_t k = 0; k < maxStarts; k++) {
|
||||
if (connections.empty ())
|
||||
break;
|
||||
|
||||
if(k > 0)
|
||||
if (k > 0)
|
||||
setReady = false;
|
||||
|
||||
while(true)
|
||||
{
|
||||
std::size_t i=0;
|
||||
for(; i<connections.size(); i++)
|
||||
{
|
||||
GstElement *el1 = gst_bin_get_by_name (GST_BIN(pipeline), connections[i].element1.c_str());
|
||||
GstElement *el2 = gst_bin_get_by_name (GST_BIN(pipeline), connections[i].element2.c_str());
|
||||
while (true) {
|
||||
std::size_t i = 0;
|
||||
for (; i < connections.size (); i++) {
|
||||
GstElement *el1 = gst_bin_get_by_name (
|
||||
GST_BIN (pipeline), connections[i].element1.c_str ());
|
||||
GstElement *el2 = gst_bin_get_by_name (
|
||||
GST_BIN (pipeline), connections[i].element2.c_str ());
|
||||
|
||||
if(!el1 || !el2)
|
||||
{
|
||||
QMessageBox::warning(0, "Internal error",
|
||||
QString("Could not find one of elements `") +
|
||||
QString(connections[i].element1.c_str()) + "`, `" +
|
||||
QString(connections[i].element2.c_str()) + "`");
|
||||
if (!el1 || !el2) {
|
||||
QMessageBox::warning (
|
||||
0,
|
||||
"Internal error",
|
||||
QString ("Could not find one of elements `")
|
||||
+ QString (connections[i].element1.c_str ()) + "`, `"
|
||||
+ QString (connections[i].element2.c_str ()) + "`");
|
||||
|
||||
gst_object_unref(el1);
|
||||
gst_object_unref(el2);
|
||||
gst_object_unref (el1);
|
||||
gst_object_unref (el2);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GstPad *pad1 = gst_element_get_static_pad(el1, connections[i].pad1.c_str());
|
||||
GstPad *pad2 = gst_element_get_static_pad(el2, connections[i].pad2.c_str());
|
||||
GstPad *pad1 = gst_element_get_static_pad (
|
||||
el1, connections[i].pad1.c_str ());
|
||||
GstPad *pad2 = gst_element_get_static_pad (
|
||||
el2, connections[i].pad2.c_str ());
|
||||
|
||||
if(pad1 && pad2)
|
||||
{
|
||||
if(GST_PAD_IS_SRC(pad1))
|
||||
gst_element_link_pads(el1, connections[i].pad1.c_str(), el2, connections[i].pad2.c_str());
|
||||
if (pad1 && pad2) {
|
||||
if (GST_PAD_IS_SRC (pad1))
|
||||
gst_element_link_pads (el1, connections[i].pad1.c_str (), el2,
|
||||
connections[i].pad2.c_str ());
|
||||
else
|
||||
gst_element_link_pads(el2, connections[i].pad2.c_str(), el1, connections[i].pad1.c_str());
|
||||
gst_element_link_pads (el2, connections[i].pad2.c_str (), el1,
|
||||
connections[i].pad1.c_str ());
|
||||
|
||||
gst_object_unref(pad1);
|
||||
gst_object_unref(pad2);
|
||||
connections.erase(connections.begin() + i);
|
||||
gst_object_unref (pad1);
|
||||
gst_object_unref (pad2);
|
||||
connections.erase (connections.begin () + i);
|
||||
|
||||
gst_object_unref(el1);
|
||||
gst_object_unref(el2);
|
||||
gst_object_unref (el1);
|
||||
gst_object_unref (el2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(pad1)
|
||||
gst_object_unref(pad1);
|
||||
if (pad1)
|
||||
gst_object_unref (pad1);
|
||||
|
||||
if(pad2)
|
||||
gst_object_unref(pad2);
|
||||
if (pad2)
|
||||
gst_object_unref (pad2);
|
||||
|
||||
gst_object_unref(el1);
|
||||
gst_object_unref(el2);
|
||||
gst_object_unref (el1);
|
||||
gst_object_unref (el2);
|
||||
}
|
||||
|
||||
if(i == connections.size())
|
||||
if (i == connections.size ())
|
||||
break;
|
||||
}
|
||||
|
||||
if(!connections.empty())
|
||||
{
|
||||
gst_element_set_state(pipeline, GST_STATE_PAUSED);
|
||||
if (!connections.empty ()) {
|
||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
|
||||
GstState state;
|
||||
gst_element_get_state (pipeline, &state, NULL, GST_MSECOND * 2500);
|
||||
|
@ -615,15 +593,16 @@ bool PipelineIE::Import(QSharedPointer<GraphManager> pgraph, const QString &file
|
|||
|
||||
}
|
||||
|
||||
if(setReady)
|
||||
gst_element_set_state(pipeline, GST_STATE_READY);
|
||||
if (setReady)
|
||||
gst_element_set_state (pipeline, GST_STATE_READY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PipelineIE::Clear(QSharedPointer<GraphManager> pgraph)
|
||||
bool
|
||||
PipelineIE::Clear (QSharedPointer<GraphManager> pgraph)
|
||||
{
|
||||
GstElement *pipeline = pgraph -> m_pGraph;
|
||||
clearPipeline(pipeline);
|
||||
GstElement *pipeline = pgraph->m_pGraph;
|
||||
clearPipeline (pipeline);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14,31 +14,34 @@
|
|||
|
||||
#include <QDebug>
|
||||
|
||||
static gint plugins_sort_cb (gconstpointer a, gconstpointer b)
|
||||
static gint
|
||||
plugins_sort_cb (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
Plugin* p1 = (Plugin*)a;
|
||||
Plugin* p2 = (Plugin*)b;
|
||||
qDebug() << "Sort p1: " << p1 -> getName() << " and p2: " << p2 -> getName();
|
||||
if (p1->getRank() > p2->getRank())
|
||||
Plugin* p1 = (Plugin*) a;
|
||||
Plugin* p2 = (Plugin*) b;
|
||||
qDebug () << "Sort p1: " << p1->getName () << " and p2: " << p2->getName ();
|
||||
if (p1->getRank () > p2->getRank ())
|
||||
return 1;
|
||||
else if (p1->getRank() == p2->getRank()) {
|
||||
else if (p1->getRank () == p2->getRank ()) {
|
||||
return 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PluginsList::PluginsList()
|
||||
PluginsList::PluginsList ()
|
||||
{
|
||||
init();
|
||||
init ();
|
||||
}
|
||||
|
||||
PluginsList::~PluginsList()
|
||||
PluginsList::~PluginsList ()
|
||||
{
|
||||
//g_list_free(m_pluginsList);
|
||||
}
|
||||
|
||||
void PluginsList::init()
|
||||
void
|
||||
PluginsList::init ()
|
||||
{
|
||||
std::size_t num = 0;
|
||||
GList *plugins;
|
||||
|
@ -47,33 +50,30 @@ void PluginsList::init()
|
|||
#if GST_VERSION_MAJOR >= 1
|
||||
registry = gst_registry_get();
|
||||
#else
|
||||
registry = gst_registry_get_default();
|
||||
registry = gst_registry_get_default ();
|
||||
#endif
|
||||
plugins = gst_registry_get_plugin_list(registry);
|
||||
while(plugins)
|
||||
{
|
||||
plugins = gst_registry_get_plugin_list (registry);
|
||||
while (plugins) {
|
||||
GstPlugin *plugin;
|
||||
plugin = (GstPlugin *) (plugins->data);
|
||||
plugins = g_list_next (plugins);
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
registry = gst_registry_get();
|
||||
#else
|
||||
registry = gst_registry_get_default();
|
||||
registry = gst_registry_get_default ();
|
||||
#endif
|
||||
GList *features = gst_registry_get_feature_list_by_plugin (registry,
|
||||
gst_plugin_get_name (plugin));
|
||||
GList *features = gst_registry_get_feature_list_by_plugin (
|
||||
registry, gst_plugin_get_name (plugin));
|
||||
|
||||
while(features)
|
||||
{
|
||||
while (features) {
|
||||
GstPluginFeature *feature;
|
||||
feature = GST_PLUGIN_FEATURE (features->data);
|
||||
if(GST_IS_ELEMENT_FACTORY (feature))
|
||||
{
|
||||
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
||||
GstElementFactory *factory;
|
||||
factory = GST_ELEMENT_FACTORY (feature);
|
||||
int rank = gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(factory));
|
||||
Plugin* p = new Plugin(GST_OBJECT_NAME (factory), rank);
|
||||
m_pluginsList = g_list_append(m_pluginsList, p);
|
||||
int rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
|
||||
Plugin* p = new Plugin (GST_OBJECT_NAME (factory), rank);
|
||||
m_pluginsList = g_list_append (m_pluginsList, p);
|
||||
num++;
|
||||
}
|
||||
|
||||
|
@ -82,69 +82,75 @@ void PluginsList::init()
|
|||
}
|
||||
}
|
||||
|
||||
GList* PluginsList::getSortedByRank()
|
||||
GList*
|
||||
PluginsList::getSortedByRank ()
|
||||
{
|
||||
GList* sorted_list = g_list_sort(m_pluginsList, plugins_sort_cb);
|
||||
GList* sorted_list = g_list_sort (m_pluginsList, plugins_sort_cb);
|
||||
return sorted_list;
|
||||
}
|
||||
|
||||
GList* PluginsList::getPluginListByCaps(GstPadDirection direction, GstCaps* caps)
|
||||
GList*
|
||||
PluginsList::getPluginListByCaps (GstPadDirection direction, GstCaps* caps)
|
||||
{
|
||||
GList * caps_plugins_list = NULL;
|
||||
GList *l,*p;
|
||||
GList *l, *p;
|
||||
|
||||
for (l = m_pluginsList; l != NULL; l = l->next) {
|
||||
Plugin* plugin = (Plugin*)(l->data);
|
||||
GstElementFactory* factory = gst_element_factory_find(plugin->getName().toStdString().c_str());
|
||||
Plugin* plugin = (Plugin*) (l->data);
|
||||
GstElementFactory* factory = gst_element_factory_find (
|
||||
plugin->getName ().toStdString ().c_str ());
|
||||
if (factory) {
|
||||
const GList* pads = gst_element_factory_get_static_pad_templates(factory);
|
||||
for (p = (GList*)pads; p != NULL; p = p->next) {
|
||||
GstStaticPadTemplate* padTemplate = (GstStaticPadTemplate*)(p->data);
|
||||
if (padTemplate->direction == direction && gst_caps_can_intersect(caps, padTemplate->static_caps.caps))
|
||||
caps_plugins_list = g_list_append(caps_plugins_list, plugin);
|
||||
const GList* pads = gst_element_factory_get_static_pad_templates (
|
||||
factory);
|
||||
for (p = (GList*) pads; p != NULL; p = p->next) {
|
||||
GstStaticPadTemplate* padTemplate = (GstStaticPadTemplate*) (p->data);
|
||||
if (padTemplate->direction == direction
|
||||
&& gst_caps_can_intersect (caps, padTemplate->static_caps.caps))
|
||||
caps_plugins_list = g_list_append (caps_plugins_list, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
return caps_plugins_list;
|
||||
}
|
||||
|
||||
PluginsListDialog::PluginsListDialog(PluginsList* pluginList, QWidget *pwgt, Qt::WindowFlags f):
|
||||
QDialog(pwgt, f)
|
||||
, m_pPluginsList(pluginList)
|
||||
, m_pGraph(NULL)
|
||||
PluginsListDialog::PluginsListDialog (PluginsList* pluginList, QWidget *pwgt,
|
||||
Qt::WindowFlags f)
|
||||
: QDialog (pwgt, f),
|
||||
m_pPluginsList (pluginList),
|
||||
m_pGraph (NULL)
|
||||
{
|
||||
m_pPlugins = new QListWidget;
|
||||
m_pPlugins->setSortingEnabled(true);
|
||||
m_pPlugins->setSortingEnabled (true);
|
||||
m_plblInfo = new QLabel;
|
||||
|
||||
m_plblInfo -> setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
m_plblInfo -> setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
m_plblInfo->setTextInteractionFlags (Qt::TextSelectableByMouse);
|
||||
m_plblInfo->setAlignment (Qt::AlignLeft | Qt::AlignTop);
|
||||
QScrollArea *pscroll = new QScrollArea;
|
||||
pscroll -> setWidget(m_plblInfo);
|
||||
m_plblInfo -> resize(pscroll -> size());
|
||||
pscroll->setWidget (m_plblInfo);
|
||||
m_plblInfo->resize (pscroll->size ());
|
||||
|
||||
QHBoxLayout *phblay = new QHBoxLayout;
|
||||
|
||||
phblay -> addWidget(m_pPlugins, 1);
|
||||
phblay -> addWidget(pscroll, 2);
|
||||
phblay->addWidget (m_pPlugins, 1);
|
||||
phblay->addWidget (pscroll, 2);
|
||||
|
||||
InitPluginsList();
|
||||
InitPluginsList ();
|
||||
|
||||
QHBoxLayout *phblayFind = new QHBoxLayout;
|
||||
|
||||
QLineEdit *ple = new QLineEdit;
|
||||
phblayFind -> addWidget(ple);
|
||||
phblayFind -> addStretch(1);
|
||||
phblayFind->addWidget (ple);
|
||||
phblayFind->addStretch (1);
|
||||
|
||||
ple -> setPlaceholderText("Search...");
|
||||
ple->setPlaceholderText ("Search...");
|
||||
|
||||
QVBoxLayout *pvblay = new QVBoxLayout;
|
||||
pvblay -> addLayout(phblayFind);
|
||||
pvblay -> addLayout(phblay);
|
||||
pvblay->addLayout (phblayFind);
|
||||
pvblay->addLayout (phblay);
|
||||
|
||||
setLayout(pvblay);
|
||||
setLayout (pvblay);
|
||||
|
||||
setWindowTitle("Add plugin");
|
||||
setWindowTitle ("Add plugin");
|
||||
|
||||
QObject::connect(m_pPlugins, SIGNAL(currentItemChanged (QListWidgetItem *, QListWidgetItem *)),
|
||||
this, SLOT(showInfo(QListWidgetItem *, QListWidgetItem *)));
|
||||
|
@ -154,148 +160,160 @@ QDialog(pwgt, f)
|
|||
|
||||
QObject::connect(ple, SIGNAL(textChanged(const QString &)), this, SLOT(filterPlagins(const QString &)));
|
||||
|
||||
installEventFilter(this);
|
||||
installEventFilter (this);
|
||||
}
|
||||
|
||||
PluginsListDialog::~PluginsListDialog()
|
||||
PluginsListDialog::~PluginsListDialog ()
|
||||
{
|
||||
if (m_pPluginsList)
|
||||
delete m_pPluginsList;
|
||||
}
|
||||
|
||||
void PluginsListDialog::showInfo(QListWidgetItem *pitem, QListWidgetItem *previous)
|
||||
void
|
||||
PluginsListDialog::showInfo (QListWidgetItem *pitem, QListWidgetItem *previous)
|
||||
{
|
||||
qDebug() << "Show Info: " << pitem -> text();
|
||||
m_plblInfo -> clear();
|
||||
qDebug () << "Show Info: " << pitem->text ();
|
||||
m_plblInfo->clear ();
|
||||
QString descr;
|
||||
descr += "<b>Plugin details</b><hr>";
|
||||
|
||||
GstElementFactory *factory = gst_element_factory_find(pitem -> text().toStdString().c_str());
|
||||
if(!factory)
|
||||
{
|
||||
qDebug() << "warning: " << pitem -> text() << " Not Found";
|
||||
GstElementFactory *factory = gst_element_factory_find (
|
||||
pitem->text ().toStdString ().c_str ());
|
||||
if (!factory) {
|
||||
qDebug () << "warning: " << pitem->text () << " Not Found";
|
||||
return;
|
||||
}
|
||||
|
||||
factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE(factory)));
|
||||
if(!factory)
|
||||
{
|
||||
qDebug() << "warning: " << pitem -> text() << " Not Found";
|
||||
factory = GST_ELEMENT_FACTORY (
|
||||
gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory)));
|
||||
if (!factory) {
|
||||
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;
|
||||
const gchar* plugin_name = GST_PLUGIN_FEATURE (factory)->plugin_name;
|
||||
if (!plugin_name) {
|
||||
return;
|
||||
}
|
||||
GstPlugin* plugin = gst_default_registry_find_plugin(plugin_name);
|
||||
GstPlugin* plugin = gst_default_registry_find_plugin (plugin_name);
|
||||
#endif
|
||||
if(!plugin)
|
||||
{
|
||||
qDebug() << "warning: " << pitem -> text() << " Not Found";
|
||||
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 : "";
|
||||
const gchar *release_date =
|
||||
(plugin->desc.release_datetime) ? plugin->desc.release_datetime : "";
|
||||
#endif
|
||||
const gchar *filename = gst_plugin_get_filename(plugin);
|
||||
const gchar *filename = gst_plugin_get_filename (plugin);
|
||||
|
||||
descr += "<b>Name</b>: " + QString(gst_plugin_get_name(plugin)) + "<br>";
|
||||
descr += "<b>Description</b>: " + QString(gst_plugin_get_description(plugin)) + "<br>";
|
||||
descr += "<b>Filename</b>: " + QString((filename != NULL) ? filename : "(null)") + "<br>";
|
||||
descr += "<b>Version</b>: " + QString(gst_plugin_get_version (plugin)) + "<br>";
|
||||
descr += "<b>License</b>: " + QString(gst_plugin_get_license (plugin)) + "<br>";
|
||||
descr += "<b>Source module</b>: " + QString(gst_plugin_get_source (plugin)) + "<br>";
|
||||
descr += "<b>Name</b>: " + QString (gst_plugin_get_name (plugin)) + "<br>";
|
||||
descr += "<b>Description</b>: "
|
||||
+ QString (gst_plugin_get_description (plugin)) + "<br>";
|
||||
descr += "<b>Filename</b>: "
|
||||
+ QString ((filename != NULL) ? filename : "(null)") + "<br>";
|
||||
descr += "<b>Version</b>: " + QString (gst_plugin_get_version (plugin))
|
||||
+ "<br>";
|
||||
descr += "<b>License</b>: " + QString (gst_plugin_get_license (plugin))
|
||||
+ "<br>";
|
||||
descr += "<b>Source module</b>: " + QString (gst_plugin_get_source (plugin))
|
||||
+ "<br>";
|
||||
|
||||
if (release_date != NULL)
|
||||
{
|
||||
if (release_date != NULL) {
|
||||
const gchar *tz = "(UTC)";
|
||||
gchar *str, *sep;
|
||||
|
||||
str = g_strdup (release_date);
|
||||
sep = strstr (str, "T");
|
||||
if (sep != NULL)
|
||||
{
|
||||
if (sep != NULL) {
|
||||
*sep = ' ';
|
||||
sep = strstr (sep + 1, "Z");
|
||||
if (sep != NULL)
|
||||
*sep = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
tz = "";
|
||||
}
|
||||
descr += "<b>Source release date</b>: " + QString(str) + " " + QString(tz) + "<br>";
|
||||
descr += "<b>Source release date</b>: " + QString (str) + " " + QString (tz)
|
||||
+ "<br>";
|
||||
g_free (str);
|
||||
}
|
||||
descr += "<b>Binary package</b>: " + QString(gst_plugin_get_package (plugin)) + "<br>";
|
||||
descr += "<b>Origin URL</b>: " + QString(gst_plugin_get_origin (plugin)) + "<br>";
|
||||
descr += "<b>Rank</b>: " + QString::number(gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(factory)));
|
||||
m_plblInfo -> setText(descr);
|
||||
descr += "<b>Binary package</b>: " + QString (gst_plugin_get_package (plugin))
|
||||
+ "<br>";
|
||||
descr += "<b>Origin URL</b>: " + QString (gst_plugin_get_origin (plugin))
|
||||
+ "<br>";
|
||||
descr += "<b>Rank</b>: "
|
||||
+ QString::number (
|
||||
gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)));
|
||||
m_plblInfo->setText (descr);
|
||||
}
|
||||
|
||||
void PluginsListDialog::insert(QListWidgetItem *pitem)
|
||||
void
|
||||
PluginsListDialog::insert (QListWidgetItem *pitem)
|
||||
{
|
||||
if(!pitem) {
|
||||
qDebug() << "Do not insert null item";
|
||||
if (!pitem) {
|
||||
qDebug () << "Do not insert null item";
|
||||
return;
|
||||
}
|
||||
qDebug() << "Insert: " << pitem -> text();
|
||||
qDebug () << "Insert: " << pitem->text ();
|
||||
|
||||
if(!m_pGraph || !m_pGraph -> AddPlugin(pitem -> text().toStdString().c_str(), NULL))
|
||||
{
|
||||
QMessageBox::warning(this, "Plugin addition problem", "Plugin `" + pitem -> text() + "` insertion was FAILED");
|
||||
qDebug() << "Plugin `" << pitem -> text() << "` insertion FAILED";
|
||||
if (!m_pGraph
|
||||
|| !m_pGraph->AddPlugin (pitem->text ().toStdString ().c_str (), NULL)) {
|
||||
QMessageBox::warning (
|
||||
this, "Plugin addition problem",
|
||||
"Plugin `" + pitem->text () + "` insertion was FAILED");
|
||||
qDebug () << "Plugin `" << pitem->text () << "` insertion FAILED";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool PluginsListDialog::eventFilter(QObject *obj, QEvent *event)
|
||||
bool
|
||||
PluginsListDialog::eventFilter (QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event -> type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *key = static_cast<QKeyEvent*>(event);
|
||||
if (event->type () == QEvent::KeyPress) {
|
||||
QKeyEvent *key = static_cast<QKeyEvent*> (event);
|
||||
|
||||
if((key -> key() == Qt::Key_Enter) || (key -> key() == Qt::Key_Return) && m_pPlugins -> currentItem())
|
||||
{
|
||||
insert(m_pPlugins -> currentItem());
|
||||
if ((key->key () == Qt::Key_Enter)
|
||||
|| (key->key () == Qt::Key_Return) && m_pPlugins->currentItem ()) {
|
||||
insert (m_pPlugins->currentItem ());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QDialog::eventFilter(obj, event);
|
||||
return QDialog::eventFilter (obj, event);
|
||||
}
|
||||
|
||||
void PluginsListDialog::filterPlagins(const QString &text)
|
||||
void
|
||||
PluginsListDialog::filterPlagins (const QString &text)
|
||||
{
|
||||
for(std::size_t i=0; i<m_pPlugins -> count(); i++)
|
||||
{
|
||||
QListWidgetItem *pitem = m_pPlugins -> item(i);
|
||||
for (std::size_t i = 0; i < m_pPlugins->count (); i++) {
|
||||
QListWidgetItem *pitem = m_pPlugins->item (i);
|
||||
|
||||
if(pitem -> text().contains(text))
|
||||
pitem -> setHidden(false);
|
||||
if (pitem->text ().contains (text))
|
||||
pitem->setHidden (false);
|
||||
else
|
||||
pitem -> setHidden(true);
|
||||
pitem->setHidden (true);
|
||||
}
|
||||
}
|
||||
|
||||
void PluginsListDialog::InitPluginsList()
|
||||
void
|
||||
PluginsListDialog::InitPluginsList ()
|
||||
{
|
||||
if (!m_pPluginsList)
|
||||
m_pPluginsList = new PluginsList ();
|
||||
|
||||
GList* plugins_list = m_pPluginsList->getList();
|
||||
GList* plugins_list = m_pPluginsList->getList ();
|
||||
GList* l;
|
||||
std::size_t num = 0;
|
||||
|
||||
for (l = plugins_list; l != NULL; l = l->next) {
|
||||
Plugin* plugin = (Plugin*)(l->data);
|
||||
m_pPlugins->addItem(plugin->getName());
|
||||
Plugin* plugin = (Plugin*) (l->data);
|
||||
m_pPlugins->addItem (plugin->getName ());
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
#include <QLabel>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
|
||||
#include "GraphManager.h"
|
||||
|
||||
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
|
@ -17,8 +15,8 @@ public:
|
|||
m_rank(rank)
|
||||
{
|
||||
}
|
||||
const QString getName() { return m_name;}
|
||||
int getRank() { return m_rank;}
|
||||
const QString getName() {return m_name;}
|
||||
int getRank() {return m_rank;}
|
||||
|
||||
private:
|
||||
const QString m_name;
|
||||
|
@ -32,25 +30,24 @@ public:
|
|||
PluginsList();
|
||||
~PluginsList();
|
||||
|
||||
GList* getList() { return m_pluginsList;}
|
||||
GList* getList() {return m_pluginsList;}
|
||||
GList* getSortedByRank();
|
||||
GList* getPluginListByCaps(GstPadDirection direction, GstCaps* caps);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
GList* m_pluginsList;
|
||||
GList* m_pluginsList;
|
||||
};
|
||||
|
||||
|
||||
class PluginsListDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
PluginsListDialog(PluginsList* pluginList, QWidget *pwgt = NULL, Qt::WindowFlags f = Qt::Window);
|
||||
~PluginsListDialog();
|
||||
|
||||
void setGraph(GraphManager* graph) { m_pGraph = graph;}
|
||||
void setGraph(GraphManager* graph) {m_pGraph = graph;}
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
@ -72,7 +69,4 @@ private:
|
|||
GraphManager *m_pGraph;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
#include "SeekSlider.h"
|
||||
|
||||
void SeekSlider::mousePressEvent(QMouseEvent *event)
|
||||
void
|
||||
SeekSlider::mousePressEvent (QMouseEvent *event)
|
||||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
if(orientation() == Qt::Vertical)
|
||||
setValue(minimum() + ((maximum()-minimum()) * (height()-event->y())) / height() ) ;
|
||||
if (event->button () == Qt::LeftButton) {
|
||||
if (orientation () == Qt::Vertical)
|
||||
setValue (minimum ()
|
||||
+ ((maximum () - minimum ()) * (height () - event->y ())) / height ());
|
||||
else
|
||||
setValue(minimum() + ((maximum()-minimum()) * event->x()) / width() ) ;
|
||||
setValue (minimum ()
|
||||
+ ((maximum () - minimum ()) * event->x ()) / width ());
|
||||
|
||||
event->accept();
|
||||
event->accept ();
|
||||
}
|
||||
|
||||
QSlider::mousePressEvent(event);
|
||||
};
|
||||
QSlider::mousePressEvent (event);
|
||||
}
|
||||
;
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
#ifndef SEEK_SLIDER_H_
|
||||
#define SEEK_SLIDER_H_
|
||||
|
||||
|
||||
#include <QSlider>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class SeekSlider: public QSlider
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
13
src/main.cpp
13
src/main.cpp
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
|
@ -11,14 +12,14 @@ int main(int argc, char **argv)
|
|||
#if GST_VERSION_MAJOR >= 1
|
||||
registry = gst_registry_get();
|
||||
#else
|
||||
registry = gst_registry_get_default();
|
||||
registry = gst_registry_get_default ();
|
||||
#endif
|
||||
gst_registry_scan_path(registry, "./plugins");
|
||||
gst_registry_scan_path (registry, "./plugins");
|
||||
|
||||
QApplication app(argc, argv);
|
||||
QApplication app (argc, argv);
|
||||
|
||||
MainWindow wgt;
|
||||
wgt.show();
|
||||
wgt.show ();
|
||||
|
||||
return app.exec();
|
||||
return app.exec ();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue