diff --git a/src/call.cpp b/src/call.cpp index ee09daee09e4c5ef02c48bf96d6930ba54f1f7d1..2daba8fd3a9ff7a39f4aaf7154e89979fdff8628 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -60,6 +60,7 @@ Call::removeCall() Manager::instance().callFactory.removeCall(*this); iceTransport_.reset(); setState(CallState::OVER); + recAudio_->closeFile(); } const std::string& diff --git a/src/media/audio/audiorecord.cpp b/src/media/audio/audiorecord.cpp index dde6a51acec881cc92df288bf3b7516aad2716e5..71cc60ba15ac2359801d15d5fdf3c8647d25e90d 100644 --- a/src/media/audio/audiorecord.cpp +++ b/src/media/audio/audiorecord.cpp @@ -128,20 +128,20 @@ sanitize(std::string s) void AudioRecord::initFilename(const std::string &peerNumber) { - std::string fName(filename_); - fName.append("-" + sanitize(peerNumber) + "-" PACKAGE); - - if (filename_.find(".wav") == std::string::npos) { - RING_DBG("Concatenate .wav file extension: name : %s", filename_.c_str()); - fName.append(".wav"); + RING_DBG("Initialize audio record for peer : %s", peerNumber.c_str()); + // if savePath_ don't contains filename + if (savePath_.find(".wav") == std::string::npos) { + filename_ = createFilename(); + filename_.append("-" + sanitize(peerNumber) + "-" PACKAGE); + filename_.append(".wav"); + } else { + filename_ = ""; } - - savePath_.append(fName); } std::string AudioRecord::getFilename() const { - return savePath_; + return savePath_ + filename_; } bool @@ -152,8 +152,8 @@ AudioRecord::openFile() const bool doAppend = fileExists(); const int access = doAppend ? SFM_RDWR : SFM_WRITE; - RING_DBG("Opening file %s with format %s", savePath_.c_str(), sndFormat_.toString().c_str()); - fileHandle_.reset(new SndfileHandle (savePath_.c_str(), + RING_DBG("Opening file %s with format %s", getFilename().c_str(), sndFormat_.toString().c_str()); + fileHandle_.reset(new SndfileHandle (getFilename().c_str(), access, SF_FORMAT_WAV | SF_FORMAT_PCM_16, sndFormat_.nb_channels, @@ -187,7 +187,7 @@ AudioRecord::isOpenFile() const noexcept bool AudioRecord::fileExists() const { - return access(savePath_.c_str(), F_OK) != -1; + return access(getFilename().c_str(), F_OK) != -1; } bool AudioRecord::isRecording() const @@ -211,7 +211,7 @@ AudioRecord::toggleRecording() void AudioRecord::stopRecording() const noexcept { - RING_DBG("Stop recording %s", savePath_.c_str()); + RING_DBG("Stop recording %s", getFilename().c_str()); recordingEnabled_ = false; } diff --git a/src/media/audio/audiorecord.h b/src/media/audio/audiorecord.h index 20035fcdfb7d436ba2afca8bc94fbf4525488c05..a11ffbb7ce31d310bc4c3b69b3a81a0228d7114b 100644 --- a/src/media/audio/audiorecord.h +++ b/src/media/audio/audiorecord.h @@ -53,7 +53,7 @@ class AudioRecord { std::string getFilename() const; /** - * Check if no otehr file is opened, then create a new one + * Check if no other file is opened, then create a new one * @param filename A string containing teh file (with/without extension) * @param type The sound file format (FILE_RAW, FILE_WAVE) * @param format Internal sound format (INT16 / INT32) @@ -62,7 +62,7 @@ class AudioRecord { bool openFile(); /** - * Close the opend recording file. If wave: cout the number of byte + * Close the opened recording file. If wave: cout the number of byte */ void closeFile(); diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index 3a48f2c0232a871c2bacd7f2b8bc0652dc182ae6..c2f62d8e1ac1950bd018f0bd9baf06bc325389e9 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -212,6 +212,7 @@ RingAccount::newOutgoingCall(const std::string& toUrl) call->setIPToIP(true); call->setSecure(isTlsEnabled()); + call->initRecFilename(toUri); auto sthis = std::static_pointer_cast<RingAccount>(shared_from_this());