diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-08-17 03:00:51 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-08-17 03:00:51 +0200 |
commit | a31d981b08519922b4c9c17b17122c02c1734ef4 (patch) | |
tree | bf2068df8fa1158aa1c1d7eef3cf17dd13cc363d /src/plugins/avfoundation | |
parent | f49bfa05d1f67327a33d2b66e9ff1bcc32ad8d05 (diff) | |
parent | 7b1bb300166aa19dc0f4c6838eb6d284af73236c (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I09f511d894db5e9987ac2b9e42266bb87ef0161d
Diffstat (limited to 'src/plugins/avfoundation')
-rw-r--r-- | src/plugins/avfoundation/camera/avfcamerautility.mm | 13 | ||||
-rw-r--r-- | src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm | 7 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/plugins/avfoundation/camera/avfcamerautility.mm b/src/plugins/avfoundation/camera/avfcamerautility.mm index e68fc703b..8c743dcbc 100644 --- a/src/plugins/avfoundation/camera/avfcamerautility.mm +++ b/src/plugins/avfoundation/camera/avfcamerautility.mm @@ -47,6 +47,7 @@ #include <functional> #include <algorithm> #include <limits> +#include <tuple> QT_BEGIN_NAMESPACE @@ -85,14 +86,18 @@ inline bool qt_area_sane(const QSize &size) && std::numeric_limits<int>::max() / size.width() >= size.height(); } -struct ResolutionPredicate : std::binary_function<AVCaptureDeviceFormat *, AVCaptureDeviceFormat *, bool> +template <template <typename...> class Comp> // std::less or std::greater (or std::equal_to) +struct ByResolution { bool operator() (AVCaptureDeviceFormat *f1, AVCaptureDeviceFormat *f2)const { Q_ASSERT(f1 && f2); const QSize r1(qt_device_format_resolution(f1)); const QSize r2(qt_device_format_resolution(f2)); - return r1.width() < r2.width() || (r2.width() == r1.width() && r1.height() < r2.height()); + // use std::tuple for lexicograpical sorting: + const Comp<std::tuple<int, int>> op = {}; + return op(std::make_tuple(r1.width(), r1.height()), + std::make_tuple(r2.width(), r2.height())); } }; @@ -143,7 +148,7 @@ QVector<AVCaptureDeviceFormat *> qt_unique_device_formats(AVCaptureDevice *captu if (!formats.size()) return formats; - std::sort(formats.begin(), formats.end(), ResolutionPredicate()); + std::sort(formats.begin(), formats.end(), ByResolution<std::less>()); QSize size(qt_device_format_resolution(formats[0])); FourCharCode codec = CMVideoFormatDescriptionGetCodecType(formats[0].formatDescription); @@ -309,7 +314,7 @@ AVCaptureDeviceFormat *qt_find_best_framerate_match(AVCaptureDevice *captureDevi QVector<AVCaptureDeviceFormat *>sorted(qt_unique_device_formats(captureDevice, filter)); // Sort formats by their resolution in decreasing order: - std::sort(sorted.begin(), sorted.end(), std::not2(ResolutionPredicate())); + std::sort(sorted.begin(), sorted.end(), ByResolution<std::greater>()); // We can use only formats with framerate ranges: sorted.erase(std::remove_if(sorted.begin(), sorted.end(), FormatHasNoFPSRange()), sorted.end()); diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm index 392960e4d..51f961729 100644 --- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm +++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm @@ -159,6 +159,13 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay qWarning("failed to create QOpenGLContext"); return nullptr; } + + // CARenderer must be re-created with different current context, so release it now. + // See lines below where m_videoLayerRenderer is constructed. + if (m_videoLayerRenderer) { + [m_videoLayerRenderer release]; + m_videoLayerRenderer = nullptr; + } } //Need current context |