diff options
author | André de la Rocha <andre.rocha@qt.io> | 2022-05-19 23:05:12 +0200 |
---|---|---|
committer | André de la Rocha <andre.rocha@qt.io> | 2022-05-25 12:45:01 +0200 |
commit | ba5408f11944104a9c0a7493325df1cc3e421251 (patch) | |
tree | 3f2266069b47bf8a03bf0a85c67ad3dd4f7a400e | |
parent | 04ec0d70095bd1281c7b7a7cac6c81c1ac9f07b8 (diff) |
Windows: Fix RTSP stream playback
Avoids changing the player topology for remote streams. Also improves
handling of error conditions related to network streaming.
Task-number: QTBUG-103567
Change-Id: I358389ed22397c3b15e5971a042e43dc369127f4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 196ea281d1843cfe62541001619a8517506af773)
-rw-r--r-- | src/multimedia/platform/windows/common/qwindowsmfdefs_p.h | 1 | ||||
-rw-r--r-- | src/multimedia/platform/windows/player/mfplayersession.cpp | 31 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/multimedia/platform/windows/common/qwindowsmfdefs_p.h b/src/multimedia/platform/windows/common/qwindowsmfdefs_p.h index 173c8f8f0..ddd8c2fac 100644 --- a/src/multimedia/platform/windows/common/qwindowsmfdefs_p.h +++ b/src/multimedia/platform/windows/common/qwindowsmfdefs_p.h @@ -82,6 +82,7 @@ extern "C" HRESULT WINAPI MFCreateDeviceSource(IMFAttributes *pAttributes, IMFMe #define QMM_MFSESSION_GETFULLTOPOLOGY_CURRENT 1 #define QMM_PRESENTATION_CURRENT_POSITION 0x7fffffffffffffff +#define QMM_WININET_E_CANNOT_CONNECT ((HRESULT)0x80072EFDL) #ifndef __IMFVideoProcessor_INTERFACE_DEFINED__ #define __IMFVideoProcessor_INTERFACE_DEFINED__ diff --git a/src/multimedia/platform/windows/player/mfplayersession.cpp b/src/multimedia/platform/windows/player/mfplayersession.cpp index f01d5344d..7507af928 100644 --- a/src/multimedia/platform/windows/player/mfplayersession.cpp +++ b/src/multimedia/platform/windows/player/mfplayersession.cpp @@ -59,6 +59,7 @@ #include "mfplayersession_p.h" #include <mferror.h> #include <nserror.h> +#include <winerror.h> #include "private/sourceresolver_p.h" #include "samplegrabber_p.h" #include "mftvideo_p.h" @@ -215,7 +216,8 @@ void MFPlayerSession::load(const QUrl &url, QIODevice *stream) } else if (createSession()) { changeStatus(QMediaPlayer::LoadingMedia); m_sourceResolver->load(url, stream); - m_updateRoutingOnStart = true; + if (url.isLocalFile()) + m_updateRoutingOnStart = true; } positionChanged(position()); } @@ -239,7 +241,13 @@ void MFPlayerSession::handleSourceError(long hr) errorCode = QMediaPlayer::FormatError; errorString = tr("Unsupported media type."); break; + case QMM_WININET_E_CANNOT_CONNECT: + errorCode = QMediaPlayer::NetworkError; + errorString = tr("A connection with the server could not be established."); + break; default: + qWarning() << "handleSourceError:" + << Qt::showbase << Qt::hex << Qt::uppercasedigits << static_cast<quint32>(hr); errorString = tr("Failed to load source."); break; } @@ -1667,8 +1675,25 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent) break; } changeStatus(QMediaPlayer::InvalidMedia); - qWarning() << "handleSessionEvent: serious error = " << hrStatus; - emit error(QMediaPlayer::ResourceError, tr("Media session serious error."), true); + qWarning() << "handleSessionEvent: serious error = " + << Qt::showbase << Qt::hex << Qt::uppercasedigits << static_cast<quint32>(hrStatus); + switch (hrStatus) { + case MF_E_NET_READ: + emit error(QMediaPlayer::NetworkError, tr("Error reading from the network."), true); + break; + case MF_E_NET_WRITE: + emit error(QMediaPlayer::NetworkError, tr("Error writing to the network."), true); + break; + case NS_E_FIREWALL: + emit error(QMediaPlayer::NetworkError, tr("Network packets might be blocked by a firewall."), true); + break; + case MF_E_MEDIAPROC_WRONGSTATE: + emit error(QMediaPlayer::ResourceError, tr("Media session state error."), true); + break; + default: + emit error(QMediaPlayer::ResourceError, tr("Media session serious error."), true); + break; + } break; case MESessionRateChanged: // If the rate change succeeded, we've already got the rate |