1 From d0ac492e3023545adad8008a3ebcac2a297dc783 Mon Sep 17 00:00:00 2001
2 From: Tasuku Suzuki <tasuku.suzuki@qt.io>
3 Date: Sun, 24 Jul 2016 00:23:10 +0900
4 Subject: [PATCH] GStreamer: support date time type in metadata
6 Change-Id: Ica57abfc0a60b401be88662483d35699d4f76321
7 Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
9 src/gsttools/qgstutils.cpp | 19 +++++++++++++++++++
10 1 file changed, 19 insertions(+)
12 diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp
13 index b5299f1..831ba96 100644
14 --- a/src/gsttools/qgstutils.cpp
15 +++ b/src/gsttools/qgstutils.cpp
17 #include "qgstutils_p.h"
19 #include <QtCore/qdatetime.h>
20 +#include <QtCore/qtimezone.h>
21 #include <QtCore/qdir.h>
22 #include <QtCore/qbytearray.h>
23 #include <QtCore/qvariant.h>
24 @@ -123,6 +124,24 @@ static void addTagToMap(const GstTagList *list,
25 if (!map->contains("year"))
26 map->insert("year", year);
28 +#if GST_CHECK_VERSION(1,0,0)
29 + } else if (G_VALUE_TYPE(&val) == GST_TYPE_DATE_TIME) {
30 + const GstDateTime *dateTime = (const GstDateTime *)g_value_get_boxed(&val);
31 + int year = gst_date_time_has_year(dateTime) ? gst_date_time_get_year(dateTime) : 0;
32 + int month = gst_date_time_has_month(dateTime) ? gst_date_time_get_month(dateTime) : 0;
33 + int day = gst_date_time_has_day(dateTime) ? gst_date_time_get_day(dateTime) : 0;
34 + if (gst_date_time_has_time(dateTime)) {
35 + int hour = gst_date_time_get_hour(dateTime);
36 + int minute = gst_date_time_get_minute(dateTime);
37 + int second = gst_date_time_get_second(dateTime);
38 + float tz = gst_date_time_get_time_zone_offset(dateTime);
39 + map->insert(QByteArray(tag), QDateTime(QDate(year,month,day), QTime(hour, minute, second), QTimeZone(tz * 60 * 60)));
40 + } else if (year > 0 && month > 0 && day > 0) {
41 + map->insert(QByteArray(tag), QDate(year,month,day));
43 + if (!map->contains("year") && year > 0)
44 + map->insert("year", year);
46 } else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) {
47 int nom = gst_value_get_fraction_numerator(&val);
48 int denom = gst_value_get_fraction_denominator(&val);