summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.co.uk>2010-11-26 10:24:49 +0200
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.co.uk>2010-11-26 15:21:14 +0200
commitb5bf162d419b0799f0ba7657b50356cbda6bb59f (patch)
tree9523426a71b86396d7c3d744fe3f2ab1f2e530a1
parent25585873f89e69b63bd040b2d91411a0090e6a2f (diff)
Remove all the remaining ValueImpl declarations and register the gstreamer types with the new ValueVTable system.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/QGlib/object.cpp11
-rw-r--r--src/QGlib/object.h25
-rw-r--r--src/QGlib/paramspec.cpp6
-rw-r--r--src/QGlib/paramspec.h1
-rw-r--r--src/QGst/buffer.cpp7
-rw-r--r--src/QGst/buffer.h1
-rw-r--r--src/QGst/caps.cpp6
-rw-r--r--src/QGst/caps.h1
-rw-r--r--src/QGst/event.cpp6
-rw-r--r--src/QGst/event.h1
-rw-r--r--src/QGst/global.cpp5
-rw-r--r--src/QGst/message.cpp6
-rw-r--r--src/QGst/message.h1
-rw-r--r--src/QGst/miniobject.cpp6
-rw-r--r--src/QGst/miniobject.h2
-rw-r--r--src/QGst/query.cpp6
-rw-r--r--src/QGst/query.h1
-rw-r--r--src/QGst/structs.cpp50
-rw-r--r--src/QGst/structs.h6
-rw-r--r--src/QGst/value.cpp143
21 files changed, 150 insertions, 143 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 52d516b..efccb79 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,7 +9,7 @@ set(QtGstreamer_SRCS
QGst/global.cpp
QGst/objectstore.cpp
- QGst/structs.cpp
+ QGst/value.cpp
QGst/structure.cpp
QGst/caps.cpp
QGst/miniobject.cpp
diff --git a/src/QGlib/object.cpp b/src/QGlib/object.cpp
index fa54f52..1b560be 100644
--- a/src/QGlib/object.cpp
+++ b/src/QGlib/object.cpp
@@ -84,15 +84,4 @@ void Object::unref()
g_object_unref(m_object);
}
-
-ObjectPtr ValueImpl_Object::get(const ValueBase & value)
-{
- return ObjectPtr::wrap(static_cast<GObject*>(g_value_get_object(value)));
-}
-
-void ValueImpl_Object::set(ValueBase & value, const ObjectPtr & data)
-{
- g_value_set_object(value, static_cast<GObject*>(data));
-}
-
}
diff --git a/src/QGlib/object.h b/src/QGlib/object.h
index 991b38f..413a085 100644
--- a/src/QGlib/object.h
+++ b/src/QGlib/object.h
@@ -57,31 +57,6 @@ void Object::setProperty(const char *name, const T & value)
}
}
-// -- ValueImpl specialization for GObject-derived classes --
-
-struct ValueImpl_Object
-{
- static ObjectPtr get(const ValueBase & value);
- static void set(ValueBase & value, const ObjectPtr & data);
-};
-
-template <typename T>
-struct ValueImpl< RefPointer<T> >
-{
- QGLIB_STATIC_ASSERT((boost::is_base_of<Object, T>::value),
- "No QGlib::ValueImpl<T> specialization has been registered for this type");
-
- static inline RefPointer<T> get(const ValueBase & value)
- {
- return ValueImpl_Object::get(value).dynamicCast<T>();
- }
-
- static inline void set(ValueBase & value, const RefPointer<T> & data)
- {
- ValueImpl_Object::set(value, data);
- }
-};
-
} //namespace QGlib
QGLIB_REGISTER_TYPE(QGlib::Object)
diff --git a/src/QGlib/paramspec.cpp b/src/QGlib/paramspec.cpp
index 010348f..a305d0c 100644
--- a/src/QGlib/paramspec.cpp
+++ b/src/QGlib/paramspec.cpp
@@ -83,8 +83,4 @@ void ParamSpec::unref()
g_param_spec_unref(G_PARAM_SPEC(m_object));
}
-}
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(QGlib::ParamSpecPtr,
- ParamSpecPtr::wrap(g_value_get_param(value)),
- g_value_set_param(value, data))
+} //namespace QGlib
diff --git a/src/QGlib/paramspec.h b/src/QGlib/paramspec.h
index b331113..48af948 100644
--- a/src/QGlib/paramspec.h
+++ b/src/QGlib/paramspec.h
@@ -69,6 +69,5 @@ protected:
QGLIB_REGISTER_TYPE(QGlib::ParamSpec) //codegen: GType=G_TYPE_PARAM
QGLIB_REGISTER_TYPE(QGlib::ParamSpec::ParamFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(QGlib::ParamSpec::ParamFlags)
-QGLIB_REGISTER_VALUEIMPL(QGlib::ParamSpecPtr)
#endif
diff --git a/src/QGst/buffer.cpp b/src/QGst/buffer.cpp
index afa386c..33aa189 100644
--- a/src/QGst/buffer.cpp
+++ b/src/QGst/buffer.cpp
@@ -83,15 +83,8 @@ BufferPtr Buffer::copy() const
return BufferPtr::wrap(gst_buffer_copy(object<GstBuffer>()), false);
}
-
} //namespace QGst
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::BufferPtr,
- QGst::BufferPtr::wrap(GST_BUFFER(gst_value_get_buffer(value))),
- gst_value_set_buffer(value, GST_MINI_OBJECT(static_cast<GstBuffer*>(data)))
-)
-
QDebug operator<<(QDebug debug, const QGst::BufferPtr & buffer)
{
debug.nospace() << "QGst::Buffer(Size: " << buffer->size() << ")";
diff --git a/src/QGst/buffer.h b/src/QGst/buffer.h
index 753469e..5b27c40 100644
--- a/src/QGst/buffer.h
+++ b/src/QGst/buffer.h
@@ -58,7 +58,6 @@ public:
} //namespace QGst
QGLIB_REGISTER_TYPE(QGst::Buffer)
-QGLIB_REGISTER_VALUEIMPL(QGst::BufferPtr)
/*! \relates QGst::Buffer */
QDebug operator<<(QDebug debug, const QGst::BufferPtr & buffer);
diff --git a/src/QGst/caps.cpp b/src/QGst/caps.cpp
index 6c67d0d..9773ecd 100644
--- a/src/QGst/caps.cpp
+++ b/src/QGst/caps.cpp
@@ -225,12 +225,6 @@ void Caps::makeWritable()
} //namespace QGst
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::CapsPtr,
- QGst::CapsPtr::wrap(gst_caps_copy(gst_value_get_caps(value)), false),
- gst_value_set_caps(value, data)
-)
-
QDebug operator<<(QDebug debug, const QGst::CapsPtr & caps)
{
debug.nospace() << "QGst::Caps(" << caps->toString() << ")";
diff --git a/src/QGst/caps.h b/src/QGst/caps.h
index 7cde95a..3c723ee 100644
--- a/src/QGst/caps.h
+++ b/src/QGst/caps.h
@@ -79,7 +79,6 @@ protected:
}
QGLIB_REGISTER_TYPE(QGst::Caps)
-QGLIB_REGISTER_VALUEIMPL(QGst::CapsPtr)
/*! \relates QGst::Caps */
QDebug operator<<(QDebug debug, const QGst::CapsPtr & caps);
diff --git a/src/QGst/event.cpp b/src/QGst/event.cpp
index 07a97f9..8cb9f17 100644
--- a/src/QGst/event.cpp
+++ b/src/QGst/event.cpp
@@ -373,12 +373,6 @@ bool StepEvent::intermediate() const
} //namespace QGst
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::EventPtr,
- QGst::EventPtr::wrap(GST_EVENT(gst_value_get_mini_object(value))),
- gst_value_set_mini_object(value, GST_MINI_OBJECT(static_cast<GstEvent*>(data)))
-)
-
QDebug operator<<(QDebug debug, QGst::EventType type)
{
debug.nospace() << gst_event_type_get_name(static_cast<GstEventType>(type));
diff --git a/src/QGst/event.h b/src/QGst/event.h
index ebfebe0..4dff1aa 100644
--- a/src/QGst/event.h
+++ b/src/QGst/event.h
@@ -225,7 +225,6 @@ public:
} //namespace QGst
QGLIB_REGISTER_TYPE(QGst::Event)
-QGLIB_REGISTER_VALUEIMPL(QGst::EventPtr)
QGST_REGISTER_SUBCLASS(Event, FlushStart)
QGST_REGISTER_SUBCLASS(Event, FlushStop)
QGST_REGISTER_SUBCLASS(Event, Eos)
diff --git a/src/QGst/global.cpp b/src/QGst/global.cpp
index 2859bec..0f5fcf2 100644
--- a/src/QGst/global.cpp
+++ b/src/QGst/global.cpp
@@ -20,6 +20,10 @@
namespace QGst {
+namespace Private {
+ void registerValueVTables();
+}
+
void init()
{
init(NULL, NULL);
@@ -31,6 +35,7 @@ void init(int *argc, char **argv[])
if (!gst_init_check(argc, argv, &error)) {
throw QGlib::Error(error);
}
+ Private::registerValueVTables();
}
void cleanup()
diff --git a/src/QGst/message.cpp b/src/QGst/message.cpp
index 5fa5eac..291a18c 100644
--- a/src/QGst/message.cpp
+++ b/src/QGst/message.cpp
@@ -550,12 +550,6 @@ quint64 QosMessage::dropped() const
} //namespace QGst
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::MessagePtr,
- QGst::MessagePtr::wrap(GST_MESSAGE(gst_value_get_mini_object(value))),
- gst_value_set_mini_object(value, GST_MINI_OBJECT(static_cast<GstMessage*>(data)))
-)
-
QDebug operator<<(QDebug debug, QGst::MessageType type)
{
debug.nospace() << gst_message_type_get_name(static_cast<GstMessageType>(type));
diff --git a/src/QGst/message.h b/src/QGst/message.h
index 5369464..9038473 100644
--- a/src/QGst/message.h
+++ b/src/QGst/message.h
@@ -319,7 +319,6 @@ public:
} //namespace QGst
QGLIB_REGISTER_TYPE(QGst::Message)
-QGLIB_REGISTER_VALUEIMPL(QGst::MessagePtr)
QGST_REGISTER_SUBCLASS(Message, Eos)
QGST_REGISTER_SUBCLASS(Message, Error)
QGST_REGISTER_SUBCLASS(Message, Warning)
diff --git a/src/QGst/miniobject.cpp b/src/QGst/miniobject.cpp
index 7846731..4a063d9 100644
--- a/src/QGst/miniobject.cpp
+++ b/src/QGst/miniobject.cpp
@@ -91,9 +91,3 @@ void MiniObject::makeWritable()
}
} //namespace QGst
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::MiniObjectPtr,
- QGst::MiniObjectPtr::wrap(gst_value_get_mini_object(value)),
- gst_value_set_mini_object(value, data)
-)
diff --git a/src/QGst/miniobject.h b/src/QGst/miniobject.h
index c8e4354..feb8ae6 100644
--- a/src/QGst/miniobject.h
+++ b/src/QGst/miniobject.h
@@ -20,7 +20,6 @@
#include "global.h"
#include "../QGlib/refpointer.h"
#include "../QGlib/type.h"
-#include "../QGlib/value.h"
namespace QGst {
@@ -48,6 +47,5 @@ protected:
} //namespace QGst
QGLIB_REGISTER_TYPE(QGst::MiniObject)
-QGLIB_REGISTER_VALUEIMPL(QGst::MiniObjectPtr)
#endif
diff --git a/src/QGst/query.cpp b/src/QGst/query.cpp
index 43a12f1..198a8ea 100644
--- a/src/QGst/query.cpp
+++ b/src/QGst/query.cpp
@@ -407,12 +407,6 @@ void UriQuery::setValue(const QUrl & uri)
} //namespace QGst
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::QueryPtr,
- QGst::QueryPtr::wrap(GST_QUERY(gst_value_get_mini_object(value))),
- gst_value_set_mini_object(value, GST_MINI_OBJECT(static_cast<GstQuery*>(data)))
-)
-
QDebug operator<<(QDebug debug, QGst::QueryType type)
{
debug.nospace() << gst_query_type_get_name(static_cast<GstQueryType>(type));
diff --git a/src/QGst/query.h b/src/QGst/query.h
index 3d7d247..9a5d05b 100644
--- a/src/QGst/query.h
+++ b/src/QGst/query.h
@@ -217,7 +217,6 @@ public:
} //namespace QGst
QGLIB_REGISTER_TYPE(QGst::Query)
-QGLIB_REGISTER_VALUEIMPL(QGst::QueryPtr)
QGST_REGISTER_SUBCLASS(Query, Position)
QGST_REGISTER_SUBCLASS(Query, Duration)
QGST_REGISTER_SUBCLASS(Query, Latency)
diff --git a/src/QGst/structs.cpp b/src/QGst/structs.cpp
deleted file mode 100644
index a07d625..0000000
--- a/src/QGst/structs.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- 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/>.
-*/
-#include "structs.h"
-#include <gst/gstvalue.h>
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::Fourcc,
- QGst::Fourcc(gst_value_get_fourcc(value)),
- gst_value_set_fourcc(value, data.value.as_integer)
-)
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::Fraction,
- QGst::Fraction(gst_value_get_fraction_numerator(value), gst_value_get_fraction_denominator(value)),
- gst_value_set_fraction(value, data.numerator, data.denominator)
-)
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::IntRange,
- QGst::IntRange(gst_value_get_int_range_min(value), gst_value_get_int_range_max(value)),
- gst_value_set_int_range(value, data.start, data.end)
-)
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::DoubleRange,
- QGst::DoubleRange(gst_value_get_double_range_min(value), gst_value_get_double_range_max(value)),
- gst_value_set_double_range(value, data.start, data.end)
-)
-
-QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(
- QGst::FractionRange,
- QGst::FractionRange(QGlib::Value(gst_value_get_fraction_range_min(value)).get<QGst::Fraction>(),
- QGlib::Value(gst_value_get_fraction_range_max(value)).get<QGst::Fraction>()),
- gst_value_set_fraction_range_full(value, data.start.numerator, data.start.denominator,
- data.end.numerator, data.end.denominator)
-)
diff --git a/src/QGst/structs.h b/src/QGst/structs.h
index fb1ddcc..5be935d 100644
--- a/src/QGst/structs.h
+++ b/src/QGst/structs.h
@@ -18,7 +18,6 @@
#define QGST_STRUCTS_H
#include "../QGlib/type.h"
-#include "../QGlib/value.h"
namespace QGst {
@@ -67,7 +66,6 @@ namespace QGst {
};
}
QGLIB_REGISTER_TYPE(QGst::Fourcc)
-QGLIB_REGISTER_VALUEIMPL(QGst::Fourcc)
namespace QGst {
/*! \headerfile structs.h <QGst/Fraction>
@@ -84,7 +82,6 @@ namespace QGst {
};
}
QGLIB_REGISTER_TYPE(QGst::Fraction)
-QGLIB_REGISTER_VALUEIMPL(QGst::Fraction)
namespace QGst {
namespace Private {
@@ -123,8 +120,5 @@ namespace QGst {
QGLIB_REGISTER_TYPE(QGst::IntRange)
QGLIB_REGISTER_TYPE(QGst::DoubleRange)
QGLIB_REGISTER_TYPE(QGst::FractionRange)
-QGLIB_REGISTER_VALUEIMPL(QGst::IntRange)
-QGLIB_REGISTER_VALUEIMPL(QGst::DoubleRange)
-QGLIB_REGISTER_VALUEIMPL(QGst::FractionRange)
#endif // QGST_STRUCTS_H
diff --git a/src/QGst/value.cpp b/src/QGst/value.cpp
new file mode 100644
index 0000000..3af0392
--- /dev/null
+++ b/src/QGst/value.cpp
@@ -0,0 +1,143 @@
+/*
+ Copyright (C) 2010 Collabora Ltd.
+ @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
+
+ 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/>.
+*/
+#include "structs.h"
+#include "miniobject.h"
+#include "../QGlib/value.h"
+#include <gst/gstvalue.h>
+#include <gst/gstminiobject.h>
+
+namespace QGst {
+namespace Private {
+
+void registerValueVTables()
+{
+ struct ValueVTable_MiniObject
+ {
+ static void get(const QGlib::ValueBase & value, void *data)
+ {
+ *reinterpret_cast<GstMiniObject**>(data) = gst_value_get_mini_object(value);
+ };
+
+ static void set(QGlib::ValueBase & value, const void *data)
+ {
+ gst_value_set_mini_object(value, *reinterpret_cast<GstMiniObject* const *>(data));
+ };
+ };
+ QGlib::ValueBase::registerValueVTable(QGlib::GetType<MiniObject>(),
+ QGlib::ValueVTable(ValueVTable_MiniObject::set, ValueVTable_MiniObject::get));
+
+
+ struct ValueVTable_Fourcc
+ {
+ static void get(const QGlib::ValueBase & value, void *data)
+ {
+ reinterpret_cast<Fourcc*>(data)->value.as_integer = gst_value_get_fourcc(value);
+ };
+
+ static void set(QGlib::ValueBase & value, const void *data)
+ {
+ gst_value_set_fourcc(value, reinterpret_cast<Fourcc const *>(data)->value.as_integer);
+ };
+ };
+ QGlib::ValueBase::registerValueVTable(QGlib::GetType<Fourcc>(),
+ QGlib::ValueVTable(ValueVTable_Fourcc::set, ValueVTable_Fourcc::get));
+
+
+ struct ValueVTable_Fraction
+ {
+ static void get(const QGlib::ValueBase & value, void *data)
+ {
+ reinterpret_cast<Fraction*>(data)->numerator = gst_value_get_fraction_numerator(value);
+ reinterpret_cast<Fraction*>(data)->denominator = gst_value_get_fraction_denominator(value);
+ };
+
+ static void set(QGlib::ValueBase & value, const void *data)
+ {
+ gst_value_set_fraction(value, reinterpret_cast<Fraction const *>(data)->numerator,
+ reinterpret_cast<Fraction const *>(data)->denominator);
+ };
+ };
+ QGlib::ValueBase::registerValueVTable(QGlib::GetType<Fraction>(),
+ QGlib::ValueVTable(ValueVTable_Fraction::set, ValueVTable_Fraction::get));
+
+
+ struct ValueVTable_IntRange
+ {
+ static void get(const QGlib::ValueBase & value, void *data)
+ {
+ reinterpret_cast<IntRange*>(data)->start = gst_value_get_int_range_min(value);
+ reinterpret_cast<IntRange*>(data)->end = gst_value_get_int_range_max(value);
+ };
+
+ static void set(QGlib::ValueBase & value, const void *data)
+ {
+ gst_value_set_int_range(value, reinterpret_cast<IntRange const *>(data)->start,
+ reinterpret_cast<IntRange const *>(data)->end);
+ };
+ };
+ QGlib::ValueBase::registerValueVTable(QGlib::GetType<IntRange>(),
+ QGlib::ValueVTable(ValueVTable_IntRange::set, ValueVTable_IntRange::get));
+
+
+ struct ValueVTable_DoubleRange
+ {
+ static void get(const QGlib::ValueBase & value, void *data)
+ {
+ reinterpret_cast<DoubleRange*>(data)->start = gst_value_get_double_range_min(value);
+ reinterpret_cast<DoubleRange*>(data)->end = gst_value_get_double_range_max(value);
+ };
+
+ static void set(QGlib::ValueBase & value, const void *data)
+ {
+ gst_value_set_double_range(value, reinterpret_cast<DoubleRange const *>(data)->start,
+ reinterpret_cast<DoubleRange const *>(data)->end);
+ };
+ };
+ QGlib::ValueBase::registerValueVTable(QGlib::GetType<DoubleRange>(),
+ QGlib::ValueVTable(ValueVTable_DoubleRange::set, ValueVTable_DoubleRange::get));
+
+
+ struct ValueVTable_FractionRange
+ {
+ static void get(const QGlib::ValueBase & value, void *data)
+ {
+ reinterpret_cast<FractionRange*>(data)->start.numerator =
+ gst_value_get_fraction_numerator(gst_value_get_fraction_range_min(value));
+ reinterpret_cast<FractionRange*>(data)->start.denominator =
+ gst_value_get_fraction_denominator(gst_value_get_fraction_range_min(value));
+ reinterpret_cast<FractionRange*>(data)->end.numerator =
+ gst_value_get_fraction_numerator(gst_value_get_fraction_range_max(value));
+ reinterpret_cast<FractionRange*>(data)->end.denominator =
+ gst_value_get_fraction_denominator(gst_value_get_fraction_range_max(value));
+ };
+
+ static void set(QGlib::ValueBase & value, const void *data)
+ {
+ gst_value_set_fraction_range_full(value,
+ reinterpret_cast<FractionRange const *>(data)->start.numerator,
+ reinterpret_cast<FractionRange const *>(data)->start.denominator,
+ reinterpret_cast<FractionRange const *>(data)->end.numerator,
+ reinterpret_cast<FractionRange const *>(data)->end.denominator);
+ };
+ };
+ QGlib::ValueBase::registerValueVTable(QGlib::GetType<FractionRange>(),
+ QGlib::ValueVTable(ValueVTable_FractionRange::set, ValueVTable_FractionRange::get));
+}
+
+} //namespace Private
+} //namespace QGst