Merge branch 'release/webrtc-voice' of https://github.com/secondlife/viewer

master
Ansariel 2024-08-02 11:59:06 +02:00
commit fa4ad236fc
12 changed files with 185 additions and 55 deletions

View File

@ -2052,18 +2052,6 @@
</map>
<key>mikktspace</key>
<map>
<key>canonical_repo</key>
<string>https://bitbucket.org/lindenlab/3p-mikktspace</string>
<key>copyright</key>
<string>Copyright (C) 2011 by Morten S. Mikkelsen, Copyright (C) 2022 Blender Authors</string>
<key>description</key>
<string>Mikktspace Tangent Generator</string>
<key>license</key>
<string>Apache 2.0</string>
<key>license_file</key>
<string>mikktspace.txt</string>
<key>name</key>
<string>mikktspace</string>
<key>platforms</key>
<map>
<key>darwin64</key>
@ -2109,8 +2097,20 @@
<string>windows64</string>
</map>
</map>
<key>license</key>
<string>Apache 2.0</string>
<key>license_file</key>
<string>mikktspace.txt</string>
<key>copyright</key>
<string>Copyright (C) 2011 by Morten S. Mikkelsen, Copyright (C) 2022 Blender Authors</string>
<key>version</key>
<string>1</string>
<key>name</key>
<string>mikktspace</string>
<key>canonical_repo</key>
<string>https://bitbucket.org/lindenlab/3p-mikktspace</string>
<key>description</key>
<string>Mikktspace Tangent Generator</string>
</map>
<key>minizip-ng</key>
<map>
@ -3078,6 +3078,8 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<string>LICENSE</string>
<key>copyright</key>
<string>Copyright (c) 2000-2012, Linden Research, Inc.</string>
<key>version</key>
<string>3.0-f14b5ec</string>
<key>name</key>
<string>viewer-manager</string>
<key>description</key>
@ -3086,8 +3088,6 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<string>https://bitbucket.org/lindenlab/vmp-standalone</string>
<key>source_type</key>
<string>hg</string>
<key>version</key>
<string>3.0-f14b5ec</string>
</map>
<key>vlc-bin</key>
<map>
@ -3236,11 +3236,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>archive</key>
<map>
<key>hash</key>
<string>0a0a972036f2b2c9c97dead40c91f7443b8ab339</string>
<string>baabb11f324be350253b1fb58cf262c1aa19fa70</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-webrtc-build/releases/download/m114.5735.08.61-debug/webrtc-m114.5735.08.61-debug.9571929057-darwin64-9571929057.tar.zst</string>
<string>https://github.com/secondlife/3p-webrtc-build/releases/download/m114.5735.08.67-debug/webrtc-m114.5735.08.67-debug.10190042668-darwin64-10190042668.tar.zst</string>
</map>
<key>name</key>
<string>darwin64</string>
@ -3250,11 +3250,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>archive</key>
<map>
<key>hash</key>
<string>8725ad23f33d946bd5a4e5f28e8c8324925c71a7</string>
<string>a13776c8f99f8975665be66ff8b51a80ba46c718</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-webrtc-build/releases/download/m114.5735.08.61-debug/webrtc-m114.5735.08.61-debug.9571929057-linux64-9571929057.tar.zst</string>
<string>https://github.com/secondlife/3p-webrtc-build/releases/download/m114.5735.08.67-debug/webrtc-m114.5735.08.67-debug.10190042668-linux64-10190042668.tar.zst</string>
</map>
<key>name</key>
<string>linux64</string>
@ -3264,11 +3264,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>archive</key>
<map>
<key>hash</key>
<string>db560661807db276a3c7d1e7d9531198c9268f68</string>
<string>965ef5d65a14191a52ee9ec6a9a8a1d2ce3f2ffb</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-webrtc-build/releases/download/m114.5735.08.61-debug/webrtc-m114.5735.08.61-debug.9571929057-windows64-9571929057.tar.zst</string>
<string>https://github.com/secondlife/3p-webrtc-build/releases/download/m114.5735.08.67-debug/webrtc-m114.5735.08.67-debug.10190042668-windows64-10190042668.tar.zst</string>
</map>
<key>name</key>
<string>windows64</string>
@ -3281,7 +3281,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
<key>copyright</key>
<string>Copyright (c) 2011, The WebRTC project authors. All rights reserved.</string>
<key>version</key>
<string>m114.5735.08.61-debug.9571929057</string>
<string>m114.5735.08.67-debug.10190042668</string>
<key>name</key>
<string>webrtc</string>
<key>vcs_branch</key>

