Remove trailing spaces. Other code cleanup.

master
Roxie Linden 2024-03-10 00:11:43 -08:00
parent 7714850fbe
commit fc462b2b0f
9 changed files with 912 additions and 1021 deletions

View File

@ -85,15 +85,15 @@ void LLAudioDeviceObserver::OnRenderData(const void *audio_samples,
}
LLCustomProcessor::LLCustomProcessor() :
mSampleRateHz(0),
mSampleRateHz(0),
mNumChannels(0),
mMicrophoneEnergy(0.0)
{
{
memset(mSumVector, 0, sizeof(mSumVector));
}
void LLCustomProcessor::Initialize(int sample_rate_hz, int num_channels)
{
{
mSampleRateHz = sample_rate_hz;
mNumChannels = num_channels;
memset(mSumVector, 0, sizeof(mSumVector));
@ -187,7 +187,7 @@ void LLWebRTCImpl::init()
{
// Initialize the audio devices on the Worker Thread
mTuningDeviceModule = webrtc::CreateAudioDeviceWithDataObserver(
webrtc::AudioDeviceModule::AudioLayer::kPlatformDefaultAudio,
webrtc::AudioDeviceModule::AudioLayer::kPlatformDefaultAudio,
mTaskQueueFactory.get(),
std::unique_ptr<webrtc::AudioDeviceDataObserver>(mTuningAudioDeviceObserver));
@ -198,7 +198,7 @@ void LLWebRTCImpl::init()
mTuningDeviceModule->SetAudioDeviceSink(this);
updateDevices();
});
mWorkerThread->BlockingCall(
[this]()
{
@ -426,7 +426,7 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
{
mTuningDeviceModule->StopPlayout();
}
mTuningDeviceModule->SetPlayoutDevice(tuningPlayoutDevice);
mTuningDeviceModule->InitSpeaker();
mTuningDeviceModule->InitPlayout();
@ -456,7 +456,7 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
mPeerDeviceModule->InitSpeaker();
mPeerDeviceModule->InitPlayout();
mPeerDeviceModule->StartPlayout();
}
});
}
@ -466,7 +466,7 @@ void LLWebRTCImpl::updateDevices()
{
int16_t renderDeviceCount = mTuningDeviceModule->PlayoutDevices();
int16_t currentRenderDeviceIndex = mTuningDeviceModule->GetPlayoutDevice();
LLWebRTCVoiceDeviceList renderDeviceList;
for (int16_t index = 0; index < renderDeviceCount; index++)
{
@ -475,7 +475,7 @@ void LLWebRTCImpl::updateDevices()
mTuningDeviceModule->PlayoutDeviceName(index, name, guid);
renderDeviceList.emplace_back(name, guid, index == currentRenderDeviceIndex);
}
int16_t captureDeviceCount = mTuningDeviceModule->RecordingDevices();
int16_t currentCaptureDeviceIndex = mTuningDeviceModule->GetRecordingDevice();
@ -533,7 +533,7 @@ LLWebRTCPeerConnectionInterface *LLWebRTCImpl::newPeerConnection()
{
rtc::scoped_refptr<LLWebRTCPeerConnectionImpl> peerConnection = rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>(new rtc::RefCountedObject<LLWebRTCPeerConnectionImpl>());
peerConnection->init(this);
mPeerConnections.emplace_back(peerConnection);
peerConnection->enableSenderTracks(!mMute);
return peerConnection.get();
@ -703,7 +703,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection()
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions offerOptions;
mPeerConnection->CreateOffer(this, offerOptions);
});
return true;
}
@ -759,7 +759,7 @@ void LLWebRTCPeerConnectionImpl::enableReceiverTracks(bool enable)
void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp)
{
RTC_LOG(LS_INFO) << __FUNCTION__ << " Remote SDP: " << sdp;
mWebRTCImpl->PostSignalingTask(
[this, sdp]()
{
@ -768,7 +768,7 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp)
RTC_LOG(LS_INFO) << __FUNCTION__ << " " << mPeerConnection->peer_connection_state();
mPeerConnection->SetRemoteDescription(webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp),
rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface>(this));
}
}
});
}
@ -801,8 +801,8 @@ void LLWebRTCPeerConnectionImpl::setMute(bool mute)
}
void LLWebRTCPeerConnectionImpl::resetMute()
{
setMute(mMute);
{
setMute(mMute);
}
void LLWebRTCPeerConnectionImpl::setReceiveVolume(float volume)
@ -893,7 +893,7 @@ void LLWebRTCPeerConnectionImpl::OnIceGatheringChange(webrtc::PeerConnectionInte
webrtc_new_state = LLWebRTCSignalingObserver::EIceGatheringState::ICE_GATHERING_NEW;
return;
}
if (mAnswerReceived)
{
for (auto &observer : mSignalingObserverList)
@ -907,7 +907,7 @@ void LLWebRTCPeerConnectionImpl::OnIceGatheringChange(webrtc::PeerConnectionInte
void LLWebRTCPeerConnectionImpl::OnConnectionChange(webrtc::PeerConnectionInterface::PeerConnectionState new_state)
{
RTC_LOG(LS_ERROR) << __FUNCTION__ << " Peer Connection State Change " << new_state;
switch (new_state)
{
case webrtc::PeerConnectionInterface::PeerConnectionState::kConnected:
@ -929,7 +929,7 @@ void LLWebRTCPeerConnectionImpl::OnConnectionChange(webrtc::PeerConnectionInterf
{
observer->OnRenegotiationNeeded();
}
break;
}
default:
@ -944,7 +944,7 @@ void LLWebRTCPeerConnectionImpl::OnConnectionChange(webrtc::PeerConnectionInterf
static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterface *candidate)
{
std::ostringstream candidate_stream;
candidate_stream <<
candidate->candidate().foundation() << " " <<
std::to_string(candidate->candidate().component()) << " " <<
@ -952,7 +952,7 @@ static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterfa
std::to_string(candidate->candidate().priority()) << " " <<
candidate->candidate().address().ipaddr().ToString() << " " <<
candidate->candidate().address().PortAsString() << " typ ";
if (candidate->candidate().type() == cricket::LOCAL_PORT_TYPE)
{
candidate_stream << "host";
@ -982,7 +982,7 @@ static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterfa
{
candidate_stream << " tcptype " << candidate->candidate().tcptype();
}
return candidate_stream.str();
}
@ -990,7 +990,7 @@ static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterfa
void LLWebRTCPeerConnectionImpl::OnIceCandidate(const webrtc::IceCandidateInterface *candidate)
{
RTC_LOG(LS_INFO) << __FUNCTION__ << " " << candidate->sdp_mline_index();
if (!candidate)
{
RTC_LOG(LS_ERROR) << __FUNCTION__ << " No Ice Candidate Given";
@ -1067,7 +1067,7 @@ void LLWebRTCPeerConnectionImpl::OnSuccess(webrtc::SessionDescriptionInterface *
}
void LLWebRTCPeerConnectionImpl::OnFailure(webrtc::RTCError error)
{
{
RTC_LOG(LS_ERROR) << ToString(error.type()) << ": " << error.message();
}
@ -1100,7 +1100,7 @@ void LLWebRTCPeerConnectionImpl::OnSetRemoteDescriptionComplete(webrtc::RTCError
}
mCachedIceCandidates.clear();
OnIceGatheringChange(mPeerConnection->ice_gathering_state());
}
//
@ -1164,7 +1164,7 @@ void LLWebRTCPeerConnectionImpl::sendData(const std::string& data, bool binary)
}
void LLWebRTCPeerConnectionImpl::setDataObserver(LLWebRTCDataObserver* observer)
{
{
mDataObserverList.emplace_back(observer);
}

View File

@ -30,7 +30,7 @@
* overall threading model than the viewer.
* The native webrtc library is also compiled with clang, and has memory management
* functions that conflict namespace-wise with those in the viewer.
*
*
* Due to these differences, code from the viewer cannot be pulled in to this
* dynamic library, so it remains very simple.
*/
@ -56,7 +56,7 @@
namespace llwebrtc
{
// LLWebRTCVoiceDevice is a simple representation of the
// LLWebRTCVoiceDevice is a simple representation of the
// components of a device, used to communicate this
// information to the viewer.

View File

@ -153,12 +153,12 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
void setTuningMode(bool enable) override;
float getTuningAudioLevel() override;
float getPeerConnectionAudioLevel() override;
//
// AudioDeviceSink
//
void OnDevicesUpdated() override;
//
// Helpers
//
@ -171,7 +171,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
{
mWorkerThread->PostTask(std::move(task), location);
}
void PostSignalingTask(absl::AnyInvocable<void() &&> task,
const webrtc::Location& location = webrtc::Location::Current())
{
@ -189,7 +189,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
{
mWorkerThread->BlockingCall(std::move(functor), location);
}
void SignalingBlockingCall(rtc::FunctionView<void()> functor,
const webrtc::Location& location = webrtc::Location::Current())
{
@ -205,7 +205,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
// Allows the LLWebRTCPeerConnectionImpl class to retrieve the
// native webrtc PeerConnectionFactory.
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> getPeerConnectionFactory()
{
{
return mPeerConnectionFactory;
}
@ -242,7 +242,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
LLAudioDeviceObserver * mTuningAudioDeviceObserver;
LLCustomProcessor * mPeerCustomProcessor;
// peer connections
std::vector<rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>> mPeerConnections;
};
@ -270,7 +270,7 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,
virtual void AddRef() const override = 0;
virtual rtc::RefCountReleaseStatus Release() const override = 0;
//
// LLWebRTCPeerConnection
//
@ -326,20 +326,20 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,
// SetLocalDescriptionObserverInterface implementation.
//
void OnSetLocalDescriptionComplete(webrtc::RTCError error) override;
//
// DataChannelObserver implementation.
//
void OnStateChange() override;
void OnMessage(const webrtc::DataBuffer& buffer) override;
// Helpers
void resetMute();
void enableSenderTracks(bool enable);
void enableReceiverTracks(bool enable);
protected:
LLWebRTCImpl * mWebRTCImpl;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory;
@ -358,7 +358,7 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,
std::vector<LLWebRTCDataObserver *> mDataObserverList;
rtc::scoped_refptr<webrtc::DataChannelInterface> mDataChannel;
};
}
#endif // LLWEBRTC_IMPL_H

View File

@ -1,25 +1,25 @@
/**
/**
* @file llvoiceclient.cpp
* @brief Voice client delegation class implementation.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@ -81,10 +81,10 @@ LLVoiceHandler gVoiceHandler;
std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserver::EStatusType inStatus)
{
std::string result = "UNTRANSLATED";
// Prevent copy-paste errors when updating this list...
#define CASE(x) case x: result = #x; break
switch(inStatus)
{
CASE(STATUS_LOGIN_RETRY);
@ -107,9 +107,9 @@ std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserv
}
break;
}
#undef CASE
return result;
}
@ -209,7 +209,7 @@ void LLVoiceClient::onSimulatorFeaturesReceived(const LLUUID& region_id)
void LLVoiceClient::setSpatialVoiceModule(const std::string &voice_server_type)
{
LLVoiceModuleInterface *module = getVoiceModule(voice_server_type);
if (!module)
if (!module)
{
return;
}
@ -264,7 +264,7 @@ void LLVoiceClient::terminate()
const LLVoiceVersionInfo LLVoiceClient::getVersion()
{
if (mSpatialVoiceModule)
if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->getVersion();
}
@ -330,12 +330,12 @@ float LLVoiceClient::tuningGetEnergy(void)
// devices
bool LLVoiceClient::deviceSettingsAvailable()
{
{
return LLWebRTCVoiceClient::getInstance()->deviceSettingsAvailable();
}
bool LLVoiceClient::deviceSettingsUpdated()
{
{
return LLWebRTCVoiceClient::getInstance()->deviceSettingsUpdated();
}
@ -363,7 +363,7 @@ const LLVoiceDeviceList& LLVoiceClient::getCaptureDevices()
const LLVoiceDeviceList& LLVoiceClient::getRenderDevices()
{
{
return LLWebRTCVoiceClient::getInstance()->getRenderDevices();
}
@ -379,7 +379,8 @@ void LLVoiceClient::getParticipantList(std::set<LLUUID> &participants)
bool LLVoiceClient::isParticipant(const LLUUID &speaker_id)
{
return LLWebRTCVoiceClient::getInstance()->isParticipant(speaker_id) || LLVivoxVoiceClient::getInstance()->isParticipant(speaker_id);
return LLWebRTCVoiceClient::getInstance()->isParticipant(speaker_id) ||
LLVivoxVoiceClient::getInstance()->isParticipant(speaker_id);
}
@ -388,14 +389,8 @@ bool LLVoiceClient::isParticipant(const LLUUID &speaker_id)
BOOL LLVoiceClient::isSessionTextIMPossible(const LLUUID& id)
{
if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->isSessionTextIMPossible(id);
}
else
{
return FALSE;
}
// all sessions can do TextIM, as we no longer support PSTN
return TRUE;
}
BOOL LLVoiceClient::isSessionCallBackPossible(const LLUUID& id)
@ -409,7 +404,7 @@ BOOL LLVoiceClient::isSessionCallBackPossible(const LLUUID& id)
bool LLVoiceClient::inProximalChannel()
{
if (mSpatialVoiceModule)
if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->inProximalChannel();
}
@ -552,7 +547,7 @@ void LLVoiceClient::updateMicMuteLogic()
{
// If not configured to use PTT, the mic should be open (otherwise the user will be unable to speak).
bool new_mic_mute = false;
if(mUsePTT)
{
// If configured to use PTT, track the user state.
@ -603,7 +598,7 @@ void LLVoiceClient::setUsePTT(bool usePTT)
mUserPTTState = false;
}
mUsePTT = usePTT;
updateMicMuteLogic();
}
@ -614,7 +609,7 @@ void LLVoiceClient::setPTTIsToggle(bool PTTIsToggle)
// When the user turns off toggle, reset the current state.
mUserPTTState = false;
}
mPTTIsToggle = PTTIsToggle;
updateMicMuteLogic();
@ -629,12 +624,12 @@ void LLVoiceClient::inputUserControlState(bool down)
{
if(mPTTIsToggle)
{
if(down) // toggle open-mic state on 'down'
if(down) // toggle open-mic state on 'down'
{
toggleUserPTTState();
}
}
else // set open-mic state as an absolute
else // set open-mic state as an absolute
{
setUserPTTState(down);
}
@ -651,39 +646,23 @@ void LLVoiceClient::toggleUserPTTState(void)
BOOL LLVoiceClient::getVoiceEnabled(const LLUUID& id)
{
if (mNonSpatialVoiceModule)
{
return mNonSpatialVoiceModule->getVoiceEnabled(id);
}
else if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->getVoiceEnabled(id);
}
else
{
return FALSE;
}
return isParticipant(id) ? TRUE : FALSE;
}
std::string LLVoiceClient::getDisplayName(const LLUUID& id)
{
if (mNonSpatialVoiceModule)
std::string result = LLWebRTCVoiceClient::getInstance()->getDisplayName(id);
if (result.empty())
{
return mNonSpatialVoiceModule->getDisplayName(id);
}
else if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->getDisplayName(id);
}
else
{
return std::string();
result = LLVivoxVoiceClient::getInstance()->getDisplayName(id);
}
return result;
}
bool LLVoiceClient::isVoiceWorking() const
{
return LLVivoxVoiceClient::getInstance()->isVoiceWorking() || LLWebRTCVoiceClient::getInstance()->isVoiceWorking();
return LLVivoxVoiceClient::getInstance()->isVoiceWorking() ||
LLWebRTCVoiceClient::getInstance()->isVoiceWorking();
}
BOOL LLVoiceClient::isParticipantAvatar(const LLUUID& id)
@ -698,48 +677,29 @@ BOOL LLVoiceClient::isOnlineSIP(const LLUUID& id)
BOOL LLVoiceClient::getIsSpeaking(const LLUUID& id)
{
return LLVivoxVoiceClient::getInstance()->getIsSpeaking(id) || LLWebRTCVoiceClient::getInstance()->getIsSpeaking(id);
return LLWebRTCVoiceClient::getInstance()->getIsSpeaking(id) ||
LLVivoxVoiceClient::getInstance()->getIsSpeaking(id);
}
BOOL LLVoiceClient::getIsModeratorMuted(const LLUUID& id)
{
// don't bother worrying about p2p calls, as
// p2p calls don't have mute.
if (mNonSpatialVoiceModule)
{
return mNonSpatialVoiceModule->getIsModeratorMuted(id);
}
else if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->getIsModeratorMuted(id);
}
else
{
return FALSE;
}
return LLWebRTCVoiceClient::getInstance()->getIsModeratorMuted(id) ||
LLVivoxVoiceClient::getInstance()->getIsModeratorMuted(id);
}
F32 LLVoiceClient::getCurrentPower(const LLUUID& id)
{
return std::fmax(LLVivoxVoiceClient::getInstance()->getCurrentPower(id), LLWebRTCVoiceClient::getInstance()->getCurrentPower(id));
{
return std::fmax(LLVivoxVoiceClient::getInstance()->getCurrentPower(id),
LLWebRTCVoiceClient::getInstance()->getCurrentPower(id));
}
BOOL LLVoiceClient::getOnMuteList(const LLUUID& id)
{
// don't bother worrying about p2p calls, as
// p2p calls don't have mute.
if (mNonSpatialVoiceModule)
{
return mNonSpatialVoiceModule->getOnMuteList(id);
}
else if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->getOnMuteList(id);
}
else
{
return FALSE;
}
return LLMuteList::getInstance()->isMuted(id, LLMute::flagVoiceChat);
}
F32 LLVoiceClient::getUserVolume(const LLUUID& id)
@ -798,7 +758,7 @@ std::string LLVoiceClient::sipURIFromID(const LLUUID &id)
{
return mNonSpatialVoiceModule->sipURIFromID(id);
}
else if (mSpatialVoiceModule)
else if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->sipURIFromID(id);
}
@ -854,7 +814,7 @@ class LLViewerRequiredVoiceVersion : public LLHTTPNode
}
LLVoiceVersionInfo versionInfo = voiceModule->getVersion();
if (input.has("body") && input["body"].has("major_version") &&
if (input.has("body") && input["body"].has("major_version") &&
input["body"]["major_version"].asInteger() > versionInfo.majorVersion)
{
if (!sAlertedUser)
@ -879,26 +839,26 @@ class LLViewerParcelVoiceInfo : public LLHTTPNode
{
//the parcel you are in has changed something about its
//voice information
//this is a misnomer, as it can also be when you are not in
//a parcel at all. Should really be something like
//LLViewerVoiceInfoChanged.....
if ( input.has("body") )
{
LLSD body = input["body"];
//body has "region_name" (str), "parcel_local_id"(int),
//"voice_credentials" (map).
//body["voice_credentials"] has "channel_uri" (str),
//body["voice_credentials"] has "channel_credentials" (str)
//if we really wanted to be extra careful,
//we'd check the supplied
//local parcel id to make sure it's for the same parcel
//we believe we're in
if ( body.has("voice_credentials") )
{
{
LLVoiceClient::getInstance()->setSpatialChannel(body["voice_credentials"]);
}
}
@ -941,7 +901,7 @@ void LLSpeakerVolumeStorage::storeSpeakerVolume(const LLUUID& speaker_id, F32 vo
bool LLSpeakerVolumeStorage::getSpeakerVolume(const LLUUID& speaker_id, F32& volume)
{
speaker_data_map_t::const_iterator it = mSpeakersData.find(speaker_id);
if (it != mSpeakersData.end())
{
volume = it->second;
@ -1020,9 +980,9 @@ void LLSpeakerVolumeStorage::load()
if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings_llsd, file))
{
LL_WARNS("Voice") << "failed to parse " << filename << LL_ENDL;
}
}
for (LLSD::map_const_iterator iter = settings_llsd.beginMap();

View File

@ -1,25 +1,25 @@
/**
/**
* @file llvoiceclient.h
* @brief Declaration of LLVoiceClient class which is the interface to the voice client process.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@ -147,32 +147,32 @@ class LLVoiceModuleInterface
public:
LLVoiceModuleInterface() {}
virtual ~LLVoiceModuleInterface() {}
virtual void init(LLPumpIO *pump)=0; // Call this once at application startup (creates connector)
virtual void terminate()=0; // Call this to clean up during shutdown
virtual void updateSettings()=0; // call after loading settings and whenever they change
virtual bool isVoiceWorking() const = 0; // connected to a voice server and voice channel
virtual void setHidden(bool hidden)=0; // Hides the user from voice.
virtual const LLVoiceVersionInfo& getVersion()=0;
/////////////////////
/// @name Tuning
//@{
virtual void tuningStart()=0;
virtual void tuningStop()=0;
virtual bool inTuningMode()=0;
virtual void tuningSetMicVolume(float volume)=0;
virtual void tuningSetSpeakerVolume(float volume)=0;
virtual float tuningGetEnergy(void)=0;
//@}
/////////////////////
/// @name Devices
//@{
@ -180,36 +180,36 @@ public:
// i.e. when the daemon is running and connected, and the device lists are populated.
virtual bool deviceSettingsAvailable()=0;
virtual bool deviceSettingsUpdated() = 0;
// Requery the vivox daemon for the current list of input/output devices.
// If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed
// (use this if you want to know when it's done).
// If you pass false, you'll have no way to know when the query finishes, but the device lists will not appear empty in the interim.
virtual void refreshDeviceLists(bool clearCurrentList = true)=0;
virtual void setCaptureDevice(const std::string& name)=0;
virtual void setRenderDevice(const std::string& name)=0;
virtual LLVoiceDeviceList& getCaptureDevices()=0;
virtual LLVoiceDeviceList& getRenderDevices()=0;
virtual void getParticipantList(std::set<LLUUID> &participants)=0;
virtual bool isParticipant(const LLUUID& speaker_id)=0;
//@}
////////////////////////////
/// @ name Channel stuff
//@{
// returns true iff the user is currently in a proximal (local spatial) channel.
// Note that gestures should only fire if this returns true.
virtual bool inProximalChannel()=0;
virtual void setNonSpatialChannel(const LLSD& channelInfo,
bool notify_on_first_join,
bool hangup_on_last_leave)=0;
virtual bool setSpatialChannel(const LLSD& channelInfo)=0;
virtual void leaveNonSpatialChannel() = 0;
virtual void processChannels(bool process) = 0;
@ -217,12 +217,12 @@ public:
virtual bool compareChannels(const LLSD &channelInfo1, const LLSD &channelInfo2) = 0;
//@}
//////////////////////////
/// @name p2p
//@{
// initiate a call with a peer using the P2P interface, which only applies to some
// voice server types. Otherwise, a group call should be used for P2P
virtual LLVoiceP2POutgoingCallInterface* getOutgoingCallInterface() = 0;
@ -231,35 +231,33 @@ public:
// answer or decline.
virtual LLVoiceP2PIncomingCallInterfacePtr getIncomingCallInterface(const LLSD &voice_call_info) = 0;
//@}
/////////////////////////
/// @name Volume/gain
//@{
virtual void setVoiceVolume(F32 volume)=0;
virtual void setMicGain(F32 volume)=0;
//@}
/////////////////////////
/// @name enable disable voice and features
//@{
virtual void setVoiceEnabled(bool enabled)=0;
virtual void setMuteMic(bool muted)=0; // Set the mute state of the local mic.
//@}
//////////////////////////
/// @name nearby speaker accessors
//@{
virtual BOOL getVoiceEnabled(const LLUUID& id)=0; // true if we've received data for this avatar
virtual std::string getDisplayName(const LLUUID& id)=0;
virtual BOOL isParticipantAvatar(const LLUUID &id)=0;
virtual BOOL getIsSpeaking(const LLUUID& id)=0;
virtual BOOL getIsModeratorMuted(const LLUUID& id)=0;
virtual F32 getCurrentPower(const LLUUID& id)=0; // "power" is related to "amplitude" in a defined way. I'm just not sure what the formula is...
virtual BOOL getOnMuteList(const LLUUID& id)=0;
virtual F32 getUserVolume(const LLUUID& id)=0;
virtual void setUserVolume(const LLUUID& id, F32 volume)=0; // set's volume for specified agent, from 0-1 (where .5 is nominal)
virtual void setUserVolume(const LLUUID& id, F32 volume)=0; // set's volume for specified agent, from 0-1 (where .5 is nominal)
//@}
//////////////////////////
/// @name text chat
//@{
@ -267,25 +265,25 @@ public:
virtual BOOL isSessionCallBackPossible(const LLUUID& id)=0;
//virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message)=0;
//@}
// authorize the user
virtual void userAuthorized(const std::string& user_id,
const LLUUID &agentID)=0;
//////////////////////////////
/// @name Status notification
//@{
virtual void addObserver(LLVoiceClientStatusObserver* observer)=0;
virtual void removeObserver(LLVoiceClientStatusObserver* observer)=0;
virtual void addObserver(LLFriendObserver* observer)=0;
virtual void removeObserver(LLFriendObserver* observer)=0;
virtual void removeObserver(LLFriendObserver* observer)=0;
virtual void addObserver(LLVoiceClientParticipantObserver* observer)=0;
virtual void removeObserver(LLVoiceClientParticipantObserver* observer)=0;
virtual void removeObserver(LLVoiceClientParticipantObserver* observer)=0;
//@}
virtual std::string sipURIFromID(const LLUUID &id)=0;
//@}
};
@ -357,9 +355,9 @@ public:
micro_changed_signal_t mMicroChangedSignal;
void terminate(); // Call this to clean up during shutdown
const LLVoiceVersionInfo getVersion();
static const F32 OVERDRIVEN_POWER_LEVEL;
static const F32 VOLUME_MIN;
@ -374,18 +372,18 @@ public:
void tuningStart();
void tuningStop();
bool inTuningMode();
void tuningSetMicVolume(float volume);
void tuningSetSpeakerVolume(float volume);
float tuningGetEnergy(void);
// devices
// This returns true when it's safe to bring up the "device settings" dialog in the prefs.
// i.e. when the daemon is running and connected, and the device lists are populated.
bool deviceSettingsAvailable();
bool deviceSettingsUpdated(); // returns true when the device list has been updated recently.
// Requery the vivox daemon for the current list of input/output devices.
// If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed
// (use this if you want to know when it's done).
@ -402,7 +400,7 @@ public:
////////////////////////////
// Channel stuff
//
// returns true iff the user is currently in a proximal (local spatial) channel.
// Note that gestures should only fire if this returns true.
bool inProximalChannel();
@ -426,35 +424,35 @@ public:
LLVoiceP2POutgoingCallInterface* getOutgoingCallInterface(const LLSD& voiceChannelInfo);
LLVoiceP2PIncomingCallInterfacePtr getIncomingCallInterface(const LLSD &voiceCallInfo);
/////////////////////////////
// Sending updates of current state
void setVoiceVolume(F32 volume);
void setMicGain(F32 volume);
void setUserVolume(const LLUUID& id, F32 volume); // set's volume for specified agent, from 0-1 (where .5 is nominal)
void setUserVolume(const LLUUID& id, F32 volume); // set's volume for specified agent, from 0-1 (where .5 is nominal)
bool voiceEnabled();
void setMuteMic(bool muted); // Use this to mute the local mic (for when the client is minimized, etc), ignoring user PTT state.
void setUserPTTState(bool ptt);
bool getUserPTTState();
void toggleUserPTTState(void);
void inputUserControlState(bool down); // interpret any sort of up-down mic-open control input according to ptt-toggle prefs
void inputUserControlState(bool down); // interpret any sort of up-down mic-open control input according to ptt-toggle prefs
void setVoiceEnabled(bool enabled);
void setUsePTT(bool usePTT);
void setPTTIsToggle(bool PTTIsToggle);
bool getPTTIsToggle();
bool getPTTIsToggle();
void updateMicMuteLogic();
boost::signals2::connection MicroChangedCallback(const micro_changed_signal_t::slot_type& cb ) { return mMicroChangedSignal.connect(cb); }
/////////////////////////////
// Accessors for data related to nearby speakers
BOOL getVoiceEnabled(const LLUUID& id); // true if we've received data for this avatar
std::string getDisplayName(const LLUUID& id);
std::string getDisplayName(const LLUUID& id);
BOOL isOnlineSIP(const LLUUID &id);
BOOL isParticipantAvatar(const LLUUID &id);
BOOL getIsSpeaking(const LLUUID& id);
@ -466,7 +464,7 @@ public:
/////////////////////////////
void getParticipantList(std::set<LLUUID> &participants);
bool isParticipant(const LLUUID& speaker_id);
//////////////////////////
/// @name text chat
//@{
@ -474,7 +472,7 @@ public:
BOOL isSessionCallBackPossible(const LLUUID& id);
//BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message) const {return true;} ;
//@}
void setSpatialVoiceModule(const std::string& voice_server_type);
void setNonSpatialVoiceModule(const std::string &voice_server_type);
@ -483,15 +481,15 @@ public:
void onRegionChanged();
void onSimulatorFeaturesReceived(const LLUUID &region_id);
void addObserver(LLVoiceClientStatusObserver* observer);
void removeObserver(LLVoiceClientStatusObserver* observer);
void addObserver(LLFriendObserver* observer);
void removeObserver(LLFriendObserver* observer);
void addObserver(LLVoiceClientParticipantObserver* observer);
void removeObserver(LLVoiceClientParticipantObserver* observer);
std::string sipURIFromID(const LLUUID &id);
std::string sipURIFromID(const LLUUID &id);
//////////////////////////
/// @name Voice effects
@ -517,7 +515,7 @@ protected:
bool mPTTDirty;
bool mPTT;
bool mUsePTT;
S32 mPTTMouseButton;
KEY mPTTKey;

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,25 @@
/**
/**
* @file llvoicevivox.h
* @brief Declaration of LLDiamondwareVoiceClient class which is the interface to the voice client process.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@ -81,12 +81,12 @@ public:
//@{
void init(LLPumpIO *pump) override; // Call this once at application startup (creates connector)
void terminate() override; // Call this to clean up during shutdown
const LLVoiceVersionInfo& getVersion() override;
void updateSettings() override; // call after loading settings and whenever they change
// Returns true if vivox has successfully logged in and is not in error state
// Returns true if vivox has successfully logged in and is not in error state
bool isVoiceWorking() const override;
/////////////////////
@ -95,12 +95,12 @@ public:
void tuningStart() override;
void tuningStop() override;
bool inTuningMode() override;
void tuningSetMicVolume(float volume) override;
void tuningSetSpeakerVolume(float volume) override;
float tuningGetEnergy(void) override;
//@}
/////////////////////
/// @name Devices
//@{
@ -108,20 +108,20 @@ public:
// i.e. when the daemon is running and connected, and the device lists are populated.
bool deviceSettingsAvailable() override;
bool deviceSettingsUpdated() override; //return if the list has been updated and never fetched, only to be called from the voicepanel.
// Requery the vivox daemon for the current list of input/output devices.
// If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed
// (use this if you want to know when it's done).
// If you pass false, you'll have no way to know when the query finishes, but the device lists will not appear empty in the interim.
void refreshDeviceLists(bool clearCurrentList = true) override;
void setCaptureDevice(const std::string& name) override;
void setRenderDevice(const std::string& name) override;
LLVoiceDeviceList& getCaptureDevices() override;
LLVoiceDeviceList& getRenderDevices() override;
//@}
void getParticipantList(std::set<LLUUID> &participants) override;
bool isParticipant(const LLUUID& speaker_id) override;
@ -129,41 +129,41 @@ public:
// virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message) const {return false;};
// Returns true if calling back the session URI after the session has closed is possible.
// Currently this will be false only for PSTN P2P calls.
// NOTE: this will return true if the session can't be found.
// Currently this will be false only for PSTN P2P calls.
// NOTE: this will return true if the session can't be found.
BOOL isSessionCallBackPossible(const LLUUID &session_id) override;
// Returns true if the session can accepte text IM's.
// Currently this will be false only for PSTN P2P calls.
// NOTE: this will return true if the session can't be found.
// NOTE: this will return true if the session can't be found.
BOOL isSessionTextIMPossible(const LLUUID &session_id) override;
////////////////////////////
/// @name Channel stuff
//@{
// returns true iff the user is currently in a proximal (local spatial) channel.
// Note that gestures should only fire if this returns true.
bool inProximalChannel() override;
void setNonSpatialChannel(const LLSD& channelInfo,
bool notify_on_first_join,
bool hangup_on_last_leave) override;
bool setSpatialChannel(const LLSD& channelInfo) override;
void leaveNonSpatialChannel() override;
void processChannels(bool process) override;
void leaveChannel(void);
bool isCurrentChannel(const LLSD &channelInfo) override;
bool compareChannels(const LLSD &channelInfo1, const LLSD &channelInfo2) override;
//@}
//////////////////////////
/// @name LLVoiceP2POutgoingCallInterface
//@{
@ -178,39 +178,37 @@ public:
bool answerInvite(const std::string &sessionHandle);
void declineInvite(const std::string &sessionHandle);
/////////////////////////
/// @name Volume/gain
//@{
void setVoiceVolume(F32 volume) override;
void setMicGain(F32 volume) override;
//@}
/////////////////////////
/// @name enable disable voice and features
//@{
void setVoiceEnabled(bool enabled) override;
void setMuteMic(bool muted) override; // Set the mute state of the local mic.
//@}
//////////////////////////
/// @name nearby speaker accessors
//@{
BOOL getVoiceEnabled(const LLUUID& id) override; // true if we've received data for this avatar
std::string getDisplayName(const LLUUID& id) override;
BOOL isParticipantAvatar(const LLUUID &id) override;
BOOL getIsSpeaking(const LLUUID& id) override;
BOOL getIsModeratorMuted(const LLUUID& id) override;
F32 getCurrentPower(const LLUUID& id) override; // "power" is related to "amplitude" in a defined way. I'm just not sure what the formula is...
BOOL getOnMuteList(const LLUUID& id) override;
F32 getUserVolume(const LLUUID& id) override;
void setUserVolume(const LLUUID& id, F32 volume) override; // set's volume for specified agent, from 0-1 (where .5 is nominal)
//@}
// authorize the user
virtual void userAuthorized(const std::string& user_id,
const LLUUID &agentID) override;
//////////////////////////////
/// @name Status notification
//@{
@ -221,7 +219,7 @@ public:
void addObserver(LLVoiceClientParticipantObserver* observer) override;
void removeObserver(LLVoiceClientParticipantObserver* observer) override;
//@}
std::string sipURIFromID(const LLUUID &id) override;
//@}
@ -267,12 +265,12 @@ public:
protected:
//////////////////////
// Vivox Specific definitions
friend class LLVivoxVoiceClientMuteListObserver;
friend class LLVivoxVoiceClientFriendsObserver;
// Vivox Specific definitions
friend class LLVivoxVoiceClientMuteListObserver;
friend class LLVivoxVoiceClientFriendsObserver;
enum streamState
{
streamStateUnknown = 0,
@ -281,16 +279,16 @@ protected:
streamStateRinging = 3,
streamStateConnecting = 6, // same as Vivox session_media_connecting enum
streamStateDisconnecting = 7, //Same as Vivox session_media_disconnecting enum
};
};
struct participantState
{
public:
participantState(const std::string &uri);
bool updateMuteState(); // true if mute state has changed
bool isAvatar();
std::string mURI;
LLUUID mAvatarID;
std::string mAccountName;
@ -315,7 +313,7 @@ protected:
typedef std::map<const std::string, participantStatePtr_t> participantMap;
typedef std::map<const LLUUID, participantStatePtr_t> participantUUIDMap;
struct sessionState
{
public:
@ -328,7 +326,7 @@ protected:
~sessionState();
LLSD getVoiceChannelInfo();
participantStatePtr_t addParticipant(const std::string &uri);
void removeParticipant(const participantStatePtr_t &participant);
void removeAllParticipants();
@ -344,7 +342,7 @@ protected:
bool isCallBackPossible();
bool isTextIMPossible();
bool isSpatial() { return mIsSpatial; }
static void for_each(sessionFunc_t func);
std::string mHandle;
@ -356,7 +354,7 @@ protected:
std::string mHash; // Channel password
std::string mErrorStatusString;
std::queue<std::string> mTextMsgQueue;
LLUUID mIMSessionID;
LLUUID mCallerID;
int mErrorStatusCode;
@ -403,7 +401,7 @@ protected:
typedef boost::shared_ptr<sessionState> sessionStatePtr_t;
typedef std::map<std::string, sessionStatePtr_t> sessionMap;
///////////////////////////////////////////////////////
// Private Member Functions
//////////////////////////////////////////////////////
@ -415,17 +413,17 @@ protected:
//@{
// Call this if the connection to the daemon terminates unexpectedly. It will attempt to reset everything and relaunch.
void daemonDied();
// Call this if we're just giving up on voice (can't provision an account, etc.). It will clean up and go away.
void giveUp();
void giveUp();
// write to the tvc
bool writeString(const std::string &str);
void connectorCreate();
void connectorShutdown();
void closeSocket(void);
void connectorShutdown();
void closeSocket(void);
// void requestVoiceAccountProvision(S32 retries = 3);
void setLoginInfo(
const std::string& account_name,
@ -434,14 +432,14 @@ protected:
const std::string& voice_account_server_uri);
void loginSendMessage();
void logout();
void logoutSendMessage();
void logoutSendMessage();
//@}
//------------------------------------
// tuning
void tuningRenderStartSendMessage(const std::string& name, bool loop);
void tuningRenderStopSendMessage();
@ -454,12 +452,12 @@ protected:
void addCaptureDevice(const LLVoiceDevice& device);
void clearRenderDevices();
void setDevicesListUpdated(bool state);
void addRenderDevice(const LLVoiceDevice& device);
void addRenderDevice(const LLVoiceDevice& device);
void buildSetAudioDevices(std::ostringstream &stream);
void getCaptureDevicesSendMessage();
void getRenderDevicesSendMessage();
// local audio updates, mic mute, speaker mute, mic volume and speaker volumes
void sendLocalAudioUpdates();
@ -486,9 +484,9 @@ protected:
void auxAudioPropertiesEvent(F32 energy);
void messageEvent(std::string &sessionHandle, std::string &uriString, std::string &alias, std::string &messageHeader, std::string &messageBody, std::string &applicationString);
void sessionNotificationEvent(std::string &sessionHandle, std::string &uriString, std::string &notificationType);
void muteListChanged();
/////////////////////////////
// VAD changes
// disable auto-VAD and configure VAD parameters explicitly
@ -504,34 +502,34 @@ protected:
void setEarLocation(S32 loc);
/////////////////////////////
// Accessors for data related to nearby speakers
// MBW -- XXX -- Not sure how to get this data out of the TVC
BOOL getUsingPTT(const LLUUID& id);
std::string getGroupID(const LLUUID& id); // group ID if the user is in group chat (empty string if not applicable)
/////////////////////////////
// Recording controls
void recordingLoopStart(int seconds = 3600, int deltaFramesPerControlFrame = 200);
void recordingLoopSave(const std::string& filename);
void recordingStop();
// Playback controls
void filePlaybackStart(const std::string& filename);
void filePlaybackStop();
void filePlaybackSetPaused(bool paused);
void filePlaybackSetMode(bool vox = false, float speed = 1.0f);
participantStatePtr_t findParticipantByID(const LLUUID& id);
#if 0
////////////////////////////////////////
// voice sessions.
typedef std::set<sessionStatePtr_t> sessionSet;
typedef sessionSet::iterator sessionIterator;
sessionIterator sessionsBegin(void);
sessionIterator sessionsEnd(void);
@ -540,7 +538,7 @@ protected:
sessionStatePtr_t findSession(const std::string &handle);
sessionStatePtr_t findSessionBeingCreatedByURI(const std::string &uri);
sessionStatePtr_t findSession(const LLUUID &participant_id);
sessionStatePtr_t addSession(const std::string &uri, const std::string &handle = std::string());
void clearSessionHandle(const sessionStatePtr_t &session);
void setSessionHandle(const sessionStatePtr_t &session, const std::string &handle);
@ -556,11 +554,11 @@ protected:
// This is called in several places where the session _may_ need to be deleted.
// It contains logic for whether to delete the session or keep it around.
void reapSession(const sessionStatePtr_t &session);
// Returns true if the session seems to indicate we've moved to a region on a different voice server
bool sessionNeedsRelog(const sessionStatePtr_t &session);
//////////////////////////////////////
// buddy list stuff, needed for SLIM later
struct buddyListEntry
@ -580,13 +578,13 @@ protected:
};
typedef std::map<std::string, buddyListEntry*> buddyListMap;
/////////////////////////////
// session control messages
void accountListBlockRulesSendMessage();
void accountListAutoAcceptRulesSendMessage();
void sessionGroupCreateSendMessage();
void sessionCreateSendMessage(const sessionStatePtr_t &session, bool startAudio = true, bool startText = false);
void sessionGroupAddSessionSendMessage(const sessionStatePtr_t &session, bool startAudio = true, bool startText = false);
@ -597,20 +595,20 @@ protected:
void sessionMediaDisconnectSendMessage(const sessionStatePtr_t &session);
// void sessionTextDisconnectSendMessage(sessionState *session);
// Pokes the state machine to leave the audio session next time around.
void sessionTerminate();
void sessionTerminate();
// Pokes the state machine to shut down the connector and restart it.
void requestRelog();
// Does the actual work to get out of the audio session
void leaveAudioSession();
friend class LLVivoxVoiceClientCapResponder;
void lookupName(const LLUUID &id);
void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name);
void avatarNameResolved(const LLUUID &id, const std::string &name);
@ -630,10 +628,10 @@ protected:
const S32 font_status,
const bool template_font = false);
void accountGetSessionFontsResponse(int statusCode, const std::string &statusString);
void accountGetTemplateFontsResponse(int statusCode, const std::string &statusString);
void accountGetTemplateFontsResponse(int statusCode, const std::string &statusString);
private:
LLVoiceVersionInfo mVoiceVersion;
// Coroutine support methods
@ -675,21 +673,21 @@ private:
// The larger it is the greater is possibility there is a problem with connection to voice server.
// Introduced while fixing EXT-4313.
int mSpatialJoiningNum;
static void idle(void *user_data);
LLHost mDaemonHost;
LLSocket::ptr_t mSocket;
// We should kill the voice daemon in case of connection alert
// We should kill the voice daemon in case of connection alert
bool mTerminateDaemon;
friend class LLVivoxProtocolParser;
std::string mAccountName;
std::string mAccountPassword;
std::string mAccountDisplayName;
bool mTuningMode;
float mTuningEnergy;
std::string mTuningAudioFile;
@ -699,13 +697,13 @@ private:
bool mTuningSpeakerVolumeDirty;
bool mDevicesListUpdated; // set to true when the device list has been updated
// and false when the panelvoicedevicesettings has queried for an update status.
std::string mSpatialSessionURI;
std::string mSpatialSessionCredentials;
std::string mMainSessionGroupHandle; // handle of the "main" session group.
std::string mChannelName; // Name of the channel to be looked up
std::string mChannelName; // Name of the channel to be looked up
sessionStatePtr_t mAudioSession; // Session state for the current audio session
bool mAudioSessionChanged; // set to true when the above pointer gets changed, so observers can be notified.
@ -713,27 +711,27 @@ private:
S32 mCurrentParcelLocalID; // Used to detect parcel boundary crossings
std::string mCurrentRegionName; // Used to detect parcel boundary crossings
bool mConnectorEstablished; // set by "Create Connector" response
bool mAccountLoggedIn; // set by login message
bool mAccountLoggedIn; // set by login message
int mNumberOfAliases;
U32 mCommandCookie;
std::string mVoiceAccountServerURI;
std::string mVoiceSIPURIHostName;
int mLoginRetryCount;
sessionMap mSessionsByHandle; // Active sessions, indexed by session handle. Sessions which are being initiated may not be in this map.
#if 0
sessionSet mSessions; // All sessions, not indexed. This is the canonical session list.
#endif
bool mBuddyListMapPopulated;
bool mBlockRulesListReceived;
bool mAutoAcceptRulesListReceived;
buddyListMap mBuddyListMap;
LLVoiceDeviceList mCaptureDevices;
LLVoiceDeviceList mRenderDevices;
@ -744,30 +742,30 @@ private:
bool mIsInitialized;
bool mShutdownComplete;
bool checkParcelChanged(bool update = false);
bool switchChannel(std::string uri = std::string(), bool spatial = true, bool no_reconnect = false, bool is_p2p = false, std::string hash = "");
void joinSession(const sessionStatePtr_t &session);
std::string nameFromID(const LLUUID &id);
bool IDFromName(const std::string name, LLUUID &uuid);
std::string sipURIFromAvatar(LLVOAvatar *avatar);
std::string sipURIFromName(std::string &name);
// Returns the name portion of the SIP URI if the string looks vaguely like a SIP URI, or an empty string if not.
std::string nameFromsipURI(const std::string &uri);
std::string nameFromsipURI(const std::string &uri);
bool inSpatialChannel(void);
LLSD getAudioSessionChannelInfo();
std::string getAudioSessionHandle();
void setHidden(bool hidden) override; //virtual
void sendPositionAndVolumeUpdate(void);
void sendCaptureAndRenderDevices();
void buildSetCaptureDevice(std::ostringstream &stream);
void buildSetRenderDevice(std::ostringstream &stream);
void sendFriendsListUpdates();
@ -778,9 +776,9 @@ private:
#endif
void enforceTether(void);
bool mSpatialCoordsDirty;
LLVector3d mCameraPosition;
LLVector3d mCameraRequestedPosition;
LLVector3 mCameraVelocity;
@ -789,30 +787,30 @@ private:
LLVector3d mAvatarPosition;
LLVector3 mAvatarVelocity;
LLQuaternion mAvatarRot;
bool mMuteMic;
bool mMuteMicDirty;
bool mHidden; //Set to true during teleport to hide the agent's position.
// Set to true when the friends list is known to have changed.
bool mFriendsListDirty;
enum
{
earLocCamera = 0, // ear at camera
earLocAvatar, // ear at avatar
earLocMixed // ear at avatar location/camera direction
};
S32 mEarLocation;
S32 mEarLocation;
bool mSpeakerVolumeDirty;
bool mSpeakerMuteDirty;
int mSpeakerVolume;
int mMicVolume;
bool mMicVolumeDirty;
bool mVoiceEnabled;
bool mProcessChannels;
bool mWriteInProgress;
@ -826,7 +824,7 @@ private:
typedef std::set<LLVoiceClientStatusObserver*> status_observer_set_t;
status_observer_set_t mStatusObservers;
void notifyStatusObservers(LLVoiceClientStatusObserver::EStatusType status);
typedef std::set<LLFriendObserver*> friend_observer_set_t;
@ -933,7 +931,7 @@ private:
};
/**
/**
* @class LLVivoxProtocolParser
* @brief This class helps construct new LLIOPipe specializations
* @see LLIOPipe
@ -946,12 +944,12 @@ class LLVivoxProtocolParser : public LLIOPipe
public:
LLVivoxProtocolParser();
virtual ~LLVivoxProtocolParser();
protected:
/* @name LLIOPipe virtual implementations
*/
//@{
/**
/**
* @brief Process the data in buffer
*/
virtual EStatus process_impl(
@ -961,16 +959,16 @@ protected:
LLSD& context,
LLPumpIO* pump);
//@}
std::string mInput;
// Expat control members
XML_Parser parser;
int responseDepth;
bool ignoringTags;
bool isEvent;
int ignoreDepth;
// Members for processing responses. The values are transient and only valid within a call to processResponse().
int returnCode;
int statusCode;
@ -985,7 +983,7 @@ protected:
std::string sessionGroupHandle;
std::string alias;
std::string applicationString;
// Members for processing events. The values are transient and only valid within a call to processResponse().
std::string eventTypeString;
int state;
@ -1024,19 +1022,19 @@ protected:
S32 fontType;
S32 fontStatus;
std::string mediaCompletionType;
// Members for processing text between tags
std::string textBuffer;
bool accumulateText;
void reset();
void processResponse(std::string tag);
static void XMLCALL ExpatStartTag(void *data, const char *el, const char **attr);
static void XMLCALL ExpatEndTag(void *data, const char *el);
static void XMLCALL ExpatCharHandler(void *data, const XML_Char *s, int len);
void StartTag(const char *tag, const char **attr);
void EndTag(const char *tag);
void CharData(const char *buffer, int length);
@ -1063,7 +1061,7 @@ class LLVoiceVivoxStats : public LLSingleton<LLVoiceVivoxStats>
LLSINGLETON(LLVoiceVivoxStats);
LOG_CLASS(LLVoiceVivoxStats);
virtual ~LLVoiceVivoxStats();
private:
F64SecondsImplicit mStartTime;
@ -1071,7 +1069,7 @@ class LLVoiceVivoxStats : public LLSingleton<LLVoiceVivoxStats>
F64 mConnectTime;
U32 mConnectAttempts;
F64 mProvisionTime;
U32 mProvisionAttempts;

View File

@ -1,25 +1,25 @@
/**
/**
* @file LLWebRTCVoiceClient.cpp
* @brief Implementation of LLWebRTCVoiceClient class which is the interface to the voice client process.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2023, Linden Research, Inc.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License only.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@ -92,7 +92,7 @@ namespace {
// Don't send positional updates more frequently than this:
const F32 UPDATE_THROTTLE_SECONDS = 0.1f;
// Cosine of a "trivially" small angle
const F32 FOUR_DEGREES = 4.0f * (F_PI / 180.0f);
const F32 MINUSCULE_ANGLE_COS = (F32) cos(0.5f * FOUR_DEGREES);
@ -302,12 +302,12 @@ void LLWebRTCVoiceClient::updateSettings()
// Observers
void LLWebRTCVoiceClient::addObserver(LLVoiceClientParticipantObserver *observer)
{
{
mParticipantObservers.insert(observer);
}
void LLWebRTCVoiceClient::removeObserver(LLVoiceClientParticipantObserver *observer)
{
{
mParticipantObservers.erase(observer);
}
@ -323,12 +323,12 @@ void LLWebRTCVoiceClient::notifyParticipantObservers()
}
void LLWebRTCVoiceClient::addObserver(LLVoiceClientStatusObserver *observer)
{
{
mStatusObservers.insert(observer);
}
void LLWebRTCVoiceClient::removeObserver(LLVoiceClientStatusObserver *observer)
{
{
mStatusObservers.erase(observer);
}
@ -352,7 +352,7 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt
}
// skipped to avoid speak button blinking
if (status != LLVoiceClientStatusObserver::STATUS_JOINING &&
if (status != LLVoiceClientStatusObserver::STATUS_JOINING &&
status != LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL &&
status != LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED)
{
@ -368,11 +368,11 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt
}
void LLWebRTCVoiceClient::addObserver(LLFriendObserver *observer)
{
{
}
void LLWebRTCVoiceClient::removeObserver(LLFriendObserver *observer)
{
{
}
//---------------------------------------------------
@ -381,12 +381,12 @@ void LLWebRTCVoiceClient::removeObserver(LLFriendObserver *observer)
// takes to process the various functions called in the loop
// The loop does the following:
// * gates whether we do channel processing depending on
// whether we're running a WebRTC voice channel or
// whether we're running a WebRTC voice channel or
// one from another voice provider.
// * If in spatial voice, it determines whether we've changed
// parcels, whether region/parcel voice settings have changed,
// etc. and manages whether the voice channel needs to change.
// * calls the state machines for the sessions to negotiate
// * calls the state machines for the sessions to negotiate
// connection to various voice channels.
// * Sends updates to the voice server when this agent's
// voice levels, or positions have changed.
@ -485,7 +485,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro()
updatePosition();
}
}
sessionState::processSessionStates();
if (mProcessChannels && voiceEnabled)
{
@ -629,7 +629,7 @@ void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceLi
}
void LLWebRTCVoiceClient::clearRenderDevices()
{
{
LL_DEBUGS("Voice") << "called" << LL_ENDL;
mRenderDevices.clear();
}
@ -661,7 +661,7 @@ void LLWebRTCVoiceClient::tuningStart()
}
void LLWebRTCVoiceClient::tuningStop()
{
{
if (mIsInTuningMode)
{
mWebRTCDeviceInterface->setTuningMode(false);
@ -680,7 +680,7 @@ void LLWebRTCVoiceClient::tuningSetMicVolume(float volume)
}
void LLWebRTCVoiceClient::tuningSetSpeakerVolume(float volume)
{
{
if (volume != mTuningSpeakerVolume)
{
@ -708,17 +708,17 @@ float LLWebRTCVoiceClient::tuningGetEnergy(void)
bool LLWebRTCVoiceClient::deviceSettingsAvailable()
{
bool result = true;
if(mRenderDevices.empty() || mCaptureDevices.empty())
result = false;
return result;
}
bool LLWebRTCVoiceClient::deviceSettingsUpdated()
{
bool updated = mDevicesListUpdated;
mDevicesListUpdated = false;
return updated;
return updated;
}
void LLWebRTCVoiceClient::refreshDeviceLists(bool clearCurrentList)
@ -758,7 +758,7 @@ void LLWebRTCVoiceClient::setHidden(bool hidden)
// status for a given channel. By filtering
// on channel and region, these functions
// can send various notifications to
// other parts of the viewer, as well as
// other parts of the viewer, as well as
// managing housekeeping
// A connection to a channel was successfully established,
@ -997,14 +997,14 @@ void LLWebRTCVoiceClient::sendPositionUpdate(bool force)
// Update our own volume on our participant, so it'll show up
// in the UI. This is done on all sessions, so switching
// sessions retains consistent volume levels.
void LLWebRTCVoiceClient::updateOwnVolume() {
void LLWebRTCVoiceClient::updateOwnVolume() {
F32 audio_level = 0.0;
if (!mMuteMic && !mTuningMode)
{
audio_level = getAudioLevel();
}
sessionState::for_each(boost::bind(predUpdateOwnVolume, _1, audio_level));
sessionState::for_each(boost::bind(predUpdateOwnVolume, _1, audio_level));
}
////////////////////////////////////
@ -1020,9 +1020,9 @@ BOOL LLWebRTCVoiceClient::isParticipantAvatar(const LLUUID &id)
void LLWebRTCVoiceClient::getParticipantList(std::set<LLUUID> &participants)
{
if (mSession)
if (mProcessChannels && mSession)
{
for (participantUUIDMap::iterator iter = mSession->mParticipantsByUUID.begin();
for (participantUUIDMap::iterator iter = mSession->mParticipantsByUUID.begin();
iter != mSession->mParticipantsByUUID.end();
iter++)
{
@ -1033,7 +1033,7 @@ void LLWebRTCVoiceClient::getParticipantList(std::set<LLUUID> &participants)
bool LLWebRTCVoiceClient::isParticipant(const LLUUID &speaker_id)
{
if (mSession)
if (mProcessChannels && mSession)
{
return (mSession->mParticipantsByUUID.find(speaker_id) != mSession->mParticipantsByUUID.end());
}
@ -1089,28 +1089,27 @@ void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, co
// participantState level participant management
LLWebRTCVoiceClient::participantState::participantState(const LLUUID& agent_id) :
LLWebRTCVoiceClient::participantState::participantState(const LLUUID& agent_id) :
mURI(agent_id.asString()),
mAvatarID(agent_id),
mIsSpeaking(false),
mIsModeratorMuted(false),
mLevel(0.f),
mVolume(LLVoiceClient::VOLUME_DEFAULT),
mOnMuteList(false)
mIsSpeaking(false),
mIsModeratorMuted(false),
mLevel(0.f),
mVolume(LLVoiceClient::VOLUME_DEFAULT)
{
}
LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::addParticipant(const LLUUID& agent_id)
{
participantStatePtr_t result;
participantUUIDMap::iterator iter = mParticipantsByUUID.find(agent_id);
if (iter != mParticipantsByUUID.end())
{
result = iter->second;
}
if(!result)
{
// participant isn't already in one list or the other.
@ -1119,31 +1118,16 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::ad
result->mAvatarID = agent_id;
LLWebRTCVoiceClient::getInstance()->lookupName(agent_id);
result->updateMuteState();
LLSpeakerVolumeStorage::getInstance()->getSpeakerVolume(result->mAvatarID, result->mVolume);
if (!LLWebRTCVoiceClient::sShuttingDown)
{
LLWebRTCVoiceClient::getInstance()->notifyParticipantObservers();
}
LL_DEBUGS("Voice") << "Participant \"" << result->mURI << "\" added." << LL_ENDL;
}
return result;
}
bool LLWebRTCVoiceClient::participantState::updateMuteState()
{
bool result = false;
bool isMuted = LLMuteList::getInstance()->isMuted(mAvatarID, LLMute::flagVoiceChat);
if(mOnMuteList != isMuted)
{
mOnMuteList = isMuted;
result = true;
}
return result;
}
@ -1218,7 +1202,7 @@ bool LLWebRTCVoiceClient::startAdHocSession(const LLSD& channelInfo, bool notify
std::string channelID = channelInfo["channel_uri"];
std::string credentials = channelInfo["channel_credentials"];
mNextSession = addSession(channelID,
sessionState::ptr_t(new adhocSessionState(channelID,
sessionState::ptr_t(new adhocSessionState(channelID,
credentials,
notify_on_first_join,
hangup_on_last_leave)));
@ -1231,7 +1215,7 @@ bool LLWebRTCVoiceClient::isVoiceWorking() const
}
// Returns true if calling back the session URI after the session has closed is possible.
// Currently this will be false only for PSTN P2P calls.
// Currently this will be false only for PSTN P2P calls.
BOOL LLWebRTCVoiceClient::isSessionCallBackPossible(const LLUUID &session_id)
{
sessionStatePtr_t session(findP2PSession(session_id));
@ -1245,14 +1229,14 @@ void LLWebRTCVoiceClient::leaveNonSpatialChannel()
// make sure we're not simply rejoining the current session
deleteSession(mNextSession);
leaveChannel(true);
}
// determine whether we're processing channels, or whether
// another voice provider is.
void LLWebRTCVoiceClient::processChannels(bool process)
{
{
mProcessChannels = process;
}
@ -1274,8 +1258,8 @@ bool LLWebRTCVoiceClient::inEstateChannel()
bool LLWebRTCVoiceClient::inSpatialChannel()
{
bool result = true;
if (mNextSession)
if (mNextSession)
{
result = mNextSession->isSpatial();
}
@ -1283,7 +1267,7 @@ bool LLWebRTCVoiceClient::inSpatialChannel()
{
result = mSession->isSpatial();
}
return result;
}
@ -1323,8 +1307,11 @@ void LLWebRTCVoiceClient::leaveChannel(bool stopTalking)
bool LLWebRTCVoiceClient::isCurrentChannel(const LLSD &channelInfo)
{
if (channelInfo["voice_server_type"].asString() != WEBRTC_VOICE_SERVER_TYPE)
if (!mProcessChannels || (channelInfo["voice_server_type"].asString() != WEBRTC_VOICE_SERVER_TYPE))
{
return false;
}
if (mSession)
{
if (!channelInfo["sessionHandle"].asString().empty())
@ -1339,7 +1326,7 @@ bool LLWebRTCVoiceClient::isCurrentChannel(const LLSD &channelInfo)
bool LLWebRTCVoiceClient::compareChannels(const LLSD &channelInfo1, const LLSD &channelInfo2)
{
return (channelInfo1["voice_server_type"] == WEBRTC_VOICE_SERVER_TYPE) &&
(channelInfo1["voice_server_type"] == channelInfo2["voice_server_type"]) &&
(channelInfo1["voice_server_type"] == channelInfo2["voice_server_type"]) &&
(channelInfo1["sip_uri"] == channelInfo2["sip_uri"]);
}
@ -1401,14 +1388,14 @@ void LLWebRTCVoiceClient::setVoiceEnabled(bool enabled)
<< " was "<< (mVoiceEnabled ? "enabled" : "disabled")
<< " coro "<< (mIsCoroutineActive ? "active" : "inactive")
<< LL_ENDL;
if (enabled != mVoiceEnabled)
{
// TODO: Refactor this so we don't call into LLVoiceChannel, but simply
// use the status observer
mVoiceEnabled = enabled;
LLVoiceClientStatusObserver::EStatusType status;
if (enabled)
{
LL_DEBUGS("Voice") << "enabling" << LL_ENDL;
@ -1446,53 +1433,32 @@ void LLWebRTCVoiceClient::setVoiceEnabled(bool enabled)
/////////////////////////////
// Accessors for data related to nearby speakers
BOOL LLWebRTCVoiceClient::getVoiceEnabled(const LLUUID& id)
{
BOOL result = FALSE;
if (!mSession)
{
return FALSE;
}
participantStatePtr_t participant(mSession->findParticipantByID(id));
if(participant)
{
// I'm not sure what the semantics of this should be.
// For now, if we have any data about the user that came through the chat channel, assume they're voice-enabled.
result = TRUE;
}
return result;
}
std::string LLWebRTCVoiceClient::getDisplayName(const LLUUID& id)
{
std::string result;
if (!mSession)
if (mProcessChannels && mSession)
{
return result;
participantStatePtr_t participant(mSession->findParticipantByID(id));
if (participant)
{
result = participant->mDisplayName;
}
}
participantStatePtr_t participant(mSession->findParticipantByID(id));
if(participant)
{
result = participant->mDisplayName;
}
return result;
}
BOOL LLWebRTCVoiceClient::getIsSpeaking(const LLUUID& id)
{
BOOL result = FALSE;
if (!mSession)
if (mProcessChannels && mSession)
{
return result;
participantStatePtr_t participant(mSession->findParticipantByID(id));
if (participant)
{
result = participant->mIsSpeaking;
}
}
participantStatePtr_t participant(mSession->findParticipantByID(id));
if(participant)
{
result = participant->mIsSpeaking;
}
return result;
}
@ -1500,23 +1466,21 @@ BOOL LLWebRTCVoiceClient::getIsSpeaking(const LLUUID& id)
BOOL LLWebRTCVoiceClient::getIsModeratorMuted(const LLUUID& id)
{
BOOL result = FALSE;
if (!mSession)
if (mProcessChannels && mSession)
{
return result;
participantStatePtr_t participant(mSession->findParticipantByID(id));
if (participant)
{
result = participant->mIsModeratorMuted;
}
}
participantStatePtr_t participant(mSession->findParticipantByID(id));
if(participant)
{
result = participant->mIsModeratorMuted;
}
return result;
}
F32 LLWebRTCVoiceClient::getCurrentPower(const LLUUID &id)
{
F32 result = 0.0;
if (!mSession)
if (!mProcessChannels || !mSession)
{
return result;
}
@ -1531,25 +1495,12 @@ F32 LLWebRTCVoiceClient::getCurrentPower(const LLUUID &id)
return result;
}
BOOL LLWebRTCVoiceClient::getOnMuteList(const LLUUID& id)
{
BOOL result = FALSE;
participantStatePtr_t participant(mSession->findParticipantByID(id));
if(participant)
{
result = participant->mOnMuteList;
}
return result;
}
// External accessors.
F32 LLWebRTCVoiceClient::getUserVolume(const LLUUID& id)
{
// Minimum volume will be returned for users with voice disabled
F32 result = LLVoiceClient::VOLUME_MIN;
participantStatePtr_t participant(mSession->findParticipantByID(id));
if(participant)
{
@ -1619,7 +1570,7 @@ void LLWebRTCVoiceClient::predSetUserMute(const LLWebRTCVoiceClient::sessionStat
std::map<std::string, LLWebRTCVoiceClient::sessionState::ptr_t> LLWebRTCVoiceClient::sessionState::mSessions;
LLWebRTCVoiceClient::sessionState::sessionState() :
LLWebRTCVoiceClient::sessionState::sessionState() :
mHangupOnLastLeave(false),
mNotifyOnFirstJoin(false),
mMicGain(1.0),
@ -1803,7 +1754,7 @@ LLWebRTCVoiceClient::sessionStatePtr_t LLWebRTCVoiceClient::findP2PSession(const
{
return result;
}
result.reset();
return result;
}
@ -1943,12 +1894,17 @@ LLWebRTCVoiceClient::adhocSessionState::adhocSessionState(const std::string &cha
}
void LLWebRTCVoiceClient::predShutdownSession(const LLWebRTCVoiceClient::sessionStatePtr_t& session)
{
{
session->shutdownAllConnections();
}
void LLWebRTCVoiceClient::deleteSession(const sessionStatePtr_t &session)
{
if (!session)
{
return;
}
// At this point, the session should be unhooked from all lists and all state should be consistent.
session->shutdownAllConnections();
// If this is the current audio session, clean up the pointer which will soon be dangling.
@ -2004,7 +1960,7 @@ void LLWebRTCVoiceClient::avatarNameResolved(const LLUUID &id, const std::string
// Leftover from vivox PTSN
std::string LLWebRTCVoiceClient::sipURIFromID(const LLUUID& id)
{
{
return id.asString();
}
@ -2014,7 +1970,7 @@ std::string LLWebRTCVoiceClient::sipURIFromID(const LLUUID& id)
// These connections manage state transitions, negotiating webrtc connections,
// and other such things for a single connection to a Secondlife WebRTC server.
// Multiple of these connections may be active at once, in the case of
// cross-region voice, or when a new connection is being created before the old
// cross-region voice, or when a new connection is being created before the old
// has a chance to shut down.
LLVoiceWebRTCConnection::LLVoiceWebRTCConnection(const LLUUID &regionID, const std::string &channelID) :
mWebRTCAudioInterface(nullptr),
@ -2132,7 +2088,7 @@ void LLVoiceWebRTCConnection::onIceUpdateError(int retries, std::string url, LLS
// Ice candidates may be streamed in before or after the SDP offer is available (see below)
// This function determines whether candidates are available to send to the Secondlife WebRTC
// server via the simulator. If so, and there are no more candidates, this code
// will make the cap call to the server sending up the ICE candidates.
// will make the cap call to the server sending up the ICE candidates.
void LLVoiceWebRTCConnection::processIceUpdates()
{
if (mShutDown || LLWebRTCVoiceClient::isShuttingDown())
@ -2211,7 +2167,7 @@ void LLVoiceWebRTCConnection::processIceUpdates()
// to the type of session (audio, video) to characteristics (the encoder type.)
// This SDP also serves as the 'ticket' to the server, security-wise.
// The Offer is retrieved from the WebRTC library on the client,
// and is passed to the simulator via a CAP, which then passes
// and is passed to the simulator via a CAP, which then passes
// it on to the Secondlife WebRTC server.
void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
@ -2510,7 +2466,7 @@ void LLVoiceWebRTCConnection::OnVoiceConnectionRequestFailure(std::string url, i
}
// Primary state machine for negotiating a single voice connection to the
// Primary state machine for negotiating a single voice connection to the
// Secondlife WebRTC server.
bool LLVoiceWebRTCConnection::connectionStateMachine()
{
@ -2553,7 +2509,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
setVoiceConnectionState(VOICE_STATE_DISCONNECT);
break;
}
// Ask the sim to ask the Secondlife WebRTC server for a connection to
// Ask the sim to ask the Secondlife WebRTC server for a connection to
// a given voice channel. On completion, we'll move on to the
// VOICE_STATE_SESSION_ESTABLISHED via a callback on a webrtc thread.
if (!requestVoiceConnection())
@ -2708,7 +2664,7 @@ void LLVoiceWebRTCConnection::OnDataReceived(const std::string &data, bool binar
// that come from voice servers that aren't their primary
// voice server. This will happen with cross-region voice
// where a participant on a neighboring region may be
// connected to multiple servers. We don't want to
// connected to multiple servers. We don't want to
// add new identical participants from all of those servers.
if (voice_data[participant_id].isMember("j"))
{
@ -2751,7 +2707,7 @@ void LLVoiceWebRTCConnection::OnDataReceived(const std::string &data, bool binar
F32 level = (F32) (voice_data[participant_id].get("p", Json::Value(participant->mLevel)).asInt()) / 128;
// convert to decibles
participant->mLevel = level;
if (voice_data[participant_id].isMember("v"))
{
participant->mIsSpeaking = voice_data[participant_id].get("v", Json::Value(false)).asBool();
@ -2821,7 +2777,7 @@ LLVoiceWebRTCSpatialConnection::LLVoiceWebRTCSpatialConnection(const LLUUID &reg
{
}
LLVoiceWebRTCSpatialConnection::~LLVoiceWebRTCSpatialConnection()
LLVoiceWebRTCSpatialConnection::~LLVoiceWebRTCSpatialConnection()
{
if (LLWebRTCVoiceClient::isShuttingDown())
{

View File

@ -1,25 +1,25 @@
/**
/**
* @file llvoicewebrtc.h
* @brief Declaration of LLWebRTCVoiceClient class which is the interface to the voice client process.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2023, Linden Research, Inc.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@ -76,12 +76,12 @@ public:
void terminate() override; // Call this to clean up during shutdown
static bool isShuttingDown() { return sShuttingDown; }
const LLVoiceVersionInfo& getVersion() override;
void updateSettings() override; // call after loading settings and whenever they change
// Returns true if WebRTC has successfully logged in and is not in error state
// Returns true if WebRTC has successfully logged in and is not in error state
bool isVoiceWorking() const override;
std::string sipURIFromID(const LLUUID &id) override;
@ -92,32 +92,32 @@ public:
void tuningStart() override;
void tuningStop() override;
bool inTuningMode() override;
void tuningSetMicVolume(float volume) override;
void tuningSetSpeakerVolume(float volume) override;
float tuningGetEnergy(void) override;
//@}
/////////////////////
/// @name Devices
//@{
// This returns true when it's safe to bring up the "device settings" dialog in the prefs.
bool deviceSettingsAvailable() override;
bool deviceSettingsUpdated() override; //return if the list has been updated and never fetched, only to be called from the voicepanel.
// Requery the WebRTC daemon for the current list of input/output devices.
// If you pass true for clearCurrentList, deviceSettingsAvailable() will be false until the query has completed
// (use this if you want to know when it's done).
// If you pass false, you'll have no way to know when the query finishes, but the device lists will not appear empty in the interim.
void refreshDeviceLists(bool clearCurrentList = true) override;
void setCaptureDevice(const std::string& name) override;
void setRenderDevice(const std::string& name) override;
LLVoiceDeviceList& getCaptureDevices() override;
LLVoiceDeviceList& getRenderDevices() override;
//@}
//@}
void getParticipantList(std::set<LLUUID> &participants) override;
bool isParticipant(const LLUUID& speaker_id) override;
@ -125,31 +125,31 @@ public:
// virtual BOOL sendTextMessage(const LLUUID& participant_id, const std::string& message) const {return false;};
// Returns true if calling back the session URI after the session has closed is possible.
// Currently this will be false only for PSTN P2P calls.
// NOTE: this will return true if the session can't be found.
// Currently this will be false only for PSTN P2P calls.
// NOTE: this will return true if the session can't be found.
BOOL isSessionCallBackPossible(const LLUUID &session_id) override;
// WebRTC doesn't preclude text im
BOOL isSessionTextIMPossible(const LLUUID &session_id) override { return TRUE; }
////////////////////////////
/// @name Channel stuff
//@{
// returns true iff the user is currently in a proximal (local spatial) channel.
// Note that gestures should only fire if this returns true.
bool inProximalChannel() override;
void setNonSpatialChannel(const LLSD& channelInfo, bool notify_on_first_join, bool hangup_on_last_leave) override
{
startAdHocSession(channelInfo, notify_on_first_join, hangup_on_last_leave);
}
bool setSpatialChannel(const LLSD &channelInfo) override
bool setSpatialChannel(const LLSD &channelInfo) override
{
processChannels(true);
return true;
}
void leaveNonSpatialChannel() override;
void processChannels(bool process) override;
@ -163,35 +163,32 @@ public:
LLVoiceP2POutgoingCallInterface *getOutgoingCallInterface() override { return nullptr; }
LLVoiceP2PIncomingCallInterfacePtr getIncomingCallInterface(const LLSD &voice_call_info) override { return nullptr; }
/////////////////////////
/// @name Volume/gain
//@{
void setVoiceVolume(F32 volume) override;
void setMicGain(F32 volume) override;
//@}
/////////////////////////
/// @name enable disable voice and features
//@{
void setVoiceEnabled(bool enabled) override;
void setMuteMic(bool muted) override; // Set the mute state of the local mic.
//@}
//////////////////////////
/// @name nearby speaker accessors
//@{
BOOL getVoiceEnabled(const LLUUID& id) override; // true if we've received data for this avatar
std::string getDisplayName(const LLUUID& id) override;
BOOL isParticipantAvatar(const LLUUID &id) override;
BOOL getIsSpeaking(const LLUUID& id) override;
BOOL getIsModeratorMuted(const LLUUID& id) override;
F32 getCurrentPower(const LLUUID& id) override; // "power" is related to "amplitude" in a defined way. I'm just not sure what the formula is...
BOOL getOnMuteList(const LLUUID& id) override;
F32 getUserVolume(const LLUUID& id) override;
void setUserVolume(const LLUUID& id, F32 volume) override; // set's volume for specified agent, from 0-1 (where .5 is nominal)
//@}
//////////////////
/// @name LLMuteListObserver
//@{
@ -208,7 +205,7 @@ public:
void OnConnectionFailure(const std::string &channelID, const LLUUID& regionID);
void sendPositionUpdate(bool force);
void updateOwnVolume();
//////////////////////////////
/// @name Status notification
//@{
@ -233,10 +230,9 @@ public:
{
public:
participantState(const LLUUID& agent_id);
bool updateMuteState(); // true if mute state has changed
bool isAvatar();
std::string mURI;
LLUUID mAvatarID;
std::string mDisplayName;
@ -245,7 +241,6 @@ public:
F32 mVolume; // the gain applied to the participant
bool mIsSpeaking;
bool mIsModeratorMuted;
bool mOnMuteList; // true if this avatar is on the user's mute list (and should be muted)
};
typedef boost::shared_ptr<participantState> participantStatePtr_t;
@ -256,7 +251,7 @@ public:
protected:
typedef std::map<const LLUUID, participantStatePtr_t> participantUUIDMap;
class sessionState
{
public:
@ -267,7 +262,7 @@ public:
static void addSession(const std::string &channelID, ptr_t& session);
virtual ~sessionState();
participantStatePtr_t addParticipant(const LLUUID& agent_id);
void removeParticipant(const participantStatePtr_t &participant);
void removeAllParticipants();
@ -284,14 +279,14 @@ public:
virtual bool processConnectionStates();
virtual void sendData(const std::string &data);
void setMuteMic(bool muted);
void setMicGain(F32 volume);
void setSpeakerVolume(F32 volume);
void setUserVolume(const LLUUID& id, F32 volume);
void setUserMute(const LLUUID& id, bool mute);
static void for_each(sessionFunc_t func);
static void reapEmptySessions();
@ -305,7 +300,7 @@ public:
std::string mHandle;
std::string mChannelID;
std::string mName;
bool mMuted; // this session is muted.
F32 mMicGain; // gain for this session.
F32 mSpeakerVolume; // volume for this session.
@ -314,7 +309,7 @@ public:
participantUUIDMap mParticipantsByUUID;
static bool hasSession(const std::string &sessionID)
static bool hasSession(const std::string &sessionID)
{ return mSessions.find(sessionID) != mSessions.end(); }
bool mHangupOnLastLeave; // notify observers after the session becomes empty.
@ -398,7 +393,7 @@ public:
void addCaptureDevice(const LLVoiceDevice& device);
void clearRenderDevices();
void addRenderDevice(const LLVoiceDevice& device);
void addRenderDevice(const LLVoiceDevice& device);
void setDevicesListUpdated(bool state);
/////////////////////////////
@ -412,22 +407,22 @@ public:
void setEarLocation(S32 loc);
/////////////////////////////
// Accessors for data related to nearby speakers
/////////////////////////////
sessionStatePtr_t findP2PSession(const LLUUID &agent_id);
sessionStatePtr_t addSession(const std::string &channel_id, sessionState::ptr_t session);
void deleteSession(const sessionStatePtr_t &session);
// Does the actual work to get out of the audio session
void leaveAudioSession();
friend class LLWebRTCVoiceClientCapResponder;
void lookupName(const LLUUID &id);
void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name);
void avatarNameResolved(const LLUUID &id, const std::string &name);
@ -448,7 +443,7 @@ private:
//---
/// Clean up objects created during a voice session.
void cleanUp();
bool mTuningMode;
F32 mTuningMicGain;
int mTuningSpeakerVolume;
@ -457,7 +452,7 @@ private:
std::string mSpatialSessionCredentials;
std::string mMainSessionGroupHandle; // handle of the "main" session group.
sessionStatePtr_t mSession; // Session state for the current session
sessionStatePtr_t mNextSession; // Session state for the session we're trying to join
@ -476,7 +471,7 @@ private:
bool inEstateChannel();
LLSD getAudioSessionChannelInfo();
void setHidden(bool hidden) override; //virtual
void enforceTether();
@ -485,9 +480,9 @@ private:
std::set<LLUUID> getNeighboringRegions() { return mNeighboringRegions; }
LLVoiceVersionInfo mVoiceVersion;
bool mSpatialCoordsDirty;
LLVector3d mListenerPosition;
LLVector3d mListenerRequestedPosition;
LLVector3 mListenerVelocity;
@ -498,23 +493,23 @@ private:
LLQuaternion mAvatarRot;
std::set<LLUUID> mNeighboringRegions; // includes current region
bool mMuteMic;
bool mHidden; //Set to true during teleport to hide the agent's position.
enum
{
earLocCamera = 0, // ear at camera
earLocAvatar, // ear at avatar
earLocMixed // ear at avatar location/camera direction
};
S32 mEarLocation;
S32 mEarLocation;
float mSpeakerVolume;
F32 mMicGain;
bool mVoiceEnabled;
bool mProcessChannels;
@ -525,7 +520,7 @@ private:
typedef std::set<LLVoiceClientStatusObserver*> status_observer_set_t;
status_observer_set_t mStatusObservers;
void notifyStatusObservers(LLVoiceClientStatusObserver::EStatusType status);
bool mIsInTuningMode;
@ -544,7 +539,7 @@ class LLVoiceWebRTCStats : public LLSingleton<LLVoiceWebRTCStats>
LLSINGLETON(LLVoiceWebRTCStats);
LOG_CLASS(LLVoiceWebRTCStats);
virtual ~LLVoiceWebRTCStats();
private:
F64SecondsImplicit mStartTime;
@ -552,7 +547,7 @@ class LLVoiceWebRTCStats : public LLSingleton<LLVoiceWebRTCStats>
F64 mConnectTime;
U32 mConnectAttempts;
F64 mProvisionTime;
U32 mProvisionAttempts;
@ -571,7 +566,7 @@ class LLVoiceWebRTCStats : public LLSingleton<LLVoiceWebRTCStats>
LLSD read();
};
class LLVoiceWebRTCConnection :
class LLVoiceWebRTCConnection :
public llwebrtc::LLWebRTCSignalingObserver,
public llwebrtc::LLWebRTCDataObserver
{
@ -610,7 +605,7 @@ class LLVoiceWebRTCConnection :
virtual void setMuteMic(bool muted);
virtual void setMicGain(F32 volume);
virtual void setSpeakerVolume(F32 volume);
void setUserVolume(const LLUUID& id, F32 volume);
void setUserMute(const LLUUID& id, bool mute);