summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-04 13:36:27 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-04 13:36:27 +0200
commit983bd3ecedf2b1c9fa68ee9cc4edc7d1be59ff37 (patch)
treede06f175521d481ebb69e8116d95ea7434aa93ac
parent1a34596b426f8a685453699ad44c45075a6c3681 (diff)
parent026aec5079375c866cd88ba176c88d2842d1b260 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp Change-Id: I4a30fc030c25e7b8da3eb9f386c4a5fa468df141
-rw-r--r--src/multimedia/audio/qaudioinput.cpp3
-rw-r--r--src/multimedia/audio/qaudiooutput.cpp3
-rw-r--r--src/multimedia/audio/qsoundeffect.cpp6
-rw-r--r--src/multimedia/playback/qmedianetworkplaylistprovider.cpp2
-rw-r--r--src/multimedia/playback/qmediaplayer.cpp4
-rw-r--r--src/multimedia/recording/qmediarecorder.cpp4
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h2
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm110
-rw-r--r--tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp12
-rw-r--r--tests/auto/integration/qsoundeffect/BLACKLIST3
10 files changed, 79 insertions, 70 deletions
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp
index bc6b6215..07165240 100644
--- a/src/multimedia/audio/qaudioinput.cpp
+++ b/src/multimedia/audio/qaudioinput.cpp
@@ -338,7 +338,8 @@ int QAudioInput::notifyInterval() const
*/
void QAudioInput::setVolume(qreal volume)
{
- d->setVolume(volume);
+ qreal v = qBound(qreal(0.0), volume, qreal(1.0));
+ d->setVolume(v);
}
/*!
diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp
index 585855ac..e96d24dd 100644
--- a/src/multimedia/audio/qaudiooutput.cpp
+++ b/src/multimedia/audio/qaudiooutput.cpp
@@ -355,7 +355,8 @@ QAudio::State QAudioOutput::state() const
*/
void QAudioOutput::setVolume(qreal volume)
{
- d->setVolume(volume);
+ qreal v = qBound(qreal(0.0), volume, qreal(1.0));
+ d->setVolume(v);
}
/*!
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp
index f653de86..f7237679 100644
--- a/src/multimedia/audio/qsoundeffect.cpp
+++ b/src/multimedia/audio/qsoundeffect.cpp
@@ -279,11 +279,7 @@ qreal QSoundEffect::volume() const
*/
void QSoundEffect::setVolume(qreal volume)
{
- if (volume < qreal(0.0) || volume > qreal(1.0)) {
- qWarning("SoundEffect: volume should be between 0.0 and 1.0");
- return;
- }
-
+ volume = qBound(qreal(0.0), volume, qreal(1.0));
if (qFuzzyCompare(d->volume(), volume))
return;
diff --git a/src/multimedia/playback/qmedianetworkplaylistprovider.cpp b/src/multimedia/playback/qmedianetworkplaylistprovider.cpp
index 67ce123d..7de90d9a 100644
--- a/src/multimedia/playback/qmedianetworkplaylistprovider.cpp
+++ b/src/multimedia/playback/qmedianetworkplaylistprovider.cpp
@@ -74,7 +74,7 @@ void QMediaNetworkPlaylistProviderPrivate::_q_handleParserError(QPlaylistFilePar
QMediaPlaylist::Error playlistError = QMediaPlaylist::NoError;
- switch ((QPlaylistFileParser::ParserError)err) {
+ switch (err) {
case QPlaylistFileParser::NoError:
return;
case QPlaylistFileParser::FormatError:
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp
index edccd30e..08f194be 100644
--- a/src/multimedia/playback/qmediaplayer.cpp
+++ b/src/multimedia/playback/qmediaplayer.cpp
@@ -962,8 +962,8 @@ void QMediaPlayer::setPlaybackRate(qreal rate)
Sets the current \a media source.
If a \a stream is supplied; media data will be read from it instead of resolving the media
- source. In this case the media source may still be used to resolve additional information
- about the media such as mime type.
+ source. In this case the media source may still be used to resolve additional information
+ about the media such as mime type. The \a stream must be open and readable.
Setting the media to a null QMediaContent will cause the player to discard all
information relating to the current media source and to cease all I/O operations related
diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp
index a5f4c15c..65eaed15 100644
--- a/src/multimedia/recording/qmediarecorder.cpp
+++ b/src/multimedia/recording/qmediarecorder.cpp
@@ -569,8 +569,10 @@ void QMediaRecorder::setVolume(qreal volume)
{
Q_D(QMediaRecorder);
- if (d->control)
+ if (d->control) {
+ volume = qMax(qreal(0.0), volume);
d->control->setVolume(volume);
+ }
}
/*!
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h
index 6721b0c8..39655004 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h
@@ -64,7 +64,7 @@ private Q_SLOTS:
private:
AVFMediaPlayerSession *m_session;
- QMap<QString, QVariant> m_tags;
+ QVariantMap m_tags;
void *m_asset;
};
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm
index 2414ff36..39783680 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm
@@ -81,6 +81,41 @@ QStringList AVFMediaPlayerMetaDataControl::availableMetaData() const
return m_tags.keys();
}
+static QString itemKey(AVMetadataItem *item)
+{
+ NSString *keyString = [item commonKey];
+
+ if (keyString.length != 0) {
+ if ([keyString isEqualToString:AVMetadataCommonKeyTitle]) {
+ return QMediaMetaData::Title;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeySubject]) {
+ return QMediaMetaData::SubTitle;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyDescription]) {
+ return QMediaMetaData::Description;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyPublisher]) {
+ return QMediaMetaData::Publisher;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyCreationDate]) {
+ return QMediaMetaData::Date;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyType]) {
+ return QMediaMetaData::MediaType;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyLanguage]) {
+ return QMediaMetaData::Language;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyCopyrights]) {
+ return QMediaMetaData::Copyright;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyAlbumName]) {
+ return QMediaMetaData::AlbumTitle;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyAuthor]) {
+ return QMediaMetaData::Author;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyArtist]) {
+ return QMediaMetaData::ContributingArtist;
+ } else if ([keyString isEqualToString: AVMetadataCommonKeyArtwork]) {
+ return QMediaMetaData::PosterUrl;
+ }
+ }
+
+ return QString();
+}
+
void AVFMediaPlayerMetaDataControl::updateTags()
{
#ifdef QT_DEBUG_AVF
@@ -89,67 +124,38 @@ void AVFMediaPlayerMetaDataControl::updateTags()
AVAsset *currentAsset = (AVAsset*)m_session->currentAssetHandle();
//Don't read the tags from the same asset more than once
- if (currentAsset == m_asset) {
+ if (currentAsset == m_asset)
return;
- }
m_asset = currentAsset;
+ QVariantMap oldTags = m_tags;
//Since we've changed assets, clear old tags
m_tags.clear();
-
- NSArray *metadataFormats = [currentAsset availableMetadataFormats];
- for ( NSString *format in metadataFormats) {
-#ifdef QT_DEBUG_AVF
- qDebug() << "format: " << [format UTF8String];
-#endif
- NSArray *metadataItems = [currentAsset metadataForFormat:format];
- for (AVMetadataItem* item in metadataItems) {
- NSString *keyString = [item commonKey];
- NSString *value = [item stringValue];
-
- if (keyString.length != 0) {
- //Process "commonMetadata" tags here:
- if ([keyString isEqualToString:AVMetadataCommonKeyTitle]) {
- m_tags.insert(QMediaMetaData::Title, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyCreator]) {
- m_tags.insert(QMediaMetaData::Author, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeySubject]) {
- m_tags.insert(QMediaMetaData::SubTitle, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyDescription]) {
- m_tags.insert(QMediaMetaData::Description, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyPublisher]) {
- m_tags.insert(QMediaMetaData::Publisher, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyContributor]) {
- m_tags.insert(QMediaMetaData::ContributingArtist, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyCreationDate]) {
- m_tags.insert(QMediaMetaData::Date, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyType]) {
- m_tags.insert(QMediaMetaData::MediaType, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyLanguage]) {
- m_tags.insert(QMediaMetaData::Language, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyCopyrights]) {
- m_tags.insert(QMediaMetaData::Copyright, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyAlbumName]) {
- m_tags.insert(QMediaMetaData::AlbumTitle, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyAuthor]) {
- m_tags.insert(QMediaMetaData::Author, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyArtist]) {
- m_tags.insert(QMediaMetaData::AlbumArtist, QString([value UTF8String]));
- } else if ([keyString isEqualToString: AVMetadataCommonKeyArtwork]) {
- m_tags.insert(QMediaMetaData::PosterUrl, QString([value UTF8String]));
+ bool changed = false;
+
+ // TODO: also process ID3, iTunes and QuickTime metadata
+
+ NSArray *metadataItems = [currentAsset commonMetadata];
+ for (AVMetadataItem* item in metadataItems) {
+ const QString key = itemKey(item);
+ if (!key.isEmpty()) {
+ const QString value = QString::fromNSString([item stringValue]);
+ if (!value.isNull()) {
+ m_tags.insert(key, value);
+ if (value != oldTags.value(key)) {
+ changed = true;
+ Q_EMIT metaDataChanged(key, value);
}
}
-
- if ([format isEqualToString:AVMetadataFormatID3Metadata]) {
- //TODO: Process ID3 metadata
- } else if ([format isEqualToString:AVMetadataFormatiTunesMetadata]) {
- //TODO: Process iTunes metadata
- } else if ([format isEqualToString:AVMetadataFormatQuickTimeUserData]) {
- //TODO: Process QuickTime metadata
- }
}
}
- Q_EMIT metaDataChanged();
+ if (oldTags.isEmpty() != m_tags.isEmpty()) {
+ Q_EMIT metaDataAvailableChanged(!m_tags.isEmpty());
+ changed = true;
+ }
+
+ if (changed)
+ Q_EMIT metaDataChanged();
}
diff --git a/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp
index ca1f2b67..f167bf8e 100644
--- a/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp
@@ -525,8 +525,8 @@ void tst_QAudioOutput::pull()
// Wait until playback finishes
QTRY_VERIFY2(audioFile->atEnd(), "didn't play to EOF");
- QTRY_VERIFY2((stateSignal.count() == 1),
- QString("didn't emit IdleState signal when at EOF, got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
+ QTRY_VERIFY(stateSignal.count() > 0);
+ QCOMPARE(qvariant_cast<QAudio::State>(stateSignal.last().at(0)), QAudio::IdleState);
QVERIFY2((audioOutput.state() == QAudio::IdleState), "didn't transitions to IdleState when at EOF");
stateSignal.clear();
@@ -702,8 +702,8 @@ void tst_QAudioOutput::push()
QTest::qWait(3000); // 3 seconds should be plenty
QVERIFY2(audioFile->atEnd(), "didn't play to EOF");
- QVERIFY2((stateSignal.count() == 1),
- QString("didn't emit IdleState signal when at EOF, got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
+ QVERIFY(stateSignal.count() > 0);
+ QCOMPARE(qvariant_cast<QAudio::State>(stateSignal.last().at(0)), QAudio::IdleState);
QVERIFY2((audioOutput.state() == QAudio::IdleState), "didn't transitions to IdleState when at EOF");
stateSignal.clear();
@@ -837,8 +837,8 @@ void tst_QAudioOutput::pushSuspendResume()
QTest::qWait(1000); // 1 seconds should be plenty
QVERIFY2(audioFile->atEnd(), "didn't play to EOF");
- QVERIFY2((stateSignal.count() == 1),
- QString("didn't emit IdleState signal when at EOF, got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
+ QVERIFY(stateSignal.count() > 0);
+ QCOMPARE(qvariant_cast<QAudio::State>(stateSignal.last().at(0)), QAudio::IdleState);
QVERIFY2((audioOutput.state() == QAudio::IdleState), "didn't transitions to IdleState when at EOF");
stateSignal.clear();
diff --git a/tests/auto/integration/qsoundeffect/BLACKLIST b/tests/auto/integration/qsoundeffect/BLACKLIST
new file mode 100644
index 00000000..abf85ae9
--- /dev/null
+++ b/tests/auto/integration/qsoundeffect/BLACKLIST
@@ -0,0 +1,3 @@
+#QTBUG-55735
+[testSetSourceWhilePlaying]
+linux