View File

@ -154,7 +154,8 @@ void LLCustomProcessor::Process(webrtc::AudioBuffer *audio_in)
// LLWebRTCImpl implementation
//
LLWebRTCImpl::LLWebRTCImpl() :
LLWebRTCImpl::LLWebRTCImpl(LLWebRTCLogCallback* logCallback) :
mLogSink(new LLWebRTCLogSink(logCallback)),
mPeerCustomProcessor(nullptr),
mMute(true),
mTuningMode(false),
@ -173,6 +174,7 @@ void LLWebRTCImpl::init()
// Normal logging is rather spammy, so turn it off.
rtc::LogMessage::LogToDebug(rtc::LS_NONE);
rtc::LogMessage::SetLogToStderr(true);
rtc::LogMessage::AddLogToStream(mLogSink, rtc::LS_VERBOSE);
mTaskQueueFactory = webrtc::CreateDefaultTaskQueueFactory();
@ -312,6 +314,7 @@ void LLWebRTCImpl::terminate()
mPeerDeviceModule = nullptr;
mTaskQueueFactory = nullptr;
});
rtc::LogMessage::RemoveLogToStream(mLogSink);
}
//
@ -458,7 +461,7 @@ void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceMo
{
device_module->SetPlayoutDevice(webrtc::AudioDeviceModule::kDefaultDevice);
}
else
else
{
device_module->SetPlayoutDevice(device);
}
@ -656,7 +659,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
// Most peer connection (signaling) happens on
// the signaling thread.
LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() :
LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() :
mWebRTCImpl(nullptr),
mPeerConnection(nullptr),
mMute(false),
@ -1171,7 +1174,7 @@ void LLWebRTCPeerConnectionImpl::OnSuccess(webrtc::SessionDescriptionInterface *
{
observer->OnOfferAvailable(mangled_sdp);
}
mPeerConnection->SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>(
webrtc::CreateSessionDescription(webrtc::SdpType::kOffer, mangled_sdp)),
rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface>(this));
@ -1327,9 +1330,9 @@ void freePeerConnection(LLWebRTCPeerConnectionInterface* peer_connection)
}
void init()
void init(LLWebRTCLogCallback* logCallback)
{
gWebRTCImpl = new LLWebRTCImpl();
gWebRTCImpl = new LLWebRTCImpl(logCallback);
gWebRTCImpl->init();
}

View File

