llfloateractivespeakers.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLFLOATERACTIVESPEAKERS_H
00033 #define LL_LLFLOATERACTIVESPEAKERS_H
00034 
00035 #include "llfloater.h"
00036 #include "llmemory.h"
00037 #include "llvoiceclient.h"
00038 #include "llframetimer.h"
00039 
00040 class LLScrollListCtrl;
00041 class LLButton;
00042 class LLPanelActiveSpeakers;
00043 class LLSpeakerMgr;
00044 class LLVoiceChannel;
00045 
00046 
00047 // data for a given participant in a voice channel
00048 class LLSpeaker : public LLRefCount
00049 {
00050 public:
00051         typedef enum e_speaker_type
00052         {
00053                 SPEAKER_AGENT,
00054                 SPEAKER_OBJECT
00055         } ESpeakerType;
00056 
00057         typedef enum e_speaker_status
00058         {
00059                 STATUS_SPEAKING,
00060                 STATUS_HAS_SPOKEN,
00061                 STATUS_VOICE_ACTIVE,
00062                 STATUS_TEXT_ONLY,
00063                 STATUS_NOT_IN_CHANNEL,
00064                 STATUS_MUTED
00065         } ESpeakerStatus;
00066 
00067 
00068         LLSpeaker(const LLUUID& id, const LLString& name = LLString::null, const ESpeakerType type = SPEAKER_AGENT);
00069         ~LLSpeaker();
00070 
00071         void lookupName();
00072 
00073         static void onAvatarNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* user_data);
00074 
00075 public:
00076 
00077         ESpeakerStatus  mStatus;                        // current activity status in speech group
00078         F32                             mLastSpokeTime;         // timestamp when this speaker last spoke
00079         F32                             mSpeechVolume;          // current speech amplitude (timea average rms amplitude?)
00080         LLString                mDisplayName;           // cache user name for this speaker
00081         LLFrameTimer    mActivityTimer; // time out speakers when they are not part of current voice channel
00082         BOOL                    mHasSpoken;                     // has this speaker said anything this session?
00083         LLColor4                mDotColor;
00084         LLUUID                  mID;
00085         BOOL                    mTyping;
00086         S32                             mSortIndex;
00087         LLViewHandle    mHandle;
00088         ESpeakerType    mType;
00089 
00090         typedef std::map<LLViewHandle, LLSpeaker*> speaker_map_t;
00091         static speaker_map_t sSpeakers;
00092 };
00093 
00094 class LLSpeakerMgr
00095 {
00096 public:
00097         LLSpeakerMgr(LLVoiceChannel* channelp);
00098         virtual ~LLSpeakerMgr();
00099 
00100         const LLPointer<LLSpeaker> findSpeaker(const LLUUID& avatar_id);
00101         void update();
00102         void setSpeakerTyping(const LLUUID& speaker_id, BOOL typing);
00103         void speakerChatted(const LLUUID& speaker_id);
00104         LLPointer<LLSpeaker> setSpeaker(const LLUUID& id, 
00105                                         const LLString& name = LLString::null, 
00106                                         LLSpeaker::ESpeakerStatus status = LLSpeaker::STATUS_TEXT_ONLY, 
00107                                         LLSpeaker::ESpeakerType = LLSpeaker::SPEAKER_AGENT);
00108 
00109         BOOL isVoiceActive();
00110 
00111         typedef std::vector<LLPointer<LLSpeaker> > speaker_list_t;
00112         void getSpeakerList(speaker_list_t* speaker_list, BOOL include_text);
00113 
00114 protected:
00115         virtual void updateSpeakerList();
00116 
00117         typedef std::map<LLUUID, LLPointer<LLSpeaker> > speaker_map_t;
00118         speaker_map_t           mSpeakers;
00119 
00120         speaker_list_t          mSpeakersSorted;
00121         LLFrameTimer            mSpeechTimer;
00122         LLVoiceChannel*         mVoiceChannel;
00123 };
00124 
00125 class LLIMSpeakerMgr : public LLSpeakerMgr
00126 {
00127 public:
00128         LLIMSpeakerMgr(LLVoiceChannel* channel);
00129         
00130         void processSpeakerListUpdate(LLSD update);
00131         void processSpeakerList(LLSD list);
00132         void processSpeakerMap(LLSD list);
00133 protected:
00134         virtual void updateSpeakerList();
00135 };
00136 
00137 class LLActiveSpeakerMgr : public LLSpeakerMgr
00138 {
00139 public:
00140         LLActiveSpeakerMgr();
00141 protected:
00142         virtual void updateSpeakerList();
00143 };
00144 
00145 class LLLocalSpeakerMgr : public LLSpeakerMgr
00146 {
00147 public:
00148         LLLocalSpeakerMgr();
00149         ~LLLocalSpeakerMgr ();
00150 protected:
00151         virtual void updateSpeakerList();
00152 };
00153 
00154 
00155 class LLFloaterActiveSpeakers : 
00156         public LLUISingleton<LLFloaterActiveSpeakers>, 
00157         public LLFloater, 
00158         public LLVoiceClientParticipantObserver
00159 {
00160         // friend of singleton class to allow construction inside getInstance() since constructor is protected
00161         // to enforce singleton constraint
00162         friend class LLUISingleton<LLFloaterActiveSpeakers>;
00163 public:
00164         virtual ~LLFloaterActiveSpeakers();
00165 
00166         /*virtual*/ BOOL postBuild();
00167         /*virtual*/ void onClose(bool app_quitting);
00168         /*virtual*/ void draw();
00169 
00170         /*virtual*/ void onChange();
00171 
00172         static void* createSpeakersPanel(void* data);
00173 
00174 protected:
00175         LLFloaterActiveSpeakers(const LLSD& seed);
00176 
00177         LLPanelActiveSpeakers*  mPanel;
00178 };
00179 
00180 class LLPanelActiveSpeakers : public LLPanel
00181 {
00182 public:
00183         LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL show_text_chatters);
00184         virtual ~LLPanelActiveSpeakers();
00185 
00186         /*virtual*/ BOOL postBuild();
00187 
00188         void refreshSpeakers();
00189         
00190         void setSpeaker(const LLUUID& id, 
00191                                         const LLString& name = LLString::null, 
00192                                         LLSpeaker::ESpeakerStatus status = LLSpeaker::STATUS_TEXT_ONLY, 
00193                                         LLSpeaker::ESpeakerType = LLSpeaker::SPEAKER_AGENT);
00194         
00195         static void onClickMuteVoice(void* user_data);
00196         static void onClickMuteVoiceCommit(LLUICtrl* ctrl, void* user_data);
00197         static void onClickMuteTextCommit(LLUICtrl* ctrl, void* user_data);
00198         static void onVolumeChange(LLUICtrl* source, void* user_data);
00199         static void onClickProfile(void* user_data);
00200 protected:
00201         LLScrollListCtrl*       mSpeakerList;
00202         LLUICtrl*                       mMuteVoiceCtrl;
00203         LLUICtrl*                       mMuteTextCtrl;
00204         LLTextBox*                      mNameText;
00205         LLButton*                       mProfileBtn;
00206         BOOL                            mShowTextChatters;
00207         LLSpeakerMgr*           mSpeakerMgr;
00208         LLFrameTimer            mIconAnimationTimer;
00209 };
00210 
00211 extern LLLocalSpeakerMgr*       gLocalSpeakerMgr;
00212 extern LLActiveSpeakerMgr*              gActiveChannelSpeakerMgr;
00213 
00214 #endif // LL_LLFLOATERACTIVESPEAKERS_H

Generated on Thu Jul 1 06:08:31 2010 for Second Life Viewer by  doxygen 1.4.7