Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cVoIPEndpoint.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cVoIPEndpoint_H
7 #define _INC_cVoIPEndpoint_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cVoIP.h"
13 #include "../AVDev/cWaveDevice.h"
15 
16 namespace GrayLib
17 {
18 #ifdef _WIN32
19  class cVoIPConnectPeer : public cVoIPConnect
20  {
21  // a connection to an audio peer. self mixing.
22  public:
23  cVoIPConnectPeer( const cNetAddress& addr )
24  : cVoIPConnect(addr)
25  {
26  }
27  };
28 
29  class cVoIPConnectServer : public cVoIPConnect
30  {
31  // a connection to the server. can manage multiple channels.
32  // Can talk on one or many channels.
33  public:
34  cVoIPConnectServer( const cNetAddress& addr )
35  : cVoIPConnect(addr)
36  {
37  }
38  };
39 
40  enum VIOP_EVENT_TYPE
41  {
42  VIOP_EVENT_UserConnect,
43  VIOP_EVENT_UserDisconnect,
44  VIOP_EVENT_QTY,
45  };
46 
47  class cVoIPEndpoint
48  {
53 
54  public:
55  cVoIPEndpoint();
56  virtual ~cVoIPEndpoint();
57 
58  HRESULT Init();
59  HRESULT Shutdown();
60 
61  // For server based connections.
62  HRESULT ConnectServer( const char* pszUserName, const char *szPassword, const char* pszCharName );
63  bool isServerConnected();
64  void DisconnectServer();
65 
66  // For peer to peer outgoing connections.
67  HRESULT ConnectPeer( const cNetAddress& addr); // start a connect to this peer address. (async)
68 
69  // For peer to peer incoming connections.
70  void OpenListen();
71  void CloseListen();
72  void onTickSound();
73 
74  // Watch for changes to the system.
75  virtual void onEvent( VIOP_EVENT_TYPE eEvent, HASHCODE_t nUser, int iArg );
76 
77  public:
78  cNetSocket m_Socket; // listen socket. port for incoming connects
79 
80  // Input audio
81  cWaveRecorder m_RecDev; // the local recorder device.
82  cArrayVal<cWaveHeaderBase> m_RecHeaders; // My unused headers. (~1 second buffer?)
83  int m_RecLevel; // the audio level of the current buffer.
84  int m_RecSquelch; // only buffers with data above level will get sent.
85 
86  // List of allowed incoming audio connections.
87  bool m_bAllowConnectionAny;
88  cArraySorted<HASHCODE_t, HASHCODE_t, HASHCODE_t> m_AllowConnections; // ip's we connect to directly.
89  cArraySorted<HASHCODE_t, HASHCODE_t, HASHCODE_t> m_StaffConnections; // ip's that must always be allowed.
90 
91  // Current open connections. (that want to hear me)
92  cArraySortHash<cVoIPConnectPeer> m_Connects;
93  };
94 #endif
95 
96 #if 0
97  enum LoginStates
98  {
99  LSTATE_LOGGEDOUT=0, LSTATE_LOGGEDIN=1
100  };
101  enum SessionStates
102  {
103  SSTATE_CONNECTED=4, SSTATE_DISCONNECTED=5, SSTATE_GROUPADDED=99, SSTATE_GROUPTERMINATED=98
104  };
105 
106  typedef void (CALLBACK *STATECALLBACK)(int loginState, int sessionState, bool bSpeaking);
107  typedef void (CALLBACK *INTENSITYCALLBACK)(int type, int level, char* participant_uri );
108 
109  // ============================================================
110 
111  extern bool Voice_Is3DChannel(int nSlot);
112 
113  extern bool Voice_CreateSessionGroup();
114  extern bool Voice_ShutdownSessionGroup();
115  extern bool Voice_AddSession(int nSlot, int nChannel, const char *szAddress=nullptr, bool b3D=false);
116  extern bool Voice_RemoveSession(int nSlot);
117  extern bool Voice_SetChannelSpeaking(int nSlot);
118  extern bool Voice_ResetSpeakingChannel();
119  extern bool Voice_RemoveAllSessions();
120  extern bool Voice_IsInSession();
121  extern bool Voice_MuteLocalMic(bool bMute);
122 
123  extern void Voice_SetSpeaking(bool bSpeaking);
124  extern void Voice_SetMicVolume(int nVolume);
125  extern void Voice_SetSpeakerVolume(int nVolume);
126  extern int Voice_GetMicVolume();
127  extern int Voice_GetSpeakerVolume();
128  extern void Voice_GetAudioInfo();
129 
130  extern bool Voice_Update();
131  extern void Voice_SetPosition(const V3DVECTOR3d *speakpos, const V3DVECTOR3d *listenpos, const V3DVECTOR3 *vdir, V3DSCALAR fHeading);
132 
133 #endif
134 };
135 
136 #endif
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cMesh.h:22
UINT_PTR HASHCODE_t
could hold a pointer converted to a number? maybe 64 or 32 bit ? same as size_t.
Definition: GrayCore.h:116