@ -56,6 +56,20 @@
namespace llwebrtc
{
class LLWebRTCLogCallback
{
public:
typedef enum {
LOG_LEVEL_VERBOSE = 0,
LOG_LEVEL_INFO,
LOG_LEVEL_WARNING,
LOG_LEVEL_ERROR
} LogLevel;
virtual void LogMessage(LogLevel level, const std::string& message) = 0;
};
// LLWebRTCVoiceDevice is a simple representation of the
// components of a device, used to communicate this
// information to the viewer.
@ -129,7 +143,7 @@ class LLWebRTCDeviceInterface
};
virtual void setAudioConfig(AudioConfig config) = 0;
// instructs webrtc to refresh the device list.
virtual void refreshDevices() = 0;
@ -231,7 +245,7 @@ class LLWebRTCSignalingObserver
class LLWebRTCPeerConnectionInterface
{
public:
struct InitOptions
{
// equivalent of PeerConnectionInterface::IceServer
@ -262,7 +276,7 @@ class LLWebRTCPeerConnectionInterface
// exports.
// This library must be initialized before use.
LLSYMEXPORT void init();
LLSYMEXPORT void init(LLWebRTCLogCallback* logSink);
// And should be terminated as part of shutdown.
LLSYMEXPORT void terminate();

View File

@ -69,6 +69,54 @@ namespace llwebrtc
class LLWebRTCPeerConnectionImpl;
class LLWebRTCLogSink : public rtc::LogSink {
public:
LLWebRTCLogSink(LLWebRTCLogCallback* callback) :
mCallback(callback)
{
}
// Destructor: close the log file
~LLWebRTCLogSink() override
{
}
void OnLogMessage(const std::string& msg,
rtc::LoggingSeverity severity) override
{
if (mCallback)
{
switch(severity)
{
case rtc::LS_VERBOSE:
mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
break;
case rtc::LS_INFO:
mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
break;
case rtc::LS_WARNING:
mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
break;
case rtc::LS_ERROR:
mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);
break;
default:
break;
}
}
}
void OnLogMessage(const std::string& message) override
{
if (mCallback)
{
mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, message);
}
}
private:
LLWebRTCLogCallback* mCallback;
};
// Implements a class allowing capture of audio data
// to determine audio level of the microphone.
@ -139,8 +187,11 @@ class LLCustomProcessor : public webrtc::CustomProcessing
class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceSink
{
public:
LLWebRTCImpl();
~LLWebRTCImpl() {}
LLWebRTCImpl(LLWebRTCLogCallback* logCallback);
~LLWebRTCImpl()
{
delete mLogSink;
}
void init();
void terminate();
@ -228,6 +279,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
void setRecording(bool recording);
protected:
LLWebRTCLogSink* mLogSink;
// The native webrtc threads
std::unique_ptr<rtc::Thread> mNetworkThread;
std::unique_ptr<rtc::Thread> mWorkerThread;
@ -235,7 +288,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
// The factory that allows creation of native webrtc PeerConnections.
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory;
rtc::scoped_refptr<webrtc::AudioProcessing> mAudioProcessingModule;
// more native webrtc stuff

View File

@ -2952,7 +2952,7 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled, const LLVector3 &
// Notice the calls to "gAwayTimer.reset()". This resets the timer that determines how long the avatar has been
// "away", so that the avatar doesn't lapse into away-mode (and slump over) while the user is still talking.
//-----------------------------------------------------------------------------------------------------------------
if (LLVoiceClient::getInstance()->getIsSpeaking( mID ))
if (LLVoiceClient::getInstance()->getIsSpeaking( mID ) && (!isInMuteList() || isSelf()))
{
if (!mVoiceVisualizer->getCurrentlySpeaking())
{

View File

@ -768,6 +768,7 @@ LLVoiceChannelP2P::LLVoiceChannelP2P(const LLUUID &session_id,
mReceivedCall(FALSE),
mOutgoingCallInterface(outgoing_call_interface)
{
mChannelInfo = LLVoiceClient::getInstance()->getP2PChannelInfoTemplate(other_user_id);
}
void LLVoiceChannelP2P::handleStatusChange(EStatusType type)

View File

@ -889,7 +889,7 @@ void LLVoiceClient::removeObserver(LLVoiceClientParticipantObserver* observer)
LLWebRTCVoiceClient::getInstance()->removeObserver(observer);
}
std::string LLVoiceClient::sipURIFromID(const LLUUID &id)
std::string LLVoiceClient::sipURIFromID(const LLUUID &id) const
{
if (mNonSpatialVoiceModule)
{
@ -905,6 +905,22 @@ std::string LLVoiceClient::sipURIFromID(const LLUUID &id)
}
}
LLSD LLVoiceClient::getP2PChannelInfoTemplate(const LLUUID& id) const
{
if (mNonSpatialVoiceModule)
{
return mNonSpatialVoiceModule->getP2PChannelInfoTemplate(id);
}
else if (mSpatialVoiceModule)
{
return mSpatialVoiceModule->getP2PChannelInfoTemplate(id);
}
else
{
return LLSD();
}
}
LLVoiceEffectInterface* LLVoiceClient::getVoiceEffectInterface() const
{
return NULL;

View File

@ -284,7 +284,8 @@ public:
virtual void removeObserver(LLVoiceClientParticipantObserver* observer)=0;
//@}
virtual std::string sipURIFromID(const LLUUID &id)=0;
virtual std::string sipURIFromID(const LLUUID &id) const=0;
virtual LLSD getP2PChannelInfoTemplate(const LLUUID& id) const=0;
//@}
};
@ -519,7 +520,8 @@ public:
void addObserver(LLVoiceClientParticipantObserver* observer);
void removeObserver(LLVoiceClientParticipantObserver* observer);
std::string sipURIFromID(const LLUUID &id);
std::string sipURIFromID(const LLUUID &id) const;
LLSD getP2PChannelInfoTemplate(const LLUUID& id) const;
//////////////////////////
/// @name Voice effects

View File

@ -296,7 +296,6 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() :
mDevicesListUpdated(false),
mAudioSession(), // TBD - should be NULL
mAudioSessionChanged(false),
mNextAudioSession(),
mCurrentParcelLocalID(0),
@ -1741,7 +1740,6 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
LL_INFOS("Voice") << "Adding or joining voice session " << nextSession->mHandle << LL_ENDL;
mAudioSession = nextSession;
mAudioSessionChanged = true;
if (!mAudioSession || !mAudioSession->mReconnect)
{
mNextAudioSession.reset();
@ -2000,9 +1998,8 @@ bool LLVivoxVoiceClient::terminateAudioSession(bool wait)
sessionStatePtr_t oldSession = mAudioSession;
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL); // needs mAudioSession for uri
mAudioSession.reset();
// We just notified status observers about this change. Don't do it again.
mAudioSessionChanged = false;
// The old session may now need to be deleted.
reapSession(oldSession);
@ -2010,9 +2007,9 @@ bool LLVivoxVoiceClient::terminateAudioSession(bool wait)
else
{
LL_WARNS("Voice") << "terminateAudioSession(" << wait << ") with NULL mAudioSession" << LL_ENDL;
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL);
}
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL);
// Always reset the terminate request flag when we get here.
// Some slower PCs have a race condition where they can switch to an incoming P2P call faster than the state machine leaves
@ -3970,7 +3967,6 @@ void LLVivoxVoiceClient::joinedAudioSession(const sessionStatePtr_t &session)
sessionStatePtr_t oldSession = mAudioSession;
mAudioSession = session;
mAudioSessionChanged = true;
// The old session may now need to be deleted.
reapSession(oldSession);
@ -5284,7 +5280,7 @@ bool LLVivoxVoiceClient::inProximalChannel()
return result;
}
std::string LLVivoxVoiceClient::sipURIFromID(const LLUUID &id)
std::string LLVivoxVoiceClient::sipURIFromID(const LLUUID &id) const
{
std::string result;
result = "sip:";
@ -5295,6 +5291,14 @@ std::string LLVivoxVoiceClient::sipURIFromID(const LLUUID &id)
return result;
}
LLSD LLVivoxVoiceClient::getP2PChannelInfoTemplate(const LLUUID& id) const
{
LLSD result;
result["channel_uri"] = sipURIFromID(id);
result["voice_server_type"] = VIVOX_VOICE_SERVER_TYPE;
return result;
}
std::string LLVivoxVoiceClient::sipURIFromAvatar(LLVOAvatar *avatar)
{
std::string result;
@ -5309,7 +5313,7 @@ std::string LLVivoxVoiceClient::sipURIFromAvatar(LLVOAvatar *avatar)
return result;
}
std::string LLVivoxVoiceClient::nameFromID(const LLUUID &uuid)
std::string LLVivoxVoiceClient::nameFromID(const LLUUID &uuid) const
{
std::string result;
@ -6289,7 +6293,6 @@ void LLVivoxVoiceClient::deleteSession(const sessionStatePtr_t &session)
if(mAudioSession == session)
{
mAudioSession.reset();
mAudioSessionChanged = true;
}
// ditto for the next audio session
@ -6398,9 +6401,10 @@ void LLVivoxVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESta
}
}
LLSD channel_info = getAudioSessionChannelInfo();
LL_DEBUGS("Voice")
<< " " << LLVoiceClientStatusObserver::status2string(status)
<< ", session channelInfo " << getAudioSessionChannelInfo()
<< ", session channelInfo " << channel_info
<< ", proximal is " << inSpatialChannel()
<< LL_ENDL;
@ -6415,7 +6419,7 @@ void LLVivoxVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESta
)
{
LLVoiceClientStatusObserver* observer = *it;
observer->onChange(status, getAudioSessionChannelInfo(), inSpatialChannel());
observer->onChange(status, channel_info, inSpatialChannel());
// In case onError() deleted an entry.
it = mStatusObservers.upper_bound(observer);
}

