sipXcallLib home page


CpPeerCall.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2017 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2006 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 
14 #ifndef _CpPeerCall_h_
15 #define _CpPeerCall_h_
16 
17 // SYSTEM INCLUDES
18 //#include <...>
19 
20 // APPLICATION INCLUDES
21 //#include <cp/PhoneApplication.h>
22 #include <cp/CpCall.h>
23 #include <cp/Connection.h>
24 
25 #include <os/OsRWMutex.h>
26 #include <cp/CallManager.h>
27 
28 #include "tapi/sipXtapiEvents.h"
29 
30 // DEFINES
31 // MACROS
32 // EXTERNAL FUNCTIONS
33 // EXTERNAL VARIABLES
34 // CONSTANTS
35 // STRUCTS
36 
37 // Container class to cache pass through address and port info
39 {
40 public:
41  MediaStreamPassThroughData(CpMediaInterface::MEDIA_STREAM_TYPE mediaType,
42  int mediaTypeStreamIndex,
43  UtlString mediaRecieveAddress,
44  int rtpPort,
45  int rtcpPort) :
46  mMediaType(mediaType),
47  mMediaTypeStreamIndex(mediaTypeStreamIndex),
48  mMediaRecieveAddress(mediaRecieveAddress),
49  mRtpPort(rtpPort),
50  mRtcpPort(rtcpPort)
51  {};
52 
57  mRtpPort(ref.mRtpPort),
58  mRtcpPort(ref.mRtcpPort)
59  {};
60 
62 
63  CpMediaInterface::MEDIA_STREAM_TYPE mMediaType;
66  int mRtpPort;
67  int mRtcpPort;
68 
69 private:
71 };
72 
73 // TYPEDEFS
74 // FORWARD DECLARATIONS
75 class Connection;
76 class SipUserAgent;
77 
78 //:Class short description which may consist of multiple lines (note the ':')
79 // Class detailed description which may extend to multiple lines
80 class CpPeerCall : public CpCall
81 
82 {
83  /* //////////////////////////// PUBLIC //////////////////////////////////// */
84 public:
85 
87  {
88  UNKNOWN = 0,
90  BLIND_TRANSFER
91  };
92 
93  /* ============================ CREATORS ================================== */
94 
95  CpPeerCall(UtlBoolean isEarlyMediaFor180Enabled = TRUE,
96  CpCallManager* callManger = NULL,
97  CpMediaInterface* callMediaInterface = NULL,
98  int callIndex = -1,
99  const char* callId = NULL,
100  SipUserAgent* sipUA = NULL,
101  int sipSessionReinviteTimer = 0,
102  const char* defaultCallExtension = NULL,
103  int holdType = CallManager::NEAR_END_HOLD,
104  int offeringDelayMilliSeconds = Connection::IMMEDIATE,
105  int availableBehavior = Connection::RING,
106  const char* forwardUnconditionalUrl = NULL,
107  int busyBehavior = Connection::BUSY,
108  const char* forwardOnBusyUrl = NULL,
109  int forwardOnNoAnswerMilliSeconds = -1,
110  const char* forwardOnNoAnswerUrl = NULL,
111  int ringingExpireSeconds = CP_MAXIMUM_RINGING_EXPIRE_SECONDS /* = 180 */);
112  //:Default constructor
124  virtual
125  ~CpPeerCall();
126  //:Destructor
127 
128  /* ============================ MANIPULATORS ============================== */
129 
130  virtual void inFocus(int talking = 1);
131  virtual void outOfFocus();
132 
133  //virtual void blindTransfer();
134 
135  //virtual void conferenceAddParty();
136 
137  Connection* addParty(const char* partyAddress,
138  const char* callController,
139  const char* originalCallConnectionAddress,
140  const char* pNewCallId,
141  SIPX_CONTACT_ID contactId = 0,
142  const void* pDisplay = NULL,
143  const void* pSecurity = NULL,
144  const char* locationHeader = NULL,
145  const int bandWidth = AUDIO_CODEC_BW_DEFAULT,
146  UtlBoolean bOnHold = false,
147  const char* originalCallId = NULL,
148  SIPX_TRANSPORT_DATA* pTransport = NULL,
149  const RTP_TRANSPORT rtpTransportOptions = RTP_TRANSPORT_UDP);
150 
151  OsStatus fireSipXMediaEvent(SIPX_MEDIA_EVENT event,
152  SIPX_MEDIA_CAUSE cause,
153  SIPX_MEDIA_TYPE type,
154  void* pEventData = NULL,
155  UtlBoolean fireIfNoConnection = FALSE);
156 
157  /* ============================ ACCESSORS ================================= */
158 
159  virtual void printCall();
160 
161  virtual void getLocalAddress(char* address, int len);
162 
163  virtual void getLocalTerminalId(char* terminal, int len);
164 
165  void hangUp(const char* callId, const char* toTag,
166  const char* fromTag);
167 
168  UtlBoolean getConnectionState(const char* callId,
169  const char* toTag,
170  const char* fromTag,
171  int& state,
172  UtlBoolean strictCompare);
173  //:Get the connection for the connection identified by the designated
174  //:callId, toTag, and fromTag. If the connection cannot be found a
175  //:UtlBoolean value of false is returned.
176 
177 
178  /* ============================ INQUIRY =================================== */
179 
180  static UtlBoolean shouldCreateCall(SipUserAgent& sipUa,
181  OsMsg& message,
182  SdpCodecList& codecFactory);
183 
184  virtual UtlBoolean hasCallId(const char* callId);
185 
186  virtual enum handleWillingness willHandleMessage(const OsMsg& eventMessage);
187 
188  virtual UtlBoolean isQueued();
189 
190  virtual UtlBoolean isLocalTerminal(const char* terminalId);
191 
192  UtlBoolean isConnection(const char* callId, const char* toTag,
193  const char* fromTag);
194 
195  virtual UtlBoolean canDisconnectConnection(Connection* pConnection);
196 
197  UtlBoolean isConnectionLocallyInitiatedRemoteHold(const char* callId,
198  const char* toTag,
199  const char* fromTag) ;
200 
201 
202  /* //////////////////////////// PROTECTED ///////////////////////////////// */
203 protected:
204  virtual UtlBoolean handleCallMessage(OsMsg& eventMessage);
205  virtual UtlBoolean handleMiNotificationMessage(MiNotification& notification) ;
206 
207  UtlBoolean handleRenegotiateCodecsConnection(OsMsg* pEventMessage);
208  //: Handles the processing of a CallManager::CP_RENEGOTIATE_CODECS_CONNECTION
209  //: message
210  UtlBoolean handleRenegotiateCodecsAllConnections(OsMsg* pEventMessage);
211  //: Handles the processing of a CallManager::CP_RENEGOTIATE_CODECS_ALL_CONNECTIONS
212  //: message
213  UtlBoolean handleSilentRemoteHold(OsMsg* pEventMessage);
214  //: Handles the processing of a CallManager::CP_SILENT_REMOTE_HOLD
215  //: message
216  UtlBoolean handleGetCodecCPULimit(OsMsg& eventMessage);
217  //: Handles the processing of a CallManager::CP_GET_CODEC_CPU_LIMIT
218  //: message
219  UtlBoolean handleSetCodecCPULimit(OsMsg& eventMessage);
220  //: Handles the processing of a CallManager::CP_SET_CODEC_CPU_LIMIT
221  //: message
222  UtlBoolean handleGetCodecCPUCost(OsMsg& eventMessage);
223  //: Handles the processing of a CallManager::CP_GET_CODEC_CPU_COST
224  //: message
225  UtlBoolean handleSetMicGain(OsMsg& eventMessage);
226  //: Handles the processing of a CallManager::CP_SET_MIC_GAIN
227  //: message
228 
229  UtlBoolean handleDialString(OsMsg* pEventMessage);
230  //: Handles the processing of a CallManager::CP_DIAL_STRING message
231  UtlBoolean handleDequeueCall(OsMsg* pEventMessage);
232  //: Handles the processing of a CallManager::CP_DEQUEUED_CALL message
233  UtlBoolean handleTransfer(OsMsg* pEventMessage);
234  //: Handles the processing of a CallManager::CP_BLIND_TRANSFER and
235  //: CallManager::CP_CONSULT_TRANSFER messages
236  UtlBoolean handleTransferAddress(OsMsg* pEventMessage);
237  //: Handles the processing of a CallManager::CP_CONSULT_TRANSFER_ADDRESS
238  //: message
239 
240  UtlBoolean handleTransferConnection(OsMsg* pEventMessage);
241  //: Handles the processing of a CallManager::CP_TRANSFER_CONNECTION
242  //: message
243  UtlBoolean handleTransfereeConnection(OsMsg* pEventMessage);
244  //: Handles the processing of a CallManager::CP_TRANSFEREE_CONNECTION
245  //: message
246  UtlBoolean handleSipMessage(OsMsg* pEventMessage);
247  //: Handles the processing of a CallManager::CP_SIP_MESSAGE message
248  UtlBoolean handleDropConnection(OsMsg* pEventMessage);
249  //: Handles the processing of a CallManager::CP_DROP_CONNECTION message
250  UtlBoolean handleForceDropConnection(OsMsg* pEventMessage);
251  //: Handles the processing of a CallManager::CP_FORCE_DROP_CONNECTION
252  //: message
253  UtlBoolean handleGetAddresses(OsMsg* pEventMessage);
254  //: Handles the processing of a CallManager::CP_GET_CALLED_ADDRESSES and
255  //: CallManager::CP_GET_CALLING_ADDRESSES messages
256  UtlBoolean handleAcceptConnection(OsMsg* pEventMessage);
257  //: Handles the processing of a CallManager::CP_ACCEPT_CONNECTION
258  //: message
259  UtlBoolean handleRejectConnection(OsMsg* pEventMessage);
260  //: Handles the processing of a CallManager::CP_REJECT_CONNECTION
261  //: message
262  UtlBoolean handleRedirectConnection(OsMsg* pEventMessage);
263  //: Handles the processing of a CallManager::CP_REDIRECT_CONNECTION
264  //: message
265  UtlBoolean handleHoldTermConnection(OsMsg* pEventMessage);
266  //: Handles the processing of a CallManager::CP_HOLD_TERM_CONNECTION
267  //: message
268  UtlBoolean handleHoldAllTermConnection(OsMsg* pEventMessage);
269  //: Handles the processing of a CallManager::CP_HOLD_ALL_TERM_CONNECTIONS
270  //: message
271  UtlBoolean handleUnholdTermConnection(OsMsg* pEventMessage);
272  //: Handles the processing of a CallManager::CP_UNHOLD_TERM_CONNECTION
273  //: message
274  UtlBoolean handleTransferConnectionStatus(OsMsg* pEventMessage);
275  //: Handles the processing of a CallManager::CP_TRANSFER_CONNECTION_STATUS
276  //: message
277  UtlBoolean handleTransfereeConnectionStatus(OsMsg* pEventMessage);
278  //: Handles the processing of a CallManager::CP_TRANSFEREE_CONNECTION_STATUS
279  //: message
280  UtlBoolean handleGetNumConnections(OsMsg* pEventMessage);
281  //: Handles the processing of CallManager::CP_GET_NUM_CONNECTIONS
282  //: and CallManager::CP_GET_NUM_TERM_CONNECTIONS messages
283  UtlBoolean handleGetConnections(OsMsg* pEventMessage);
284  //: Handles the processing of a CallManager::CP_GET_CONNECTIONS
285  //: message
286  UtlBoolean handleGetSession(OsMsg* pEventMessage);
287  //: Handles the processing of a CallManager::CP_GET_SESSION
288  //: message
289  UtlBoolean handleGetCallState(OsMsg* pEventMessage);
290  //: Handles the processing of a CallManager::CP_GET_CALLSTATE
291  //: message
292  UtlBoolean handleGetConnectionState(OsMsg* pEventMessage);
293  //: Handles the processing of a CallManager::CP_GET_CONNECTIONSTATE
294  //: message
295  UtlBoolean handleGetNextCseq(OsMsg* pEventMessage);
296  //: Handles the processing of a CallManager::CP_GET_NEXT_CSEQ
297  //: message
298  UtlBoolean handleGetTerminalConnectionState(OsMsg* pEventMessage);
299  //: Handles the processing of a
300  //: CallManager::CP_GET_TERMINALCONNECTIONSTATE message
301  UtlBoolean handleIsLocalTerminalConnection(OsMsg* pEventMessage);
302  //: Handles the processing of a CallManager::CP_IS_LOCAL_TERM_CONNECTION
303  //: message
304  UtlBoolean handleCancelTimer(OsMsg* pEventMessage);
305  //: Handles the processing of a CallManager::CP_CANCEL_TIMER
306  //: message
307  UtlBoolean handleOfferingExpired(OsMsg* pEventMessage);
308  //: Handles the processing of a CallManager::CP_OFFERING_EXPIRED
309  //: message
310  UtlBoolean handleRingingExpired(OsMsg* pEventMessage);
311  //: Handles the processing of a CallManager::CP_RINGING_EXPIRED
312  //: message
313  UtlBoolean handleUnholdAllTermConnections(OsMsg* pEventMessage);
314  //: Handles the processing of a
315  //: CallManager::CP_UNHOLD_ALL_TERM_CONNECTIONS message
316  UtlBoolean handleUnholdLocalTermConnection(OsMsg* pEventMessage);
317  //: Handles the processing of a
318  //: CallManager::CP_UNHOLD_LOCAL_TERM_CONNECTION message
319  UtlBoolean handleHoldLocalTermConnection(OsMsg* pEventMessage);
320  //: Handles the processing of a CallManager::CP_HOLD_LOCAL_TERM_CONNECTION
321  //: message
322  UtlBoolean handleGetLocalContacts(OsMsg* pEventMessage);
323  //: Handles the procesing of a CP_GET_LOCAL_CONTACTS message
324 
325  UtlBoolean handleSendInfo(OsMsg* pEventMessage);
326  //: Handles the processing of a CP_INFO message, and sends an INFO message
327 
328  UtlBoolean handleGetInviteHeaderValue(OsMsg* pEventMessage);
329  //: Handles CP_GET_INVITE_HEADER_VALUE event to retrieve SIP INVITE header value
330 
331  UtlBoolean handleGetMediaConnectionId(OsMsg* pEventMessage);
332  //: Handles the processing of a CP_GET_MEDIA_CONNECTION_ID message
333 
334  UtlBoolean handleLimitCodecs(OsMsg* pEventMessage);
335  //: Handles the processing of CP_LIMIT_CODEC message
336 
337  UtlBoolean handleLimitCodecPreferences(OsMsg* pEventMessage);
338  //: Handles the processing of the CP_LIMIT_CODEC_PREFERENCES message
339 
340  UtlBoolean handleGetMediaEnergyLevels(OsMsg* pEventMessage);
341  //: Handles the processing of a CP_GET_MEDIA_ENERGY_LEVELS message
342 
343  UtlBoolean handleGetCallMediaEnergyLevels(OsMsg* pEventMessage);
344  //: Handles the processing of a CP_GET_CALL_MEDIA_ENERGY_LEVELS message
345 
346  UtlBoolean handleGetMediaRtpSourceIDs(OsMsg* pEventMessage);
347  //: Handles the processing of a CP_GET_MEDIA_RTP_SOURCE_IDS message
348 
349  UtlBoolean handleGetCanAddParty(OsMsg* pEventMessage);
350  //: Handles the processing of a CP_GET_CAN_ADD_PARTY message
351 
352  UtlBoolean handleSplitConnection(OsMsg* pEventMessage) ;
353  //: Handles the processing of a CP_SPLIT_CONNECTION message
354 
355  UtlBoolean handleJoinConnection(OsMsg* pEventMessage) ;
356  //: Handles the processing of a CP_JOIN_CONNECTION message
357 
358  UtlBoolean handleSetMediaPassThrough(const OsMsg& eventMessage);
359  //: Handles processing of CP_SET_MEDIA_PASS_THROUGH
360 
361  UtlBoolean handleTransferOtherPartyHold(OsMsg* pEventMessage) ;
362  //: Handles the processing of a CP_TRANSFER_OTHER_PARTY_HOLD message
363 
364  UtlBoolean handleTransferOtherPartyJoin(OsMsg* pEventMessage) ;
365  //: Handles the processing of a CP_TRANSFER_OTHER_PARTY_JOIN message
366 
367  UtlBoolean handleTransferOtherPartyUnhold(OsMsg* pEventMessage) ;
368  //: Handles the processing of a CP_TRANSFER_OTHER_PARTY_UNHOLD message
369 
370  UtlBoolean handleGetUserAgent(OsMsg* pEventMessage);
371 
372  virtual UtlBoolean getConnectionState(const char* remoteAddress, int& state);
373 
374  virtual UtlBoolean getTermConnectionState(const char* address,
375  const char* terminal,
376  int& state);
377 
378  virtual void onHook();
379  virtual void offHook(const void* hWnd = NULL);
380 
381  // Connection manipulators
382  Connection* findHandlingConnection(OsMsg& eventMessage);
383  Connection* findHandlingConnection(UtlString& remoteAddress);
384  Connection* findHandlingConnection(const char* callId,
385  const char* toTag,
386  const char* fromTag,
387  UtlBoolean strictCompare);
388 
389  void addConnection(Connection* connection);
390  void removeConnection(Connection* connection);
391  Connection* findQueuedConnection();
392  UtlBoolean isConnectionLive(int* localConnectionState = NULL);
393  void dropIfDead();
394  void dropDeadConnections();
395 
396  void handleGetTermConnections(OsMsg* pEventMessage);
397  void handleSetOutboundLine(OsMsg* pEventMessage);
398 
399  void getLocalContactAddresses( SIPX_CONTACT_ADDRESS contacts[],
400  size_t nMaxContacts,
401  size_t& nActualContacts) ;
402 
403 
404  /* //////////////////////////// PRIVATE /////////////////////////////////// */
405 private:
406 
407  //void doHold();
408  //void doOffHold();
409 
414  UtlString forwardOnBusy;
416  UtlString forwardOnNoAnswer;
417  SipUserAgent* sipUserAgent;
418  //Connection* connection;
419  //UtlString extension;
421  UtlDList mConnections;
422  OsRWMutex mConnectionMutex;
424  UtlString mLocalAddress;
425  UtlString mLocalTerminalId;
427  UtlBoolean mbRequestedDrop; // Have we requested to be dropped by the CallManager
428  SIPXTACK_SECURITY_ATTRIBUTES* mpSecurity;
429 
432 
433  CpPeerCall(const CpPeerCall& rCpPeerCall);
434  //:Copy constructor
435 
436  CpPeerCall& operator=(const CpPeerCall& rhs);
437  //:Assignment operator
438 
439  UtlBoolean checkForTag(UtlString &address);
440 
442 };
443 
444 /* ============================ INLINE METHODS ============================ */
445 
446 #endif // _CpPeerCall_h_
Abstract call manager.
Definition: CpCallManager.h:97
Definition: Connection.h:164
UtlString forwardOnNoAnswer
Definition: CpPeerCall.h:416
CpMediaInterface::MEDIA_STREAM_TYPE mMediaType
Definition: CpPeerCall.h:61
SIPX_CALLSTATE_CAUSE
Callstate cause events identify the reason for a Callstate event or provide more detail.
Definition: sipXtapiEvents.h:244
UtlString forwardUnconditional
Definition: CpPeerCall.h:412
Definition: CpPeerCall.h:89
MediaStreamPassThroughData * mpPassThroughData
Definition: CpPeerCall.h:441
#define CP_MAXIMUM_RINGING_EXPIRE_SECONDS
Definition: CallManager.h:43
virtual ~MediaStreamPassThroughData()
Definition: CpPeerCall.h:61
SipUserAgent * sipUserAgent
Definition: CpPeerCall.h:417
callDialingMode
Definition: CpPeerCall.h:86
MediaStreamPassThroughData(const MediaStreamPassThroughData &ref)
Definition: CpPeerCall.h:53
int noAnswerTimeout
Definition: CpPeerCall.h:415
Definition: CpPeerCall.h:38
UtlBoolean mIsEarlyMediaFor180
Definition: CpPeerCall.h:426
Definition: CpCallManager.h:223
int lineBusyBehavior
Definition: CpPeerCall.h:413
sipXtapi event declarations
SIPXTACK_SECURITY_ATTRIBUTES * mpSecurity
Definition: CpPeerCall.h:428
Definition: Connection.h:58
int SIPX_CONTACT_ID
Type for storing Contact Record identifiers.
Definition: sipXtapi.h:632
SIPX_CALLSTATE_EVENT
Major call state events identify significant changes in the state of a call.
Definition: sipXtapiEvents.h:163
Definition: Connection.h:139
UtlBoolean mbRequestedDrop
Definition: CpPeerCall.h:427
UtlString mLocalAddress
Definition: CpPeerCall.h:424
SIPX_CALLSTATE_CAUSE eLastMinor
Definition: CpPeerCall.h:431
UNKNOWN
Definition: PtGatewayInterface.h:84
SIPX_MEDIA_EVENT
Enumeration of possible media events.
Definition: sipXtapiEvents.h:490
int mRtpPort
Definition: CpPeerCall.h:66
SIPX_MEDIA_TYPE
Enumeration of possible media event types.
Definition: sipXtapiEvents.h:660
Definition: CpPeerCall.h:80
UtlString mMediaRecieveAddress
Definition: CpPeerCall.h:65
UtlString forwardOnBusy
Definition: CpPeerCall.h:414
MediaStreamPassThroughData(CpMediaInterface::MEDIA_STREAM_TYPE mediaType, int mediaTypeStreamIndex, UtlString mediaRecieveAddress, int rtpPort, int rtcpPort)
Definition: CpPeerCall.h:41
Definition: sipXtapiInternal.h:288
int lineAvailableBehavior
Definition: CpPeerCall.h:411
Definition: Connection.h:145
UtlString mLocalTerminalId
Definition: CpPeerCall.h:425
SIPX_CALLSTATE_EVENT eLastMajor
Definition: CpPeerCall.h:430
handleWillingness
Definition: CpCall.h:101
Definition: CpCall.h:56
UtlDList mConnections
Definition: CpPeerCall.h:421
Value used to signify the default bandwidth level when calling sipxCallConnect, sipxCallAccept, or sipxConferenceAdd.
Definition: sipXtapi.h:203
OsRWMutex mConnectionMutex
Definition: CpPeerCall.h:422
int offeringDelay
Definition: CpPeerCall.h:410
The CONTACT_ADDRESS structure includes contact information (IP-address and port), address source type...
Definition: sipXtapi.h:640
int mDialMode
Definition: CpPeerCall.h:423
int mRtcpPort
Definition: CpPeerCall.h:67
int mMediaTypeStreamIndex
Definition: CpPeerCall.h:64
int mSipSessionReinviteTimer
Definition: CpPeerCall.h:420
SIPX_MEDIA_CAUSE
Enumeration of possible media event causes.
Definition: sipXtapiEvents.h:638