/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. #ifndef LL_LLCALLFLOATER_H
  28. #define LL_LLCALLFLOATER_H
  29. #include "lltransientdockablefloater.h"
  30. #include "llvoicechannel.h"
  31. #include "llvoiceclient.h"
  32. class LLAvatarList;
  33. class LLAvatarListItem;
  34. class LLAvatarName;
  35. class LLNonAvatarCaller;
  36. class LLOutputMonitorCtrl;
  37. class LLParticipantList;
  38. class LLSpeakerMgr;
  39. class LLSpeakersDelayActionsStorage;
  40. /**
  41. * The Voice Control Panel is an ambient window summoned by clicking the flyout chevron
  42. * on the Speak button. It can be torn-off and freely positioned onscreen.
  43. *
  44. * When the Resident is engaged in Voice Chat, the Voice Control Panel provides control
  45. * over the audible volume of each of the other participants, the Resident's own Voice
  46. * Morphing settings (if she has subscribed to enable the feature), and Voice Recording.
  47. *
  48. * When the Resident is engaged in any chat except Nearby Chat, the Voice Control Panel
  49. * also provides a 'Leave Call' button to allow the Resident to leave that voice channel.
  50. */
  51. class LLCallFloater : public LLTransientDockableFloater, LLVoiceClientParticipantObserver
  52. {
  53. public:
  54. LOG_CLASS(LLCallFloater);
  55. LLCallFloater(const LLSD& key);
  56. ~LLCallFloater();
  57. /*virtual*/ BOOL postBuild();
  58. /*virtual*/ void onOpen(const LLSD& key);
  59. /*virtual*/ void draw();
  60. /*virtual*/ void setFocus( BOOL b );
  61. /**
  62. * Is called by LLVoiceClient::notifyParticipantObservers when voice participant list is changed.
  63. *
  64. * Refreshes list to display participants not in voice as disabled.
  65. */
  66. /*virtual*/ void onParticipantsChanged();
  67. static void sOnCurrentChannelChanged(const LLUUID& session_id);
  68. private:
  69. typedef enum e_voice_controls_type
  70. {
  71. VC_LOCAL_CHAT,
  72. VC_GROUP_CHAT,
  73. VC_AD_HOC_CHAT,
  74. VC_PEER_TO_PEER,
  75. VC_PEER_TO_PEER_AVALINE
  76. }EVoiceControls;
  77. typedef enum e_speaker_state
  78. {
  79. STATE_UNKNOWN,
  80. STATE_INVITED,
  81. STATE_JOINED,
  82. STATE_LEFT,
  83. } ESpeakerState;
  84. typedef std::map<LLUUID, ESpeakerState> speaker_state_map_t;
  85. void leaveCall();
  86. /**
  87. * Updates mSpeakerManager and list according to current Voice Channel
  88. *
  89. * It compares mSpeakerManager & current Voice Channel session IDs.
  90. * If they are different gets Speaker manager related to current channel and updates channel participant list.
  91. */
  92. void updateSession();
  93. /**
  94. * Refreshes participant list according to current Voice Channel
  95. */
  96. void refreshParticipantList();
  97. /**
  98. * Handles event on avatar list is refreshed after it was marked dirty.
  99. *
  100. * It sets initial participants voice states (once after the first refreshing)
  101. * and updates voice states each time anybody is joined/left voice chat in session.
  102. */
  103. void onAvatarListRefreshed();
  104. /**
  105. * Updates window title with an avatar name
  106. */
  107. void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
  108. void updateTitle();
  109. void initAgentData();
  110. void setModeratorMutedVoice(bool moderator_muted);
  111. void updateAgentModeratorState();
  112. void onModeratorNameCache(const LLAvatarName& av_name);
  113. /**
  114. * Sets initial participants voice states in avatar list (Invited, Joined, Has Left).
  115. *
  116. * @see refreshParticipantList()
  117. * @see onAvatarListRefreshed()
  118. * @see mInitParticipantsVoiceState
  119. */
  120. void initParticipantsVoiceState();
  121. /**
  122. * Updates participants voice states in avatar list (Invited, Joined, Has Left).
  123. *
  124. * @see onAvatarListRefreshed()
  125. * @see onChanged()
  126. */
  127. void updateParticipantsVoiceState();
  128. /**
  129. * Updates voice state of participant not in current voice channel depend on its current state.
  130. */
  131. void updateNotInVoiceParticipantState(LLAvatarListItem* item);
  132. void setState(LLAvatarListItem* item, ESpeakerState state);
  133. void setState(const LLUUID& speaker_id, ESpeakerState state)
  134. {
  135. lldebugs << "Storing state: " << speaker_id << ", " << state << llendl;
  136. mSpeakerStateMap[speaker_id] = state;
  137. }
  138. ESpeakerState getState(const LLUUID& speaker_id)
  139. {
  140. lldebugs << "Getting state: " << speaker_id << ", " << mSpeakerStateMap[speaker_id] << llendl;
  141. return mSpeakerStateMap[speaker_id];
  142. }
  143. /**
  144. * Instantiates new LLAvatarListItemRemoveTimer and adds it into the map if it is not already created.
  145. *
  146. * @param voice_speaker_id LLUUID of Avatar List item to be removed from the list when timer expires.
  147. */
  148. void setVoiceRemoveTimer(const LLUUID& voice_speaker_id);
  149. /**
  150. * Removes specified by UUID Avatar List item.
  151. *
  152. * @param voice_speaker_id LLUUID of Avatar List item to be removed from the list.
  153. */
  154. bool removeVoiceLeftParticipant(const LLUUID& voice_speaker_id);
  155. /**
  156. * Deletes all timers from the list to prevent started timers from ticking after destruction
  157. * and after switching on another voice channel.
  158. */
  159. void resetVoiceRemoveTimers();
  160. /**
  161. * Removes specified by UUID timer from the map.
  162. *
  163. * @param voice_speaker_id LLUUID of Avatar List item whose timer should be removed from the map.
  164. */
  165. void removeVoiceRemoveTimer(const LLUUID& voice_speaker_id);
  166. /**
  167. * Called by LLParticipantList before adding a speaker to the participant list.
  168. *
  169. * If false is returned, the speaker will not be added to the list.
  170. *
  171. * @param speaker_id Speaker to validate.
  172. * @return true if this is a valid speaker, false otherwise.
  173. */
  174. bool validateSpeaker(const LLUUID& speaker_id);
  175. /**
  176. * Connects to passed channel to be updated according to channel's voice states.
  177. */
  178. void connectToChannel(LLVoiceChannel* channel);
  179. /**
  180. * Callback to process changing of voice channel's states.
  181. */
  182. void onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state);
  183. /**
  184. * Updates floater according to passed channel's voice state.
  185. */
  186. void updateState(const LLVoiceChannel::EState& new_state);
  187. /**
  188. * Resets floater to be ready to show voice participants.
  189. *
  190. * Clears all data from the latest voice session.
  191. */
  192. void reset(const LLVoiceChannel::EState& new_state);
  193. private:
  194. speaker_state_map_t mSpeakerStateMap;
  195. LLSpeakerMgr* mSpeakerManager;
  196. LLParticipantList* mParticipants;
  197. LLAvatarList* mAvatarList;
  198. LLNonAvatarCaller* mNonAvatarCaller;
  199. EVoiceControls mVoiceType;
  200. LLPanel* mAgentPanel;
  201. LLOutputMonitorCtrl* mSpeakingIndicator;
  202. bool mIsModeratorMutedVoice;
  203. /**
  204. * Flag indicated that participants voice states should be initialized.
  205. *
  206. * It is used due to Avatar List has delayed refreshing after it content is changed.
  207. * Real initializing is performed when Avatar List is first time refreshed.
  208. *
  209. * @see onAvatarListRefreshed()
  210. * @see initParticipantsVoiceState()
  211. */
  212. bool mInitParticipantsVoiceState;
  213. boost::signals2::connection mAvatarListRefreshConnection;
  214. /**
  215. * time out speakers when they are not part of current session
  216. */
  217. LLSpeakersDelayActionsStorage* mSpeakerDelayRemover;
  218. /**
  219. * Stores reference to current voice channel.
  220. *
  221. * Is used to ignore voice channel changed callback for the same channel.
  222. *
  223. * @see sOnCurrentChannelChanged()
  224. */
  225. static LLVoiceChannel* sCurrentVoiceChannel;
  226. /* virtual */
  227. LLTransientFloaterMgr::ETransientGroup getGroup() { return LLTransientFloaterMgr::IM; }
  228. boost::signals2::connection mVoiceChannelStateChangeConnection;
  229. };
  230. #endif //LL_LLCALLFLOATER_H