summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp56
-rw-r--r--indra/llwebrtc/llwebrtc.h6
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h10
3 files changed, 49 insertions, 23 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index b2f5e0212e..4741ed92a3 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -399,11 +399,6 @@ float LLWebRTCImpl::getTuningAudioLevel() { return 20 * mTuningAudioDeviceObserv
float LLWebRTCImpl::getPeerAudioLevel() { return 20 * mPeerAudioDeviceObserver->getMicrophoneEnergy(); }
-void LLWebRTCImpl::setSpeakerVolume(float volume) { mPeerDeviceModule->SetSpeakerVolume( (uint32_t)(volume * VOLUME_SCALE_WEBRTC));}
-void LLWebRTCImpl::setMicrophoneVolume(float volume) { mPeerDeviceModule->SetMicrophoneVolume((uint32_t)(volume * VOLUME_SCALE_WEBRTC));}
-
-void LLWebRTCImpl::setMute(bool mute) { mPeerDeviceModule->SetMicrophoneMute(mute); }
-
//
// Helpers
//
@@ -417,6 +412,7 @@ LLWebRTCPeerConnection * LLWebRTCImpl::newPeerConnection()
peerConnection->enableTracks(!mMute);
return peerConnection.get();
}
+
void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnection * peer_connection)
{
std::vector<rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>>::iterator it =
@@ -506,12 +502,11 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection()
audioOptions.echo_cancellation = false; // incompatible with opus stereo
audioOptions.noise_suppression = true;
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = mPeerConnectionFactory->CreateLocalMediaStream("SLStream");
-
+ mLocalStream = mPeerConnectionFactory->CreateLocalMediaStream("SLStream");
rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
mPeerConnectionFactory->CreateAudioTrack("SLAudio", mPeerConnectionFactory->CreateAudioSource(audioOptions).get()));
audio_track->set_enabled(true);
- stream->AddTrack(audio_track);
+ mLocalStream->AddTrack(audio_track);
mPeerConnection->AddTrack(audio_track, {"SLStream"});
@@ -545,6 +540,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection()
params.codecs.push_back(codecparam);
receiver->SetParameters(params);
}
+
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions offerOptions;
mPeerConnection->CreateOffer(this, offerOptions);
@@ -606,13 +602,47 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp)
void LLWebRTCPeerConnectionImpl::setMute(bool mute)
{
mMute = mute;
- auto senders = mPeerConnection->GetSenders();
-
- RTC_LOG(LS_INFO) << __FUNCTION__ << (mute ? "disabling" : "enabling") << " streams count " << senders.size();
+ if (mPeerConnection)
+ {
+ auto senders = mPeerConnection->GetSenders();
+
+ RTC_LOG(LS_INFO) << __FUNCTION__ << (mute ? "disabling" : "enabling") << " streams count " << senders.size();
+ for (auto &sender : senders)
+ {
+ auto track = sender->track();
+ if(track)
+ {
+ track->set_enabled(!mMute);
+ }
+ }
+ }
+}
+
+void LLWebRTCPeerConnectionImpl::setReceiveVolume(float volume)
+{
+ auto receivers = mPeerConnection->GetReceivers();
- for (auto &sender : senders)
+ for (auto &receiver : receivers)
{
- sender->track()->set_enabled(!mMute);
+ for (auto& stream : receiver->streams())
+ {
+ for (auto& track : stream->GetAudioTracks())
+ {
+ track->GetSource()->SetVolume(volume);
+ }
+ }
+ }
+}
+
+void LLWebRTCPeerConnectionImpl::setSendVolume(float volume)
+{
+ if (mLocalStream)
+ {
+ auto track = mLocalStream->FindAudioTrack("SLStream");
+ if (track)
+ {
+ track->GetSource()->SetVolume(volume);
+ }
}
}
diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h
index ed80fa5648..9766f2f231 100644
--- a/indra/llwebrtc/llwebrtc.h
+++ b/indra/llwebrtc/llwebrtc.h
@@ -85,10 +85,6 @@ class LLWebRTCDeviceInterface
virtual void setTuningMode(bool enable) = 0;
virtual float getTuningAudioLevel() = 0;
-
- virtual void setSpeakerVolume(float volume) = 0; // volume between 0.0 and 1.0
- virtual void setMicrophoneVolume(float volume) = 0; // volume between 0.0 and 1.0
- virtual void setMute(bool mute) = 0;
virtual float getPeerAudioLevel() = 0;
};
@@ -96,6 +92,8 @@ class LLWebRTCAudioInterface
{
public:
virtual void setMute(bool mute) = 0;
+ virtual void setReceiveVolume(float volume) = 0; // volume between 0.0 and 1.0
+ virtual void setSendVolume(float volume) = 0; // volume between 0.0 and 1.0
};
class LLWebRTCDataObserver
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index 76e29c63fb..efb0d3add3 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -116,10 +116,6 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface
void setTuningMode(bool enable) override;
float getTuningAudioLevel() override;
float getPeerAudioLevel() override;
-
- void setSpeakerVolume(float volume) override; // range 0.0-1.0
- void setMicrophoneVolume(float volume) override; // range 0.0-1.0
- void setMute(bool mute) override;
//
// Helpers
@@ -224,12 +220,13 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnection,
void shutdownConnection() override;
void AnswerAvailable(const std::string &sdp) override;
-
//
// LLWebRTCAudioInterface
//
void setMute(bool mute) override;
-
+ void setReceiveVolume(float volume) override; // volume between 0.0 and 1.0
+ void setSendVolume(float volume) override; // volume between 0.0 and 1.0
+
//
// LLWebRTCDataInterface
//
@@ -291,6 +288,7 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnection,
bool mAnswerReceived;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> mPeerConnection;
+ rtc::scoped_refptr<webrtc::MediaStreamInterface> mLocalStream;
std::vector<LLWebRTCDataObserver *> mDataObserverList;
rtc::scoped_refptr<webrtc::DataChannelInterface> mDataChannel;