Skip to content
Snippets Groups Projects
Commit 168253ed authored by Andreas Traczyk's avatar Andreas Traczyk Committed by gerrit2
Browse files

audio: fix unmuting of audio after audio has been muted

Saves the previous mute state in AudioRtpSession and AudioSender,
so that when the audio encoder is re-instantiated, it can be set
to a previously set state (if any).

Change-Id: I25809499fd5afca1b6ae0f03c685a10ba95f94ac
Tuleap: #1298
parent cd409b81
Branches
Tags
No related merge requests found
......@@ -48,7 +48,8 @@ class AudioSender {
const std::string& dest,
const MediaDescription& args,
SocketPair& socketPair,
const uint16_t seqVal);
const uint16_t seqVal,
bool muteState);
~AudioSender();
void setMuted(bool isMuted);
......@@ -69,6 +70,7 @@ class AudioSender {
AudioBuffer micData_;
AudioBuffer resampledData_;
const uint16_t seqVal_;
bool muteState_ = false;
using seconds = std::chrono::duration<double, std::ratio<1>>;
const seconds secondsPerPacket_ {0.02}; // 20 ms
......@@ -82,11 +84,13 @@ AudioSender::AudioSender(const std::string& id,
const std::string& dest,
const MediaDescription& args,
SocketPair& socketPair,
const uint16_t seqVal) :
const uint16_t seqVal,
bool muteState) :
id_(id),
dest_(dest),
args_(args),
seqVal_(seqVal),
muteState_(muteState),
loop_([&] { return setup(socketPair); },
std::bind(&AudioSender::process, this),
std::bind(&AudioSender::cleanup, this))
......@@ -108,6 +112,7 @@ AudioSender::setup(SocketPair& socketPair)
try {
/* Encoder setup */
RING_DBG("audioEncoder_->openOutput %s", dest_.c_str());
audioEncoder_->setMuted(muteState_);
audioEncoder_->openOutput(dest_.c_str(), args_);
audioEncoder_->setInitSeqVal(seqVal_);
audioEncoder_->setIOContext(muxContext_);
......@@ -178,6 +183,7 @@ AudioSender::process()
void
AudioSender::setMuted(bool isMuted)
{
muteState_ = isMuted;
audioEncoder_->setMuted(isMuted);
}
......@@ -385,7 +391,7 @@ AudioRtpSession::startSender()
sender_.reset();
socketPair_->stopSendOp(false);
sender_.reset(new AudioSender(callID_, getRemoteRtpUri(), send_,
*socketPair_, initSeqVal_));
*socketPair_, initSeqVal_, muteState_));
} catch (const MediaEncoderException &e) {
RING_ERR("%s", e.what());
send_.enabled = false;
......@@ -480,8 +486,10 @@ void
AudioRtpSession::setMuted(bool isMuted)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (sender_)
if (sender_) {
muteState_ = isMuted;
sender_->setMuted(isMuted);
}
}
} // namespace ring
......@@ -56,6 +56,7 @@ class AudioRtpSession : public RtpSession {
std::unique_ptr<AudioReceiveThread> receiveThread_;
std::shared_ptr<RingBuffer> ringbuffer_;
uint16_t initSeqVal_ = 0;
bool muteState_ = false;
};
} // namespace ring
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment