summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2023-04-28 21:59:08 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-05-01 17:33:46 +0000
commitea62bd143d9a3084fcc3900c73889d8b734624c1 (patch)
tree81edd990da1b6ab03227939f721d0a829f3d6ba7
parent5cacbebb3103ff9134265c4d20b1675029579ee5 (diff)
downloadqtmultimedia-ea62bd143d9a3084fcc3900c73889d8b734624c1.tar.gz
AVFVideoSink: Set pixel format even when rhi is not set
QVideoSink::setRhi() is new and not documented. One may still use default constructed QVideoSink as an output for QMediaPlayer. In this case we still need be able produce valid video frames into the sink. Amends 2e43d29e1d5d50b44b8f6d4f000968e3933c279a. Fixes: QTBUG-113286 Change-Id: Ib4632e66e8df78af44178af611604aac5e797b53 Reviewed-by: Lars Knoll <lars@knoll.priv.no> (cherry picked from commit aa2b9b0474b3bd268f01f0d0e8f6e6c9b681ba3f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/darwin/avfvideosink.mm46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/plugins/multimedia/darwin/avfvideosink.mm b/src/plugins/multimedia/darwin/avfvideosink.mm
index 1fa316b98..f25b4e7a2 100644
--- a/src/plugins/multimedia/darwin/avfvideosink.mm
+++ b/src/plugins/multimedia/darwin/avfvideosink.mm
@@ -172,36 +172,13 @@ void AVFVideoSinkInterface::setLayer(CALayer *layer)
void AVFVideoSinkInterface::setOutputSettings()
{
- if (!m_rhi)
- return;
-
if (m_outputSettings)
[m_outputSettings release];
m_outputSettings = nil;
// Set pixel format
NSDictionary *dictionary = nil;
- if (m_rhi->backend() == QRhi::Metal) {
- dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
- @[
- @(kCVPixelFormatType_32BGRA),
- @(kCVPixelFormatType_32RGBA),
- @(kCVPixelFormatType_422YpCbCr8),
- @(kCVPixelFormatType_422YpCbCr8_yuvs),
- @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
- @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
- @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
- @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
- @(kCVPixelFormatType_OneComponent8),
- @(kCVPixelFormatType_OneComponent16),
- @(kCVPixelFormatType_420YpCbCr8Planar),
- @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
- ]
-#ifndef Q_OS_IOS // This key is not supported and generates a warning.
- , (NSString *)kCVPixelBufferMetalCompatibilityKey: @true
-#endif // Q_OS_IOS
- };
- } else if (m_rhi->backend() == QRhi::OpenGLES2) {
+ if (m_rhi && m_rhi->backend() == QRhi::OpenGLES2) {
#if QT_CONFIG(opengl)
dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
@(kCVPixelFormatType_32BGRA)
@@ -210,7 +187,28 @@ void AVFVideoSinkInterface::setOutputSettings()
#endif // Q_OS_IOS
};
#endif
+ } else {
+ dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
+ @[
+ @(kCVPixelFormatType_32BGRA),
+ @(kCVPixelFormatType_32RGBA),
+ @(kCVPixelFormatType_422YpCbCr8),
+ @(kCVPixelFormatType_422YpCbCr8_yuvs),
+ @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
+ @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
+ @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
+ @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
+ @(kCVPixelFormatType_OneComponent8),
+ @(kCVPixelFormatType_OneComponent16),
+ @(kCVPixelFormatType_420YpCbCr8Planar),
+ @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
+ ]
+#ifndef Q_OS_IOS // This key is not supported and generates a warning.
+ , (NSString *)kCVPixelBufferMetalCompatibilityKey: @true
+#endif // Q_OS_IOS
+ };
}
+
m_outputSettings = [[NSDictionary alloc] initWithDictionary:dictionary];
}