19#include "miniobject.h"
21#include "../QGlib/value.h"
27GetTypeImpl<QDate>::operator Type() {
return G_TYPE_DATE; }
28GetTypeImpl<QDateTime>::operator Type() {
return GST_TYPE_DATE_TIME; }
35void registerValueVTables()
37 struct ValueVTable_Fraction
41 reinterpret_cast<Fraction*
>(data)->numerator = gst_value_get_fraction_numerator(value);
42 reinterpret_cast<Fraction*
>(data)->denominator = gst_value_get_fraction_denominator(value);
47 gst_value_set_fraction(value,
reinterpret_cast<Fraction
const *
>(data)->numerator,
48 reinterpret_cast<Fraction
const *
>(data)->denominator);
55 struct ValueVTable_IntRange
59 reinterpret_cast<IntRange*
>(data)->start = gst_value_get_int_range_min(value);
60 reinterpret_cast<IntRange*
>(data)->end = gst_value_get_int_range_max(value);
65 gst_value_set_int_range(value,
reinterpret_cast<IntRange const *
>(data)->start,
66 reinterpret_cast<IntRange const *
>(data)->end);
72 struct ValueVTable_Int64Range
76 reinterpret_cast<Int64Range*
>(data)->start = gst_value_get_int64_range_min(value);
77 reinterpret_cast<Int64Range*
>(data)->end = gst_value_get_int64_range_max(value);
82 gst_value_set_int64_range(value,
reinterpret_cast<Int64Range const *
>(data)->start,
83 reinterpret_cast<Int64Range const *
>(data)->end);
90 struct ValueVTable_DoubleRange
94 reinterpret_cast<DoubleRange*
>(data)->start = gst_value_get_double_range_min(value);
95 reinterpret_cast<DoubleRange*
>(data)->end = gst_value_get_double_range_max(value);
100 gst_value_set_double_range(value,
reinterpret_cast<DoubleRange const *
>(data)->start,
108 struct ValueVTable_FractionRange
113 gst_value_get_fraction_numerator(gst_value_get_fraction_range_min(value));
115 gst_value_get_fraction_denominator(gst_value_get_fraction_range_min(value));
117 gst_value_get_fraction_numerator(gst_value_get_fraction_range_max(value));
119 gst_value_get_fraction_denominator(gst_value_get_fraction_range_max(value));
124 gst_value_set_fraction_range_full(value,
125 reinterpret_cast<FractionRange const *
>(data)->start.numerator,
126 reinterpret_cast<FractionRange const *
>(data)->start.denominator,
127 reinterpret_cast<FractionRange const *
>(data)->end.numerator,
128 reinterpret_cast<FractionRange const *
>(data)->end.denominator);
134 struct ValueVTable_Structure
138 *
reinterpret_cast<Structure*
>(data) = Structure(gst_value_get_structure(value));
143 gst_value_set_structure(value, *
reinterpret_cast<Structure
const *
>(data));
149 struct ValueVTable_QDate
153 const GDate *gdate =
static_cast<const GDate *
>(g_value_get_boxed(value));
154 *
reinterpret_cast<QDate*
>(data) = QDate(g_date_get_year(gdate),
155 g_date_get_month(gdate),
156 g_date_get_day(gdate));
161 const QDate *qdate =
reinterpret_cast<QDate
const *
>(data);
162 GDate *gdate = g_date_new_dmy(qdate->day(),
163 static_cast<GDateMonth
>(qdate->month()),
165 g_value_set_boxed(value, gdate);
172 struct ValueVTable_QDateTime
176 const GstDateTime *gdatetime =
static_cast<GstDateTime*
>(g_value_get_boxed(value));
178 QDate date = QDate(gst_date_time_get_year(gdatetime),
179 gst_date_time_get_month(gdatetime),
180 gst_date_time_get_day(gdatetime));
183 float tzoffset = gst_date_time_get_time_zone_offset(gdatetime);
185 float minutesOffset = std::modf(tzoffset, &hourOffset);
187 int hour = gst_date_time_get_hour(gdatetime) - hourOffset;
188 int minute = gst_date_time_get_minute(gdatetime) - (minutesOffset * 60);
194 }
else if (minute < 0) {
196 minute = 60 + minute;
200 date = date.addDays(1);
202 }
else if (hour < 0) {
203 date = date.addDays(-1);
207 QTime time = QTime(hour, minute,
208 gst_date_time_get_second(gdatetime),
209 gst_date_time_get_microsecond(gdatetime)/1000);
211 *
reinterpret_cast<QDateTime*
>(data) = QDateTime(date, time, Qt::UTC);
216 QDateTime qdatetime =
reinterpret_cast<QDateTime
const *
>(data)->toUTC();
217 GstDateTime *gdatetime = gst_date_time_new(0.0f,
218 qdatetime.date().year(),
219 qdatetime.date().month(),
220 qdatetime.date().day(),
221 qdatetime.time().hour(),
222 qdatetime.time().minute(),
223 qdatetime.time().second() + (qdatetime.time().msec()/1000.0)
226 g_value_take_boxed(value, gdatetime);
Wrapper class for GValue.
static void registerValueVTable(Type type, const ValueVTable &vtable)
Wrappers for Glib and GObject classes.
Wrappers for GStreamer classes.
Private::Range< double > DoubleRange
Helper structure for accessing double ranges.
Private::Range< Fraction > FractionRange
Helper structure for accessing fraction ranges.
Private::Range< qint64 > Int64Range
Helper structure for accessing qint64 ranges.
Private::Range< int > IntRange
Helper structure for accessing int ranges.