summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <kiagiadakis.george@gmail.com>2010-03-25 16:05:15 +0200
committerGeorge Kiagiadakis <kiagiadakis.george@gmail.com>2010-03-25 16:05:15 +0200
commit1d12c4e6e34dc6b0528fec459e702f63349f07d9 (patch)
tree732ec6119d58220c307174c477984aca6e18a5ed
parentb08b62e3dd943a041051e125b31f588e0fee5c82 (diff)
Add the most useful methods to the GstObject wrapper class.
-rw-r--r--src/QGst/helpers_p.h30
-rw-r--r--src/QGst/object.cpp43
-rw-r--r--src/QGst/object.h13
3 files changed, 85 insertions, 1 deletions
diff --git a/src/QGst/helpers_p.h b/src/QGst/helpers_p.h
new file mode 100644
index 0000000..9b11258
--- /dev/null
+++ b/src/QGst/helpers_p.h
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef HELPERS_P_H
+#define HELPERS_P_H
+
+#include <glib.h>
+#include <QtCore/QString>
+
+inline QString gcharPtrToQString(gchar *str)
+{
+ QString result = QString::fromUtf8(str);
+ g_free(str);
+ return result;
+}
+
+#endif
diff --git a/src/QGst/object.cpp b/src/QGst/object.cpp
index 0f81027..cb68603 100644
--- a/src/QGst/object.cpp
+++ b/src/QGst/object.cpp
@@ -15,10 +15,51 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "object.h"
-#include <gst/gst.h>
+#include "helpers_p.h"
+#include <gst/gstobject.h>
namespace QGst {
+QString Object::name() const
+{
+ return gcharPtrToQString(gst_object_get_name(GST_OBJECT(m_object)));
+}
+
+bool Object::setName(const QString & name)
+{
+ return gst_object_set_name(GST_OBJECT(m_object), name.isEmpty() ? NULL : name.toUtf8().constData());
+}
+
+ObjectPtr Object::parent() const
+{
+ return ObjectPtr::wrap(gst_object_get_parent(GST_OBJECT(m_object)), false);
+}
+
+bool Object::setParent(const QGst::ObjectPtr & parent)
+{
+ return gst_object_set_parent(GST_OBJECT(m_object), parent);
+}
+
+void Object::unparent()
+{
+ gst_object_unparent(GST_OBJECT(m_object));
+}
+
+QString Object::namePrefix() const
+{
+ return gcharPtrToQString(gst_object_get_name_prefix(GST_OBJECT(m_object)));
+}
+
+void Object::setNamePrefix(const QString & prefix)
+{
+ gst_object_set_name_prefix(GST_OBJECT(m_object), prefix.toUtf8());
+}
+
+bool Object::isAncestorOf(const QGst::ObjectPtr & object) const
+{
+ return gst_object_has_ancestor(object, GST_OBJECT(m_object));
+}
+
void Object::ref()
{
gst_object_ref(m_object);
diff --git a/src/QGst/object.h b/src/QGst/object.h
index 825af1d..10e187e 100644
--- a/src/QGst/object.h
+++ b/src/QGst/object.h
@@ -25,6 +25,19 @@ namespace QGst {
class Object : public QGlib::Object
{
QGST_WRAPPER(Object)
+public:
+ QString name() const;
+ bool setName(const QString & name);
+
+ ObjectPtr parent() const;
+ bool setParent(const ObjectPtr & parent);
+ void unparent();
+
+ QString namePrefix() const;
+ void setNamePrefix(const QString & prefix);
+
+ bool isAncestorOf(const ObjectPtr & object) const;
+
protected:
virtual void ref();
virtual void unref();