summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-02-04 19:57:09 +0100
committerLars Knoll <lars.knoll@qt.io>2021-02-09 14:34:54 +0000
commit0eb4012490601a3d45bd7239e117ae583d71dc97 (patch)
tree61e502a4d0f3931d1327981c9e4171c1e5405cd3 /src/multimedia
parent7b963b971afb942f7b7f6da5374fae251e8af887 (diff)
Add support for retrieving a mimetype for a QMediaFormat
And remove WMA from the list of supported codecs, add ALAC instead as it's more widely used. Change-Id: I3c08f2d1871783dc1e15c948e2ec9a7a033cb917 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/platform/android/mediacapture/qandroidcapturesession.cpp4
-rw-r--r--src/multimedia/platform/gstreamer/qgstreamerformatsinfo.cpp6
-rw-r--r--src/multimedia/qmediaformat.cpp72
-rw-r--r--src/multimedia/qmediaformat.h12
4 files changed, 59 insertions, 35 deletions
diff --git a/src/multimedia/platform/android/mediacapture/qandroidcapturesession.cpp b/src/multimedia/platform/android/mediacapture/qandroidcapturesession.cpp
index 7672e7a01..d39058d6a 100644
--- a/src/multimedia/platform/android/mediacapture/qandroidcapturesession.cpp
+++ b/src/multimedia/platform/android/mediacapture/qandroidcapturesession.cpp
@@ -269,14 +269,12 @@ void QAndroidCaptureSession::start()
case QMediaFormat::Mpeg4Audio:
extension = "m4a";
break;
- case QMediaFormat::Opus:
- extension = "opus";
+ case QMediaFormat::ALAC:
case QMediaFormat::ASF:
case QMediaFormat::AVI:
case QMediaFormat::Matroska:
case QMediaFormat::FLAC:
case QMediaFormat::Wave:
- case QMediaFormat::WindowsMediaAudio:
case QMediaFormat::UnspecifiedFormat:
break;
}
diff --git a/src/multimedia/platform/gstreamer/qgstreamerformatsinfo.cpp b/src/multimedia/platform/gstreamer/qgstreamerformatsinfo.cpp
index 6b2744f3d..1e5c41969 100644
--- a/src/multimedia/platform/gstreamer/qgstreamerformatsinfo.cpp
+++ b/src/multimedia/platform/gstreamer/qgstreamerformatsinfo.cpp
@@ -65,7 +65,7 @@ static struct {
{ "audio/mpeg, mpegversion=(int)1, layer=(int)3", QMediaFormat::FileFormat::MP3 },
{ "audio/mpeg, mpegversion=(int)4", QMediaFormat::FileFormat::AAC },
{ "audio/x-flac", QMediaFormat::FileFormat::FLAC },
- { "audio/x-wma", QMediaFormat::FileFormat::WindowsMediaAudio },
+ { "audio/x-alac", QMediaFormat::FileFormat::ALAC },
{ nullptr, QMediaFormat::FileFormat::UnspecifiedFormat },
};
@@ -95,7 +95,7 @@ static struct {
{ "audio/x-ac3", QMediaFormat::AudioCodec::AC3 },
{ "audio/x-eac3", QMediaFormat::AudioCodec::EAC3 },
{ "audio/x-flac", QMediaFormat::AudioCodec::FLAC },
- { "audio/x-wma", QMediaFormat::AudioCodec::WindowsMediaAudio },
+ { "audio/x-alac", QMediaFormat::AudioCodec::ALAC },
{ "audio/x-true-hd", QMediaFormat::AudioCodec::DolbyTrueHD },
{ "audio/x-vorbis", QMediaFormat::AudioCodec::Vorbis },
{ nullptr, QMediaFormat::AudioCodec::Unspecified },
@@ -109,8 +109,6 @@ static auto getList(QGstCodecsInfo::ElementType type, Map *map, Hash &hash)
QGstCodecsInfo info(type);
auto codecs = info.supportedCodecs();
for (const auto &c : codecs) {
- if (type == QGstCodecsInfo::AudioDecoder)
- qDebug() << "gst format" << c;
Map *m = map;
while (m->name) {
if (m->name == c.toLatin1()) {
diff --git a/src/multimedia/qmediaformat.cpp b/src/multimedia/qmediaformat.cpp
index 0a5e9a27f..80fe154b0 100644
--- a/src/multimedia/qmediaformat.cpp
+++ b/src/multimedia/qmediaformat.cpp
@@ -40,6 +40,7 @@
#include "qmediaformat.h"
#include "private/qmediaplatformintegration_p.h"
#include "private/qmediaplatformformatinfo_p.h"
+#include <QtCore/qmimedatabase.h>
QT_BEGIN_NAMESPACE
@@ -48,23 +49,22 @@ namespace {
// info from https://en.wikipedia.org/wiki/Comparison_of_video_container_formats
constexpr bool audioSupportMatrix[QMediaFormat::FileFormat::LastFileFormat + 1][(int)QMediaFormat::AudioCodec::LastAudioCodec + 1] =
{
- // MP3, AAC, AC3, EAC3, FLAC, DTHD, Opus,Vorbis, Wave, WMA
+ // MP3, AAC, AC3, EAC3, FLAC, DTHD, Opus,Vorbis, Wave, ALAC
// Container formats (Audio and Video)
- { true, true, true, true, true, false, true, false, false, true }, // ASF
+ { true, true, true, true, true, false, true, false, false, true }, // ASF
{ true, true, true, false, true, false, true, false, false, true }, // AVI,
{ true, true, true, true, true, true, true, true, false, true }, // Matroska,
{ true, true, true, true, true, true, true, false, false, true }, // MPEG4,
{ false, false, false, false, true, false, true, true, false, false }, // Ogg,
- { true, true, true, true, false, false, false, false, false, false }, // QuickTime,
+ { true, true, true, true, false, false, false, false, false, true }, // QuickTime,
{ false, false, false, false, true, false, true, true, false, false }, // WebM,
// Audio Formats
{ false, true, false, false, false, false, false, false, false, false }, // AAC,
{ false, false, false, false, true, false, false, false, false, false }, // FLAC,
{ true, false, false, false, false, false, false, false, false, false }, // Mpeg3,
{ true, true, true, true, true, true, true, false, false, true }, // Mpeg4Audio,
- { false, false, false, false, false, false, true, false, false, false }, // Opus,
+ { false, false, false, false, false, false, false, false, false, true }, // ALAC,
{ false, false, false, false, false, false, false, false, true, false }, // Wave,
- { false, false, false, false, false, false, false, false, false, true }, // WindowsMediaAudio
};
inline bool formatSupportsCodec(QMediaFormat::FileFormat format, QMediaFormat::AudioCodec codec)
@@ -89,9 +89,8 @@ constexpr bool videoSupportMatrix[QMediaFormat::FileFormat::LastFileFormat + 1][
{ false, false, false, false, false, false, false, false, false, false }, // FLAC,
{ false, false, false, false, false, false, false, false, false, false }, // Mpeg3,
{ false, false, false, false, false, false, false, false, false, false }, // Mpeg4Audio,
- { false, false, false, false, false, false, false, false, false, false }, // Opus,
+ { false, false, false, false, false, false, false, false, false, false }, // ALAC,
{ false, false, false, false, false, false, false, false, false, false }, // Wave,
- { false, false, false, false, false, false, false, false, false, false }, // WindowsMediaAudio
};
inline bool formatSupportsCodec(QMediaFormat::FileFormat format, QMediaFormat::VideoCodec codec)
@@ -117,9 +116,8 @@ constexpr QMediaFormat::FileFormat audioFormatPriorityList[] =
QMediaFormat::AAC,
QMediaFormat::MP3,
QMediaFormat::Mpeg4Audio,
- QMediaFormat::Opus,
QMediaFormat::FLAC,
- QMediaFormat::WindowsMediaAudio,
+ QMediaFormat::ALAC,
QMediaFormat::Wave,
QMediaFormat::UnspecifiedFormat
};
@@ -132,7 +130,6 @@ constexpr QMediaFormat::AudioCodec audioPriorityList[] =
QMediaFormat::AudioCodec::Opus,
QMediaFormat::AudioCodec::EAC3,
QMediaFormat::AudioCodec::DolbyTrueHD,
- QMediaFormat::AudioCodec::WindowsMediaAudio,
QMediaFormat::AudioCodec::FLAC,
QMediaFormat::AudioCodec::Vorbis,
QMediaFormat::AudioCodec::Wave,
@@ -153,6 +150,26 @@ constexpr QMediaFormat::VideoCodec videoPriorityList[] =
QMediaFormat::VideoCodec::MotionJPEG,
};
+const char *mimeTypeForFormat[QMediaFormat::LastFileFormat + 2] =
+{
+ "",
+ "video/x-ms-asf",
+ "video/x-msvideo",
+ "video/x-matroska",
+ "video/mp4",
+ "video/ogg",
+ "video/quicktime",
+ "video/webm",
+ // Audio Formats
+ "audio/aac",
+ "audio/flac",
+ "audio/mpeg",
+ "audio/mp4",
+ "audio/alac",
+ "audio/wave",
+};
+
+
}
void QMediaFormatPrivate::resolveForEncoding(QMediaFormat *f, bool audioOnly)
@@ -381,9 +398,20 @@ bool QMediaFormat::isAudioFormat() const
return fmt >= AAC;
}
+/*!
+ Returns the mimetype for the file format used in this media format.
+
+ \sa format(), setFormat()
+ */
+QMimeType QMediaFormat::mimeType() const
+{
+ return QMimeDatabase().mimeTypeForName(QString::fromLatin1(mimeTypeForFormat[fmt + 1]));
+}
+
QString QMediaFormat::fileFormatName(QMediaFormat::FileFormat c)
{
- constexpr const char *descriptions[] = {
+ constexpr const char *descriptions[QMediaFormat::LastFileFormat + 2] = {
+ "Unspecified File Format"
"ASF",
"AVI",
"Matroska",
@@ -396,11 +424,10 @@ QString QMediaFormat::fileFormatName(QMediaFormat::FileFormat c)
"FLAC",
"MP3",
"MPEG-4 Audio",
- "Opus",
- "Wave",
- "Windows Media Audio",
+ "ALAC",
+ "Wave"
};
- return QString::fromUtf8(descriptions[int(c)]);
+ return QString::fromUtf8(descriptions[int(c) + 1]);
}
QString QMediaFormat::audioCodecName(QMediaFormat::AudioCodec c)
@@ -416,7 +443,7 @@ QString QMediaFormat::audioCodecName(QMediaFormat::AudioCodec c)
"Opus",
"Vorbis",
"Wave",
- "WindowsMediaAudio",
+ "ALAC",
};
return QString::fromUtf8(descriptions[int(c) + 1]);
}
@@ -441,10 +468,10 @@ QString QMediaFormat::videoCodecName(QMediaFormat::VideoCodec c)
QString QMediaFormat::fileFormatDescription(QMediaFormat::FileFormat c)
{
- constexpr const char *descriptions[] = {
+ constexpr const char *descriptions[QMediaFormat::LastFileFormat + 2] = {
"Unspecified File Format",
- "Windows Media Format (ASF)",
- "Audio Video Interleave (AVI)",
+ "Windows Media Format",
+ "Audio Video Interleave",
"Matroska Multimedia Container",
"MPEG-4 Video Container",
"Ogg",
@@ -455,9 +482,8 @@ QString QMediaFormat::fileFormatDescription(QMediaFormat::FileFormat c)
"Free Lossless Audio Codec (FLAC)",
"MP3",
"MPEG-4 Audio Container",
- "Opus Audio Encoding",
- "Wave File",
- "Windows Media Audio",
+ "Apple Lossless Audio Codec (ALAC)",
+ "Wave File"
};
return QString::fromUtf8(descriptions[int(c) + 1]);
}
@@ -475,7 +501,7 @@ QString QMediaFormat::audioCodecDescription(QMediaFormat::AudioCodec c)
"Opus",
"Vorbis",
"Wave",
- "Windows Media Audio",
+ "Apple Lossless Audio Codec (ALAC)",
};
return QString::fromUtf8(descriptions[int(c) + 1]);
}
diff --git a/src/multimedia/qmediaformat.h b/src/multimedia/qmediaformat.h
index 69e795545..a488fd378 100644
--- a/src/multimedia/qmediaformat.h
+++ b/src/multimedia/qmediaformat.h
@@ -46,6 +46,7 @@
QT_BEGIN_NAMESPACE
+class QMimeType;
class QMediaFormat;
class QMediaEncoderSettings;
class QMediaFormatPrivate
@@ -72,10 +73,9 @@ public:
FLAC,
MP3,
Mpeg4Audio,
- Opus,
+ ALAC,
Wave,
- WindowsMediaAudio,
- LastFileFormat = WindowsMediaAudio
+ LastFileFormat = Wave
};
enum class AudioCodec {
@@ -89,8 +89,8 @@ public:
Opus,
Vorbis,
Wave,
- WindowsMediaAudio,
- LastAudioCodec = WindowsMediaAudio
+ ALAC,
+ LastAudioCodec = ALAC
};
enum class VideoCodec {
@@ -127,6 +127,8 @@ public:
bool isAudioFormat() const;
+ QMimeType mimeType() const;
+
static QString fileFormatName(QMediaFormat::FileFormat c);
static QString audioCodecName(QMediaFormat::AudioCodec c);
static QString videoCodecName(QMediaFormat::VideoCodec c);