summaryrefslogtreecommitdiffstats
path: root/src/multimedia/video/qvideoframe.cpp
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2012-01-12 16:11:47 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-13 07:54:19 +0100
commitc8f48841ef86d27b363ef3332158e8952165853d (patch)
tree2ba692fb45ac4e17dedcbaa5e7e61710b6fc07b9 /src/multimedia/video/qvideoframe.cpp
parent41ff2e68291181fc7d79abcb01c5edb2472ad5b0 (diff)
Add a metaData property to QVideoFrame.
Change-Id: I6614cd86e3e1e170277bfc751222b5b42cb657eb Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Diffstat (limited to 'src/multimedia/video/qvideoframe.cpp')
-rw-r--r--src/multimedia/video/qvideoframe.cpp53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp
index 687716ac8..c58b6ebe8 100644
--- a/src/multimedia/video/qvideoframe.cpp
+++ b/src/multimedia/video/qvideoframe.cpp
@@ -115,6 +115,7 @@ public:
QAbstractVideoBuffer *buffer;
int mappedCount;
QMutex mapMutex;
+ QVariantMap metadata;
private:
Q_DISABLE_COPY(QVideoFramePrivate)
@@ -754,6 +755,45 @@ void QVideoFrame::setEndTime(qint64 time)
}
/*!
+ Returns any extra metadata associated with this frame.
+ */
+QVariantMap QVideoFrame::availableMetaData() const
+{
+ return d->metadata;
+}
+
+/*!
+ Returns any metadata for this frame for the given \a key.
+
+ This might include frame specific information from
+ a camera, or subtitles from a decoded video stream.
+
+ See the documentation for the relevant video frame
+ producer for further information about available metadata.
+ */
+QVariant QVideoFrame::metaData(const QString &key) const
+{
+ return d->metadata.value(key);
+}
+
+/*!
+ Sets the metadata for the given \a key to \a value.
+
+ If \a value is a null variant, any metadata for this key will be removed.
+
+ The producer of the video frame might use this to associate
+ certain data with this frame, or for an intermediate processor
+ to add information for a consumer of this frame.
+ */
+void QVideoFrame::setMetaData(const QString &key, const QVariant &value)
+{
+ if (!value.isNull())
+ d->metadata.insert(key, value);
+ else
+ d->metadata.remove(key);
+}
+
+/*!
Returns a video pixel format equivalent to an image \a format. If there is no equivalent
format QVideoFrame::InvalidType is returned instead.
@@ -843,6 +883,9 @@ QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format)
return QImage::Format_Invalid;
}
+
+
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, QVideoFrame::PixelFormat pf)
{
@@ -1005,12 +1048,16 @@ static QString qFormatTimeStamps(qint64 start, qint64 end)
QDebug operator<<(QDebug dbg, const QVideoFrame& f)
{
- return dbg << "QVideoFrame(" << f.size() << ","
+ dbg.nospace() << "QVideoFrame(" << f.size() << ","
<< f.pixelFormat() << ", "
<< f.handleType() << ", "
<< f.mapMode() << ", "
- << qFormatTimeStamps(f.startTime(), f.endTime()).toLatin1().constData()
- << ")";
+ << qFormatTimeStamps(f.startTime(), f.endTime()).toLatin1().constData();
+ if (f.availableMetaData().count()) {
+ dbg.nospace() << ", metaData: ";
+ dbg.nospace() << f.availableMetaData();
+ }
+ return dbg.nospace() << ")";
}
#endif