Skip to content

Commit

Permalink
FEAT(client): Add MP3 Recording
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinry authored and Krzmbrzl committed Nov 4, 2023
1 parent 1e5a126 commit 82099b8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mumble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions src/mumble/VoiceRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/mumble/VoiceRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ enum Format {
#ifdef USE_SNDFILE_OPUS
// OPUS Format
OPUS,
#endif
#ifdef USE_SNDFILE_MP3
MP3,
#endif
kEnd
};
Expand Down

0 comments on commit 82099b8

Please sign in to comment.