19 #include "miniobject.h"
20 #include "structure.h"
21 #include "../QGlib/value.h"
23 #include <gst/gstvalue.h>
24 #include <gst/gstminiobject.h>
25 #include <gst/gstdatetime.h>
29 GetTypeImpl<QDate>::operator Type() {
return GST_TYPE_DATE; }
30 GetTypeImpl<QDateTime>::operator Type() {
return GST_TYPE_DATE_TIME; }
37 void registerValueVTables()
39 struct ValueVTable_MiniObject
43 *
reinterpret_cast<GstMiniObject**
>(data) = gst_value_get_mini_object(value);
48 gst_value_set_mini_object(value, *reinterpret_cast<GstMiniObject* const *>(data));
55 struct ValueVTable_Fourcc
59 reinterpret_cast<Fourcc*
>(data)->value.as_integer = gst_value_get_fourcc(value);
64 gst_value_set_fourcc(value, reinterpret_cast<Fourcc const *>(data)->value.as_integer);
71 struct ValueVTable_Fraction
75 reinterpret_cast<Fraction*
>(data)->numerator = gst_value_get_fraction_numerator(value);
76 reinterpret_cast<Fraction*
>(data)->denominator = gst_value_get_fraction_denominator(value);
81 gst_value_set_fraction(value, reinterpret_cast<Fraction const *>(data)->numerator,
82 reinterpret_cast<Fraction const *>(data)->denominator);
89 struct ValueVTable_IntRange
93 reinterpret_cast<IntRange*
>(data)->start = gst_value_get_int_range_min(value);
94 reinterpret_cast<IntRange*
>(data)->end = gst_value_get_int_range_max(value);
99 gst_value_set_int_range(value, reinterpret_cast<IntRange const *>(data)->start,
100 reinterpret_cast<IntRange const *>(data)->end);
106 struct ValueVTable_Int64Range
110 reinterpret_cast<Int64Range*
>(data)->start = gst_value_get_int64_range_min(value);
111 reinterpret_cast<Int64Range*
>(data)->end = gst_value_get_int64_range_max(value);
116 gst_value_set_int64_range(value, reinterpret_cast<Int64Range const *>(data)->start,
117 reinterpret_cast<Int64Range const *>(data)->end);
124 struct ValueVTable_DoubleRange
128 reinterpret_cast<DoubleRange*
>(data)->start = gst_value_get_double_range_min(value);
129 reinterpret_cast<DoubleRange*
>(data)->end = gst_value_get_double_range_max(value);
134 gst_value_set_double_range(value, reinterpret_cast<DoubleRange const *>(data)->start,
135 reinterpret_cast<DoubleRange const *>(data)->end);
142 struct ValueVTable_FractionRange
147 gst_value_get_fraction_numerator(gst_value_get_fraction_range_min(value));
149 gst_value_get_fraction_denominator(gst_value_get_fraction_range_min(value));
151 gst_value_get_fraction_numerator(gst_value_get_fraction_range_max(value));
153 gst_value_get_fraction_denominator(gst_value_get_fraction_range_max(value));
158 gst_value_set_fraction_range_full(value,
159 reinterpret_cast<FractionRange const *>(data)->start.numerator,
160 reinterpret_cast<FractionRange const *>(data)->start.denominator,
161 reinterpret_cast<FractionRange const *>(data)->end.numerator,
162 reinterpret_cast<FractionRange const *>(data)->end.denominator);
168 struct ValueVTable_Structure
172 *
reinterpret_cast<Structure*
>(data) = Structure(gst_value_get_structure(value));
177 gst_value_set_structure(value, *reinterpret_cast<Structure const *>(data));
183 struct ValueVTable_QDate
187 const GDate *gdate = gst_value_get_date(value);
188 *
reinterpret_cast<QDate*
>(data) = QDate(g_date_get_year(gdate),
189 g_date_get_month(gdate),
190 g_date_get_day(gdate));
195 const QDate *qdate =
reinterpret_cast<QDate
const *
>(data);
196 GDate *gdate = g_date_new_dmy(qdate->day(),
197 static_cast<GDateMonth
>(qdate->month()),
199 gst_value_set_date(value, gdate);
206 struct ValueVTable_QDateTime
210 const GstDateTime *gdatetime =
static_cast<GstDateTime*
>(g_value_get_boxed(value));
212 QDate date = QDate(gst_date_time_get_year(gdatetime),
213 gst_date_time_get_month(gdatetime),
214 gst_date_time_get_day(gdatetime));
217 float tzoffset = gst_date_time_get_time_zone_offset(gdatetime);
219 float minutesOffset = std::modf(tzoffset, &hourOffset);
221 int hour = gst_date_time_get_hour(gdatetime) - hourOffset;
222 int minute = gst_date_time_get_minute(gdatetime) - (minutesOffset * 60);
228 }
else if (minute < 0) {
230 minute = 60 + minute;
234 date = date.addDays(1);
236 }
else if (hour < 0) {
237 date = date.addDays(-1);
241 QTime time = QTime(hour, minute,
242 gst_date_time_get_second(gdatetime),
243 gst_date_time_get_microsecond(gdatetime)/1000);
245 *
reinterpret_cast<QDateTime*
>(data) = QDateTime(date, time, Qt::UTC);
250 QDateTime qdatetime =
reinterpret_cast<QDateTime
const *
>(data)->toUTC();
251 GstDateTime *gdatetime = gst_date_time_new(0.0f,
252 qdatetime.date().year(),
253 qdatetime.date().month(),
254 qdatetime.date().day(),
255 qdatetime.time().hour(),
256 qdatetime.time().minute(),
257 qdatetime.time().second() + (qdatetime.time().msec()/1000.0)
260 g_value_take_boxed(value, gdatetime);