From 0a6f22dbbc3f36b82190b1dc52ecee082c8b90bc Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Mon, 7 Oct 2019 14:31:56 +0200 Subject: AVF: Emit StalledMedia when unbuffered and resume playback afterwards If remote source is requested to play but there is a limitation in network bandwidth, StalledMedia status is never emitted, also the playback is not resumed after buffer gets full again. Based on AVPlayerItem.playbackLikelyToKeepUp introduced changing the media status and resuming the playback. Task-number: QTBUG-49806 Change-Id: If8aa10a1ea2cee2a40c679871b836d2dca622fcd Reviewed-by: Ville Voutilainen --- .../avfoundation/mediaplayer/avfmediaplayersession.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index 2309221c2..3b25a5801 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -922,6 +922,19 @@ void AVFMediaPlayerSession::processBufferStateChange(int bufferStatus) if (bufferStatus == m_bufferStatus) return; + auto status = m_mediaStatus; + // Buffered -> unbuffered. + if (!bufferStatus) { + status = QMediaPlayer::StalledMedia; + } else if (status == QMediaPlayer::StalledMedia) { + status = QMediaPlayer::BufferedMedia; + // Resume playback. + [[static_cast(m_observer) player] setRate:m_rate]; + } + + if (m_mediaStatus != status) + Q_EMIT mediaStatusChanged(m_mediaStatus = status); + m_bufferStatus = bufferStatus; Q_EMIT bufferStatusChanged(bufferStatus); } -- cgit v1.2.3 From 5f6f82baeacce06dc4bdcaa307eff1772e89cd3e Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Mon, 7 Oct 2019 11:57:30 +0200 Subject: DirectShow: Fix crash when media in qrc is set twice When qrc media content is set, it allocates and opens QFile. If the same content is set again, the url remains the same, but it creats new QFile, and need to update DirectShowIOReader by new stream. Change-Id: If3f5c187c4e2987e1a593b45f9a46c3c1b77ce45 Reviewed-by: Ville Voutilainen --- src/plugins/directshow/player/directshowplayercontrol.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/directshow/player/directshowplayercontrol.cpp b/src/plugins/directshow/player/directshowplayercontrol.cpp index 87bd53bc4..8fddc2102 100644 --- a/src/plugins/directshow/player/directshowplayercontrol.cpp +++ b/src/plugins/directshow/player/directshowplayercontrol.cpp @@ -51,6 +51,7 @@ DirectShowPlayerControl::DirectShowPlayerControl(DirectShowPlayerService *servic : QMediaPlayerControl(parent) , m_service(service) , m_audio(0) + , m_stream(0) , m_updateProperties(0) , m_state(QMediaPlayer::StoppedState) , m_status(QMediaPlayer::NoMedia) @@ -221,7 +222,7 @@ const QIODevice *DirectShowPlayerControl::mediaStream() const void DirectShowPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) { - if (m_media == media) + if (m_media == media && m_stream == stream) return; m_pendingPosition = -1; -- cgit v1.2.3 From 047c1da00704c8287441abf1bf13e2141d1c3b5d Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Tue, 8 Oct 2019 09:44:30 +0200 Subject: WinRT: Ignore media in MediaPlayer only if stream is not changed too When qrc media content is set, it allocates and opens QFile. If the same content is set again, the url remains the same, but it creats new QFile, and need to update by new stream. Change-Id: Iee6c50135bb8304177affbe70b27d24898fc5b5c Reviewed-by: Ville Voutilainen --- src/plugins/winrt/qwinrtmediaplayercontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp index 7991f435b..779703392 100644 --- a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp +++ b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp @@ -722,7 +722,7 @@ void QWinRTMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *s { Q_D(QWinRTMediaPlayerControl); - if (d->media == media) + if (d->media == media && d->stream.data() == stream) return; d->media = media; -- cgit v1.2.3 From e9d8f6a181ad1c2fff622e894b0c8353838d9b7a Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Tue, 8 Oct 2019 10:37:08 +0200 Subject: Fix qConvertFuncs to respect QVideoFrame::Format_ABGR32 in the end Additional to bf6ac0 commit, need to fix convert funcs Change-Id: I8eb82234557489e66bc179e1696afc154332b656 Reviewed-by: Ville Voutilainen --- src/multimedia/video/qvideoframe.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index e94b838f9..b466a3180 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -1048,7 +1048,6 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrame::NPixelFormats] = { /* Format_ARGB8565_Premultiplied */ nullptr, // Not needed /* Format_BGRA32 */ qt_convert_BGRA32_to_ARGB32, /* Format_BGRA32_Premultiplied */ qt_convert_BGRA32_to_ARGB32, - /* Format_ABGR32 */ nullptr, /* Format_BGR32 */ qt_convert_BGRA32_to_ARGB32, /* Format_BGR24 */ qt_convert_BGR24_to_ARGB32, /* Format_BGR565 */ qt_convert_BGR565_to_ARGB32, @@ -1071,7 +1070,9 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrame::NPixelFormats] = { /* Format_Y16 */ nullptr, /* Format_Jpeg */ nullptr, // Not needed /* Format_CameraRaw */ nullptr, - /* Format_AdobeDng */ nullptr + /* Format_AdobeDng */ nullptr, + /* Format_ABGR32 */ nullptr, // ### Qt 6: reorder + }; static void qInitConvertFuncsAsm() -- cgit v1.2.3 From 56d430962a50af234902cd799920a5b6df6d80eb Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Wed, 25 Sep 2019 17:17:12 +0700 Subject: Create QML camera.viewfinder eagerly QDeclarativeCameraViewfinder connects to QCamera's statusChanged() to update its chached settings when the status becomes LoadedStatus or ActiveStatus. However, it's updated after QDeclarativeCamera has signaled cameraStatusChanged because QDeclarativeCameraViewfinder connects the that signal after QDeclarativeCamera, making those connected to cameraSignalChanged still receiving old values despite camera.cameraStatus already changed. This commit moves the creation of QDeclarativeCameraViewfinder into the constructor of QDeclarativeCamera, before the later connects to signals. This make values in camera.viewfinder reflects the correct value by the time cameraStatusChanged is signaled. A side effect of this change is that camera.viewfinder.resolutionChanged and similar signals will be signaled before camera.cameraStatusChanged. This might not be as bad as it seems; if the user of resolutionChanged checks camera.cameraStatus, the value will be correct anyway as it's not cached. Change-Id: Ief0c3d55e441cc872d37de937ba54fed0f2b877d Reviewed-by: VaL Doroshchuk --- src/imports/multimedia/qdeclarativecamera.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp index 6d36e462d..91bda2ea2 100644 --- a/src/imports/multimedia/qdeclarativecamera.cpp +++ b/src/imports/multimedia/qdeclarativecamera.cpp @@ -177,7 +177,6 @@ QDeclarativeCamera::QDeclarativeCamera(QObject *parent) : QObject(parent), m_camera(0), m_metaData(0), - m_viewfinder(0), m_pendingState(ActiveState), m_componentComplete(false) { @@ -190,6 +189,7 @@ QDeclarativeCamera::QDeclarativeCamera(QObject *parent) : m_flash = new QDeclarativeCameraFlash(m_camera); m_focus = new QDeclarativeCameraFocus(m_camera); m_imageProcessing = new QDeclarativeCameraImageProcessing(m_camera); + m_viewfinder = new QDeclarativeCameraViewfinder(m_camera); connect(m_camera, SIGNAL(captureModeChanged(QCamera::CaptureModes)), this, SIGNAL(captureModeChanged())); @@ -960,9 +960,6 @@ QDeclarativeMediaMetaData *QDeclarativeCamera::metaData() QDeclarativeCameraViewfinder *QDeclarativeCamera::viewfinder() { - if (!m_viewfinder) - m_viewfinder = new QDeclarativeCameraViewfinder(m_camera); - return m_viewfinder; } -- cgit v1.2.3