summaryrefslogtreecommitdiffstats
path: root/src/multimedia/qmediaformat.cpp
diff options
context:
space:
mode:
authorPiotr Srebrny <piotr.srebrny@qt.io>2021-06-15 22:21:55 +0200
committerPiotr Srebrny <piotr.srebrny@qt.io>2021-06-16 12:51:27 +0200
commite1f0c82576325a220a9dd1775c7b28dff60905c9 (patch)
tree93205265b4c09618c4e984ec135e1fd2785ce7e1 /src/multimedia/qmediaformat.cpp
parent36fbb6ab08734aff1a73ea4ed255e06bd5aa99f8 (diff)
Fix media codecs resolver when switching between audio and audio/video
Removing isSupported condition as it is true when audio only format is selected while flags indicate that video codec is required. The same occurs when going from audio/video format to audio format. Reset format if it does not support video while required. Change-Id: I2c056d935351cfc7a471a7376fa51da320cdb353 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/multimedia/qmediaformat.cpp')
-rw-r--r--src/multimedia/qmediaformat.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/multimedia/qmediaformat.cpp b/src/multimedia/qmediaformat.cpp
index c91b23425..ca9fc0cd3 100644
--- a/src/multimedia/qmediaformat.cpp
+++ b/src/multimedia/qmediaformat.cpp
@@ -432,8 +432,7 @@ bool QMediaFormat::operator==(const QMediaFormat &other) const
*/
void QMediaFormat::resolveForEncoding(ResolveFlags flags)
{
- if (isSupported(Encode))
- return;
+ const bool requiresVideo = (flags & ResolveFlags::RequiresVideo) != 0;
QMediaFormat nullFormat;
auto supportedFormats = nullFormat.supportedFileFormats(QMediaFormat::Encode);
@@ -456,6 +455,10 @@ void QMediaFormat::resolveForEncoding(ResolveFlags flags)
return *list;
};
+ // reset format if it does not support video when video is required
+ if (requiresVideo && this->supportedVideoCodecs(QMediaFormat::Encode).isEmpty())
+ fmt = QMediaFormat::UnspecifiedFormat;
+
// reset non supported formats and codecs
if (!supportedFormats.contains(fmt))
fmt = QMediaFormat::UnspecifiedFormat;
@@ -464,7 +467,7 @@ void QMediaFormat::resolveForEncoding(ResolveFlags flags)
if ((flags == NoFlags) || !supportedVideoCodecs.contains(video))
video = QMediaFormat::VideoCodec::Unspecified;
- if (!(flags == NoFlags)) {
+ if (requiresVideo) {
// try finding a file format that is supported
if (fmt == QMediaFormat::UnspecifiedFormat)
fmt = bestSupportedFileFormat(audio, video);
@@ -483,7 +486,7 @@ void QMediaFormat::resolveForEncoding(ResolveFlags flags)
return;
// find a working video codec
- if (!(flags == NoFlags)) {
+ if (requiresVideo) {
// reset the audio codec, so that we won't throw away the video codec
// if it is supported (choosing the specified video codec has higher
// priority than the specified audio codec)