llvoicechannel.h
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:6k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llvoicechannel.h
  3.  * @brief Voice channel related classes
  4.  *
  5.  * $LicenseInfo:firstyear=2001&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2001-2010, 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_VOICECHANNEL_H
  33. #define LL_VOICECHANNEL_H
  34. #include "llhandle.h"
  35. #include "llvoiceclient.h"
  36. class LLPanel;
  37. class LLVoiceChannel : public LLVoiceClientStatusObserver
  38. {
  39. public:
  40. typedef enum e_voice_channel_state
  41. {
  42. STATE_NO_CHANNEL_INFO,
  43. STATE_ERROR,
  44. STATE_HUNG_UP,
  45. STATE_READY,
  46. STATE_CALL_STARTED,
  47. STATE_RINGING,
  48. STATE_CONNECTED
  49. } EState;
  50. typedef enum e_voice_channel_direction
  51. {
  52. INCOMING_CALL,
  53. OUTGOING_CALL
  54. } EDirection;
  55. typedef boost::signals2::signal<void(const EState& old_state, const EState& new_state, const EDirection& direction, bool ended_by_agent)> state_changed_signal_t;
  56. // on current channel changed signal
  57. typedef boost::function<void(const LLUUID& session_id)> channel_changed_callback_t;
  58. typedef boost::signals2::signal<void(const LLUUID& session_id)> channel_changed_signal_t;
  59. static channel_changed_signal_t sCurrentVoiceChannelChangedSignal;
  60. static boost::signals2::connection setCurrentVoiceChannelChangedCallback(channel_changed_callback_t cb, bool at_front = false);
  61. LLVoiceChannel(const LLUUID& session_id, const std::string& session_name);
  62. virtual ~LLVoiceChannel();
  63. /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
  64. virtual void handleStatusChange(EStatusType status);
  65. virtual void handleError(EStatusType status);
  66. virtual void deactivate();
  67. virtual void activate();
  68. virtual void setChannelInfo(
  69. const std::string& uri,
  70. const std::string& credentials);
  71. virtual void getChannelInfo();
  72. virtual BOOL isActive();
  73. virtual BOOL callStarted();
  74. const std::string& getSessionName() const { return mSessionName; }
  75. boost::signals2::connection setStateChangedCallback(const state_changed_signal_t::slot_type& callback)
  76. { return mStateChangedCallback.connect(callback); }
  77. const LLUUID getSessionID() { return mSessionID; }
  78. EState getState() { return mState; }
  79. void updateSessionID(const LLUUID& new_session_id);
  80. const LLSD& getNotifyArgs() { return mNotifyArgs; }
  81. void setCallDirection(EDirection direction) {mCallDirection = direction;}
  82. EDirection getCallDirection() {return mCallDirection;}
  83. static LLVoiceChannel* getChannelByID(const LLUUID& session_id);
  84. static LLVoiceChannel* getChannelByURI(std::string uri);
  85. static LLVoiceChannel* getCurrentVoiceChannel() { return sCurrentVoiceChannel; }
  86. static void initClass();
  87. static void suspend();
  88. static void resume();
  89. protected:
  90. virtual void setState(EState state);
  91. /**
  92.  * Use this method if you want mStateChangedCallback to be executed while state is changed
  93.  */
  94. void doSetState(const EState& state);
  95. void setURI(std::string uri);
  96. // there can be two directions ICOMING and OUTGOING
  97. EDirection mCallDirection;
  98. std::string mURI;
  99. std::string mCredentials;
  100. LLUUID mSessionID;
  101. EState mState;
  102. std::string mSessionName;
  103. LLSD mNotifyArgs;
  104. LLSD mCallDialogPayload;
  105. // true if call was ended by agent
  106. bool mCallEndedByAgent;
  107. BOOL mIgnoreNextSessionLeave;
  108. LLHandle<LLPanel> mLoginNotificationHandle;
  109. typedef std::map<LLUUID, LLVoiceChannel*> voice_channel_map_t;
  110. static voice_channel_map_t sVoiceChannelMap;
  111. typedef std::map<std::string, LLVoiceChannel*> voice_channel_map_uri_t;
  112. static voice_channel_map_uri_t sVoiceChannelURIMap;
  113. static LLVoiceChannel* sCurrentVoiceChannel;
  114. static LLVoiceChannel* sSuspendedVoiceChannel;
  115. static BOOL sSuspended;
  116. private:
  117. state_changed_signal_t mStateChangedCallback;
  118. };
  119. class LLVoiceChannelGroup : public LLVoiceChannel
  120. {
  121. public:
  122. LLVoiceChannelGroup(const LLUUID& session_id, const std::string& session_name);
  123. /*virtual*/ void handleStatusChange(EStatusType status);
  124. /*virtual*/ void handleError(EStatusType status);
  125. /*virtual*/ void activate();
  126. /*virtual*/ void deactivate();
  127. /*vritual*/ void setChannelInfo(
  128. const std::string& uri,
  129. const std::string& credentials);
  130. /*virtual*/ void getChannelInfo();
  131. protected:
  132. virtual void setState(EState state);
  133. private:
  134. U32 mRetries;
  135. BOOL mIsRetrying;
  136. };
  137. class LLVoiceChannelProximal : public LLVoiceChannel, public LLSingleton<LLVoiceChannelProximal>
  138. {
  139. public:
  140. LLVoiceChannelProximal();
  141. /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
  142. /*virtual*/ void handleStatusChange(EStatusType status);
  143. /*virtual*/ void handleError(EStatusType status);
  144. /*virtual*/ BOOL isActive();
  145. /*virtual*/ void activate();
  146. /*virtual*/ void deactivate();
  147. };
  148. class LLVoiceChannelP2P : public LLVoiceChannelGroup
  149. {
  150. public:
  151. LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id);
  152. /*virtual*/ void handleStatusChange(EStatusType status);
  153. /*virtual*/ void handleError(EStatusType status);
  154.     /*virtual*/ void activate();
  155. /*virtual*/ void getChannelInfo();
  156. void setSessionHandle(const std::string& handle, const std::string &inURI);
  157. protected:
  158. virtual void setState(EState state);
  159. private:
  160. std::string mSessionHandle;
  161. LLUUID mOtherUserID;
  162. BOOL mReceivedCall;
  163. };
  164. #endif  // LL_VOICECHANNEL_H