summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-06-17 15:32:17 +0200
committerLars Knoll <lars.knoll@qt.io>2021-06-18 15:28:06 +0200
commit435d7a1dd3ad96ea64045a320fffad8908e1c2cf (patch)
tree5ba588b7f08a75311eab517e70889b8596f6a163
parent46bc0ea5550903a27923d84c730de39a78e7689a (diff)
Partly fix support for audio only formats in gstreamer
Make sure we detect encoding/decoding capabilities for mp3, flac and wave. This needs a bit more work to clean up the file formats that are actually MP4 (cross-platform), and ensure encodebin in gstreamer handles this correctly. Change-Id: If7027bd94195ba3f795da598a67c42172070aad6 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
-rw-r--r--src/multimedia/platform/gstreamer/qgstreamerformatinfo.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/multimedia/platform/gstreamer/qgstreamerformatinfo.cpp b/src/multimedia/platform/gstreamer/qgstreamerformatinfo.cpp
index 0f91e774d..4705848a4 100644
--- a/src/multimedia/platform/gstreamer/qgstreamerformatinfo.cpp
+++ b/src/multimedia/platform/gstreamer/qgstreamerformatinfo.cpp
@@ -52,9 +52,9 @@ QMediaFormat::AudioCodec QGstreamerFormatInfo::audioCodecForCaps(QGstStructure s
name += 6;
if (!strcmp(name, "mpeg")) {
auto version = structure["mpegversion"].toInt();
- if (version == 1) {
- auto layer = structure["layer"].toInt();
- if (layer == 3)
+ if (0 && version == 1) {
+ auto layer = structure["layer"];
+ if (!layer.isNull())
return QMediaFormat::AudioCodec::MP3;
}
if (version == 4)
@@ -135,6 +135,17 @@ QMediaFormat::FileFormat QGstreamerFormatInfo::fileFormatForCaps(QGstStructure s
return QMediaFormat::FileFormat::Ogg;
} else if (!strcmp(name, "video/webm")) {
return QMediaFormat::FileFormat::WebM;
+ } else if (!strcmp(name, "audio/x-m4a")) {
+ return QMediaFormat::FileFormat::Mpeg4Audio;
+ } else if (!strcmp(name, "audio/x-wav")) {
+ return QMediaFormat::FileFormat::Wave;
+ } else if (!strcmp(name, "audio/mpeg")) {
+ auto mpegversion = structure["mpegversion"].toInt();
+ if (mpegversion == 1) {
+ auto layer = structure["layer"];
+ if (!layer.isNull())
+ return QMediaFormat::FileFormat::MP3;
+ }
}
return QMediaFormat::UnspecifiedFormat;
}
@@ -246,8 +257,11 @@ QList<QGstreamerFormatInfo::CodecMap> QGstreamerFormatInfo::getMuxerList(bool de
if (padTemplate->direction != padDirection) {
QGstMutableCaps caps = gst_static_caps_get(&padTemplate->static_caps);
+ bool acceptsRawAudio = false;
for (int i = 0; i < caps.size(); i++) {
QGstStructure structure = caps.at(i);
+ if (structure.name() == "audio/x-raw")
+ acceptsRawAudio = true;
auto audio = audioCodecForCaps(structure);
if (audio != QMediaFormat::AudioCodec::Unspecified && supportedAudioCodecs.contains(audio))
audioCodecs.append(audio);
@@ -255,11 +269,33 @@ QList<QGstreamerFormatInfo::CodecMap> QGstreamerFormatInfo::getMuxerList(bool de
if (video != QMediaFormat::VideoCodec::Unspecified && supportedVideoCodecs.contains(video))
videoCodecs.append(video);
}
+ if (acceptsRawAudio && fileFormats.size() == 1) {
+ switch (fileFormats.at(0)) {
+ case QMediaFormat::AAC:
+ case QMediaFormat::Mpeg4Audio:
+ case QMediaFormat::ALAC:
+ default:
+ break;
+ case QMediaFormat::MP3:
+ audioCodecs.append(QMediaFormat::AudioCodec::MP3);
+ break;
+ case QMediaFormat::FLAC:
+ audioCodecs.append(QMediaFormat::AudioCodec::FLAC);
+ break;
+ case QMediaFormat::Wave:
+ audioCodecs.append(QMediaFormat::AudioCodec::Wave);
+ break;
+ }
+ }
}
}
if (!audioCodecs.isEmpty() || !videoCodecs.isEmpty()) {
- for (auto f : qAsConst(fileFormats))
+ for (auto f : qAsConst(fileFormats)) {
muxers.append({f, audioCodecs, videoCodecs});
+ if (f == QMediaFormat::MPEG4 && !fileFormats.contains(QMediaFormat::Mpeg4Audio)) {
+ muxers.append({QMediaFormat::Mpeg4Audio, audioCodecs, {}});
+ }
+ }
}
}
gst_plugin_feature_list_free(elementList);