diff options
Diffstat (limited to 'linden/indra/newview/llvoiceclient.h')
-rw-r--r-- | linden/indra/newview/llvoiceclient.h | 441 |
1 files changed, 318 insertions, 123 deletions
diff --git a/linden/indra/newview/llvoiceclient.h b/linden/indra/newview/llvoiceclient.h index 2220d59..13dd974 100644 --- a/linden/indra/newview/llvoiceclient.h +++ b/linden/indra/newview/llvoiceclient.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -41,6 +41,7 @@ class LLVivoxProtocolParser; | |||
41 | #include "v3math.h" | 41 | #include "v3math.h" |
42 | #include "llframetimer.h" | 42 | #include "llframetimer.h" |
43 | #include "llviewerregion.h" | 43 | #include "llviewerregion.h" |
44 | #include "llcallingcard.h" // for LLFriendObserver | ||
44 | 45 | ||
45 | class LLVoiceClientParticipantObserver | 46 | class LLVoiceClientParticipantObserver |
46 | { | 47 | { |
@@ -91,41 +92,10 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient> | |||
91 | 92 | ||
92 | public: | 93 | public: |
93 | 94 | ||
94 | enum serviceType | ||
95 | { | ||
96 | serviceTypeUnknown, // Unknown, returned if no data on the avatar is available | ||
97 | serviceTypeA, // spatialized local chat | ||
98 | serviceTypeB, // remote multi-party chat | ||
99 | serviceTypeC // one-to-one and small group chat | ||
100 | }; | ||
101 | static F32 OVERDRIVEN_POWER_LEVEL; | 95 | static F32 OVERDRIVEN_POWER_LEVEL; |
102 | 96 | ||
103 | void updateSettings(); // call after loading settings and whenever they change | 97 | void updateSettings(); // call after loading settings and whenever they change |
104 | 98 | ||
105 | ///////////////////////////// | ||
106 | // session control messages | ||
107 | void connect(); | ||
108 | |||
109 | void connectorCreate(); | ||
110 | void connectorShutdown(); | ||
111 | |||
112 | void requestVoiceAccountProvision(S32 retries = 3); | ||
113 | void userAuthorized( | ||
114 | const std::string& firstName, | ||
115 | const std::string& lastName, | ||
116 | const LLUUID &agentID); | ||
117 | void login(const std::string& accountName, const std::string &password); | ||
118 | void loginSendMessage(); | ||
119 | void logout(); | ||
120 | void logoutSendMessage(); | ||
121 | |||
122 | void channelGetListSendMessage(); | ||
123 | void sessionCreateSendMessage(); | ||
124 | void sessionConnectSendMessage(); | ||
125 | void sessionTerminate(); | ||
126 | void sessionTerminateSendMessage(); | ||
127 | void sessionTerminateByHandle(std::string &sessionHandle); | ||
128 | |||
129 | void getCaptureDevicesSendMessage(); | 99 | void getCaptureDevicesSendMessage(); |
130 | void getRenderDevicesSendMessage(); | 100 | void getRenderDevicesSendMessage(); |
131 | 101 | ||
@@ -170,23 +140,32 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient> | |||
170 | 140 | ||
171 | ///////////////////////////// | 141 | ///////////////////////////// |
172 | // Response/Event handlers | 142 | // Response/Event handlers |
173 | void connectorCreateResponse(int statusCode, std::string &statusString, std::string &connectorHandle); | 143 | void connectorCreateResponse(int statusCode, std::string &statusString, std::string &connectorHandle, std::string &versionID); |
174 | void loginResponse(int statusCode, std::string &statusString, std::string &accountHandle); | 144 | void loginResponse(int statusCode, std::string &statusString, std::string &accountHandle, int numberOfAliases); |
175 | void channelGetListResponse(int statusCode, std::string &statusString); | 145 | void sessionCreateResponse(std::string &requestId, int statusCode, std::string &statusString, std::string &sessionHandle); |
176 | void sessionCreateResponse(int statusCode, std::string &statusString, std::string &sessionHandle); | 146 | void sessionGroupAddSessionResponse(std::string &requestId, int statusCode, std::string &statusString, std::string &sessionHandle); |
177 | void sessionConnectResponse(int statusCode, std::string &statusString); | 147 | void sessionConnectResponse(std::string &requestId, int statusCode, std::string &statusString); |
178 | void sessionTerminateResponse(int statusCode, std::string &statusString); | ||
179 | void logoutResponse(int statusCode, std::string &statusString); | 148 | void logoutResponse(int statusCode, std::string &statusString); |
180 | void connectorShutdownResponse(int statusCode, std::string &statusString); | 149 | void connectorShutdownResponse(int statusCode, std::string &statusString); |
181 | 150 | ||
182 | void loginStateChangeEvent(std::string &accountHandle, int statusCode, std::string &statusString, int state); | 151 | void accountLoginStateChangeEvent(std::string &accountHandle, int statusCode, std::string &statusString, int state); |
183 | void sessionNewEvent(std::string &accountHandle, std::string &eventSessionHandle, int state, std::string &nameString, std::string &uriString); | 152 | void mediaStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, int statusCode, std::string &statusString, int state, bool incoming); |
184 | void sessionStateChangeEvent(std::string &uriString, int statusCode, std::string &statusString, std::string &sessionHandle, int state, bool isChannel, std::string &nameString); | 153 | void textStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, bool enabled, int state, bool incoming); |
185 | void participantStateChangeEvent(std::string &uriString, int statusCode, std::string &statusString, int state, std::string &nameString, std::string &displayNameString, int participantType); | 154 | void sessionAddedEvent(std::string &uriString, std::string &alias, std::string &sessionHandle, std::string &sessionGroupHandle, bool isChannel, bool incoming, std::string &nameString, std::string &applicationString); |
186 | void participantPropertiesEvent(std::string &uriString, int statusCode, std::string &statusString, bool isLocallyMuted, bool isModeratorMuted, bool isSpeaking, int volume, F32 energy); | 155 | void sessionGroupAddedEvent(std::string &sessionGroupHandle); |
156 | void sessionRemovedEvent(std::string &sessionHandle, std::string &sessionGroupHandle); | ||
157 | void participantAddedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, std::string &uriString, std::string &alias, std::string &nameString, std::string &displayNameString, int participantType); | ||
158 | void participantRemovedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, std::string &uriString, std::string &alias, std::string &nameString); | ||
159 | void participantUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, std::string &uriString, std::string &alias, bool isModeratorMuted, bool isSpeaking, int volume, F32 energy); | ||
187 | void auxAudioPropertiesEvent(F32 energy); | 160 | void auxAudioPropertiesEvent(F32 energy); |
188 | 161 | void buddyPresenceEvent(std::string &uriString, std::string &alias, std::string &statusString, std::string &applicationString); | |
162 | void messageEvent(std::string &sessionHandle, std::string &uriString, std::string &alias, std::string &messageHeader, std::string &messageBody, std::string &applicationString); | ||
163 | void sessionNotificationEvent(std::string &sessionHandle, std::string &uriString, std::string ¬ificationType); | ||
164 | void subscriptionEvent(std::string &buddyURI, std::string &subscriptionHandle, std::string &alias, std::string &displayName, std::string &applicationString, std::string &subscriptionType); | ||
165 | |||
166 | void buddyListChanged(); | ||
189 | void muteListChanged(); | 167 | void muteListChanged(); |
168 | void updateFriends(U32 mask); | ||
190 | 169 | ||
191 | ///////////////////////////// | 170 | ///////////////////////////// |
192 | // Sending updates of current state | 171 | // Sending updates of current state |
@@ -210,7 +189,6 @@ static void updatePosition(void); | |||
210 | void setVoiceVolume(F32 volume); | 189 | void setVoiceVolume(F32 volume); |
211 | void setMicGain(F32 volume); | 190 | void setMicGain(F32 volume); |
212 | void setUserVolume(const LLUUID& id, F32 volume); // set's volume for specified agent, from 0-1 (where .5 is nominal) | 191 | void setUserVolume(const LLUUID& id, F32 volume); // set's volume for specified agent, from 0-1 (where .5 is nominal) |
213 | void setVivoxDebugServerName(std::string &serverName); | ||
214 | void setLipSyncEnabled(BOOL enabled); | 192 | void setLipSyncEnabled(BOOL enabled); |
215 | BOOL lipSyncEnabled(); | 193 | BOOL lipSyncEnabled(); |
216 | 194 | ||
@@ -225,57 +203,261 @@ static void updatePosition(void); | |||
225 | BOOL getIsSpeaking(const LLUUID& id); | 203 | BOOL getIsSpeaking(const LLUUID& id); |
226 | BOOL getIsModeratorMuted(const LLUUID& id); | 204 | BOOL getIsModeratorMuted(const LLUUID& id); |
227 | F32 getCurrentPower(const LLUUID& id); // "power" is related to "amplitude" in a defined way. I'm just not sure what the formula is... | 205 | F32 getCurrentPower(const LLUUID& id); // "power" is related to "amplitude" in a defined way. I'm just not sure what the formula is... |
228 | BOOL getPTTPressed(const LLUUID& id); // This is the inverse of the "locally muted" property. | ||
229 | BOOL getOnMuteList(const LLUUID& id); | 206 | BOOL getOnMuteList(const LLUUID& id); |
230 | F32 getUserVolume(const LLUUID& id); | 207 | F32 getUserVolume(const LLUUID& id); |
231 | std::string getDisplayName(const LLUUID& id); | 208 | std::string getDisplayName(const LLUUID& id); |
232 | 209 | ||
233 | // MBW -- XXX -- Not sure how to get this data out of the TVC | 210 | // MBW -- XXX -- Not sure how to get this data out of the TVC |
234 | BOOL getUsingPTT(const LLUUID& id); | 211 | BOOL getUsingPTT(const LLUUID& id); |
235 | serviceType getServiceType(const LLUUID& id); // type of chat the user is involved in (see bHear scope doc for definitions of A/B/C) | ||
236 | std::string getGroupID(const LLUUID& id); // group ID if the user is in group chat (empty string if not applicable) | 212 | std::string getGroupID(const LLUUID& id); // group ID if the user is in group chat (empty string if not applicable) |
237 | 213 | ||
238 | ///////////////////////////// | 214 | ///////////////////////////// |
239 | BOOL getAreaVoiceDisabled(); // returns true if the area the avatar is in is speech-disabled. | 215 | BOOL getAreaVoiceDisabled(); // returns true if the area the avatar is in is speech-disabled. |
240 | // Use this to determine whether to show a "no speech" icon in the menu bar. | 216 | // Use this to determine whether to show a "no speech" icon in the menu bar. |
217 | |||
218 | ///////////////////////////// | ||
219 | // Recording controls | ||
220 | void recordingLoopStart(int seconds = 3600, int deltaFramesPerControlFrame = 200); | ||
221 | void recordingLoopSave(const std::string& filename); | ||
222 | void recordingStop(); | ||
223 | |||
224 | // Playback controls | ||
225 | void filePlaybackStart(const std::string& filename); | ||
226 | void filePlaybackStop(); | ||
227 | void filePlaybackSetPaused(bool paused); | ||
228 | void filePlaybackSetMode(bool vox = false, float speed = 1.0f); | ||
229 | |||
230 | |||
231 | // This is used by the string-keyed maps below, to avoid storing the string twice. | ||
232 | // The 'const std::string *' in the key points to a string actually stored in the object referenced by the map. | ||
233 | // The add and delete operations for each map allocate and delete in the right order to avoid dangling references. | ||
234 | // The default compare operation would just compare pointers, which is incorrect, so they must use this comparitor instead. | ||
235 | struct stringMapComparitor | ||
236 | { | ||
237 | bool operator()(const std::string* a, const std::string * b) const | ||
238 | { | ||
239 | return a->compare(*b) < 0; | ||
240 | } | ||
241 | }; | ||
241 | 242 | ||
243 | struct uuidMapComparitor | ||
244 | { | ||
245 | bool operator()(const LLUUID* a, const LLUUID * b) const | ||
246 | { | ||
247 | return *a < *b; | ||
248 | } | ||
249 | }; | ||
250 | |||
242 | struct participantState | 251 | struct participantState |
243 | { | 252 | { |
244 | public: | 253 | public: |
245 | participantState(const std::string &uri); | 254 | participantState(const std::string &uri); |
255 | |||
256 | bool updateMuteState(); | ||
257 | |||
246 | std::string mURI; | 258 | std::string mURI; |
247 | std::string mName; | 259 | LLUUID mAvatarID; |
260 | std::string mAccountName; | ||
248 | std::string mDisplayName; | 261 | std::string mDisplayName; |
249 | bool mPTT; | ||
250 | bool mIsSpeaking; | ||
251 | bool mIsModeratorMuted; | ||
252 | LLFrameTimer mSpeakingTimeout; | 262 | LLFrameTimer mSpeakingTimeout; |
253 | F32 mLastSpokeTimestamp; | 263 | F32 mLastSpokeTimestamp; |
254 | F32 mPower; | 264 | F32 mPower; |
255 | int mVolume; | 265 | int mVolume; |
256 | serviceType mServiceType; | ||
257 | std::string mGroupID; | 266 | std::string mGroupID; |
258 | bool mOnMuteList; // true if this avatar is on the user's mute list (and should be muted) | ||
259 | int mUserVolume; | 267 | int mUserVolume; |
268 | bool mPTT; | ||
269 | bool mIsSpeaking; | ||
270 | bool mIsModeratorMuted; | ||
271 | bool mOnMuteList; // true if this avatar is on the user's mute list (and should be muted) | ||
260 | bool mVolumeDirty; // true if this participant needs a volume command sent (either mOnMuteList or mUserVolume has changed) | 272 | bool mVolumeDirty; // true if this participant needs a volume command sent (either mOnMuteList or mUserVolume has changed) |
261 | bool mAvatarIDValid; | 273 | bool mAvatarIDValid; |
262 | LLUUID mAvatarID; | 274 | bool mIsSelf; |
275 | }; | ||
276 | typedef std::map<const std::string *, participantState*, stringMapComparitor> participantMap; | ||
277 | |||
278 | typedef std::map<const LLUUID *, participantState*, uuidMapComparitor> participantUUIDMap; | ||
279 | |||
280 | enum streamState | ||
281 | { | ||
282 | streamStateUnknown = 0, | ||
283 | streamStateIdle = 1, | ||
284 | streamStateConnected = 2, | ||
285 | streamStateRinging = 3, | ||
263 | }; | 286 | }; |
264 | typedef std::map<std::string, participantState*> participantMap; | ||
265 | 287 | ||
266 | participantState *findParticipant(const std::string &uri); | 288 | struct sessionState |
267 | participantState *findParticipantByAvatar(LLVOAvatar *avatar); | 289 | { |
290 | public: | ||
291 | sessionState(); | ||
292 | ~sessionState(); | ||
293 | |||
294 | participantState *addParticipant(const std::string &uri); | ||
295 | // Note: after removeParticipant returns, the participant* that was passed to it will have been deleted. | ||
296 | // Take care not to use the pointer again after that. | ||
297 | void removeParticipant(participantState *participant); | ||
298 | void removeAllParticipants(); | ||
299 | |||
300 | participantState *findParticipant(const std::string &uri); | ||
301 | participantState *findParticipantByID(const LLUUID& id); | ||
302 | |||
303 | std::string mHandle; | ||
304 | std::string mGroupHandle; | ||
305 | std::string mSIPURI; | ||
306 | std::string mAlias; | ||
307 | std::string mName; | ||
308 | std::string mAlternateSIPURI; | ||
309 | std::string mHash; // Channel password | ||
310 | std::string mErrorStatusString; | ||
311 | std::queue<std::string> mTextMsgQueue; | ||
312 | |||
313 | LLUUID mIMSessionID; | ||
314 | LLUUID mCallerID; | ||
315 | int mErrorStatusCode; | ||
316 | int mMediaStreamState; | ||
317 | int mTextStreamState; | ||
318 | bool mCreateInProgress; // True if a Session.Create has been sent for this session and no response has been received yet. | ||
319 | bool mMediaConnectInProgress; // True if a Session.MediaConnect has been sent for this session and no response has been received yet. | ||
320 | bool mVoiceInvitePending; // True if a voice invite is pending for this session (usually waiting on a name lookup) | ||
321 | bool mTextInvitePending; // True if a text invite is pending for this session (usually waiting on a name lookup) | ||
322 | bool mSynthesizedCallerID; // True if the caller ID is a hash of the SIP URI -- this means we shouldn't do a name lookup. | ||
323 | bool mIsChannel; // True for both group and spatial channels (false for p2p, PSTN) | ||
324 | bool mIsSpatial; // True for spatial channels | ||
325 | bool mIsP2P; | ||
326 | bool mIncoming; | ||
327 | bool mVoiceEnabled; | ||
328 | bool mReconnect; // Whether we should try to reconnect to this session if it's dropped | ||
329 | // Set to true when the mute state of someone in the participant list changes. | ||
330 | // The code will have to walk the list to find the changed participant(s). | ||
331 | bool mVolumeDirty; | ||
332 | |||
333 | bool mParticipantsChanged; | ||
334 | participantMap mParticipantsByURI; | ||
335 | participantUUIDMap mParticipantsByUUID; | ||
336 | }; | ||
337 | |||
268 | participantState *findParticipantByID(const LLUUID& id); | 338 | participantState *findParticipantByID(const LLUUID& id); |
269 | |||
270 | participantMap *getParticipantList(void); | 339 | participantMap *getParticipantList(void); |
340 | |||
341 | typedef std::map<const std::string*, sessionState*, stringMapComparitor> sessionMap; | ||
342 | typedef std::set<sessionState*> sessionSet; | ||
343 | |||
344 | typedef sessionSet::iterator sessionIterator; | ||
345 | sessionIterator sessionsBegin(void); | ||
346 | sessionIterator sessionsEnd(void); | ||
347 | |||
348 | sessionState *findSession(const std::string &handle); | ||
349 | sessionState *findSessionBeingCreatedByURI(const std::string &uri); | ||
350 | sessionState *findSession(const LLUUID &participant_id); | ||
351 | sessionState *findSessionByCreateID(const std::string &create_id); | ||
352 | |||
353 | sessionState *addSession(const std::string &uri, const std::string &handle = LLStringUtil::null); | ||
354 | void setSessionHandle(sessionState *session, const std::string &handle = LLStringUtil::null); | ||
355 | void setSessionURI(sessionState *session, const std::string &uri); | ||
356 | void deleteSession(sessionState *session); | ||
357 | void deleteAllSessions(void); | ||
358 | |||
359 | void verifySessionState(void); | ||
360 | |||
361 | void joinedAudioSession(sessionState *session); | ||
362 | void leftAudioSession(sessionState *session); | ||
363 | |||
364 | // This is called in several places where the session _may_ need to be deleted. | ||
365 | // It contains logic for whether to delete the session or keep it around. | ||
366 | void reapSession(sessionState *session); | ||
367 | |||
368 | // Returns true if the session seems to indicate we've moved to a region on a different voice server | ||
369 | bool sessionNeedsRelog(sessionState *session); | ||
370 | |||
371 | struct buddyListEntry | ||
372 | { | ||
373 | buddyListEntry(const std::string &uri); | ||
374 | std::string mURI; | ||
375 | std::string mDisplayName; | ||
376 | LLUUID mUUID; | ||
377 | bool mOnlineSL; | ||
378 | bool mOnlineSLim; | ||
379 | bool mCanSeeMeOnline; | ||
380 | bool mHasBlockListEntry; | ||
381 | bool mHasAutoAcceptListEntry; | ||
382 | bool mNameResolved; | ||
383 | bool mInSLFriends; | ||
384 | bool mInVivoxBuddies; | ||
385 | bool mNeedsNameUpdate; | ||
386 | }; | ||
387 | |||
388 | typedef std::map<const std::string*, buddyListEntry*, stringMapComparitor> buddyListMap; | ||
389 | |||
390 | // This should be called when parsing a buddy list entry sent by SLVoice. | ||
391 | void processBuddyListEntry(const std::string &uri, const std::string &displayName); | ||
392 | |||
393 | buddyListEntry *addBuddy(const std::string &uri); | ||
394 | buddyListEntry *addBuddy(const std::string &uri, const std::string &displayName); | ||
395 | buddyListEntry *findBuddy(const std::string &uri); | ||
396 | buddyListEntry *findBuddy(const LLUUID &id); | ||
397 | buddyListEntry *findBuddyByDisplayName(const std::string &name); | ||
398 | void deleteBuddy(const std::string &uri); | ||
399 | void deleteAllBuddies(void); | ||
400 | |||
401 | void deleteAllBlockRules(void); | ||
402 | void addBlockRule(const std::string &blockMask, const std::string &presenceOnly); | ||
403 | void deleteAllAutoAcceptRules(void); | ||
404 | void addAutoAcceptRule(const std::string &autoAcceptMask, const std::string &autoAddAsBuddy); | ||
405 | void accountListBlockRulesResponse(int statusCode, const std::string &statusString); | ||
406 | void accountListAutoAcceptRulesResponse(int statusCode, const std::string &statusString); | ||
407 | |||
408 | ///////////////////////////// | ||
409 | // session control messages | ||
410 | void connectorCreate(); | ||
411 | void connectorShutdown(); | ||
271 | 412 | ||
413 | void requestVoiceAccountProvision(S32 retries = 3); | ||
414 | void userAuthorized( | ||
415 | const std::string& firstName, | ||
416 | const std::string& lastName, | ||
417 | const LLUUID &agentID); | ||
418 | void login( | ||
419 | const std::string& account_name, | ||
420 | const std::string& password, | ||
421 | const std::string& voice_sip_uri_hostname, | ||
422 | const std::string& voice_account_server_uri); | ||
423 | void loginSendMessage(); | ||
424 | void logout(); | ||
425 | void logoutSendMessage(); | ||
426 | |||
427 | void accountListBlockRulesSendMessage(); | ||
428 | void accountListAutoAcceptRulesSendMessage(); | ||
429 | |||
430 | void sessionGroupCreateSendMessage(); | ||
431 | void sessionCreateSendMessage(sessionState *session, bool startAudio = true, bool startText = false); | ||
432 | void sessionGroupAddSessionSendMessage(sessionState *session, bool startAudio = true, bool startText = false); | ||
433 | void sessionMediaConnectSendMessage(sessionState *session); // just joins the audio session | ||
434 | void sessionTextConnectSendMessage(sessionState *session); // just joins the text session | ||
435 | void sessionTerminateSendMessage(sessionState *session); | ||
436 | void sessionMediaDisconnectSendMessage(sessionState *session); | ||
437 | void sessionTextDisconnectSendMessage(sessionState *session); | ||
438 | |||
439 | // Pokes the state machine to leave the audio session next time around. | ||
440 | void sessionTerminate(); | ||
441 | |||
442 | // Pokes the state machine to shut down the connector and restart it. | ||
443 | void requestRelog(); | ||
444 | |||
445 | // Does the actual work to get out of the audio session | ||
446 | void leaveAudioSession(); | ||
447 | |||
272 | void addObserver(LLVoiceClientParticipantObserver* observer); | 448 | void addObserver(LLVoiceClientParticipantObserver* observer); |
273 | void removeObserver(LLVoiceClientParticipantObserver* observer); | 449 | void removeObserver(LLVoiceClientParticipantObserver* observer); |
274 | 450 | ||
275 | void addStatusObserver(LLVoiceClientStatusObserver* observer); | 451 | void addObserver(LLVoiceClientStatusObserver* observer); |
276 | void removeStatusObserver(LLVoiceClientStatusObserver* observer); | 452 | void removeObserver(LLVoiceClientStatusObserver* observer); |
453 | |||
454 | void addObserver(LLFriendObserver* observer); | ||
455 | void removeObserver(LLFriendObserver* observer); | ||
456 | |||
457 | void lookupName(const LLUUID &id); | ||
458 | static void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* user_data); | ||
459 | void avatarNameResolved(const LLUUID &id, const std::string &name); | ||
277 | 460 | ||
278 | // static void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* user_data); | ||
279 | typedef std::vector<std::string> deviceList; | 461 | typedef std::vector<std::string> deviceList; |
280 | 462 | ||
281 | deviceList *getCaptureDevices(); | 463 | deviceList *getCaptureDevices(); |
@@ -287,8 +469,16 @@ static void updatePosition(void); | |||
287 | void setSpatialChannel( | 469 | void setSpatialChannel( |
288 | const std::string &uri, | 470 | const std::string &uri, |
289 | const std::string &credentials); | 471 | const std::string &credentials); |
290 | void callUser(LLUUID &uuid); | 472 | // start a voice session with the specified user |
291 | void answerInvite(std::string &sessionHandle, LLUUID& other_user_id); | 473 | void callUser(const LLUUID &uuid); |
474 | |||
475 | // Send a text message to the specified user, initiating the session if necessary. | ||
476 | bool sendTextMessage(const LLUUID& participant_id, const std::string& message); | ||
477 | |||
478 | // close any existing text IM session with the specified user | ||
479 | void endUserIMSession(const LLUUID &uuid); | ||
480 | |||
481 | bool answerInvite(std::string &sessionHandle); | ||
292 | void declineInvite(std::string &sessionHandle); | 482 | void declineInvite(std::string &sessionHandle); |
293 | void leaveNonSpatialChannel(); | 483 | void leaveNonSpatialChannel(); |
294 | 484 | ||
@@ -301,33 +491,37 @@ static void updatePosition(void); | |||
301 | bool inProximalChannel(); | 491 | bool inProximalChannel(); |
302 | 492 | ||
303 | std::string sipURIFromID(const LLUUID &id); | 493 | std::string sipURIFromID(const LLUUID &id); |
304 | 494 | ||
495 | // Returns true if the indicated user is online via SIP presence according to SLVoice. | ||
496 | // Note that we only get SIP presence data for other users that are in our vivox buddy list. | ||
497 | bool isOnlineSIP(const LLUUID &id); | ||
498 | |||
305 | private: | 499 | private: |
306 | 500 | ||
307 | // internal state for a simple state machine. This is used to deal with the asynchronous nature of some of the messages. | 501 | // internal state for a simple state machine. This is used to deal with the asynchronous nature of some of the messages. |
308 | // Note: if you change this list, please make corresponding changes to LLVoiceClient::state2string(). | 502 | // Note: if you change this list, please make corresponding changes to LLVoiceClient::state2string(). |
309 | enum state | 503 | enum state |
310 | { | 504 | { |
505 | stateDisableCleanup, | ||
311 | stateDisabled, // Voice is turned off. | 506 | stateDisabled, // Voice is turned off. |
312 | stateStart, // Class is initialized, socket is created | 507 | stateStart, // Class is initialized, socket is created |
313 | stateDaemonLaunched, // Daemon has been launched | 508 | stateDaemonLaunched, // Daemon has been launched |
314 | stateConnecting, // connect() call has been issued | 509 | stateConnecting, // connect() call has been issued |
510 | stateConnected, // connection to the daemon has been made, send some initial setup commands. | ||
315 | stateIdle, // socket is connected, ready for messaging | 511 | stateIdle, // socket is connected, ready for messaging |
512 | stateMicTuningStart, | ||
513 | stateMicTuningRunning, | ||
514 | stateMicTuningStop, | ||
316 | stateConnectorStart, // connector needs to be started | 515 | stateConnectorStart, // connector needs to be started |
317 | stateConnectorStarting, // waiting for connector handle | 516 | stateConnectorStarting, // waiting for connector handle |
318 | stateConnectorStarted, // connector handle received | 517 | stateConnectorStarted, // connector handle received |
319 | stateMicTuningNoLogin, // mic tuning before login | ||
320 | stateLoginRetry, // need to retry login (failed due to changing password) | 518 | stateLoginRetry, // need to retry login (failed due to changing password) |
321 | stateLoginRetryWait, // waiting for retry timer | 519 | stateLoginRetryWait, // waiting for retry timer |
322 | stateNeedsLogin, // send login request | 520 | stateNeedsLogin, // send login request |
323 | stateLoggingIn, // waiting for account handle | 521 | stateLoggingIn, // waiting for account handle |
324 | stateLoggedIn, // account handle received | 522 | stateLoggedIn, // account handle received |
523 | stateCreatingSessionGroup, // Creating the main session group | ||
325 | stateNoChannel, // | 524 | stateNoChannel, // |
326 | stateMicTuningStart, | ||
327 | stateMicTuningRunning, | ||
328 | stateMicTuningStop, | ||
329 | stateSessionCreate, // need to send Session.Create command | ||
330 | stateSessionConnect, // need to send Session.Connect command | ||
331 | stateJoiningSession, // waiting for session handle | 525 | stateJoiningSession, // waiting for session handle |
332 | stateSessionJoined, // session handle received | 526 | stateSessionJoined, // session handle received |
333 | stateRunning, // in session, steady state | 527 | stateRunning, // in session, steady state |
@@ -354,7 +548,7 @@ static void updatePosition(void); | |||
354 | 548 | ||
355 | state mState; | 549 | state mState; |
356 | bool mSessionTerminateRequested; | 550 | bool mSessionTerminateRequested; |
357 | bool mNonSpatialChannel; | 551 | bool mRelogRequested; |
358 | 552 | ||
359 | void setState(state inState); | 553 | void setState(state inState); |
360 | state getState(void) { return mState; }; | 554 | state getState(void) { return mState; }; |
@@ -377,18 +571,7 @@ static void updatePosition(void); | |||
377 | std::string mAccountDisplayName; | 571 | std::string mAccountDisplayName; |
378 | std::string mAccountFirstName; | 572 | std::string mAccountFirstName; |
379 | std::string mAccountLastName; | 573 | std::string mAccountLastName; |
380 | 574 | ||
381 | std::string mNextP2PSessionURI; // URI of the P2P session to join next | ||
382 | std::string mNextSessionURI; // URI of the session to join next | ||
383 | std::string mNextSessionHandle; // Session handle of the session to join next | ||
384 | std::string mNextSessionHash; // Password hash for the session to join next | ||
385 | bool mNextSessionSpatial; // Will next session be a spatial chat? | ||
386 | bool mNextSessionNoReconnect; // Next session should not auto-reconnect (i.e. user -> user chat) | ||
387 | bool mNextSessionResetOnClose; // If this is true, go back to spatial chat when the next session terminates. | ||
388 | |||
389 | std::string mSessionStateEventHandle; // session handle received in SessionStateChangeEvents | ||
390 | std::string mSessionStateEventURI; // session URI received in SessionStateChangeEvents | ||
391 | |||
392 | bool mTuningMode; | 575 | bool mTuningMode; |
393 | float mTuningEnergy; | 576 | float mTuningEnergy; |
394 | std::string mTuningAudioFile; | 577 | std::string mTuningAudioFile; |
@@ -399,32 +582,40 @@ static void updatePosition(void); | |||
399 | state mTuningExitState; // state to return to when we leave tuning mode. | 582 | state mTuningExitState; // state to return to when we leave tuning mode. |
400 | 583 | ||
401 | std::string mSpatialSessionURI; | 584 | std::string mSpatialSessionURI; |
402 | 585 | std::string mSpatialSessionCredentials; | |
403 | bool mSessionResetOnClose; | 586 | |
404 | 587 | std::string mMainSessionGroupHandle; // handle of the "main" session group. | |
405 | int mVivoxErrorStatusCode; | ||
406 | std::string mVivoxErrorStatusString; | ||
407 | 588 | ||
408 | std::string mChannelName; // Name of the channel to be looked up | 589 | std::string mChannelName; // Name of the channel to be looked up |
409 | bool mAreaVoiceDisabled; | 590 | bool mAreaVoiceDisabled; |
410 | std::string mSessionURI; // URI of the session we're in. | 591 | sessionState *mAudioSession; // Session state for the current audio session |
411 | bool mSessionP2P; // true if this session is a p2p call | 592 | bool mAudioSessionChanged; // set to true when the above pointer gets changed, so observers can be notified. |
593 | |||
594 | sessionState *mNextAudioSession; // Session state for the audio session we're trying to join | ||
595 | |||
596 | // std::string mSessionURI; // URI of the session we're in. | ||
597 | // std::string mSessionHandle; // returned by ? | ||
412 | 598 | ||
413 | S32 mCurrentParcelLocalID; // Used to detect parcel boundary crossings | 599 | S32 mCurrentParcelLocalID; // Used to detect parcel boundary crossings |
414 | std::string mCurrentRegionName; // Used to detect parcel boundary crossings | 600 | std::string mCurrentRegionName; // Used to detect parcel boundary crossings |
415 | 601 | ||
416 | std::string mConnectorHandle; // returned by "Create Connector" message | 602 | std::string mConnectorHandle; // returned by "Create Connector" message |
417 | std::string mAccountHandle; // returned by login message | 603 | std::string mAccountHandle; // returned by login message |
418 | std::string mSessionHandle; // returned by ? | 604 | int mNumberOfAliases; |
419 | U32 mCommandCookie; | 605 | U32 mCommandCookie; |
420 | 606 | ||
421 | std::string mAccountServerName; | 607 | std::string mVoiceAccountServerURI; |
422 | std::string mAccountServerURI; | 608 | std::string mVoiceSIPURIHostName; |
423 | 609 | ||
424 | int mLoginRetryCount; | 610 | int mLoginRetryCount; |
425 | 611 | ||
426 | participantMap mParticipantMap; | 612 | sessionMap mSessionsByHandle; // Active sessions, indexed by session handle. Sessions which are being initiated may not be in this map. |
427 | bool mParticipantMapChanged; | 613 | sessionSet mSessions; // All sessions, not indexed. This is the canonical session list. |
614 | |||
615 | bool mBuddyListMapPopulated; | ||
616 | bool mBlockRulesListReceived; | ||
617 | bool mAutoAcceptRulesListReceived; | ||
618 | buddyListMap mBuddyListMap; | ||
428 | 619 | ||
429 | deviceList mCaptureDevices; | 620 | deviceList mCaptureDevices; |
430 | deviceList mRenderDevices; | 621 | deviceList mRenderDevices; |
@@ -434,40 +625,41 @@ static void updatePosition(void); | |||
434 | bool mCaptureDeviceDirty; | 625 | bool mCaptureDeviceDirty; |
435 | bool mRenderDeviceDirty; | 626 | bool mRenderDeviceDirty; |
436 | 627 | ||
437 | participantState *addParticipant(const std::string &uri); | ||
438 | // Note: after removeParticipant returns, the participant* that was passed to it will have been deleted. | ||
439 | // Take care not to use the pointer again after that. | ||
440 | void removeParticipant(participantState *participant); | ||
441 | void removeAllParticipants(); | ||
442 | |||
443 | void updateMuteState(participantState *participant); | ||
444 | |||
445 | typedef std::map<std::string, std::string> channelMap; | ||
446 | channelMap mChannelMap; | ||
447 | |||
448 | // These are used by the parser when processing a channel list response. | ||
449 | void clearChannelMap(void); | ||
450 | void addChannelMapEntry(std::string &name, std::string &uri); | ||
451 | std::string findChannelURI(std::string &name); | ||
452 | |||
453 | // This should be called when the code detects we have changed parcels. | 628 | // This should be called when the code detects we have changed parcels. |
454 | // It initiates the call to the server that gets the parcel channel. | 629 | // It initiates the call to the server that gets the parcel channel. |
455 | void parcelChanged(); | 630 | void parcelChanged(); |
456 | 631 | ||
457 | void switchChannel(std::string uri = std::string(), bool spatial = true, bool noReconnect = false, std::string hash = ""); | 632 | void switchChannel(std::string uri = std::string(), bool spatial = true, bool no_reconnect = false, bool is_p2p = false, std::string hash = ""); |
458 | void joinSession(std::string handle, std::string uri); | 633 | void joinSession(sessionState *session); |
459 | 634 | ||
460 | std::string nameFromAvatar(LLVOAvatar *avatar); | 635 | static std::string nameFromAvatar(LLVOAvatar *avatar); |
461 | std::string nameFromID(const LLUUID &id); | 636 | static std::string nameFromID(const LLUUID &id); |
462 | bool IDFromName(const std::string name, LLUUID &uuid); | 637 | static bool IDFromName(const std::string name, LLUUID &uuid); |
463 | std::string displayNameFromAvatar(LLVOAvatar *avatar); | 638 | static std::string displayNameFromAvatar(LLVOAvatar *avatar); |
464 | std::string sipURIFromAvatar(LLVOAvatar *avatar); | 639 | std::string sipURIFromAvatar(LLVOAvatar *avatar); |
465 | std::string sipURIFromName(std::string &name); | 640 | std::string sipURIFromName(std::string &name); |
641 | |||
642 | // Returns the name portion of the SIP URI if the string looks vaguely like a SIP URI, or an empty string if not. | ||
643 | static std::string nameFromsipURI(const std::string &uri); | ||
644 | |||
645 | bool inSpatialChannel(void); | ||
646 | std::string getAudioSessionURI(); | ||
647 | std::string getAudioSessionHandle(); | ||
466 | 648 | ||
467 | void sendPositionalUpdate(void); | 649 | void sendPositionalUpdate(void); |
468 | 650 | ||
469 | void buildSetCaptureDevice(std::ostringstream &stream); | 651 | void buildSetCaptureDevice(std::ostringstream &stream); |
470 | void buildSetRenderDevice(std::ostringstream &stream); | 652 | void buildSetRenderDevice(std::ostringstream &stream); |
653 | void buildLocalAudioUpdates(std::ostringstream &stream); | ||
654 | |||
655 | void clearAllLists(); | ||
656 | void checkFriend(const LLUUID& id); | ||
657 | void sendFriendsListUpdates(); | ||
658 | |||
659 | // start a text IM session with the specified user | ||
660 | // This will be asynchronous, the session may be established at a future time. | ||
661 | sessionState* startUserIMSession(const LLUUID& uuid); | ||
662 | void sendQueuedTextMessages(sessionState *session); | ||
471 | 663 | ||
472 | void enforceTether(void); | 664 | void enforceTether(void); |
473 | 665 | ||
@@ -491,10 +683,9 @@ static void updatePosition(void); | |||
491 | bool mPTTIsToggle; | 683 | bool mPTTIsToggle; |
492 | bool mUserPTTState; | 684 | bool mUserPTTState; |
493 | bool mMuteMic; | 685 | bool mMuteMic; |
494 | 686 | ||
495 | // Set to true when the mute state of someone in the participant list changes. | 687 | // Set to true when the friends list is known to have changed. |
496 | // The code will have to walk the list to find the changed participant(s). | 688 | bool mFriendsListDirty; |
497 | bool mVolumeDirty; | ||
498 | 689 | ||
499 | enum | 690 | enum |
500 | { | 691 | { |
@@ -522,14 +713,18 @@ static void updatePosition(void); | |||
522 | BOOL mLipSyncEnabled; | 713 | BOOL mLipSyncEnabled; |
523 | 714 | ||
524 | typedef std::set<LLVoiceClientParticipantObserver*> observer_set_t; | 715 | typedef std::set<LLVoiceClientParticipantObserver*> observer_set_t; |
525 | observer_set_t mObservers; | 716 | observer_set_t mParticipantObservers; |
526 | 717 | ||
527 | void notifyObservers(); | 718 | void notifyParticipantObservers(); |
528 | 719 | ||
529 | typedef std::set<LLVoiceClientStatusObserver*> status_observer_set_t; | 720 | typedef std::set<LLVoiceClientStatusObserver*> status_observer_set_t; |
530 | status_observer_set_t mStatusObservers; | 721 | status_observer_set_t mStatusObservers; |
531 | 722 | ||
532 | void notifyStatusObservers(LLVoiceClientStatusObserver::EStatusType status); | 723 | void notifyStatusObservers(LLVoiceClientStatusObserver::EStatusType status); |
724 | |||
725 | typedef std::set<LLFriendObserver*> friend_observer_set_t; | ||
726 | friend_observer_set_t mFriendObservers; | ||
727 | void notifyFriendObservers(); | ||
533 | }; | 728 | }; |
534 | 729 | ||
535 | extern LLVoiceClient *gVoiceClient; | 730 | extern LLVoiceClient *gVoiceClient; |