Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qmediametadata.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qmediametadata.h"
5#include <QtCore/qcoreapplication.h>
6#include <qvariant.h>
7#include <qobject.h>
8#include <qdatetime.h>
9#include <qmediaformat.h>
10#include <qsize.h>
11#include <qurl.h>
12#include <qimage.h>
13
15
82{
83 switch (key) {
84 case Title:
85 case Comment:
86 case Description:
87 case Publisher:
88 case Copyright:
89 case MediaType:
90 case AlbumTitle:
91 case AlbumArtist:
92 return QMetaType::fromType<QString>();
93 case Genre:
94 case Author:
96 case Composer:
97 case LeadPerformer:
98 return QMetaType::fromType<QStringList>();
99
100 case Date:
101 return QMetaType::fromType<QDateTime>();
102
103 case Language:
104 return QMetaType::fromType<QLocale::Language>();
105 case Url:
106 return QMetaType::fromType<QUrl>();
107
108 case Duration:
109 return QMetaType::fromType<qint64>();
110 case FileFormat:
111 return QMetaType::fromType<QMediaFormat::FileFormat>();
112
113 case AudioBitRate:
114 case VideoBitRate:
115 case TrackNumber:
116 case Orientation:
117 return QMetaType::fromType<int>();
118 case AudioCodec:
119 return QMetaType::fromType<QMediaFormat::AudioCodec>();
120 case VideoCodec:
121 return QMetaType::fromType<QMediaFormat::VideoCodec>();
122 case VideoFrameRate:
123 return QMetaType::fromType<qreal>();
124
125
126 case ThumbnailImage:
127 case CoverArtImage:
128 return QMetaType::fromType<QImage>();
129
130 case Resolution:
131 return QMetaType::fromType<QSize>();
132 default:
133 return QMetaType::fromType<void>();
134 }
135}
136
143
152/*
153 Some potential attributes to add if we can properly support them.
154 Might require that we add EXIF support to Qt Multimedia
155
156 \header \li {3,1}
157 Photo attributes.
158 \row \li CameraManufacturer \li The manufacturer of the camera used to capture the media. \li QString
159 \row \li CameraModel \li The model of the camera used to capture the media. \li QString
160 \row \li Event \li The event during which the media was captured. \li QString
161 \row \li Subject \li The subject of the media. \li QString
162 \row \li ExposureTime \li Exposure time, given in seconds. \li qreal
163 \row \li FNumber \li The F Number. \li int
164 \row \li ExposureProgram
165 \li The class of the program used by the camera to set exposure when the picture is taken. \li QString
166 \row \li ISOSpeedRatings
167 \li Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232. \li qreal
168 \row \li ExposureBiasValue
169 \li The exposure bias.
170 The unit is the APEX (Additive System of Photographic Exposure) setting. \li qreal
171 \row \li DateTimeOriginal \li The date and time when the original image data was generated. \li QDateTime
172 \row \li DateTimeDigitized \li The date and time when the image was stored as digital data. \li QDateTime
173 \row \li SubjectDistance \li The distance to the subject, given in meters. \li qreal
174 \row \li LightSource
175 \li The kind of light source. \li QString
176 \row \li Flash
177 \li Status of flash when the image was shot. \li QCamera::FlashMode
178 \row \li FocalLength
179 \li The actual focal length of the lens, in mm. \li qreal
180 \row \li ExposureMode
181 \li Indicates the exposure mode set when the image was shot. \li QCamera::ExposureMode
182 \row \li WhiteBalance
183 \li Indicates the white balance mode set when the image was shot. \li QCamera::WhiteBalanceMode
184 \row \li DigitalZoomRatio
185 \li Indicates the digital zoom ratio when the image was shot. \li qreal
186 \row \li FocalLengthIn35mmFilm
187 \li Indicates the equivalent focal length assuming a 35mm film camera, in mm. \li qreal
188 \row \li SceneCaptureType
189 \li Indicates the type of scene that was shot.
190 It can also be used to record the mode in which the image was shot. \li QString
191 \row \li GainControl
192 \li Indicates the degree of overall image gain adjustment. \li qreal
193 \row \li Contrast
194 \li Indicates the direction of contrast processing applied by the camera when the image was shot. \li qreal
195 \row \li Saturation
196 \li Indicates the direction of saturation processing applied by the camera when the image was shot. \li qreal
197 \row \li Sharpness
198 \li Indicates the direction of sharpness processing applied by the camera when the image was shot. \li qreal
199 \row \li DeviceSettingDescription
200 \li Exif tag, indicates information on the picture-taking conditions of a particular camera model. \li QString
201
202 \row \li GPSLatitude
203 \li Latitude value of the geographical position (decimal degrees).
204 A positive latitude indicates the Northern Hemisphere,
205 and a negative latitude indicates the Southern Hemisphere. \li double
206 \row \li GPSLongitude
207 \li Longitude value of the geographical position (decimal degrees).
208 A positive longitude indicates the Eastern Hemisphere,
209 and a negative longitude indicates the Western Hemisphere. \li double
210 \row \li GPSAltitude
211 \li The value of altitude in meters above sea level. \li double
212 \row \li GPSTimeStamp
213 \li Time stamp of GPS data. \li QDateTime
214 \row \li GPSSatellites
215 \li GPS satellites used for measurements. \li QString
216 \row \li GPSStatus
217 \li Status of GPS receiver at image creation time. \li QString
218 \row \li GPSDOP
219 \li Degree of precision for GPS data. \li qreal
220 \row \li GPSSpeed
221 \li Speed of GPS receiver movement in kilometers per hour. \li qreal
222 \row \li GPSTrack
223 \li Direction of GPS receiver movement.
224 The range of values is [0.0, 360),
225 with 0 direction pointing on either true or magnetic north,
226 depending on GPSTrackRef. \li qreal
227 \row \li GPSTrackRef
228 \li Reference for movement direction. \li QChar.
229 'T' means true direction and 'M' is magnetic direction.
230 \row \li GPSImgDirection
231 \li Direction of image when captured. \li qreal
232 The range of values is [0.0, 360).
233 \row \li GPSImgDirectionRef
234 \li Reference for image direction. \li QChar.
235 'T' means true direction and 'M' is magnetic direction.
236 \row \li GPSMapDatum
237 \li Geodetic survey data used by the GPS receiver. \li QString
238 \row \li GPSProcessingMethod
239 \li The name of the method used for location finding. \li QString
240 \row \li GPSAreaInformation
241 \li The name of the GPS area. \li QString
242
243 \endtable
244*/
245
361{
363 if (value.isNull())
364 return QString();
365
366 switch (key) {
367 // string based or convertible to string
368 case Title:
369 case Author:
370 case Comment:
371 case Description:
372 case Genre:
373 case Publisher:
374 case Copyright:
375 case Date:
376 case Url:
377 case MediaType:
378 case AudioBitRate:
379 case VideoBitRate:
380 case VideoFrameRate:
381 case AlbumTitle:
382 case AlbumArtist:
384 case TrackNumber:
385 case Composer:
386 case Orientation:
387 case LeadPerformer:
388 return value.toString();
389 case Language: {
390 auto l = value.value<QLocale::Language>();
392 }
393 case Duration: {
395 return time.toString();
396 }
397 case FileFormat:
399 case AudioCodec:
401 case VideoCodec:
403 case Resolution: {
404 QSize size = value.toSize();
405 return QString::fromUtf8("%1 x %2").arg(size.width()).arg(size.height());
406 }
407 case ThumbnailImage:
408 case CoverArtImage:
409 break;
410 }
411 return QString();
412}
424{
425 switch (key) {
427 return (QCoreApplication::translate("QMediaMetaData", "Title"));
429 return (QCoreApplication::translate("QMediaMetaData", "Author"));
431 return (QCoreApplication::translate("QMediaMetaData", "Comment"));
433 return (QCoreApplication::translate("QMediaMetaData", "Description"));
435 return (QCoreApplication::translate("QMediaMetaData", "Genre"));
437 return (QCoreApplication::translate("QMediaMetaData", "Date"));
439 return (QCoreApplication::translate("QMediaMetaData", "Language"));
441 return (QCoreApplication::translate("QMediaMetaData", "Publisher"));
443 return (QCoreApplication::translate("QMediaMetaData", "Copyright"));
445 return (QCoreApplication::translate("QMediaMetaData", "Url"));
447 return (QCoreApplication::translate("QMediaMetaData", "Duration"));
449 return (QCoreApplication::translate("QMediaMetaData", "Media type"));
451 return (QCoreApplication::translate("QMediaMetaData", "Container Format"));
453 return (QCoreApplication::translate("QMediaMetaData", "Audio bit rate"));
455 return (QCoreApplication::translate("QMediaMetaData", "Audio codec"));
457 return (QCoreApplication::translate("QMediaMetaData", "Video bit rate"));
459 return (QCoreApplication::translate("QMediaMetaData", "Video codec"));
461 return (QCoreApplication::translate("QMediaMetaData", "Video frame rate"));
463 return (QCoreApplication::translate("QMediaMetaData", "Album title"));
465 return (QCoreApplication::translate("QMediaMetaData", "Album artist"));
467 return (QCoreApplication::translate("QMediaMetaData", "Contributing artist"));
469 return (QCoreApplication::translate("QMediaMetaData", "Track number"));
471 return (QCoreApplication::translate("QMediaMetaData", "Composer"));
473 return (QCoreApplication::translate("QMediaMetaData", "Thumbnail image"));
475 return (QCoreApplication::translate("QMediaMetaData", "Cover art image"));
477 return (QCoreApplication::translate("QMediaMetaData", "Orientation"));
479 return (QCoreApplication::translate("QMediaMetaData", "Resolution"));
481 return (QCoreApplication::translate("QMediaMetaData", "Lead performer"));
482 }
483 return QString();
484}
485
486// operator documentation
515
516#include "moc_qmediametadata.cpp"
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
static QString languageToString(Language language)
Returns a QString containing the name of language.
Definition qlocale.cpp:1542
static Q_INVOKABLE QString videoCodecName(VideoCodec codec)
\qmlmethod string QtMultimedia::mediaFormat::videoCodecName(codec) Returns a string based name for co...
AudioCodec
\qmlproperty enumeration QtMultimedia::mediaFormat::fileFormat
static Q_INVOKABLE QString audioCodecName(AudioCodec codec)
\qmlmethod string QtMultimedia::mediaFormat::audioCodecName(codec) Returns a string based name for co...
FileFormat
Describes the container format used in a multimedia file or stream.
VideoCodec
\qmlproperty enumeration QtMultimedia::mediaFormat::audioCodec
static Q_INVOKABLE QString fileFormatName(FileFormat fileFormat)
\qmlmethod string QtMultimedia::mediaFormat::fileFormatName(fileFormat) Returns a string based name f...
Q_INVOKABLE QString stringValue(Key k) const
\qmlmethod string QtMultimedia::mediaMetaData::stringValue(Key key) Returns the meta data for key key...
static Q_INVOKABLE QString metaDataKeyToString(Key k)
\qmlmethod string QtMultimedia::mediaMetaData::metaDataKeyToString(Key key) returns a string represen...
static QMetaType keyType(Key key)
Returns the meta type used to store data for Key key.
\inmodule QtCore
Definition qmetatype.h:320
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8606
\inmodule QtCore \reentrant
Definition qdatetime.h:189
static constexpr QTime fromMSecsSinceStartOfDay(int msecs)
Returns a new QTime instance with the time set to the number of msecs since the start of the day,...
Definition qdatetime.h:217
\inmodule QtCore
Definition qvariant.h:64
T value() const &
Definition qvariant.h:511
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data