diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt index 57de9ffe0..de2b1a59f 100644 --- a/src/mumble/CMakeLists.txt +++ b/src/mumble/CMakeLists.txt @@ -451,6 +451,13 @@ endif() find_pkg("SndFile;LibSndFile;sndfile" REQUIRED) +# Check if sndfile version supports opus +if("${sndfile_VERSION}" VERSION_GREATER_EQUAL "1.0.29") + target_compile_definitions(mumble PRIVATE USE_SNDFILE_OPUS) +else() + message(WARNING "libsnfile is missing Opus-support -> No Opus-format recording") +endif() + # Look for various targets as they are named differently on different platforms if(static AND TARGET sndfile-static) target_link_libraries(mumble PRIVATE sndfile-static) diff --git a/src/mumble/VoiceRecorder.cpp b/src/mumble/VoiceRecorder.cpp index bba6bf34b..189b173f2 100644 --- a/src/mumble/VoiceRecorder.cpp +++ b/src/mumble/VoiceRecorder.cpp @@ -212,6 +212,18 @@ SF_INFO VoiceRecorder::createSoundFileInfo() const { qWarning() << "VoiceRecorder: recording started to" << m_config.fileName << "@" << m_config.sampleRate << "hz in FLAC format"; break; +#ifdef USE_SNDFILE_OPUS + case VoiceRecorderFormat::OPUS: + sfinfo.frames = 0; + sfinfo.samplerate = m_config.sampleRate; + sfinfo.channels = 1; + sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_OPUS; + sfinfo.sections = 0; + sfinfo.seekable = 0; + qWarning() << "VoiceRecorder: recording started to" << m_config.fileName << "@" << m_config.sampleRate + << "hz in OPUS format"; + break; +#endif } Q_ASSERT(sf_format_check(&sfinfo)); @@ -429,6 +441,10 @@ QString VoiceRecorderFormat::getFormatDescription(VoiceRecorderFormat::Format fm return VoiceRecorder::tr(".au - Uncompressed"); case VoiceRecorderFormat::FLAC: return VoiceRecorder::tr(".flac - Lossless compressed"); +#ifdef USE_SNDFILE_OPUS + case VoiceRecorderFormat::OPUS: + return VoiceRecorder::tr(".opus - Lossy compressed"); +#endif default: return QString(); } @@ -446,6 +462,10 @@ QString VoiceRecorderFormat::getFormatDefaultExtension(VoiceRecorderFormat::Form return QLatin1String("au"); case VoiceRecorderFormat::FLAC: return QLatin1String("flac"); +#ifdef USE_SNDFILE_OPUS + case VoiceRecorderFormat::OPUS: + return QLatin1String("opus"); +#endif default: return QString(); } diff --git a/src/mumble/VoiceRecorder.h b/src/mumble/VoiceRecorder.h index 97c6e0c90..886f02a27 100644 --- a/src/mumble/VoiceRecorder.h +++ b/src/mumble/VoiceRecorder.h @@ -51,6 +51,10 @@ enum Format { AU, /// FLAC Format FLAC, +#ifdef USE_SNDFILE_OPUS + // OPUS Format + OPUS, +#endif kEnd };