diff options
| author | Roxie Linden <roxie@lindenlab.com> | 2023-09-28 10:55:13 -0700 | 
|---|---|---|
| committer | Roxie Linden <roxie@lindenlab.com> | 2024-02-22 23:11:34 -0800 | 
| commit | 4359b574e8ed505b3f4019f70823e34cf571ba76 (patch) | |
| tree | 43f87106545d573ad6b225472fa9d872c7aded72 /indra/newview | |
| parent | c5796c225dc98190bb2372780849822d85455618 (diff) | |
Transmit position and power when joining
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 101 | ||||
| -rw-r--r-- | indra/newview/llvoicewebrtc.h | 4 | 
2 files changed, 55 insertions, 50 deletions
| diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index a1e63c29cf..ccaa02b704 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -1124,7 +1124,7 @@ bool LLWebRTCVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession      // tell peers that this participant has joined.      Json::FastWriter writer; -    Json::Value      root; +    Json::Value      root = getPositionAndVolumeUpdateJson(true);      root["j"]             = true;      std::string json_data = writer.write(root);      mWebRTCDataInterface->sendData(json_data, false); @@ -2167,60 +2167,63 @@ void LLWebRTCVoiceClient::setHidden(bool hidden)      }  } -void LLWebRTCVoiceClient::sendPositionAndVolumeUpdate(void) -{	 - +Json::Value LLWebRTCVoiceClient::getPositionAndVolumeUpdateJson(bool force) +{ +    Json::Value root = Json::objectValue; -    if (mWebRTCDataInterface && mWebRTCAudioInterface) +    if ((mSpatialCoordsDirty || force) && inSpatialChannel())      { -        Json::Value  root = Json::objectValue; -         -        if (mSpatialCoordsDirty && inSpatialChannel()) -        { -            root["sp"] = Json::objectValue; -            root["sp"]["x"] = (int)(mAvatarPosition[0]*100); -            root["sp"]["y"] = (int)(mAvatarPosition[1]*100); -            root["sp"]["z"] = (int)(mAvatarPosition[2]*100); -            root["sh"] = Json::objectValue; -            root["sh"]["x"] = (int)(mAvatarRot[0]*100); -            root["sh"]["y"] = (int)(mAvatarRot[1]*100); -            root["sh"]["z"] = (int)(mAvatarRot[2]*100); -            root["sh"]["w"] = (int)(mAvatarRot[3]*100); +        root["sp"]      = Json::objectValue; +        root["sp"]["x"] = (int) (mAvatarPosition[0] * 100); +        root["sp"]["y"] = (int) (mAvatarPosition[1] * 100); +        root["sp"]["z"] = (int) (mAvatarPosition[2] * 100); +        root["sh"]      = Json::objectValue; +        root["sh"]["x"] = (int) (mAvatarRot[0] * 100); +        root["sh"]["y"] = (int) (mAvatarRot[1] * 100); +        root["sh"]["z"] = (int) (mAvatarRot[2] * 100); +        root["sh"]["w"] = (int) (mAvatarRot[3] * 100); + +        root["lp"]      = Json::objectValue; +        root["lp"]["x"] = (int) (mCameraPosition[0] * 100); +        root["lp"]["y"] = (int) (mCameraPosition[1] * 100); +        root["lp"]["z"] = (int) (mCameraPosition[2] * 100); +        root["lh"]      = Json::objectValue; +        root["lh"]["x"] = (int) (mCameraRot[0] * 100); +        root["lh"]["y"] = (int) (mCameraRot[1] * 100); +        root["lh"]["z"] = (int) (mCameraRot[2] * 100); +        root["lh"]["w"] = (int) (mCameraRot[3] * 100); + +        mSpatialCoordsDirty = false; +    } -             -            root["lp"] = Json::objectValue; -            root["lp"]["x"] = (int)(mCameraPosition[0]*100); -            root["lp"]["y"] = (int)(mCameraPosition[1]*100); -            root["lp"]["z"] = (int)(mCameraPosition[2]*100); -            root["lh"] = Json::objectValue; -            root["lh"]["x"] = (int)(mCameraRot[0]*100); -            root["lh"]["y"] = (int)(mCameraRot[1]*100); -            root["lh"]["z"] = (int)(mCameraRot[2]*100); -            root["lh"]["w"] = (int)(mCameraRot[3]*100); +    F32 audio_level = 0.0; -            mSpatialCoordsDirty = false; -        } -         -         -        F32 audio_level = 0.0; -         -		if (!mMuteMic) -        { -            audio_level = (F32) mWebRTCDeviceInterface->getAudioLevel(); -        } -        uint32_t uint_audio_level = mMuteMic ? 0 : (uint32_t) (audio_level * 128); -        if (uint_audio_level != mAudioLevel) +    if (!mMuteMic) +    { +        audio_level = (F32) mWebRTCDeviceInterface->getAudioLevel(); +    } +    uint32_t uint_audio_level = mMuteMic ? 0 : (uint32_t) (audio_level * 128); +    if (force || (uint_audio_level != mAudioLevel)) +    { +        root["p"]                         = uint_audio_level; +        mAudioLevel                       = uint_audio_level; +        participantStatePtr_t participant = findParticipantByID(gAgentID); +        if (participant)          { -            root["p"]					      = uint_audio_level; -            mAudioLevel                       = uint_audio_level; -            participantStatePtr_t participant = findParticipantByID(gAgentID); -            if (participant) -            { -                participant->mPower = audio_level; -                participant->mIsSpeaking = participant->mPower > SPEAKING_AUDIO_LEVEL; -            } +            participant->mPower      = audio_level; +            participant->mIsSpeaking = participant->mPower > SPEAKING_AUDIO_LEVEL;          } -         +    } +    return root; +} + +void LLWebRTCVoiceClient::sendPositionAndVolumeUpdate() +{	 + + +    if (mWebRTCDataInterface && mWebRTCAudioInterface) +    { +        Json::Value root = getPositionAndVolumeUpdateJson(false);          if (root.size() > 0)          { diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index 1d013c6609..bd4346022f 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -40,6 +40,7 @@ class LLWebRTCProtocolParser;  #include "lleventcoro.h"  #include "llcoros.h"  #include <queue> +#include "json/reader.h"  #ifdef LL_USESYSTEMLIBS  # include "expat.h" @@ -806,7 +807,8 @@ private:  	std::string getAudioSessionHandle();      void setHidden(bool hidden) override; //virtual -	void sendPositionAndVolumeUpdate(void); +    Json::Value getPositionAndVolumeUpdateJson(bool force); +	void sendPositionAndVolumeUpdate();  	void sendFriendsListUpdates(); | 
