Fix writing orientation and date exif tags in camerabin.

Orientation tags need to be transformed from the string tag returned
by gstreamer to the orientation in degrees.  Date tags need to be
inserted with gst_date_time_new_local_time.  Finally setting a tag
value shouldn't clear all other tags.

Change-Id: I28922148251084c12cf6c93d9b097fa5df41da9d
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Andrew den Exter
2013-12-05 17:30:04 +10:00
committed by The Qt Project
parent 0be45b5669
commit 4565cf26af
2 changed files with 63 additions and 4 deletions

View File

@@ -76,6 +76,7 @@
#include <QtGui/qdesktopservices.h>
#include <QtGui/qimage.h>
#include <QtCore/qdatetime.h>
//#define CAMERABIN_DEBUG 1
//#define CAMERABIN_DEBUG_DUMP_BIN 1
@@ -737,7 +738,7 @@ void CameraBinSession::setMetaData(const QMap<QByteArray, QVariant> &data)
switch(tagValue.type()) {
case QVariant::String:
gst_tag_setter_add_tags(GST_TAG_SETTER(element),
GST_TAG_MERGE_REPLACE_ALL,
GST_TAG_MERGE_REPLACE,
tagName.toUtf8().constData(),
tagValue.toString().toUtf8().constData(),
NULL);
@@ -745,18 +746,29 @@ void CameraBinSession::setMetaData(const QMap<QByteArray, QVariant> &data)
case QVariant::Int:
case QVariant::LongLong:
gst_tag_setter_add_tags(GST_TAG_SETTER(element),
GST_TAG_MERGE_REPLACE_ALL,
GST_TAG_MERGE_REPLACE,
tagName.toUtf8().constData(),
tagValue.toInt(),
NULL);
break;
case QVariant::Double:
gst_tag_setter_add_tags(GST_TAG_SETTER(element),
GST_TAG_MERGE_REPLACE_ALL,
GST_TAG_MERGE_REPLACE,
tagName.toUtf8().constData(),
tagValue.toDouble(),
NULL);
break;
case QVariant::DateTime: {
QDateTime date = tagValue.toDateTime().toLocalTime();
gst_tag_setter_add_tags(GST_TAG_SETTER(element),
GST_TAG_MERGE_REPLACE,
tagName.toUtf8().constData(),
gst_date_time_new_local_time(
date.date().year(), date.date().month(), date.date().day(),
date.time().hour(), date.time().minute(), date.time().second()),
NULL);
break;
}
default:
break;
}
@@ -932,6 +944,7 @@ bool CameraBinSession::processBusMessage(const QGstreamerMessage &message)
emit stateChanged(m_state = QCamera::UnloadedState);
break;
case GST_STATE_READY:
setMetaData(m_metaData);
if (m_state != QCamera::LoadedState)
emit stateChanged(m_state = QCamera::LoadedState);
break;