summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2023-04-28 21:59:08 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2023-05-01 20:15:13 +0300
commitaa2b9b0474b3bd268f01f0d0e8f6e6c9b681ba3f (patch)
tree0845644d3cd1542677351a68e906dcb947f75015
parent494cdc948ccceea37cdc25ae3f6ba32768d73635 (diff)
downloadqtmultimedia-aa2b9b0474b3bd268f01f0d0e8f6e6c9b681ba3f.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 Pick-to: 6.5 Change-Id: Ib4632e66e8df78af44178af611604aac5e797b53 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
-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];
}