aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoiceclient.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:27 -0500
committerJacek Antonelli2008-08-15 23:45:27 -0500
commita8a62201ba762e98dff92cf49033e577fc34d8d4 (patch)
tree11f8513c5cdc222f2fac0c93eb724c089803c200 /linden/indra/newview/llvoiceclient.cpp
parentSecond Life viewer sources 1.18.6.4-RC (diff)
downloadmeta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.zip
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.gz
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.bz2
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.xz
Second Life viewer sources 1.19.0.0
Diffstat (limited to 'linden/indra/newview/llvoiceclient.cpp')
-rw-r--r--linden/indra/newview/llvoiceclient.cpp202
1 files changed, 124 insertions, 78 deletions
diff --git a/linden/indra/newview/llvoiceclient.cpp b/linden/indra/newview/llvoiceclient.cpp
index 891ea73..6079447 100644
--- a/linden/indra/newview/llvoiceclient.cpp
+++ b/linden/indra/newview/llvoiceclient.cpp
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -29,11 +29,11 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#include <boost/tokenizer.hpp>
33
34#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
35#include "llvoiceclient.h" 33#include "llvoiceclient.h"
36 34
35#include <boost/tokenizer.hpp>
36
37#include "llsdutil.h" 37#include "llsdutil.h"
38 38
39#include "llvoavatar.h" 39#include "llvoavatar.h"
@@ -43,7 +43,6 @@
43#include "llcallbacklist.h" 43#include "llcallbacklist.h"
44#include "llviewerregion.h" 44#include "llviewerregion.h"
45#include "llviewernetwork.h" // for gGridChoice 45#include "llviewernetwork.h" // for gGridChoice
46#include "llfloateractivespeakers.h" // for LLSpeakerMgr
47#include "llbase64.h" 46#include "llbase64.h"
48#include "llviewercontrol.h" 47#include "llviewercontrol.h"
49#include "llkeyboard.h" 48#include "llkeyboard.h"
@@ -532,7 +531,7 @@ void LLVivoxProtocolParser::CharData(const char *buffer, int length)
532 531
533void LLVivoxProtocolParser::processResponse(std::string tag) 532void LLVivoxProtocolParser::processResponse(std::string tag)
534{ 533{
535// llinfos << tag << llendl; 534 //llinfos << tag << llendl;
536 535
537 if (isEvent) 536 if (isEvent)
538 { 537 {
@@ -768,7 +767,7 @@ static HANDLE sGatewayHandle = 0;
768static bool isGatewayRunning() 767static bool isGatewayRunning()
769{ 768{
770 bool result = false; 769 bool result = false;
771 if(sGatewayHandle != 0) 770 if(sGatewayHandle != 0)
772 { 771 {
773 DWORD waitresult = WaitForSingleObject(sGatewayHandle, 0); 772 DWORD waitresult = WaitForSingleObject(sGatewayHandle, 0);
774 if(waitresult != WAIT_OBJECT_0) 773 if(waitresult != WAIT_OBJECT_0)
@@ -854,7 +853,7 @@ LLVoiceClient::LLVoiceClient()
854 setPTTKey(keyString); 853 setPTTKey(keyString);
855 mPTTIsToggle = gSavedSettings.getBOOL("PushToTalkToggle"); 854 mPTTIsToggle = gSavedSettings.getBOOL("PushToTalkToggle");
856 mEarLocation = gSavedSettings.getS32("VoiceEarLocation"); 855 mEarLocation = gSavedSettings.getS32("VoiceEarLocation");
857 setVoiceVolume(gSavedSettings.getF32("AudioLevelVoice")); 856 setVoiceVolume(gSavedSettings.getBOOL("MuteVoice") ? 0.f : gSavedSettings.getF32("AudioLevelVoice"));
858 std::string captureDevice = gSavedSettings.getString("VoiceInputAudioDevice"); 857 std::string captureDevice = gSavedSettings.getString("VoiceInputAudioDevice");
859 setCaptureDevice(captureDevice); 858 setCaptureDevice(captureDevice);
860 std::string renderDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); 859 std::string renderDevice = gSavedSettings.getString("VoiceOutputAudioDevice");
@@ -876,7 +875,6 @@ LLVoiceClient::LLVoiceClient()
876 mTuningMicVolumeDirty = true; 875 mTuningMicVolumeDirty = true;
877 mTuningSpeakerVolume = 0; 876 mTuningSpeakerVolume = 0;
878 mTuningSpeakerVolumeDirty = true; 877 mTuningSpeakerVolumeDirty = true;
879 mTuningCaptureRunning = false;
880 878
881 // gMuteListp isn't set up at this point, so we defer this until later. 879 // gMuteListp isn't set up at this point, so we defer this until later.
882// gMuteListp->addObserver(&mutelist_listener); 880// gMuteListp->addObserver(&mutelist_listener);
@@ -1138,14 +1136,15 @@ const char *LLVoiceClient::state2string(LLVoiceClient::state inState)
1138 CASE(stateConnectorStart); 1136 CASE(stateConnectorStart);
1139 CASE(stateConnectorStarting); 1137 CASE(stateConnectorStarting);
1140 CASE(stateConnectorStarted); 1138 CASE(stateConnectorStarted);
1141 CASE(stateMicTuningNoLogin);
1142 CASE(stateLoginRetry); 1139 CASE(stateLoginRetry);
1143 CASE(stateLoginRetryWait); 1140 CASE(stateLoginRetryWait);
1144 CASE(stateNeedsLogin); 1141 CASE(stateNeedsLogin);
1145 CASE(stateLoggingIn); 1142 CASE(stateLoggingIn);
1146 CASE(stateLoggedIn); 1143 CASE(stateLoggedIn);
1147 CASE(stateNoChannel); 1144 CASE(stateNoChannel);
1148 CASE(stateMicTuningLoggedIn); 1145 CASE(stateMicTuningStart);
1146 CASE(stateMicTuningRunning);
1147 CASE(stateMicTuningStop);
1149 CASE(stateSessionCreate); 1148 CASE(stateSessionCreate);
1150 CASE(stateSessionConnect); 1149 CASE(stateSessionConnect);
1151 CASE(stateJoiningSession); 1150 CASE(stateJoiningSession);
@@ -1164,6 +1163,7 @@ const char *LLVoiceClient::state2string(LLVoiceClient::state inState)
1164 CASE(stateJoinSessionFailed); 1163 CASE(stateJoinSessionFailed);
1165 CASE(stateJoinSessionFailedWaiting); 1164 CASE(stateJoinSessionFailedWaiting);
1166 CASE(stateJail); 1165 CASE(stateJail);
1166 CASE(stateMicTuningNoLogin);
1167 } 1167 }
1168 1168
1169#undef CASE 1169#undef CASE
@@ -1483,7 +1483,8 @@ void LLVoiceClient::stateMachine()
1483 } 1483 }
1484 else if(mTuningMode) 1484 else if(mTuningMode)
1485 { 1485 {
1486 setState(stateMicTuningNoLogin); 1486 mTuningExitState = stateConnectorStart;
1487 setState(stateMicTuningStart);
1487 } 1488 }
1488 break; 1489 break;
1489 1490
@@ -1515,24 +1516,63 @@ void LLVoiceClient::stateMachine()
1515 } 1516 }
1516 break; 1517 break;
1517 1518
1518 case stateMicTuningNoLogin: 1519 case stateMicTuningStart:
1519 case stateMicTuningLoggedIn: 1520 if(mUpdateTimer.hasExpired())
1520 { 1521 {
1521 // Both of these behave essentially the same. The only difference is where the exit transition goes to. 1522 if(mCaptureDeviceDirty || mRenderDeviceDirty)
1522 if(mTuningMode && mVoiceEnabled && !mSessionTerminateRequested) 1523 {
1523 { 1524 // These can't be changed while in tuning mode. Set them before starting.
1524 if(!mTuningCaptureRunning) 1525 std::ostringstream stream;
1526
1527 if(mCaptureDeviceDirty)
1528 {
1529 buildSetCaptureDevice(stream);
1530 }
1531
1532 if(mRenderDeviceDirty)
1533 {
1534 buildSetRenderDevice(stream);
1535 }
1536
1537 mCaptureDeviceDirty = false;
1538 mRenderDeviceDirty = false;
1539
1540 if(!stream.str().empty())
1541 {
1542 writeString(stream.str());
1543 }
1544
1545 // This will come around again in the same state and start the capture, after the timer expires.
1546 mUpdateTimer.start();
1547 mUpdateTimer.setTimerExpirySec(UPDATE_THROTTLE_SECONDS);
1548 }
1549 else
1525 { 1550 {
1526 // duration parameter is currently unused, per Mike S. 1551 // duration parameter is currently unused, per Mike S.
1527 tuningCaptureStartSendMessage(10000); 1552 tuningCaptureStartSendMessage(10000);
1553
1554 setState(stateMicTuningRunning);
1528 } 1555 }
1529 1556 }
1530 if(mTuningMicVolumeDirty || mTuningSpeakerVolumeDirty || mCaptureDeviceDirty || mRenderDeviceDirty) 1557
1558 break;
1559
1560 case stateMicTuningRunning:
1561 if(!mTuningMode || !mVoiceEnabled || mSessionTerminateRequested || mCaptureDeviceDirty || mRenderDeviceDirty)
1562 {
1563 // All of these conditions make us leave tuning mode.
1564 setState(stateMicTuningStop);
1565 }
1566 else
1567 {
1568 // process mic/speaker volume changes
1569 if(mTuningMicVolumeDirty || mTuningSpeakerVolumeDirty)
1531 { 1570 {
1532 std::ostringstream stream; 1571 std::ostringstream stream;
1533 1572
1534 if(mTuningMicVolumeDirty) 1573 if(mTuningMicVolumeDirty)
1535 { 1574 {
1575 llinfos << "setting tuning mic level to " << mTuningMicVolume << llendl;
1536 stream 1576 stream
1537 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.SetMicLevel.1\">" 1577 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.SetMicLevel.1\">"
1538 << "<Level>" << mTuningMicVolume << "</Level>" 1578 << "<Level>" << mTuningMicVolume << "</Level>"
@@ -1547,20 +1587,8 @@ void LLVoiceClient::stateMachine()
1547 << "</Request>\n\n\n"; 1587 << "</Request>\n\n\n";
1548 } 1588 }
1549 1589
1550 if(mCaptureDeviceDirty)
1551 {
1552 buildSetCaptureDevice(stream);
1553 }
1554
1555 if(mRenderDeviceDirty)
1556 {
1557 buildSetRenderDevice(stream);
1558 }
1559
1560 mTuningMicVolumeDirty = false; 1590 mTuningMicVolumeDirty = false;
1561 mTuningSpeakerVolumeDirty = false; 1591 mTuningSpeakerVolumeDirty = false;
1562 mCaptureDeviceDirty = false;
1563 mRenderDeviceDirty = false;
1564 1592
1565 if(!stream.str().empty()) 1593 if(!stream.str().empty())
1566 { 1594 {
@@ -1568,23 +1596,19 @@ void LLVoiceClient::stateMachine()
1568 } 1596 }
1569 } 1597 }
1570 } 1598 }
1571 else 1599 break;
1572 { 1600
1573 // transition out of mic tuning 1601 case stateMicTuningStop:
1574 if(mTuningCaptureRunning) 1602 {
1575 { 1603 // transition out of mic tuning
1576 tuningCaptureStopSendMessage(); 1604 tuningCaptureStopSendMessage();
1577 } 1605
1578 1606 setState(mTuningExitState);
1579 if(getState() == stateMicTuningNoLogin) 1607
1580 { 1608 // if we exited just to change devices, this will keep us from re-entering too fast.
1581 setState(stateConnectorStart); 1609 mUpdateTimer.start();
1582 } 1610 mUpdateTimer.setTimerExpirySec(UPDATE_THROTTLE_SECONDS);
1583 else 1611
1584 {
1585 setState(stateNoChannel);
1586 }
1587 }
1588 } 1612 }
1589 break; 1613 break;
1590 1614
@@ -1654,7 +1678,8 @@ void LLVoiceClient::stateMachine()
1654 } 1678 }
1655 else if(mTuningMode) 1679 else if(mTuningMode)
1656 { 1680 {
1657 setState(stateMicTuningLoggedIn); 1681 mTuningExitState = stateNoChannel;
1682 setState(stateMicTuningStart);
1658 } 1683 }
1659 else if(!mNextSessionHandle.empty()) 1684 else if(!mNextSessionHandle.empty())
1660 { 1685 {
@@ -1880,6 +1905,12 @@ void LLVoiceClient::stateMachine()
1880 case stateJail: 1905 case stateJail:
1881 // We have given up. Do nothing. 1906 // We have given up. Do nothing.
1882 break; 1907 break;
1908
1909 case stateMicTuningNoLogin:
1910 // *TODO: Implement me.
1911 llwarns << "stateMicTuningNoLogin not handled"
1912 << llendl;
1913 break;
1883 } 1914 }
1884 1915
1885 if(mParticipantMapChanged) 1916 if(mParticipantMapChanged)
@@ -2183,9 +2214,9 @@ bool LLVoiceClient::inTuningMode()
2183 bool result = false; 2214 bool result = false;
2184 switch(getState()) 2215 switch(getState())
2185 { 2216 {
2186 case stateMicTuningNoLogin: 2217 case stateMicTuningRunning:
2187 case stateMicTuningLoggedIn:
2188 result = true; 2218 result = true;
2219 break;
2189 default: 2220 default:
2190 break; 2221 break;
2191 } 2222 }
@@ -2193,10 +2224,7 @@ bool LLVoiceClient::inTuningMode()
2193} 2224}
2194 2225
2195void LLVoiceClient::tuningRenderStartSendMessage(const std::string& name, bool loop) 2226void LLVoiceClient::tuningRenderStartSendMessage(const std::string& name, bool loop)
2196{ 2227{
2197 if(!inTuningMode())
2198 return;
2199
2200 mTuningAudioFile = name; 2228 mTuningAudioFile = name;
2201 std::ostringstream stream; 2229 std::ostringstream stream;
2202 stream 2230 stream
@@ -2210,9 +2238,6 @@ void LLVoiceClient::tuningRenderStartSendMessage(const std::string& name, bool l
2210 2238
2211void LLVoiceClient::tuningRenderStopSendMessage() 2239void LLVoiceClient::tuningRenderStopSendMessage()
2212{ 2240{
2213 if(!inTuningMode())
2214 return;
2215
2216 std::ostringstream stream; 2241 std::ostringstream stream;
2217 stream 2242 stream
2218 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.RenderAudioStop.1\">" 2243 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.RenderAudioStop.1\">"
@@ -2224,9 +2249,8 @@ void LLVoiceClient::tuningRenderStopSendMessage()
2224 2249
2225void LLVoiceClient::tuningCaptureStartSendMessage(int duration) 2250void LLVoiceClient::tuningCaptureStartSendMessage(int duration)
2226{ 2251{
2227 if(!inTuningMode()) 2252 llinfos << "sending CaptureAudioStart" << llendl;
2228 return; 2253
2229
2230 std::ostringstream stream; 2254 std::ostringstream stream;
2231 stream 2255 stream
2232 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.CaptureAudioStart.1\">" 2256 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.CaptureAudioStart.1\">"
@@ -2234,15 +2258,12 @@ void LLVoiceClient::tuningCaptureStartSendMessage(int duration)
2234 << "</Request>\n\n\n"; 2258 << "</Request>\n\n\n";
2235 2259
2236 writeString(stream.str()); 2260 writeString(stream.str());
2237
2238 mTuningCaptureRunning = true;
2239} 2261}
2240 2262
2241void LLVoiceClient::tuningCaptureStopSendMessage() 2263void LLVoiceClient::tuningCaptureStopSendMessage()
2242{ 2264{
2243 if(!inTuningMode()) 2265 llinfos << "sending CaptureAudioStop" << llendl;
2244 return; 2266
2245
2246 std::ostringstream stream; 2267 std::ostringstream stream;
2247 stream 2268 stream
2248 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.CaptureAudioStop.1\">" 2269 << "<Request requestId=\"" << mCommandCookie++ << "\" action=\"Aux.CaptureAudioStop.1\">"
@@ -2250,7 +2271,7 @@ void LLVoiceClient::tuningCaptureStopSendMessage()
2250 2271
2251 writeString(stream.str()); 2272 writeString(stream.str());
2252 2273
2253 mTuningCaptureRunning = false; 2274 mTuningEnergy = 0.0f;
2254} 2275}
2255 2276
2256void LLVoiceClient::tuningSetMicVolume(float volume) 2277void LLVoiceClient::tuningSetMicVolume(float volume)
@@ -2914,12 +2935,16 @@ void LLVoiceClient::sessionNewEvent(
2914 LLUUID caller_id; 2935 LLUUID caller_id;
2915 if(IDFromName(nameString, caller_id)) 2936 if(IDFromName(nameString, caller_id))
2916 { 2937 {
2917 gIMMgr->inviteToSession(LLIMMgr::computeSessionID(IM_SESSION_P2P_INVITE, caller_id), 2938 gIMMgr->inviteToSession(
2918 LLString::null, 2939 LLIMMgr::computeSessionID(
2919 caller_id, 2940 IM_SESSION_P2P_INVITE,
2920 LLString::null, 2941 caller_id),
2921 IM_SESSION_P2P_INVITE, 2942 LLString::null,
2922 eventSessionHandle); 2943 caller_id,
2944 LLString::null,
2945 IM_SESSION_P2P_INVITE,
2946 LLIMMgr::INVITATION_TYPE_VOICE,
2947 eventSessionHandle);
2923 } 2948 }
2924 else 2949 else
2925 { 2950 {
@@ -2985,6 +3010,7 @@ void LLVoiceClient::participantPropertiesEvent(
2985 { 3010 {
2986 participant->mPTT = !isLocallyMuted; 3011 participant->mPTT = !isLocallyMuted;
2987 participant->mIsSpeaking = isSpeaking; 3012 participant->mIsSpeaking = isSpeaking;
3013 participant->mIsModeratorMuted = isModeratorMuted;
2988 if (isSpeaking) 3014 if (isSpeaking)
2989 { 3015 {
2990 participant->mSpeakingTimeout.reset(); 3016 participant->mSpeakingTimeout.reset();
@@ -3022,7 +3048,7 @@ void LLVoiceClient::muteListChanged()
3022///////////////////////////// 3048/////////////////////////////
3023// Managing list of participants 3049// Managing list of participants
3024LLVoiceClient::participantState::participantState(const std::string &uri) : 3050LLVoiceClient::participantState::participantState(const std::string &uri) :
3025 mURI(uri), mPTT(false), mIsSpeaking(false), mPower(0.0), mServiceType(serviceTypeUnknown), 3051 mURI(uri), mPTT(false), mIsSpeaking(false), mIsModeratorMuted(false), mPower(0.0), mServiceType(serviceTypeUnknown),
3026 mOnMuteList(false), mUserVolume(100), mVolumeDirty(false), mAvatarIDValid(false) 3052 mOnMuteList(false), mUserVolume(100), mVolumeDirty(false), mAvatarIDValid(false)
3027{ 3053{
3028} 3054}
@@ -3204,7 +3230,6 @@ void LLVoiceClient::parcelChanged()
3204 3230
3205 std::string url = gAgent.getRegion()->getCapability("ParcelVoiceInfoRequest"); 3231 std::string url = gAgent.getRegion()->getCapability("ParcelVoiceInfoRequest");
3206 LLSD data; 3232 LLSD data;
3207 data["method"] = "call";
3208 LLHTTPClient::post( 3233 LLHTTPClient::post(
3209 url, 3234 url,
3210 data, 3235 data,
@@ -3265,6 +3290,7 @@ void LLVoiceClient::switchChannel(
3265 { 3290 {
3266 // Leave any channel we may be in 3291 // Leave any channel we may be in
3267 llinfos << "leaving channel" << llendl; 3292 llinfos << "leaving channel" << llendl;
3293 notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED);
3268 } 3294 }
3269 else 3295 else
3270 { 3296 {
@@ -3786,6 +3812,19 @@ BOOL LLVoiceClient::getIsSpeaking(const LLUUID& id)
3786 return result; 3812 return result;
3787} 3813}
3788 3814
3815BOOL LLVoiceClient::getIsModeratorMuted(const LLUUID& id)
3816{
3817 BOOL result = FALSE;
3818
3819 participantState *participant = findParticipantByID(id);
3820 if(participant)
3821 {
3822 result = participant->mIsModeratorMuted;
3823 }
3824
3825 return result;
3826}
3827
3789F32 LLVoiceClient::getCurrentPower(const LLUUID& id) 3828F32 LLVoiceClient::getCurrentPower(const LLUUID& id)
3790{ 3829{
3791 F32 result = 0; 3830 F32 result = 0;
@@ -3956,7 +3995,14 @@ void LLVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::EStatusTy
3956 { 3995 {
3957 case 20713: status = LLVoiceClientStatusObserver::ERROR_CHANNEL_FULL; break; 3996 case 20713: status = LLVoiceClientStatusObserver::ERROR_CHANNEL_FULL; break;
3958 case 20714: status = LLVoiceClientStatusObserver::ERROR_CHANNEL_LOCKED; break; 3997 case 20714: status = LLVoiceClientStatusObserver::ERROR_CHANNEL_LOCKED; break;
3959 case 20715: status = LLVoiceClientStatusObserver::ERROR_NOT_AVAILABLE; 3998 case 20715:
3999 //invalid channel, we may be using a set of poorly cached
4000 //info
4001 status = LLVoiceClientStatusObserver::ERROR_NOT_AVAILABLE;
4002 break;
4003 case 1009:
4004 //invalid username and password
4005 status = LLVoiceClientStatusObserver::ERROR_NOT_AVAILABLE;
3960 break; 4006 break;
3961 } 4007 }
3962 4008