[gstreamermm: 54/167] fixed query class
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 54/167] fixed query class
- Date: Tue, 3 Sep 2013 19:23:37 +0000 (UTC)
commit 518421ab76b08eaba65b40ef29b75268479c2865
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date: Fri Jul 26 13:54:12 2013 +0200
fixed query class
gstreamer/src/query.ccg | 60 +++++++++-------------------------------------
gstreamer/src/query.hg | 22 ++++++++++-------
2 files changed, 25 insertions(+), 57 deletions(-)
---
diff --git a/gstreamer/src/query.ccg b/gstreamer/src/query.ccg
index 0b106ae..5b1f07f 100644
--- a/gstreamer/src/query.ccg
+++ b/gstreamer/src/query.ccg
@@ -46,30 +46,22 @@ Glib::RefPtr<Gst::Query> Query::create_writable()
return Glib::wrap(gst_query_make_writable(gobj()));
}
-QueryApplication::QueryApplication(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryApplication>
QueryApplication::create(QueryType type, Gst::Structure& structure)
{
// Create copy because query takes ownership of structure:
GstStructure* copy_struct = gst_structure_copy(structure.gobj());
- GstQuery* query = gst_query_new_application(GstQueryType(type),
+ GstQuery* query = gst_query_new_custom(GstQueryType(type),
copy_struct);
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryApplication>(query);
}
-QueryConvert::QueryConvert(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryConvert>
QueryConvert::create(Format src_format, gint64 value, Format dest_format)
{
GstQuery* query = gst_query_new_convert(GstFormat(src_format), value,
GstFormat(dest_format));
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryConvert>(query);
}
void QueryConvert::set(Format src_format, gint64 src_value, Format dest_format, gint64 dest_value)
@@ -122,14 +114,10 @@ gint64 QueryConvert::parse_dest_value() const
return dest_value;
}
-QueryPosition::QueryPosition(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryPosition> QueryPosition::create(Format format)
{
GstQuery* query = gst_query_new_position(GstFormat(format));
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryPosition>(query);
}
void QueryPosition::set(Format format, gint64 position)
@@ -158,14 +146,10 @@ Format QueryPosition::parse_format() const
return format;
}
-QueryDuration::QueryDuration(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryDuration> QueryDuration::create(Format format)
{
GstQuery* query = gst_query_new_duration(GstFormat(format));
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryDuration>(query);
}
void QueryDuration::set(Format format, gint64 duration)
@@ -194,14 +178,10 @@ Format QueryDuration::parse_format() const
return format;
}
-QueryLatency::QueryLatency(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryLatency> QueryLatency::create()
{
GstQuery* query = gst_query_new_latency();
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryLatency>(query);
}
void QueryLatency::set(bool live, ClockTime min_latency, ClockTime max_latency)
@@ -241,14 +221,10 @@ ClockTime QueryLatency::parse_max() const
return max;
}
-QuerySeeking::QuerySeeking(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QuerySeeking> QuerySeeking::create(Format format)
{
GstQuery* query = gst_query_new_seeking(GstFormat(format));
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QuerySeeking>(query);
}
void QuerySeeking::set(Format format, bool seekable, gint64 segment_start, gint64 segment_end)
@@ -297,14 +273,10 @@ gint64 QuerySeeking::parse_end() const
return end;
}
-QueryFormats::QueryFormats(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryFormats> QueryFormats::create()
{
GstQuery* query = gst_query_new_formats();
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryFormats>(query);
}
void QueryFormats::set(const Glib::ArrayHandle<Format>& formats)
@@ -322,26 +294,22 @@ void QueryFormats::set(int n_formats, const Glib::ArrayHandle<Format>& formats)
guint QueryFormats::parse_length() const
{
guint n_formats = 0;
- gst_query_parse_formats_length(const_cast<GstQuery*>(gobj()), &n_formats);
+ gst_query_parse_n_formats(const_cast<GstQuery*>(gobj()), &n_formats);
return n_formats;
}
Format QueryFormats::parse(guint nth) const
{
Format format = Gst::FORMAT_UNDEFINED;
- gst_query_parse_formats_nth(const_cast<GstQuery*>(gobj()), nth,
+ gst_query_parse_nth_format(const_cast<GstQuery*>(gobj()), nth,
reinterpret_cast<GstFormat*>(&format));
return format;
}
-QuerySegment::QuerySegment(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QuerySegment> QuerySegment::create(Format format)
{
GstQuery* query = gst_query_new_segment(GstFormat(format));
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QuerySegment>(query);
}
void QuerySegment::set(double rate, Format format, gint64 start_value, gint64 stop_value)
@@ -388,14 +356,10 @@ gint64 QuerySegment::parse_stop() const
return stop;
}
-QueryBuffering::QueryBuffering(GstQuery* castitem) :
-Query(castitem)
-{}
-
Glib::RefPtr<Gst::QueryBuffering> QueryBuffering::create(Format format)
{
GstQuery* query = gst_query_new_buffering(GstFormat(format));
- return Glib::wrap(query);
+ return Glib::wrap_query_derived<Gst::QueryBuffering>(query);
}
void QueryBuffering::set(bool busy, int percent)
diff --git a/gstreamer/src/query.hg b/gstreamer/src/query.hg
index ac6f79d..01a83e3 100644
--- a/gstreamer/src/query.hg
+++ b/gstreamer/src/query.hg
@@ -25,6 +25,19 @@
_DEFS(gstreamermm,gst)
+namespace Glib
+{
+ template<typename T>
+ Glib::RefPtr<T> wrap_query_derived(GstQuery* object, bool take_copy = false)
+ {
+ if(take_copy && object)
+ gst_query_ref(object);
+
+ // See the comment at the top of this file, if you want to know why the cast works.
+ return Glib::RefPtr<T>(reinterpret_cast<T*>(object));
+ }
+}
+
namespace Gst
{
@@ -141,7 +154,6 @@ protected:
class QueryApplication : public Query
{
public:
- explicit QueryApplication(GstQuery* query);
/** Constructs a new custom application query object. The Gst::Query may be
* used by applications in their own way. Please note that a custom
@@ -160,7 +172,6 @@ public:
class QueryConvert : public Query
{
public:
- explicit QueryConvert(GstQuery* query);
/** Constructs a new convert query object. A convert query is used to ask
* for a conversion between one format and another.
@@ -225,7 +236,6 @@ public:
class QueryPosition : public Query
{
public:
- explicit QueryPosition(GstQuery* query);
/** Constructs a new query stream position query object. A position query is
* used to query the current position of playback in the streams, in some
@@ -266,7 +276,6 @@ public:
class QueryDuration : public Query
{
public:
- explicit QueryDuration(GstQuery* query);
/** Constructs a new stream duration query object to query in the given
* format. A duration query will give the total length of the stream.
@@ -306,7 +315,6 @@ public:
class QueryLatency : public Query
{
public:
- explicit QueryLatency(GstQuery* query);
/** Constructs a new latency query object. A latency query is usually
* performed by sinks to compensate for additional latency introduced by
@@ -352,7 +360,6 @@ public:
class QuerySeeking : public Query
{
public:
- explicit QuerySeeking(GstQuery* query);
/** Constructs a new query object for querying seeking properties of the
* stream.
@@ -406,7 +413,6 @@ public:
class QueryFormats : public Query
{
public:
- explicit QueryFormats(GstQuery* query);
/** Constructs a new query object for querying formats of the stream.
* @return The new Gst::QueryFormats.
@@ -447,7 +453,6 @@ public:
class QuerySegment : public Query
{
public:
- explicit QuerySegment(GstQuery* query);
/** Constructs a new segment query object. A segment query is used to
* discover information about the currently configured segment for playback.
@@ -516,7 +521,6 @@ public:
class QueryBuffering : public Query
{
public:
- explicit QueryBuffering(GstQuery* query);
/** Constructs a new query object for querying the buffering status of a
* stream.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]