summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/platform/darwin')
-rw-r--r--src/multimedia/platform/darwin/camera/avfcameradebug_p.h2
-rw-r--r--src/multimedia/platform/darwin/camera/avfmediarecordercontrol.mm17
-rw-r--r--src/multimedia/platform/darwin/qdarwinformatsinfo.mm149
-rw-r--r--src/multimedia/platform/darwin/qdarwinformatsinfo_p.h17
4 files changed, 91 insertions, 94 deletions
diff --git a/src/multimedia/platform/darwin/camera/avfcameradebug_p.h b/src/multimedia/platform/darwin/camera/avfcameradebug_p.h
index 616e53d99..cbb64b316 100644
--- a/src/multimedia/platform/darwin/camera/avfcameradebug_p.h
+++ b/src/multimedia/platform/darwin/camera/avfcameradebug_p.h
@@ -57,7 +57,7 @@
QT_USE_NAMESPACE
-//#define AVF_DEBUG_CAMERA
+#define AVF_DEBUG_CAMERA
#ifdef AVF_DEBUG_CAMERA
#define qDebugCamera qDebug
diff --git a/src/multimedia/platform/darwin/camera/avfmediarecordercontrol.mm b/src/multimedia/platform/darwin/camera/avfmediarecordercontrol.mm
index 721f2c1fa..69c56d402 100644
--- a/src/multimedia/platform/darwin/camera/avfmediarecordercontrol.mm
+++ b/src/multimedia/platform/darwin/camera/avfmediarecordercontrol.mm
@@ -48,6 +48,7 @@
#include "avfcamerautility_p.h"
#include <QtCore/qurl.h>
+#include <QtCore/qmimetype.h>
#include <QtCore/qfileinfo.h>
#include <QtMultimedia/qcameracontrol.h>
#include <CoreAudio/CoreAudio.h>
@@ -469,9 +470,13 @@ void AVFMediaRecorderControl::applySettings()
return;
}
- bool videoEnabled = m_cameraControl->captureMode().testFlag(QCamera::CaptureVideo);
QMediaEncoderSettings resolved = m_settings;
- resolved.resolveFormat(videoEnabled ? QMediaEncoderSettings::AudioAndVideo : QMediaEncoderSettings::AudioOnly);
+ resolved.resolveFormat();
+ qDebug() << "file profile" << QMediaFormat::fileFormatName(resolved.format());
+ qDebug() << "video profile" << QMediaFormat::videoCodecName(resolved.videoCodec());
+ qDebug() << "audio profile" << QMediaFormat::audioCodecName(resolved.audioCodec());
+
+ const AVFConfigurationLock lock(m_session->videoCaptureDevice()); // prevents activeFormat from being overridden
// Configure audio settings
[m_movieOutput setOutputSettings:avfAudioSettings(resolved)
@@ -483,8 +488,6 @@ void AVFMediaRecorderControl::applySettings()
NSDictionary *videoSettings = avfVideoSettings(resolved, captureDevice, videoConnection);
- const AVFConfigurationLock lock(m_session->videoCaptureDevice()); // prevents activeFormat from being overridden
-
[m_movieOutput setOutputSettings:videoSettings forConnection:videoConnection];
}
@@ -540,7 +543,9 @@ void AVFMediaRecorderControl::setState(QMediaRecorder::State state)
QString outputLocationPath = m_outputLocation.scheme() == QLatin1String("file") ?
m_outputLocation.path() : m_outputLocation.toString();
- QString extension = "mov";// ######m_service->mediaContainerControl()->containerFormat();
+ QMediaEncoderSettings resolved = m_settings;
+ resolved.resolveFormat();
+ QString extension = resolved.mimeType().preferredSuffix();
QUrl actualLocation = QUrl::fromLocalFile(
m_storageLocation.generateFileName(outputLocationPath,
@@ -550,7 +555,7 @@ void AVFMediaRecorderControl::setState(QMediaRecorder::State state)
qDebugCamera() << "Video capture location:" << actualLocation.toString();
- applySettings();
+// applySettings();
[m_movieOutput startRecordingToOutputFileURL:actualLocation.toNSURL()
recordingDelegate:m_recorderDelagate];
diff --git a/src/multimedia/platform/darwin/qdarwinformatsinfo.mm b/src/multimedia/platform/darwin/qdarwinformatsinfo.mm
index 16e8458e2..11a458dea 100644
--- a/src/multimedia/platform/darwin/qdarwinformatsinfo.mm
+++ b/src/multimedia/platform/darwin/qdarwinformatsinfo.mm
@@ -62,14 +62,14 @@ static struct {
QMediaFormat::VideoCodec value;
} videoCodecMap[] = {
// See CMVideoCodecType for the four character code names of codecs
- { "video/mp4; codecs=\"mp1v\"", QMediaFormat::VideoCodec::MPEG1 },
- { "video/mp4; codecs=\"mp2v\"", QMediaFormat::VideoCodec::MPEG2 },
- { "video/mp4; codecs=\"mp4v\"", QMediaFormat::VideoCodec::MPEG4 },
- { "video/mp4; codecs=\"avc1\"", QMediaFormat::VideoCodec::H264 },
- { "video/mp4; codecs=\"hvc1\"", QMediaFormat::VideoCodec::H265 },
- { "video/mp4; codecs=\"vp09\"", QMediaFormat::VideoCodec::VP9 },
- { "video/mp4; codecs=\"av01\"", QMediaFormat::VideoCodec::AV1 }, // ### ????
- { "video/mp4; codecs=\"jpeg\"", QMediaFormat::VideoCodec::MotionJPEG },
+ { "; codecs=\"mp1v\"", QMediaFormat::VideoCodec::MPEG1 },
+ { "; codecs=\"mp2v\"", QMediaFormat::VideoCodec::MPEG2 },
+ { "; codecs=\"mp4v\"", QMediaFormat::VideoCodec::MPEG4 },
+ { "; codecs=\"avc1\"", QMediaFormat::VideoCodec::H264 },
+ { "; codecs=\"hvc1\"", QMediaFormat::VideoCodec::H265 },
+ { "; codecs=\"vp09\"", QMediaFormat::VideoCodec::VP9 },
+ { "; codecs=\"av01\"", QMediaFormat::VideoCodec::AV1 }, // ### ????
+ { "; codecs=\"jpeg\"", QMediaFormat::VideoCodec::MotionJPEG },
{ nullptr, QMediaFormat::VideoCodec::Unspecified }
};
@@ -78,11 +78,15 @@ static struct {
QMediaFormat::AudioCodec value;
} audioCodecMap[] = {
// AudioFile.h
- { "audio/mp3", QMediaFormat::AudioCodec::MP3 },
- { "audio/aac", QMediaFormat::AudioCodec::AAC },
- { "video/mp4; codecs=\"ac-3\"", QMediaFormat::AudioCodec::AC3 },
- { "video/mp4; codecs=\"ec-3\"", QMediaFormat::AudioCodec::EAC3 },
- { "audio/flac", QMediaFormat::AudioCodec::FLAC },
+ // ### The next two entries do not work, probably because they contain non a space and period and AVFoundation doesn't like that
+ // We know they are supported on all Apple platforms, so we'll add them manually below
+// { "; codecs=\".mp3\"", QMediaFormat::AudioCodec::MP3 },
+// { "; codecs=\"aac \"", QMediaFormat::AudioCodec::AAC },
+ { "; codecs=\"ac-3\"", QMediaFormat::AudioCodec::AC3 },
+ { "; codecs=\"ec-3\"", QMediaFormat::AudioCodec::EAC3 },
+ { "; codecs=\"flac\"", QMediaFormat::AudioCodec::FLAC },
+ { "; codecs=\"alac\"", QMediaFormat::AudioCodec::FLAC },
+ { "; codecs=\"opus\"", QMediaFormat::AudioCodec::Opus },
{ nullptr, QMediaFormat::AudioCodec::Unspecified },
};
@@ -92,85 +96,86 @@ QDarwinFormatInfo::QDarwinFormatInfo()
for (AVFileType filetype in avtypes) {
auto *m = mediaContainerMap;
while (m->name) {
- if (!strcmp(filetype.UTF8String, m->name)) {
- m_decodableMediaContainers.append(m->value);
- break;
+ if (strcmp(filetype.UTF8String, m->name)) {
+ ++m;
+ continue;
}
- ++m;
- }
- }
- {
- auto *m = videoCodecMap;
- while (m->name) {
- if ([AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:m->name]])
- m_decodableVideoCodecs << m->value;
- ++m;
- }
- }
- {
- auto *m = audioCodecMap;
- while (m->name) {
- qDebug() << "audio" << m->name << [AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:m->name]];
- if ([AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:m->name]])
- m_decodableAudioCodecs << m->value;
+ QList<QMediaFormat::VideoCodec> video;
+ QList<QMediaFormat::AudioCodec> audio;
+// qDebug() << "Media container" << m->name << "supported";
+
+ auto *v = videoCodecMap;
+ while (v->name) {
+ QByteArray extendedMimetype = m->name;
+ extendedMimetype += v->name;
+// qDebug() << "video" << extendedMimetype << [AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:extendedMimetype.constData()]];
+ if ([AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:extendedMimetype.constData()]])
+ video << v->value;
+ ++v;
+ }
+
+ auto *a = audioCodecMap;
+ while (a->name) {
+ QByteArray extendedMimetype = m->name;
+ extendedMimetype += a->name;
+// qDebug() << "audio" << extendedMimetype << [AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:extendedMimetype.constData()]];
+ if ([AVURLAsset isPlayableExtendedMIMEType:[NSString stringWithUTF8String:extendedMimetype.constData()]])
+ audio << a->value;
+ ++a;
+ }
+ // Added manually, see comment in the list above
+ if (m->value <= QMediaFormat::AAC)
+ audio << QMediaFormat::AudioCodec::AAC;
+ if (m->value < QMediaFormat::AAC || m->value == QMediaFormat::MP3)
+ audio << QMediaFormat::AudioCodec::MP3;
+
+ decoders << CodecMap{ m->value, audio, video };
++m;
}
}
- // Audio format seems to be symmetric
- m_encodableAudioCodecs = m_decodableAudioCodecs;
+#if 1
+ // ### Verify that this is correct
+ encoders = decoders;
+#else
// ### Haven't seen a good way to figure this out.
// seems AVFoundation only supports those for encoding
- m_encodableMediaContainers << QMediaFormat::MPEG4 << QMediaFormat::QuickTime;
- // AVCaptureVideoDataOutput.availableVideoCodecTypes does not mention H265 even though it is supported
- m_encodableVideoCodecs << QMediaFormat::VideoCodec::H264 << QMediaFormat::VideoCodec::H265 << QMediaFormat::VideoCodec::MotionJPEG;
+ encoders = {
+ { QMediaFormat::MPEG4,
+ { QMediaFormat::AudioCodec::AAC, QMediaFormat::AudioCodec::MP3, QMediaFormat::AudioCodec::ALAC, QMediaFormat::AudioCodec::AC3, QMediaFormat::AudioCodec::EAC3, },
+ { QMediaFormat::VideoCodec::H264, QMediaFormat::VideoCodec::H265, QMediaFormat::VideoCodec::MotionJPEG } },
+ { QMediaFormat::QuickTime,
+ { QMediaFormat::AudioCodec::AAC, QMediaFormat::AudioCodec::MP3, QMediaFormat::AudioCodec::ALAC, QMediaFormat::AudioCodec::AC3, QMediaFormat::AudioCodec::EAC3, },
+ { QMediaFormat::VideoCodec::H264, QMediaFormat::VideoCodec::H265, QMediaFormat::VideoCodec::MotionJPEG } },
+ { QMediaFormat::AAC,
+ { QMediaFormat::AudioCodec::AAC },
+ {} },
+ { QMediaFormat::MP3,
+ { QMediaFormat::AudioCodec::MP3 },
+ {} },
+ { QMediaFormat::FLAC,
+ { QMediaFormat::AudioCodec::FLAC },
+ {} },
+ { QMediaFormat::Mpeg4Audio,
+ { QMediaFormat::AudioCodec::AAC },
+ {} }
+ };
+#endif
}
QDarwinFormatInfo::~QDarwinFormatInfo()
{
}
-QList<QMediaFormat::FileFormat> QDarwinFormatInfo::decodableMediaContainers() const
-{
- return m_decodableMediaContainers;
-}
-
-QList<QMediaFormat::AudioCodec> QDarwinFormatInfo::decodableAudioCodecs() const
-{
- return m_decodableAudioCodecs;
-}
-
-QList<QMediaFormat::VideoCodec> QDarwinFormatInfo::decodableVideoCodecs() const
-{
- return m_decodableVideoCodecs;
-}
-
-QList<QMediaFormat::FileFormat> QDarwinFormatInfo::encodableMediaContainers() const
-{
- return m_encodableMediaContainers;
-}
-
-QList<QMediaFormat::AudioCodec> QDarwinFormatInfo::encodableAudioCodecs() const
-{
- return m_encodableAudioCodecs;
-}
-
-QList<QMediaFormat::VideoCodec> QDarwinFormatInfo::encodableVideoCodecs() const
-{
- return m_encodableVideoCodecs;
-}
-
int QDarwinFormatInfo::audioFormatForCodec(QMediaFormat::AudioCodec codec)
{
int codecId = kAudioFormatMPEG4AAC;
switch (codec) {
case QMediaFormat::AudioCodec::Unspecified:
case QMediaFormat::AudioCodec::DolbyTrueHD:
- case QMediaFormat::AudioCodec::Opus:
case QMediaFormat::AudioCodec::Vorbis:
case QMediaFormat::AudioCodec::Wave:
- case QMediaFormat::AudioCodec::WindowsMediaAudio:
// Unsupported, shouldn't happen. Fall back to AAC
case QMediaFormat::AudioCodec::AAC:
codecId = kAudioFormatMPEG4AAC;
@@ -186,6 +191,10 @@ int QDarwinFormatInfo::audioFormatForCodec(QMediaFormat::AudioCodec codec)
break;
case QMediaFormat::AudioCodec::FLAC:
codecId = kAudioFormatFLAC;
+ case QMediaFormat::AudioCodec::ALAC:
+ codecId = kAudioFormatAppleLossless;
+ case QMediaFormat::AudioCodec::Opus:
+ codecId = kAudioFormatOpus;
break;
}
return codecId;
diff --git a/src/multimedia/platform/darwin/qdarwinformatsinfo_p.h b/src/multimedia/platform/darwin/qdarwinformatsinfo_p.h
index ad53c745b..44e03c5b2 100644
--- a/src/multimedia/platform/darwin/qdarwinformatsinfo_p.h
+++ b/src/multimedia/platform/darwin/qdarwinformatsinfo_p.h
@@ -64,25 +64,8 @@ public:
QDarwinFormatInfo();
~QDarwinFormatInfo();
- QList<QMediaFormat::FileFormat> decodableMediaContainers() const override;
- QList<QMediaFormat::AudioCodec> decodableAudioCodecs() const override;
- QList<QMediaFormat::VideoCodec> decodableVideoCodecs() const override;
-
- QList<QMediaFormat::FileFormat> encodableMediaContainers() const override;
- QList<QMediaFormat::AudioCodec> encodableAudioCodecs() const override;
- QList<QMediaFormat::VideoCodec> encodableVideoCodecs() const override;
-
static int audioFormatForCodec(QMediaFormat::AudioCodec codec);
static NSString *videoFormatForCodec(QMediaFormat::VideoCodec codec);
-
-private:
- QList<QMediaFormat::FileFormat> m_decodableMediaContainers;
- QList<QMediaFormat::AudioCodec> m_decodableAudioCodecs;
- QList<QMediaFormat::VideoCodec> m_decodableVideoCodecs;
-
- QList<QMediaFormat::FileFormat> m_encodableMediaContainers;
- QList<QMediaFormat::AudioCodec> m_encodableAudioCodecs;
- QList<QMediaFormat::VideoCodec> m_encodableVideoCodecs;
};
QT_END_NAMESPACE