From c877776c354a625373e1dc0f38ac4918da9a056f Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 29 Nov 2018 14:48:58 +0300 Subject: GStreamer: support video orientation Change-Id: I233c45824f517c185cb245d8a7d77cab8551fc51 Reviewed-by: VaL Doroshchuk --- src/gsttools/qgstutils.cpp | 31 +++++++++++++++++++++++++++++++ src/gsttools/qgstutils_p.h | 5 +++++ 2 files changed, 36 insertions(+) (limited to 'src/gsttools') diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp index 5989d2133..ac4428e04 100644 --- a/src/gsttools/qgstutils.cpp +++ b/src/gsttools/qgstutils.cpp @@ -1521,6 +1521,37 @@ QString QGstUtils::fileExtensionForMimeType(const QString &mimeType) return extension; } +#if GST_CHECK_VERSION(0,10,30) +QVariant QGstUtils::fromGStreamerOrientation(const QVariant &value) +{ + // Note gstreamer tokens either describe the counter clockwise rotation of the + // image or the clockwise transform to apply to correct the image. The orientation + // value returned is the clockwise rotation of the image. + const QString token = value.toString(); + if (token == QStringLiteral("rotate-90")) + return 270; + if (token == QStringLiteral("rotate-180")) + return 180; + if (token == QStringLiteral("rotate-270")) + return 90; + return 0; +} + +QVariant QGstUtils::toGStreamerOrientation(const QVariant &value) +{ + switch (value.toInt()) { + case 90: + return QStringLiteral("rotate-270"); + case 180: + return QStringLiteral("rotate-180"); + case 270: + return QStringLiteral("rotate-90"); + default: + return QStringLiteral("rotate-0"); + } +} +#endif + void qt_gst_object_ref_sink(gpointer object) { #if GST_CHECK_VERSION(0,10,24) diff --git a/src/gsttools/qgstutils_p.h b/src/gsttools/qgstutils_p.h index 24d3e889d..387a2e27a 100644 --- a/src/gsttools/qgstutils_p.h +++ b/src/gsttools/qgstutils_p.h @@ -148,6 +148,11 @@ namespace QGstUtils { Q_GSTTOOLS_EXPORT QPair structureFrameRateRange(const GstStructure *s); Q_GSTTOOLS_EXPORT QString fileExtensionForMimeType(const QString &mimeType); + +#if GST_CHECK_VERSION(0,10,30) + Q_GSTTOOLS_EXPORT QVariant fromGStreamerOrientation(const QVariant &value); + Q_GSTTOOLS_EXPORT QVariant toGStreamerOrientation(const QVariant &value); +#endif } Q_GSTTOOLS_EXPORT void qt_gst_object_ref_sink(gpointer object); -- cgit v1.2.3