gnomemm r1277 - in gstreamermm/trunk: . gst/src tests tools/m4
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1277 - in gstreamermm/trunk: . gst/src tests tools/m4
- Date: Tue, 8 Jan 2008 20:06:55 +0000 (GMT)
Author: jaalburqu
Date: Tue Jan 8 20:06:54 2008
New Revision: 1277
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1277&view=rev
Log:
2008-01-08 Josà Alburquerque <jaalburqu svn gnome org>
* gst/src/enums.ccg: added get_name() and get_quark() for QueryType
* gst/src/enums.hg: wrapped QueryType
* gst/src/event.ccg:
* gst/src/event.hg: removed Gst::Event default constructor def
* gst/src/format.ccg: renamed get_format_by_nick() to get_format();
commented out badly defined formats_contain_format() method; renamed
get_format_details() to get_details() and reordered args
* gst/src/format.hg: redefined struct FormatDefinition to use
Glib::QueryQuark instead of GQuark
* gst/src/message.ccg:
* gst/src/message.hg: removed Gst::Message default constructor def
* gst/src/query.ccg:
* gst/src/query.hg: wrapped GstQuery
* tests/Makefile.am: added test to wrap a query
* tests/test-query-wrap.cc: new wrap query source file
* tools/m4/convert_gst.m4: added QueryType/GstQueryType conversions
Added:
gstreamermm/trunk/tests/test-query-wrap.cc
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/gst/src/enums.ccg
gstreamermm/trunk/gst/src/enums.hg
gstreamermm/trunk/gst/src/event.ccg
gstreamermm/trunk/gst/src/event.hg
gstreamermm/trunk/gst/src/format.ccg
gstreamermm/trunk/gst/src/format.hg
gstreamermm/trunk/gst/src/message.ccg
gstreamermm/trunk/gst/src/message.hg
gstreamermm/trunk/gst/src/query.ccg
gstreamermm/trunk/gst/src/query.hg
gstreamermm/trunk/tests/Makefile.am
gstreamermm/trunk/tools/m4/convert_gst.m4
Modified: gstreamermm/trunk/gst/src/enums.ccg
==============================================================================
--- gstreamermm/trunk/gst/src/enums.ccg (original)
+++ gstreamermm/trunk/gst/src/enums.ccg Tue Jan 8 20:06:54 2008
@@ -18,6 +18,11 @@
return gst_message_type_get_name(GstMessageType(t));
}
+Glib::ustring get_name(QueryType t)
+{
+ return gst_query_type_get_name(GstQueryType(t));
+}
+
Glib::ustring get_name(State s)
{
return gst_element_state_get_name(GstState(s));
@@ -43,4 +48,9 @@
return Glib::QueryQuark(gst_message_type_to_quark(GstMessageType(t)));
}
+Glib::QueryQuark get_quark(QueryType t)
+{
+ return Glib::QueryQuark(gst_query_type_to_quark(GstQueryType(t)));
+}
+
} //namespace Gst
Modified: gstreamermm/trunk/gst/src/enums.hg
==============================================================================
--- gstreamermm/trunk/gst/src/enums.hg (original)
+++ gstreamermm/trunk/gst/src/enums.hg Tue Jan 8 20:06:54 2008
@@ -162,6 +162,7 @@
_WRAP_ENUM(PadDirection, GstPadDirection)
_WRAP_ENUM(PadLinkReturn, GstPadLinkReturn)
_WRAP_ENUM(PadPresence, GstPadPresence)
+_WRAP_ENUM(QueryType, GstQueryType)
enum SeekFlags
{
@@ -181,11 +182,13 @@
Glib::ustring get_name(EventType t);
Glib::ustring get_name(Format f);
Glib::ustring get_name(MessageType t);
+Glib::ustring get_name(QueryType t);
Glib::ustring get_name(State s);
Glib::ustring get_name(StateChangeReturn s);
Glib::QueryQuark get_quark(EventType t);
Glib::QueryQuark get_quark(Format f);
Glib::QueryQuark get_quark(MessageType t);
+Glib::QueryQuark get_quark(QueryType t);
} //namespace Gst
Modified: gstreamermm/trunk/gst/src/event.ccg
==============================================================================
--- gstreamermm/trunk/gst/src/event.ccg (original)
+++ gstreamermm/trunk/gst/src/event.ccg Tue Jan 8 20:06:54 2008
@@ -2,10 +2,6 @@
namespace Gst
{
-Event::Event()
-{
-}
-
const Structure& Event::get_structure()
{
structure_ = Structure(const_cast<GstStructure*>(gst_event_get_structure(gobj())), false);
Modified: gstreamermm/trunk/gst/src/event.hg
==============================================================================
--- gstreamermm/trunk/gst/src/event.hg (original)
+++ gstreamermm/trunk/gst/src/event.hg Tue Jan 8 20:06:54 2008
@@ -13,7 +13,6 @@
_CLASS_GSTMINIOBJECT(Event, GstEvent, GST_EVENT, Gst::MiniObject, GstMiniObject)
public:
- Event();
const Structure& get_structure();
public:
Modified: gstreamermm/trunk/gst/src/format.ccg
==============================================================================
--- gstreamermm/trunk/gst/src/format.ccg (original)
+++ gstreamermm/trunk/gst/src/format.ccg Tue Jan 8 20:06:54 2008
@@ -8,18 +8,21 @@
return Format(gst_format_register(nick.c_str(), description.c_str()));
}
-Format get_format_by_nick(const Glib::ustring& nick)
+Format get_format(const Glib::ustring& nick)
{
return Format(gst_format_get_by_nick(nick.c_str()));
}
+//TODO: first arg is an array of Formats
+/*
bool formats_contain_format(const Format& formats, Format format)
{
GstFormat gstformats = GstFormat(formats);
return gst_formats_contains(&gstformats, GstFormat(format));
}
+*/
-bool get_format_details(FormatDefinition &def, Format format)
+bool get_details(Format format, FormatDefinition &def)
{
const GstFormatDefinition* gstdef = gst_format_get_details(GstFormat(format));
Modified: gstreamermm/trunk/gst/src/format.hg
==============================================================================
--- gstreamermm/trunk/gst/src/format.hg (original)
+++ gstreamermm/trunk/gst/src/format.hg Tue Jan 8 20:06:54 2008
@@ -8,14 +8,17 @@
Format value;
Glib::ustring nick;
Glib::ustring description;
- GQuark quark;
+ Glib::QueryQuark quark;
};
//Note that GstFormat is an enum. That's why these are not member functions of a class.
Format register_format(const Glib::ustring& nick, const Glib::ustring&description);
- Format get_format_by_nick(const Glib::ustring& nick);
- bool formats_contain_format(const Format& formats, Format format);
- bool get_format_details(FormatDefinition& def, Format format);
+ Format get_format(const Glib::ustring& nick);
+
+ //TODO: first arg is an array of Formats
+ //TODO: bool formats_contain_format(const Format& formats, Format format);
+
+ bool get_details(Format format, FormatDefinition& def);
} //namespace Gst
Modified: gstreamermm/trunk/gst/src/message.ccg
==============================================================================
--- gstreamermm/trunk/gst/src/message.ccg (original)
+++ gstreamermm/trunk/gst/src/message.ccg Tue Jan 8 20:06:54 2008
@@ -1,10 +1,6 @@
namespace Gst
{
-Message::Message()
-{
-}
-
const Structure&
Message::get_structure()
{
Modified: gstreamermm/trunk/gst/src/message.hg
==============================================================================
--- gstreamermm/trunk/gst/src/message.hg (original)
+++ gstreamermm/trunk/gst/src/message.hg Tue Jan 8 20:06:54 2008
@@ -15,7 +15,6 @@
_CLASS_GSTMINIOBJECT(Message, GstMessage, GST_MESSAGE, Gst::MiniObject, GstMiniObject)
_IGNORE(gst_message_ref, gst_message_unref)
public:
- Message();
const Structure& get_structure();
public:
Modified: gstreamermm/trunk/gst/src/query.ccg
==============================================================================
--- gstreamermm/trunk/gst/src/query.ccg (original)
+++ gstreamermm/trunk/gst/src/query.ccg Tue Jan 8 20:06:54 2008
@@ -3,4 +3,220 @@
namespace Gst
{
+const Structure& Query::get_structure()
+{
+ structure_ = Structure(const_cast<GstStructure*>(gst_query_get_structure(gobj())), false);
+ return structure_;
+}
+
+bool get_details(QueryType type, QueryTypeDefinition &def)
+{
+ const GstQueryTypeDefinition* gstdef = gst_query_type_get_details(GstQueryType(type));
+
+ g_return_val_if_fail(gstdef != NULL, false);
+
+ def.value = QueryType(gstdef->value);
+ def.nick = gstdef->nick;
+ def.description = gstdef->description;
+ def.quark = gstdef->quark;
+
+ return true;
+}
+
+QueryConvert::QueryConvert(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QueryConvert::create(Format src_format, gint64 value, Format dest_format)
+{
+ GstQuery* query = gst_query_new_convert(GstFormat(src_format), value,
+ GstFormat(dest_format));
+ return Gst::Query::wrap(query);
+}
+
+void QueryConvert::set(Format src_format, gint64 src_value, Format dest_format, gint64 dest_value)
+{
+ gst_query_set_convert(gobj(), GstFormat(src_format), src_value, GstFormat(dest_format), dest_value);
+}
+
+void QueryConvert::parse(Format& src_format, gint64& src_value, Format& dest_format, gint64& dest_value)
+{
+ gst_query_parse_convert(gobj(), (GstFormat*)(&src_format), &src_value, (GstFormat*)(&dest_format), &dest_value);
+}
+
+QueryPosition::QueryPosition(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QueryPosition::create(Format format)
+{
+ GstQuery* query = gst_query_new_position(GstFormat(format));
+ return Gst::Query::wrap(query);
+}
+
+void QueryPosition::set(Format format, gint64 position)
+{
+ gst_query_set_position(gobj(), GstFormat(format), position);
+}
+
+void QueryPosition::parse(Format& format, gint64& position)
+{
+ gst_query_parse_position(gobj(), (GstFormat*)(&format), &position);
+}
+
+QueryDuration::QueryDuration(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QueryDuration::create(Format format)
+{
+ GstQuery* query = gst_query_new_duration(GstFormat(format));
+ return Gst::Query::wrap(query);
+}
+
+void QueryDuration::set(Format format, gint64 duration)
+{
+ gst_query_set_duration(gobj(), GstFormat(format), duration);
+}
+
+void QueryDuration::parse(Format& format, gint64& duration)
+{
+ gst_query_parse_duration(gobj(), (GstFormat*)(&format), &duration);
+}
+
+QueryLatency::QueryLatency(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QueryLatency::create()
+{
+ GstQuery* query = gst_query_new_latency();
+ return Gst::Query::wrap(query);
+}
+
+void QueryLatency::set(bool live, ClockTime min_latency, ClockTime max_latency)
+{
+ gst_query_set_latency(gobj(), live, GstClockTime(min_latency), GstClockTime(max_latency));
+}
+
+void QueryLatency::parse(bool& live, ClockTime& min_latency, ClockTime& max_latency)
+{
+ gboolean glive;
+ gst_query_parse_latency(gobj(), &glive, (ClockTime*)(&min_latency), (ClockTime*)(&max_latency));
+ live = glive;
+}
+
+QuerySeeking::QuerySeeking(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QuerySeeking::create(Format format)
+{
+ GstQuery* query = gst_query_new_seeking(GstFormat(format));
+ return Gst::Query::wrap(query);
+}
+
+void QuerySeeking::set(Format format, bool seekable, gint64 segment_start, gint64 segment_end)
+{
+ gst_query_set_seeking(gobj(), GstFormat(format), seekable, segment_start, segment_end);
+}
+
+void QuerySeeking::parse(Format& format, bool& seekable, gint64& segment_start, gint64& segment_end)
+{
+ gboolean gseekable;
+ gst_query_parse_seeking(gobj(), (GstFormat*)(&format), &gseekable, &segment_start, &segment_end);
+ seekable = gseekable;
+}
+
+QueryFormats::QueryFormats(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QueryFormats::create()
+{
+ GstQuery* query = gst_query_new_formats();
+ return Gst::Query::wrap(query);
+}
+
+void QueryFormats::set(int n_formats, const va_list& varargs)
+{
+ gst_query_set_formats(gobj(), n_formats, const_cast<va_list&>(varargs));
+}
+
+void QueryFormats::parse(guint& n_formats)
+{
+ gst_query_parse_formats_length(gobj(), &n_formats);
+}
+
+void QueryFormats::parse(guint nth, Format& format)
+{
+ gst_query_parse_formats_nth(gobj(), nth, (GstFormat*)(&format));
+}
+
+QuerySegment::QuerySegment(GstQuery* castitem) :
+Query(castitem)
+{
+}
+
+Glib::RefPtr<Query> QuerySegment::create(Format format)
+{
+ GstQuery* query = gst_query_new_segment(GstFormat(format));
+ return Gst::Query::wrap(query);
+}
+
+void QuerySegment::set(double rate, Format format, gint64 start_value, gint64 stop_value)
+{
+ gst_query_set_segment(gobj(), rate, GstFormat(format), start_value, stop_value);
+}
+
+void QuerySegment::parse(double& rate, Format& format, gint64& start_value, gint64& stop_value)
+{
+ gst_query_parse_segment(gobj(), &rate, (GstFormat*)(&format), &start_value, &stop_value);
+}
+
+Glib::RefPtr<Query> Query::wrap(GstQuery* query, bool take_copy) {
+
+ Glib::RefPtr<Query> result;
+
+ if(!query)
+ return result;
+
+ switch (GST_QUERY_TYPE(query)) {
+ case GST_QUERY_POSITION:
+ result = Glib::RefPtr<Query>( new Gst::QueryPosition(query) );
+ break;
+ case GST_QUERY_DURATION:
+ result = Glib::RefPtr<Query>( new Gst::QueryDuration(query) );
+ break;
+ case GST_QUERY_LATENCY:
+ result = Glib::RefPtr<Query>( new Gst::QueryLatency(query) );
+ break;
+ case GST_QUERY_SEEKING:
+ result = Glib::RefPtr<Query>( new Gst::QuerySeeking(query) );
+ break;
+ case GST_QUERY_SEGMENT:
+ result = Glib::RefPtr<Query>( new Gst::QuerySegment(query) );
+ break;
+ case GST_QUERY_CONVERT:
+ result = Glib::RefPtr<Query>( new Gst::QueryConvert(query) );
+ break;
+ case GST_QUERY_FORMATS:
+ result = Glib::RefPtr<Query>( new Gst::QueryFormats(query) );
+ break;
+ default:
+ result = Gst::wrap(query, false);
+ }
+
+ if(result && take_copy)
+ result->reference();
+
+ return result;
+}
+
} //namesapce Gst
Modified: gstreamermm/trunk/gst/src/query.hg
==============================================================================
--- gstreamermm/trunk/gst/src/query.hg (original)
+++ gstreamermm/trunk/gst/src/query.hg Tue Jan 8 20:06:54 2008
@@ -6,10 +6,113 @@
namespace Gst
{
+
+struct QueryTypeDefinition
+{
+ QueryType value;
+ Glib::ustring nick;
+ Glib::ustring description;
+ Glib::QueryQuark quark;
+};
+
class Query : public MiniObject
{
protected:
_CLASS_GSTMINIOBJECT(Query, GstQuery, GST_QUERY, Gst::MiniObject, GstMiniObject)
+
+public:
+ const Structure& get_structure();
+
+public:
+ _MEMBER_GET(query_type, type, QueryType, GstQueryType)
+
+ /** Wrap a GstQuery* in a C++ instance, creating an instance of a derived
+ * Gst::Query. Gst::wrap() would just create a Gst::Query (rather than a
+ * derived one) because the derived Gst::Query classes do not correspond
+ * to GType types in the GStreamer API.
+ */
+ static Glib::RefPtr<Query> wrap(GstQuery* query, bool take_copy=false);
+
+ _WRAP_METHOD(static QueryType register_query_type(const Glib::ustring& nick, const Glib::ustring& description), gst_query_type_register)
+ _WRAP_METHOD(static QueryType get_query_type(const Glib::ustring& nick), gst_query_type_get_by_nick)
+ //TODO: static bool query_types_contains(const std::vector<const QueryType>& types, QueryType type)
+
+ bool get_details(QueryType type, QueryTypeDefinition& def);
+
+protected:
+ Structure structure_;
+};
+
+class QueryConvert : public Query
+{
+public:
+ explicit QueryConvert(GstQuery* query);
+
+ static Glib::RefPtr<Query> create(Format src_format, gint64 value, Format dest_format);
+ void set(Format src_format, gint64 src_value, Format dest_format, gint64 dest_value);
+ void parse(Format& src_format, gint64& src_value, Format& dest_format, gint64& dest_value);
+};
+
+class QueryPosition : public Query
+{
+public:
+ explicit QueryPosition(GstQuery* query);
+
+ static Glib::RefPtr<Query> create(Format format);
+ void set(Format format, gint64 position);
+ void parse(Format& format, gint64& position);
+};
+
+class QueryDuration : public Query
+{
+public:
+ explicit QueryDuration(GstQuery* query);
+
+ static Glib::RefPtr<Query> create(Format format);
+ void set(Format format, gint64 duration);
+ void parse(Format& format, gint64& duration);
+};
+
+class QueryLatency : public Query
+{
+public:
+ explicit QueryLatency(GstQuery* query);
+
+ static Glib::RefPtr<Query> create();
+ void set(bool live, ClockTime min_latency, ClockTime max_latency);
+ void parse(bool& live, ClockTime& min_latency, ClockTime& max_latency);
+};
+
+class QuerySeeking : public Query
+{
+public:
+ explicit QuerySeeking(GstQuery* query);
+
+ static Glib::RefPtr<Query> create(Format format);
+ void set(Format format, bool seeakable, gint64 segment_start, gint64 segment_end);
+ void parse(Format& format, bool& seekable, gint64& segment_start, gint64& segment_end);
+};
+
+class QueryFormats : public Query
+{
+public:
+ explicit QueryFormats(GstQuery* query);
+
+ static Glib::RefPtr<Query> create();
+ void set(int n_formats, const va_list& varargs);
+ //TODO: set(int n_formats, const std::vector<const Format>& formats);
+ void parse(guint& n_formats);
+ void parse(guint nth, Format& format);
+};
+
+class QuerySegment : public Query
+{
+public:
+ explicit QuerySegment(GstQuery* query);
+
+ static Glib::RefPtr<Query> create(Format format);
+ void set(double rate, Format format, gint64 start_value, gint64 stop_value);
+ void parse(double& rate, Format& format, gint64& start_value, gint64& stop_value);
};
}//namespace Gst
Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am (original)
+++ gstreamermm/trunk/tests/Makefile.am Tue Jan 8 20:06:54 2008
@@ -4,7 +4,7 @@
noinst_PROGRAMS = test-create-element test-pipeline-add-element \
test-link-elements test-create-bin test-miniobject-wrap \
- test-message-wrap test-event-wrap
+ test-message-wrap test-event-wrap test-query-wrap
test_create_element_SOURCES=test-create-element.cc
test_create_element_LDFLAGS= GSTMM_LIBS@
@@ -27,6 +27,9 @@
test_event_wrap_SOURCES=test-event-wrap.cc
test_event_wrap_LDFLAGS= GSTMM_LIBS@
+test_query_wrap_SOURCES=test-query-wrap.cc
+test_query_wrap_LDFLAGS= GSTMM_LIBS@
+
#runtestbasic runtestlangs \
#runtestsearch runtestmimetypes \
#runtestgetbuffer
Added: gstreamermm/trunk/tests/test-query-wrap.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-query-wrap.cc Tue Jan 8 20:06:54 2008
@@ -0,0 +1,19 @@
+#include <gstmm.h>
+#include <iostream>
+
+int main (int argc, char* argv[])
+{
+ Gst::init(argc, argv);
+
+ GstQuery* cquery = gst_query_new_position(GST_FORMAT_PERCENT);
+
+ Glib::RefPtr<Gst::Query> query = Gst::Query::wrap(cquery);
+
+ std::cout << "C++ query instance is !NULL: " << (bool)(query) << std::endl;
+
+ Glib::RefPtr<Gst::QueryPosition> query_position = Glib::RefPtr<Gst::QueryPosition>::cast_dynamic(query);
+ std::cout << "query is a Gst::QueryPosition: " << (bool)query_position << std::endl;
+ std::cout << "query type name: '" << Gst::get_name(query->get_query_type()) << "'" << std::endl;
+
+ return 0;
+}
Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4 (original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4 Tue Jan 8 20:06:54 2008
@@ -57,6 +57,8 @@
_CONVERSION(`MessageType',`GstMessageType',`GstMessageType($3)')
_CONVERSION(`GstEventType',`EventType',`EventType($3)')
_CONVERSION(`EventType',`GstEventType',`GstEventType($3)')
+_CONVERSION(`GstQueryType',`QueryType',`QueryType($3)')
+_CONVERSION(`QueryType',`GstQueryType',`GstQueryType($3)')
_CONVERSION(`GQuark',`Glib::QueryQuark',`Glib::QueryQuark($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]