diff options
author | Roxanne Skelly <roxanne@roxiware.com> | 2024-04-08 04:10:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 04:10:34 -0700 |
commit | f2ec9e5cca078434e624e42afec11ebd7d681e06 (patch) | |
tree | d6afcd0bc1cf2c86e5f5a668749c01c14bf04da2 /indra | |
parent | a0cc1b6bd2b1f3578c8d34b634e4add20bae2dd2 (diff) | |
parent | 648741470f67120d99aec3a4aeceeaf4395cca09 (diff) |
Merge pull request #1150 from secondlife/roxie/webrtc-voice
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 11 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc.h | 7 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc_impl.h | 1 | ||||
-rw-r--r-- | indra/newview/llimview.cpp | 82 | ||||
-rw-r--r-- | indra/newview/llvoicechannel.h | 2 | ||||
-rw-r--r-- | indra/newview/llvoicevivox.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 4 |
7 files changed, 85 insertions, 24 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 7570bb4434..eb9bb65e67 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -26,7 +26,6 @@ #include "llwebrtc_impl.h" #include <algorithm> -#include <format> #include <string.h> #include "api/audio_codecs/audio_decoder_factory.h" @@ -389,7 +388,7 @@ void LLWebRTCImpl::unsetDevicesObserver(LLWebRTCDevicesObserver *observer) void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device) { device_module->StopRecording(); -#if LL_WINDOWS +#if WEBRTC_WIN if (device < 0) { device_module->SetRecordingDevice(webrtc::AudioDeviceModule::kDefaultDevice); @@ -442,7 +441,7 @@ void LLWebRTCImpl::setCaptureDevice(const std::string &id) void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device) { device_module->StopPlayout(); -#if LL_WINDOWS +#if WEBRTC_WIN if (device < 0) { device_module->SetPlayoutDevice(webrtc::AudioDeviceModule::kDefaultDevice); @@ -501,10 +500,10 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id) // updateDevices needs to happen on the worker thread. void LLWebRTCImpl::updateDevices() { - int16_t renderDeviceCount = mTuningDeviceModule->PlayoutDevices(); + int16_t renderDeviceCount = mTuningDeviceModule->PlayoutDevices(); mPlayoutDeviceList.clear(); -#if LL_WINDOWS +#if WEBRTC_WIN int16_t index = 0; #else // index zero is always "Default" for darwin/linux, @@ -522,7 +521,7 @@ void LLWebRTCImpl::updateDevices() int16_t captureDeviceCount = mTuningDeviceModule->RecordingDevices(); mRecordingDeviceList.clear(); -#if LL_WINDOWS +#if WEBRTC_WIN index = 0; #else // index zero is always "Default" for darwin/linux, diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index 8830799cde..ac71e0c744 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -78,7 +78,12 @@ class LLWebRTCVoiceDevice LLWebRTCVoiceDevice(const std::string &display_name, const std::string &id) : mDisplayName(display_name), mID(id) - {}; + { + if (mID.empty()) + { + mID = display_name; + } + }; }; typedef std::vector<LLWebRTCVoiceDevice> LLWebRTCVoiceDeviceList; diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 78ae6b4444..e1031099c7 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -35,6 +35,7 @@ #define WEBRTC_POSIX 1 #elif __linux__ #define WEBRTC_LINUX 1 +#define WEBRTC_POSIX 1 #endif #include "llwebrtc.h" diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 215cc4103b..9c8fcd3283 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -102,7 +102,7 @@ enum EMultiAgentChatSessionType void startConferenceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId, LLSD agents); -void startP2PCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId); +void startP2PVoiceCoro(std::string url, LLUUID tempSessionId, LLUUID creatorId, LLUUID otherParticipantId); void chatterBoxInvitationCoro(std::string url, LLUUID sessionId, LLIMMgr::EInvitationType invitationType); void chatterBoxHistoryCoro(std::string url, LLUUID sessionId, std::string from, std::string message, U32 timestamp); @@ -456,14 +456,14 @@ void startConferenceCoro(std::string url, } } -void startP2PCoro(std::string url, LLUUID sessionID, LLUUID creatorId, LLUUID otherParticipantId) +void startP2PVoiceCoro(std::string url, LLUUID sessionID, LLUUID creatorId, LLUUID otherParticipantId) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("ConferenceChatStart", httpPolicy)); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("StartP2PVoiceCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLSD postData; - postData["method"] = "start p2p"; + postData["method"] = "start p2p voice"; postData["session-id"] = sessionID; postData["params"] = otherParticipantId; LLSD altParams; @@ -2125,7 +2125,7 @@ bool LLIMModel::sendStartSession( if (region) { std::string url = region->getCapability("ChatSessionRequest"); - LLCoros::instance().launch("startP2P", boost::bind(&startP2PCoro, url, temp_session_id, gAgent.getID(), other_participant_id)); + LLCoros::instance().launch("startP2PVoiceCoro", boost::bind(&startP2PVoiceCoro, url, temp_session_id, gAgent.getID(), other_participant_id)); } return true; } @@ -2727,7 +2727,7 @@ LLIncomingCallDialog::LLIncomingCallDialog(const LLSD& payload) : void LLIncomingCallDialog::onLifetimeExpired() { - LLVoiceP2PIncomingCallInterfacePtr call = LLVoiceClient::getInstance()->getIncomingCallInterface(mPayload["voice_session_info"]); + LLVoiceP2PIncomingCallInterfacePtr call = LLVoiceClient::getInstance()->getIncomingCallInterface(mPayload["voice_channel_info"]); if (call) { // restart notification's timer if call is still valid @@ -3005,24 +3005,42 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload { if (type == IM_SESSION_P2P_INVITE) { - LLVoiceP2PIncomingCallInterfacePtr call = LLVoiceClient::getInstance()->getIncomingCallInterface(payload["voice_session_info"]); + // decline p2p voice, either via the vivox-style call mechanism + // or via the webrtc-style "decline p2p" mechanism. + LLVoiceP2PIncomingCallInterfacePtr call = LLVoiceClient::getInstance()->getIncomingCallInterface(payload["voice_channel_info"]); if (call) { call->declineInvite(); } + else + { + // webrtc-style decline. + LLViewerRegion *region = gAgent.getRegion(); + if (region) + { + std::string url = region->getCapability("ChatSessionRequest"); + + LLSD data; + data["method"] = "decline p2p voice"; + data["session-id"] = session_id; + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, data, "P2P declined", "P2P decline failed."); + } + } } else { - std::string url = gAgent.getRegion()->getCapability( - "ChatSessionRequest"); + LLViewerRegion *region = gAgent.getRegion(); + if (region) + { + std::string url = region->getCapability("ChatSessionRequest"); - LLSD data; - data["method"] = "decline invitation"; - data["session-id"] = session_id; + LLSD data; + data["method"] = "decline invitation"; + data["session-id"] = session_id; - LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, data, - "Invitation declined", - "Invitation decline failed."); + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, data, "Invitation declined", "Invitation decline failed."); + } } } @@ -3572,6 +3590,40 @@ void LLIMMgr::clearPendingInvitation(const LLUUID& session_id) void LLIMMgr::processAgentListUpdates(const LLUUID& session_id, const LLSD& body) { + if (body.isMap() && body.has("agent_updates") && body["agent_updates"].isMap()) + { + LLSD::map_const_iterator update_it; + for (update_it = body["agent_updates"].beginMap(); update_it != body["agent_updates"].endMap(); ++update_it) + { + LLUUID agent_id = LLUUID(update_it->first); + LLSD agent_data = update_it->second; + if (agent_data.has("transition") && agent_data["transition"].asString() == "LEAVE") + { + // ignore actual leaves as those will be handled separately. + continue; + } + + if (agent_id != gAgentID && agent_data.isMap() && agent_data.has("info") && agent_data["info"].isMap()) + { + // Is one of the participants leaving a P2P Chat? + if (agent_data["info"].has("can_voice_chat") && !agent_data["info"]["can_voice_chat"].asBoolean()) + { + LLVoiceChannelGroup *channelp = dynamic_cast < LLVoiceChannelGroup*>(LLVoiceChannel::getChannelByID(session_id)); + if (channelp && channelp->isP2P()) + { + // it's an adhoc-style P2P channel, and the peer has declined voice. notify the user + // and shut down the voice channel. + LLSD notifyArgs = LLSD::emptyMap(); + notifyArgs["VOICE_CHANNEL_NAME"] = channelp->getSessionName(); + LLNotificationsUtil::add("P2PCallDeclined", notifyArgs); + endCall(session_id); + break; + } + } + } + } + } + LLFloaterIMSession* im_floater = LLFloaterIMSession::findInstance(session_id); if ( im_floater ) { diff --git a/indra/newview/llvoicechannel.h b/indra/newview/llvoicechannel.h index bc22bf0df6..adc387e22d 100644 --- a/indra/newview/llvoicechannel.h +++ b/indra/newview/llvoicechannel.h @@ -147,6 +147,8 @@ public: void setChannelInfo(const LLSD &channelInfo) override; void requestChannelInfo() override; + bool isP2P() { return mIsP2P; } + protected: void setState(EState state) override; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index f5c9e3aa98..be9e055203 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -5089,7 +5089,7 @@ bool LLVivoxVoiceClient::isCurrentChannel(const LLSD &channelInfo) } if (mAudioSession) { - if (!channelInfo["sessionHandle"].asString().empty()) + if (!channelInfo["session_handle"].asString().empty()) { return mAudioSession->mHandle == channelInfo["session_handle"].asString(); } diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 3cc4aa113c..cb01a079cc 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -1360,7 +1360,7 @@ bool LLWebRTCVoiceClient::isCurrentChannel(const LLSD &channelInfo) if (mSession) { - if (!channelInfo["sessionHandle"].asString().empty()) + if (!channelInfo["session_handle"].asString().empty()) { return mSession->mHandle == channelInfo["session_handle"].asString(); } @@ -2368,12 +2368,14 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro() if (!regionp || !regionp->capabilitiesReceived()) { LL_DEBUGS("Voice") << "no capabilities for voice provisioning; waiting " << LL_ENDL; + setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); return; } std::string url = regionp->getCapability("ProvisionVoiceAccountRequest"); if (url.empty()) { + setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); return; } |