summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/3rdparty/phonon/mmf/utils.cpp22
-rw-r--r--tests/auto/mediaobject/media/test.sdp32
-rwxr-xr-xtests/auto/mediaobject/mediaobject.pro6
-rw-r--r--tests/auto/mediaobject/mediaobject.qrc1
-rw-r--r--tests/auto/mediaobject/tst_mediaobject.cpp75
5 files changed, 118 insertions, 18 deletions
diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp
index 2d17bd2..c556afc 100644
--- a/src/3rdparty/phonon/mmf/utils.cpp
+++ b/src/3rdparty/phonon/mmf/utils.cpp
@@ -52,22 +52,24 @@ void MMF::Utils::panic(PanicCode code)
User::Panic(PanicCategory, code);
}
-
-static const TInt KMimePrefixLength = 6; // either "audio/" or "video/"
_LIT(KMimePrefixAudio, "audio/");
_LIT(KMimePrefixVideo, "video/");
+_LIT(KMimeSDP, "application/sdp");
+
+enum ConstantStringLengths {
+ KMimePrefixLength = 6, // either "audio/" or "video/",
+ KMimeSDPLength = 15 // "application/sdp"
+};
MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType)
{
- MediaType result = MediaTypeUnknown;
-
if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) {
- result = MediaTypeAudio;
- } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) {
- result = MediaTypeVideo;
- }
-
- return result;
+ return MediaTypeAudio;
+ } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0 ||
+ mimeType.Left(KMimeSDPLength).Compare(KMimeSDP) == 0) {
+ return MediaTypeVideo;
+ } else
+ return MediaTypeUnknown;
}
QString MMF::Utils::symbianErrorToString(int errorCode)
diff --git a/tests/auto/mediaobject/media/test.sdp b/tests/auto/mediaobject/media/test.sdp
new file mode 100644
index 0000000..0d8706c
--- /dev/null
+++ b/tests/auto/mediaobject/media/test.sdp
@@ -0,0 +1,32 @@
+v=0
+o=- 3476526279 2351211129 IN IP4 XXX.XXX.XXX.XXX
+s=SOME STRING
+e=support@localhost
+c=IN IP4 XXX.XXX.XXX.XXX
+t=0 0
+a=range:npt=now-
+a=random_access_denied
+a=control:rtsp://link
+m=video 0 RTP/AVP 96
+b=AS:100
+b=RR:2500
+b=RS:2500
+a=control:rtsp://link
+a=rtpmap:96 MP4V-ES/90000
+a=3GPP-Adaptation-Support:1
+a=cliprect:0,0,144,176
+a=mpeg4-esid:201
+a=x-envivio-verid:00022B15
+a=fmtp:96 profile-level-id=2;config=000001b002000001b50ea020202f000001000000012000c788ba9850584121463f
+a=framerate:15.0
+m=audio 0 RTP/AVP 97
+b=AS:14
+b=RR:350
+b=RS:350
+a=control:rtsp://link
+a=rtpmap:97 AMR/8000
+a=3GPP-Adaptation-Support:1
+a=mpeg4-esid:101
+a=x-envivio-verid:00022B15
+a=fmtp:97 octet-align=1
+a=maxptime:200
diff --git a/tests/auto/mediaobject/mediaobject.pro b/tests/auto/mediaobject/mediaobject.pro
index 5d4a098..bef2fe9 100755
--- a/tests/auto/mediaobject/mediaobject.pro
+++ b/tests/auto/mediaobject/mediaobject.pro
@@ -14,3 +14,9 @@ wince*{
DEFINES += tst_MediaObject=tst_MediaObject_waveout
}
+symbian*:{
+ addFiles.sources = media/test.sdp
+ addFiles.path = media
+ DEPLOYMENT += addFiles
+}
+
diff --git a/tests/auto/mediaobject/mediaobject.qrc b/tests/auto/mediaobject/mediaobject.qrc
index 4f46213..77954f4 100644
--- a/tests/auto/mediaobject/mediaobject.qrc
+++ b/tests/auto/mediaobject/mediaobject.qrc
@@ -3,5 +3,6 @@
<file>media/sax.wav</file>
<file>media/sax.ogg</file>
<file>media/sax.mp3</file>
+<file>media/test.sdp</file>
</qresource>
</RCC>
diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp
index 16b2611..4cb08fb 100644
--- a/tests/auto/mediaobject/tst_mediaobject.cpp
+++ b/tests/auto/mediaobject/tst_mediaobject.cpp
@@ -139,6 +139,7 @@ class tst_MediaObject : public QObject
void pauseToPause();
void pauseToPlay();
void pauseToStop();
+ void playSDP();
void testPrefinishMark();
void testSeek();
@@ -160,6 +161,11 @@ class tst_MediaObject : public QObject
Phonon::MediaObject *m_media;
QSignalSpy *m_stateChangedSignalSpy;
QString m_tmpFileName;
+
+ static void copyMediaFile(const QString &original,
+ const QString &name,
+ QString &resultFilePath,
+ QUrl *const asURL = 0);
#endif //QT_NO_PHONON
bool m_success;
};
@@ -352,6 +358,24 @@ void tst_MediaObject::_pausePlayback()
m_success = true;
}
+/*!
+ Copies the file \a name to the testing area. The resulting file name path is
+ returned in resultFilePath, and also set as a URL in \a asURL.
+ */
+void tst_MediaObject::copyMediaFile(const QString &original,
+ const QString &name,
+ QString &resultFilePath,
+ QUrl *const asURL)
+{
+ resultFilePath = QDir::toNativeSeparators(QDir::tempPath() + name);
+ if (asURL)
+ *asURL = QUrl::fromLocalFile(resultFilePath);
+
+ QFile::remove(resultFilePath);
+ QVERIFY(QFile::copy(original, resultFilePath));
+ QFile::setPermissions(resultFilePath, QFile::permissions(resultFilePath) | QFile::WriteOther);
+}
+
void tst_MediaObject::initTestCase()
{
QCoreApplication::setApplicationName("tst_MediaObject");
@@ -375,14 +399,8 @@ void tst_MediaObject::initTestCase()
QVERIFY(m_stateChangedSignalSpy->isValid());
m_stateChangedSignalSpy->clear();
- if (m_url.isEmpty()) {
- m_tmpFileName = QDir::toNativeSeparators(QDir::tempPath() + MEDIA_FILE);
- QFile::remove(m_tmpFileName);
- QVERIFY(QFile::copy(MEDIA_FILEPATH, m_tmpFileName));
- QFile::Permissions p = QFile::permissions(m_tmpFileName);
- QFile::setPermissions(m_tmpFileName, p | QFile::WriteOther);
- m_url = QUrl::fromLocalFile(m_tmpFileName);
- }
+ if (m_url.isEmpty())
+ copyMediaFile(MEDIA_FILEPATH, MEDIA_FILE, m_tmpFileName, &m_url);
qDebug() << "Using url:" << m_url.toString();
@@ -533,6 +551,47 @@ void tst_MediaObject::pauseToStop()
stopPlayback(Phonon::PausedState);
}
+/*!
+
+ We attempt to play a SDP file. An SDP file essentially describes different
+ media streams and is hence a layer in front of the actual media(s).
+ Sometimes the backend handles the SDP file, in other cases not.
+
+ Some Phonon backends doesn't support SDP at all, ifdef appropriately. Real
+ Player and Helix, the two backends for Symbian, are known to support SDP.
+ */
+void tst_MediaObject::playSDP()
+{
+#ifdef Q_OS_SYMBIAN
+ QString sdpFile;
+ copyMediaFile(QLatin1String(":/media/test.sdp"), QLatin1String("test.sdp"), sdpFile);
+
+ // Let's verify our test setup.
+ QVERIFY(QFileInfo(sdpFile).isReadable());
+
+ // We need a window in order to setup the video.
+ QWidget widget;
+ widget.show();
+
+ const MediaSource oldSource(m_media->currentSource());
+ const MediaSource sdpSource(sdpFile);
+ m_media->setCurrentSource(sdpSource);
+ if (m_media->state() != Phonon::StoppedState)
+ QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000);
+
+ // At this point we're in error state due to absent media, but it has now loaded the SDP:
+ QCOMPARE(m_media->errorString(), QString::fromLatin1("Buffering clip failed: Unknown error (-39)"));
+
+ // We cannot play the SDP, we can neither attempt to play it, because we
+ // won't get a state change from ErrorState to ErrorState, and hence block
+ // on a never occuring signal.
+ m_media->setCurrentSource(oldSource);
+
+#else
+ QSKIP("Unsupported on this platform.", SkipAll);
+#endif
+}
+
void tst_MediaObject::testPrefinishMark()
{
const qint32 requestedPrefinishMarkTime = 2000;