PageRenderTime 17ms CodeModel.GetById 2ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llcallfloater.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 273 lines | 93 code | 43 blank | 137 comment | 0 complexity | fe68ede9acb659021aa296d05b596049 MD5 | raw file
  1/** 
  2 * @file llcallfloater.h
  3 * @author Mike Antipov
  4 * @brief Voice Control Panel in a Voice Chats (P2P, Group, Nearby...).
  5 *
  6 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LL_LLCALLFLOATER_H
 29#define LL_LLCALLFLOATER_H
 30
 31#include "lltransientdockablefloater.h"
 32#include "llvoicechannel.h"
 33#include "llvoiceclient.h"
 34
 35class LLAvatarList;
 36class LLAvatarListItem;
 37class LLAvatarName;
 38class LLNonAvatarCaller;
 39class LLOutputMonitorCtrl;
 40class LLParticipantList;
 41class LLSpeakerMgr;
 42class LLSpeakersDelayActionsStorage;
 43
 44/**
 45 * The Voice Control Panel is an ambient window summoned by clicking the flyout chevron
 46 * on the Speak button. It can be torn-off and freely positioned onscreen.
 47 *
 48 * When the Resident is engaged in Voice Chat, the Voice Control Panel provides control
 49 * over the audible volume of each of the other participants, the Resident's own Voice
 50 * Morphing settings (if she has subscribed to enable the feature), and Voice Recording.
 51 *
 52 * When the Resident is engaged in any chat except Nearby Chat, the Voice Control Panel
 53 * also provides a 'Leave Call' button to allow the Resident to leave that voice channel.
 54 */
 55class LLCallFloater : public LLTransientDockableFloater, LLVoiceClientParticipantObserver
 56{
 57public:
 58
 59	LOG_CLASS(LLCallFloater);
 60
 61	LLCallFloater(const LLSD& key);
 62	~LLCallFloater();
 63
 64	/*virtual*/ BOOL postBuild();
 65	/*virtual*/ void onOpen(const LLSD& key);
 66	/*virtual*/ void draw();
 67	/*virtual*/ void setFocus( BOOL b );
 68
 69	/**
 70	 * Is called by LLVoiceClient::notifyParticipantObservers when voice participant list is changed.
 71	 *
 72	 * Refreshes list to display participants not in voice as disabled.
 73	 */
 74	/*virtual*/ void onParticipantsChanged();
 75
 76	static void sOnCurrentChannelChanged(const LLUUID& session_id);
 77
 78private:
 79	typedef enum e_voice_controls_type
 80	{
 81		VC_LOCAL_CHAT,
 82		VC_GROUP_CHAT,
 83		VC_AD_HOC_CHAT,
 84		VC_PEER_TO_PEER,
 85		VC_PEER_TO_PEER_AVALINE
 86	}EVoiceControls;
 87
 88	typedef enum e_speaker_state
 89	{
 90		STATE_UNKNOWN,
 91		STATE_INVITED,
 92		STATE_JOINED,
 93		STATE_LEFT,
 94	} ESpeakerState;
 95
 96	typedef std::map<LLUUID, ESpeakerState> speaker_state_map_t;
 97
 98	void leaveCall();
 99
100	/**
101	 * Updates mSpeakerManager and list according to current Voice Channel
102	 *
103	 * It compares mSpeakerManager & current Voice Channel session IDs.
104	 * If they are different gets Speaker manager related to current channel and updates channel participant list.
105	 */
106	void updateSession();
107
108	/**
109	 * Refreshes participant list according to current Voice Channel
110	 */
111	void refreshParticipantList();
112
113	/**
114	 * Handles event on avatar list is refreshed after it was marked dirty.
115	 *
116	 * It sets initial participants voice states (once after the first refreshing)
117	 * and updates voice states each time anybody is joined/left voice chat in session.
118	 */
119	void onAvatarListRefreshed();
120
121	/**
122	 * Updates window title with an avatar name
123	 */
124	void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
125	
126	void updateTitle();
127	void initAgentData();
128	void setModeratorMutedVoice(bool moderator_muted);
129	void updateAgentModeratorState();
130	void onModeratorNameCache(const LLAvatarName& av_name);
131
132	/**
133	 * Sets initial participants voice states in avatar list (Invited, Joined, Has Left).
134	 *
135	 * @see refreshParticipantList()
136	 * @see onAvatarListRefreshed()
137	 * @see mInitParticipantsVoiceState
138	 */
139	void initParticipantsVoiceState();
140
141	/**
142	 * Updates participants voice states in avatar list (Invited, Joined, Has Left).
143	 *
144	 * @see onAvatarListRefreshed()
145	 * @see onChanged()
146	 */
147	void updateParticipantsVoiceState();
148
149	/**
150	 * Updates voice state of participant not in current voice channel depend on its current state.
151	 */
152	void updateNotInVoiceParticipantState(LLAvatarListItem* item);
153	void setState(LLAvatarListItem* item, ESpeakerState state);
154	void setState(const LLUUID& speaker_id, ESpeakerState state)
155	{
156		lldebugs << "Storing state: " << speaker_id << ", " << state << llendl;
157		mSpeakerStateMap[speaker_id] = state;
158	}
159
160	ESpeakerState getState(const LLUUID& speaker_id)
161	{
162		lldebugs << "Getting state: " << speaker_id << ", " << mSpeakerStateMap[speaker_id] << llendl;
163
164		return mSpeakerStateMap[speaker_id];
165	}
166
167	/**
168	 * Instantiates new LLAvatarListItemRemoveTimer and adds it into the map if it is not already created.
169	 *
170	 * @param voice_speaker_id LLUUID of Avatar List item to be removed from the list when timer expires.
171	 */
172	void setVoiceRemoveTimer(const LLUUID& voice_speaker_id);
173
174	/**
175	 * Removes specified by UUID Avatar List item.
176	 *
177	 * @param voice_speaker_id LLUUID of Avatar List item to be removed from the list.
178	 */
179	bool removeVoiceLeftParticipant(const LLUUID& voice_speaker_id);
180
181	/**
182	 * Deletes all timers from the list to prevent started timers from ticking after destruction
183	 * and after switching on another voice channel.
184	 */
185	void resetVoiceRemoveTimers();
186
187	/**
188	 * Removes specified by UUID timer from the map.
189	 *
190	 * @param voice_speaker_id LLUUID of Avatar List item whose timer should be removed from the map.
191	 */
192	void removeVoiceRemoveTimer(const LLUUID& voice_speaker_id);
193
194	/**
195	 * Called by LLParticipantList before adding a speaker to the participant list.
196	 *
197	 * If false is returned, the speaker will not be added to the list.
198	 *
199	 * @param speaker_id Speaker to validate.
200	 * @return true if this is a valid speaker, false otherwise.
201	 */
202	bool validateSpeaker(const LLUUID& speaker_id);
203
204	/**
205	 * Connects to passed channel to be updated according to channel's voice states.
206	 */
207	void connectToChannel(LLVoiceChannel* channel);
208
209	/**
210	 * Callback to process changing of voice channel's states.
211	 */
212	void onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state);
213
214	/**
215	 * Updates floater according to passed channel's voice state.
216	 */
217	void updateState(const LLVoiceChannel::EState& new_state);
218
219	/**
220	 * Resets floater to be ready to show voice participants.
221	 *
222	 * Clears all data from the latest voice session.
223	 */
224	void reset(const LLVoiceChannel::EState& new_state);
225
226private:
227	speaker_state_map_t mSpeakerStateMap;
228	LLSpeakerMgr* mSpeakerManager;
229	LLParticipantList* mParticipants;
230	LLAvatarList* mAvatarList;
231	LLNonAvatarCaller* mNonAvatarCaller;
232	EVoiceControls mVoiceType;
233	LLPanel* mAgentPanel;
234	LLOutputMonitorCtrl* mSpeakingIndicator;
235	bool mIsModeratorMutedVoice;
236
237	/**
238	 * Flag indicated that participants voice states should be initialized.
239	 *
240	 * It is used due to Avatar List has delayed refreshing after it content is changed.
241	 * Real initializing is performed when Avatar List is first time refreshed.
242	 *
243	 * @see onAvatarListRefreshed()
244	 * @see initParticipantsVoiceState()
245	 */
246	bool mInitParticipantsVoiceState;
247
248	boost::signals2::connection mAvatarListRefreshConnection;
249
250
251	/**
252	 * time out speakers when they are not part of current session
253	 */
254	LLSpeakersDelayActionsStorage* mSpeakerDelayRemover;
255
256	/**
257	 * Stores reference to current voice channel.
258	 *
259	 * Is used to ignore voice channel changed callback for the same channel.
260	 *
261	 * @see sOnCurrentChannelChanged()
262	 */
263	static LLVoiceChannel* sCurrentVoiceChannel;
264
265	/* virtual */
266	LLTransientFloaterMgr::ETransientGroup getGroup() { return LLTransientFloaterMgr::IM; }
267
268	boost::signals2::connection mVoiceChannelStateChangeConnection;
269};
270
271
272#endif //LL_LLCALLFLOATER_H
273