From 82099b896f08228910bd1e52d85fe418f0002d90 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 3 Oct 2023 09:59:07 -0400 Subject: [PATCH] FEAT(client): Add MP3 Recording --- src/mumble/CMakeLists.txt | 7 +++++++ src/mumble/VoiceRecorder.cpp | 20 ++++++++++++++++++++ src/mumble/VoiceRecorder.h | 3 +++ 3 files changed, 30 insertions(+) diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt index be7d539c8b1..094dfbf507d 100644 --- a/src/mumble/CMakeLists.txt +++ b/src/mumble/CMakeLists.txt @@ -507,6 +507,13 @@ else() message(WARNING "libsndfile is missing Opus-support -> No Opus-format recording") endif() +# Check if sndfile version supports mp3 +if("${sndfile_VERSION}" VERSION_GREATER_EQUAL "1.1.0") + target_compile_definitions(mumble_client_object_lib PUBLIC USE_SNDFILE_MP3) +else() + message(WARNING "libsndfile is missing Mp3-support -> No Mp3-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_client_object_lib PUBLIC sndfile-static) diff --git a/src/mumble/VoiceRecorder.cpp b/src/mumble/VoiceRecorder.cpp index 58035c8a76f..3e1c3b82c41 100644 --- a/src/mumble/VoiceRecorder.cpp +++ b/src/mumble/VoiceRecorder.cpp @@ -223,6 +223,18 @@ SF_INFO VoiceRecorder::createSoundFileInfo() const { qWarning() << "VoiceRecorder: recording started to" << m_config.fileName << "@" << m_config.sampleRate << "hz in OPUS format"; break; +#endif +#ifdef USE_SNDFILE_MP3 + case VoiceRecorderFormat::MP3: + sfinfo.frames = 0; + sfinfo.samplerate = m_config.sampleRate; + sfinfo.channels = 1; + sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III; + sfinfo.sections = 0; + sfinfo.seekable = 0; + qWarning() << "VoiceRecorder: recording started to" << m_config.fileName << "@" << m_config.sampleRate + << "hz in MP3 format"; + break; #endif } @@ -445,6 +457,10 @@ QString VoiceRecorderFormat::getFormatDescription(VoiceRecorderFormat::Format fm #ifdef USE_SNDFILE_OPUS case VoiceRecorderFormat::OPUS: return VoiceRecorder::tr(".opus - Lossy compressed"); +#endif +#ifdef USE_SNDFILE_MP3 + case VoiceRecorderFormat::MP3: + return VoiceRecorder::tr(".mp3 - Lossy compressed"); #endif default: return QString(); @@ -466,6 +482,10 @@ QString VoiceRecorderFormat::getFormatDefaultExtension(VoiceRecorderFormat::Form #ifdef USE_SNDFILE_OPUS case VoiceRecorderFormat::OPUS: return QLatin1String("opus"); +#endif +#ifdef USE_SNDFILE_MP3 + case VoiceRecorderFormat::MP3: + return QLatin1String("mp3"); #endif default: return QString(); diff --git a/src/mumble/VoiceRecorder.h b/src/mumble/VoiceRecorder.h index 7d482822524..0778d811553 100644 --- a/src/mumble/VoiceRecorder.h +++ b/src/mumble/VoiceRecorder.h @@ -54,6 +54,9 @@ enum Format { #ifdef USE_SNDFILE_OPUS // OPUS Format OPUS, +#endif +#ifdef USE_SNDFILE_MP3 + MP3, #endif kEnd };