View File

@ -221,7 +221,8 @@ public:
void removeObserver(LLVoiceClientParticipantObserver* observer) override;
//@}
std::string sipURIFromID(const LLUUID &id) override;
std::string sipURIFromID(const LLUUID &id) const override;
LLSD getP2PChannelInfoTemplate(const LLUUID& id) const override;
//@}
/// @name LLVoiceEffectInterface virtual implementations
@ -706,7 +707,6 @@ private:
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.
sessionStatePtr_t mNextAudioSession; // Session state for the audio session we're trying to join
@ -748,7 +748,7 @@ private:
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);
std::string nameFromID(const LLUUID &id) const;
bool IDFromName(const std::string name, LLUUID &uuid);
std::string sipURIFromAvatar(LLVOAvatar *avatar);
std::string sipURIFromName(std::string &name);

View File

@ -250,7 +250,7 @@ LLWebRTCVoiceClient::~LLWebRTCVoiceClient()
void LLWebRTCVoiceClient::init(LLPumpIO* pump)
{
// constructor will set up LLVoiceClient::getInstance()
llwebrtc::init();
llwebrtc::init(this);
mWebRTCDeviceInterface = llwebrtc::getDeviceInterface();
mWebRTCDeviceInterface->setDevicesObserver(this);
@ -281,6 +281,29 @@ void LLWebRTCVoiceClient::cleanUp()
LL_DEBUGS("Voice") << "Exiting" << LL_ENDL;
}
void LLWebRTCVoiceClient::LogMessage(llwebrtc::LLWebRTCLogCallback::LogLevel level, const std::string& message)
{
switch (level)
{
case llwebrtc::LLWebRTCLogCallback::LOG_LEVEL_VERBOSE:
LL_DEBUGS("Voice") << message << LL_ENDL;
break;
case llwebrtc::LLWebRTCLogCallback::LOG_LEVEL_INFO:
LL_INFOS("Voice") << message << LL_ENDL;
break;
case llwebrtc::LLWebRTCLogCallback::LOG_LEVEL_WARNING:
LL_WARNS("Voice") << message << LL_ENDL;
break;
case llwebrtc::LLWebRTCLogCallback::LOG_LEVEL_ERROR:
// use WARN so that we don't crash on a webrtc error.
// webrtc will force a crash on a fatal error.
LL_WARNS("Voice") << message << LL_ENDL;
break;
default:
break;
}
}
// --------------------------------------------------
const LLVoiceVersionInfo& LLWebRTCVoiceClient::getVersion()
@ -2066,11 +2089,16 @@ void LLWebRTCVoiceClient::avatarNameResolved(const LLUUID &id, const std::string
}
// Leftover from vivox PTSN
std::string LLWebRTCVoiceClient::sipURIFromID(const LLUUID& id)
std::string LLWebRTCVoiceClient::sipURIFromID(const LLUUID& id) const
{
return id.asString();
}
LLSD LLWebRTCVoiceClient::getP2PChannelInfoTemplate(const LLUUID& id) const
{
return LLSD();
}
/////////////////////////////
// LLVoiceWebRTCConnection

View File

@ -62,7 +62,8 @@ extern const std::string WEBRTC_VOICE_SERVER_TYPE;
class LLWebRTCVoiceClient : public LLSingleton<LLWebRTCVoiceClient>,
virtual public LLVoiceModuleInterface,
public llwebrtc::LLWebRTCDevicesObserver,
public LLMuteListObserver
public LLMuteListObserver,
public llwebrtc::LLWebRTCLogCallback
{
LLSINGLETON_C11(LLWebRTCVoiceClient);
LOG_CLASS(LLWebRTCVoiceClient);
@ -84,7 +85,15 @@ public:
// 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;
std::string sipURIFromID(const LLUUID &id) const override;
LLSD getP2PChannelInfoTemplate(const LLUUID& id) const override;
///////////////////
/// @name Logging
/// @{
void LogMessage(llwebrtc::LLWebRTCLogCallback::LogLevel level, const std::string& message) override;
//@}
/////////////////////
/// @name Tuning