llvoicechannel.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /**
  2. * @file llvoicechannel.h
  3. * @brief Voice channel related classes
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  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
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  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
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLVOICECHANNEL_H
  33. #define LL_LLVOICECHANNEL_H
  34. #include "hbfastmap.h"
  35. #include "llpanel.h"
  36. #include "llvoiceclient.h"
  37. class LLVoiceChannel : public LLVoiceClientStatusObserver
  38. {
  39. protected:
  40. LOG_CLASS(LLVoiceChannel);
  41. public:
  42. typedef enum e_voice_channel_state
  43. {
  44. STATE_NO_CHANNEL_INFO,
  45. STATE_ERROR,
  46. STATE_HUNG_UP,
  47. STATE_READY,
  48. STATE_CALL_STARTED,
  49. STATE_RINGING,
  50. STATE_CONNECTED
  51. } EState;
  52. LLVoiceChannel(const LLUUID& session_id, const std::string& session_name);
  53. virtual ~LLVoiceChannel();
  54. // LLVoiceClientStatusObserver override
  55. void onChange(EStatusType status, const LLSD& channel_info,
  56. bool proximal) override;
  57. virtual void handleStatusChange(EStatusType status);
  58. virtual void handleError(EStatusType status);
  59. virtual void deactivate();
  60. virtual void activate();
  61. virtual void setChannelInfo(const LLSD& channel_info);
  62. virtual void requestChannelInfo();
  63. virtual bool isActive();
  64. LL_INLINE virtual bool isP2P() const { return false; }
  65. LL_INLINE bool callStarted() const
  66. {
  67. return mState >= STATE_CALL_STARTED;
  68. }
  69. LL_INLINE const LLUUID& getSessionID() const { return mSessionID; }
  70. LL_INLINE EState getState() const { return mState; }
  71. void updateSessionID(const LLUUID& new_session_id);
  72. LL_INLINE const LLSD& getNotifyArgs() const { return mNotifyArgs; }
  73. static LLVoiceChannel* getChannelByID(const LLUUID& session_id);
  74. LL_INLINE static LLVoiceChannel* getCurrentVoiceChannel()
  75. {
  76. return sCurrentVoiceChannel;
  77. }
  78. static void initClass();
  79. static void suspend();
  80. static void resume();
  81. protected:
  82. virtual void setState(EState state);
  83. protected:
  84. LLHandle<LLPanel> mLoginNotificationHandle;
  85. LLUUID mSessionID;
  86. std::string mSessionName;
  87. std::string mCredentials;
  88. LLSD mChannelInfo;
  89. LLSD mNotifyArgs;
  90. EState mState;
  91. bool mOutgoingCall;
  92. bool mIgnoreNextSessionLeave;
  93. typedef fast_hmap<LLUUID, LLVoiceChannel*> voice_channel_map_t;
  94. static voice_channel_map_t sVoiceChannelMap;
  95. static LLVoiceChannel* sCurrentVoiceChannel;
  96. static LLVoiceChannel* sSuspendedVoiceChannel;
  97. static bool sSuspended;
  98. };
  99. class LLVoiceChannelGroup : public LLVoiceChannel
  100. {
  101. protected:
  102. LOG_CLASS(LLVoiceChannelGroup);
  103. public:
  104. LLVoiceChannelGroup(const LLUUID& session_id,
  105. const std::string& session_name, bool is_p2p = false);
  106. void handleStatusChange(EStatusType status) override;
  107. void handleError(EStatusType status) override;
  108. void activate() override;
  109. void deactivate() override;
  110. void setChannelInfo(const LLSD& channel_info) override;
  111. void requestChannelInfo() override;
  112. LL_INLINE bool isP2P() const override { return mIsP2P; }
  113. protected:
  114. void setState(EState state) override;
  115. private:
  116. static void voiceCallCapCoro(const std::string& url, LLUUID session_id);
  117. private:
  118. U32 mRetries;
  119. bool mIsP2P;
  120. bool mIsRetrying;
  121. };
  122. class LLVoiceChannelProximal final : public LLVoiceChannel,
  123. public LLSingleton<LLVoiceChannelProximal>
  124. {
  125. friend class LLSingleton<LLVoiceChannelProximal>;
  126. protected:
  127. LOG_CLASS(LLVoiceChannelProximal);
  128. public:
  129. LLVoiceChannelProximal();
  130. void onChange(EStatusType status, const LLSD& channel_info,
  131. bool proximal) override;
  132. void handleStatusChange(EStatusType status) override;
  133. void handleError(EStatusType status) override;
  134. bool isActive() override;
  135. void activate() override;
  136. void deactivate() override;
  137. };
  138. class LLVoiceChannelP2P final : public LLVoiceChannelGroup
  139. {
  140. protected:
  141. LOG_CLASS(LLVoiceChannelP2P);
  142. public:
  143. LLVoiceChannelP2P(const LLUUID& session_id,
  144. const std::string& session_name,
  145. const LLUUID& other_user_id, U32 server_type);
  146. void handleStatusChange(EStatusType status) override;
  147. void handleError(EStatusType status) override;
  148. void activate() override;
  149. void deactivate() override;
  150. void setChannelInfo(const LLSD& channel_info) override;
  151. void requestChannelInfo() override;
  152. protected:
  153. void setState(EState state) override;
  154. private:
  155. LLUUID mOtherUserID;
  156. U32 mVoiceServerType;
  157. bool mVivoxIncomingCall;
  158. bool mReceivedCall;
  159. };
  160. #endif // LL_LLVOICECHANNEL_H