sipXcallLib home page


CpCall.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _CpCall_h_
13 #define _CpCall_h_
14 
15 // SYSTEM INCLUDES
16 //#include <...>
17 
18 // APPLICATION INCLUDES
19 #include <os/OsServerTask.h>
20 #include <os/OsRWMutex.h>
21 #include "os/OsUtil.h"
22 #include "os/OsLockingList.h"
23 #include <os/OsMsgDispatcher.h>
24 #include <sdp/SdpCodec.h>
25 #include <ptapi/PtEvent.h>
26 #include <ptapi/PtConnection.h>
28 #include <cp/CallManager.h>
29 #include "tao/TaoObjectMap.h"
30 #include <mi/MiNotification.h>
31 
32 // DEFINES
33 #define MINIMUM_DTMF_LENGTH 50
34 #define MINIMUM_DTMF_SILENCE 50
35 
36 // MACROS
37 // EXTERNAL FUNCTIONS
38 // EXTERNAL VARIABLES
39 // CONSTANTS
40 // STRUCTS
41 struct DtmfEvent {
42  int event;
46  UtlBoolean enabled;
47 };
48 
49 // TYPEDEFS
50 // FORWARD DECLARATIONS
51 class CpCallManager;
52 class CpMediaInterface;
53 
54 //:Class short description which may consist of multiple lines (note the ':')
55 // Class detailed description which may extend to multiple lines
56 class CpCall : public OsServerTask
57 {
58  /* //////////////////////////// PUBLIC //////////////////////////////////// */
59 public:
60 
61  enum eventType
62  {
63  CONNECTION_STATE = 0,
65  CALL_STATE
66  };
67 
69  {
70  METAEVENT_START = 0,
72  METAEVENT_END
73  };
74 
75  enum callTypes
76  {
78 
79  // There are three types of parties involved with a transfer:
80  // Transfer Controller -
81  // Transferee -
82  // Transfer Target -
83  // There are two calls involved with a transfer:
84  // Original call - between the transfer controller and transferee(s)
85  // Target Call - between all parties, the transfer controller and
86  // transfer target connect on this call first. If this is
87  // consultative the transfer controller does not drop out
88  // immediately
93  //CP_TRANSFER_TARGET_ORIGINAL_CALL, // do not know if this is needed
94  CP_TRANSFER_TARGET_TARGET_CALL
95  };
96 
97  // The following enumeration defines the degree of willingness
98  // that a call has for handling a message. It is not always
99  // a binary decision, so this allows a weighting as to the amount
100  // of willingness.
102  {
103  // Does not match by any means
104  CP_WILL_NOT_HANDLE = 0,
105 
106  // Will handle if a better match is not found
107  // (i.e. check all the remaining calls first).
109 
110  // Is a definite match no need to search any further
111  CP_DEFINITELY_WILL_HANDLE
112  };
113  /* ============================ CREATORS ================================== */
114 
115  CpCall(CpCallManager* manager = NULL,
116  CpMediaInterface* callMediaInterface = NULL,
117  int callIndex = -1,
118  const char* callId = NULL,
119  int holdType = CallManager::NEAR_END_HOLD);
120  //:Default constructor
121 
122  virtual
123  ~CpCall();
124  //:Destructor
125 
126  /* ============================ MANIPULATORS ============================== */
127 
128  void setDropState(UtlBoolean state);
129 
130  void postMetaEvent(int state, int remoteIsCallee = -1); // remoteIsCallee = -1 means not set
131 
132  void postTaoListenerMessage(int responseCode,
133  UtlString responseText,
134  int eventId,
135  int type,
136  int cause = PtEvent::CAUSE_NORMAL,
137  int remoteIsCallee = 1,
138  UtlString remoteAddress = "",
139  int isRemote = 0,
140  UtlString targetCallId = OsUtil::NULL_OS_STRING);
141 
142  void setCallState(int responseCode, UtlString responseText, int state, int cause = PtEvent::CAUSE_NORMAL);
143 
144  virtual void inFocus(int talking = 1);
145  virtual void outOfFocus();
146 
147  virtual void sendFlowgraphMessage(OsMsg& flowgraphMessage);
148 
149  //virtual void hold();
150  //virtual void offHold();
151  virtual void localHold();
152  virtual void hangUp(UtlString callId, int metaEventId);
153  //virtual void blindTransfer() = 0;
154  //virtual void conferenceAddParty() = 0;
155 
156  virtual void getLocalAddress(char* address, int len);
157 
158  virtual void getLocalTerminalId(char* terminal, int len);
159 
160  virtual void getCallId(UtlString& callId);
161  //: Gets the main call Id for this call
162  // Note: a call may have many callIds (i.e. one for each connection)
163  virtual void setCallId(const char* callId);
164  //: Sets the main call Id for this call
165 
166  void setLocalConnectionState(int newState);
167  //: Sets the local connection state for this call
168 
169  int getLocalConnectionState() { return mLocalConnectionState; };
170  //: Sets the local connection state for this call
171 
172  /* ============================ ACCESSORS ================================= */
173  static int getCallTrackingListCount();
174  //returns the number of call tasks currently outstanding.
175 
176  int getCallIndex();
177 
178  int getCallState();
179 
180  virtual void printCall();
181 
182  // This should go away
183  void enableDtmf();
184 
185  static void getStateString(int state, UtlString* stateLabel);
186 
187  // Meta Event Utilities
188  // For the meta events, the first callId (index=0) is the new
189  // call, the subsequent callIds (index = 1 through numCalls)
190  // are the old calls
191  virtual void startMetaEvent(int metaEventId, int metaEventType,
192  int numCalls, const char* metaEventCallIds[], int remoteIsCallee = -1); // remoteIsCallee = -1 means not set
193 
194  virtual void setMetaEvent(int metaEventId, int metaEventType,
195  int numCalls, const char* metaEventCallIds[]);
196 
197  void getMetaEvent(int& metaEventId, int& metaEventType,
198  int& numCalls, const UtlString* metaEventCallIds[]) const;
199 
200  virtual void stopMetaEvent(int remoteIsCallee = -1); // remoteIsCallee = -1 means not set
201 
202  void setCallType(int callType);
203  int getCallType() const;
204 
205  void setTargetCallId(const char* targetCallId);
206  void getTargetCallId(UtlString& targetCallId) const;
207  void setOriginalCallId(const char* targetCallId);
208  void getOriginalCallId(UtlString& targetCallId) const;
209 
210  int getLocalConnectionState(int state);
211 
212  /* ============================ INQUIRY =================================== */
213 
214  virtual UtlBoolean hasCallId(const char* callId) = 0;
215 
216  virtual enum handleWillingness willHandleMessage(const OsMsg& eventMessage) = 0;
217 
218  virtual UtlBoolean isQueued();
219 
220  virtual UtlBoolean isCallIdSet();
221 
222  virtual UtlBoolean isLocalHeld();
223 
224  virtual UtlBoolean canDisconnectConnection(Connection* pConnection) = 0;
225 
226  virtual UtlBoolean isInFocus() const { return mCallInFocus ;} ;
227 
228  /* //////////////////////////// PROTECTED ///////////////////////////////// */
229 protected:
230  virtual UtlBoolean handleMessage(OsMsg& eventMessage);
231  virtual UtlBoolean handleCallMessage(OsMsg& eventMessage) = 0;
232  virtual UtlBoolean handleMiNotificationMessage(MiNotification& notification) = 0 ;
233  virtual void onHook() = 0;
234 
235  virtual UtlBoolean getConnectionState(const char* remoteAddress, int& state) = 0;
236 
237  virtual UtlBoolean getTermConnectionState(const char* address,
238  const char* terminal,
239  int& state) = 0;
240 
241  void addHistoryEvent(const char* messageLogString);
242  void addHistoryEvent(const int msgSubType,
243  const CpMultiStringMessage* multiStringMessage);
244 
246  UtlString mCallId;
247  volatile UtlBoolean mCallInFocus;
248  UtlBoolean mRemoteDtmf;
249  UtlBoolean mDtmfEnabled;
250  OsRWMutex mCallIdMutex;
251  CpMediaInterface* mpMediaInterface;
257  UtlBoolean mLocalHeld;
258 
259  OsMsgDispatcher mMediaMsgDispatcher;
260 
261  UtlBoolean mDropping;
265  UtlString* mpMetaEventCallIds;
266 
268  UtlString mCallHistory[CP_CALL_HISTORY_LENGTH];
269 
270  /* //////////////////////////// PRIVATE /////////////////////////////////// */
271 private:
272 
273  static OsLockingList *spCallTrackingList;
274  //: maintains a list of the Call-nnn names
275 
276 
277  static OsStatus addToCallTrackingList(UtlString &rCallTaskName);
278  //: function used to add call names to the tracking list
279 
280  static OsStatus removeFromCallTrackingList(UtlString &rCallTaskName);
281  //: function used to remove call names from the tracking list
282 
284  UtlString mOriginalCallId;
285  UtlString mTargetCallId;
286 
287  CpCall& operator=(const CpCall& rhs);
288  //:Assignment operator (disabled)
289  CpCall(const CpCall& rCpCall);
290  //:Copy constructor (disabled)
291 
292  int tcStateFromEventId(int eventId);
293 };
294 
295 /* ============================ INLINE METHODS ============================ */
296 
297 #endif // _CpCall_h_
int mCallState
Definition: CpCall.h:253
OsMsgDispatcher mMediaMsgDispatcher
Definition: CpCall.h:259
Abstract call manager.
Definition: CpCallManager.h:97
int mCallIndex
Definition: CpCall.h:252
metaEventState
Definition: CpCall.h:68
int mMessageEventCount
Definition: CpCall.h:267
eventType
Definition: CpCall.h:61
static OsLockingList * spCallTrackingList
Definition: CpCall.h:273
int event
Definition: CpCall.h:42
UtlBoolean mRemoteDtmf
Definition: CpCall.h:248
int mLocalTermConnectionState
Definition: CpCall.h:256
callTypes
Definition: CpCall.h:75
volatile UtlBoolean mCallInFocus
Definition: CpCall.h:247
UtlBoolean enabled
Definition: CpCall.h:46
Definition: PtEvent.h:279
Definition: CpCall.h:64
int timeoutSecs
Definition: CpCall.h:44
UtlString mOriginalCallId
Definition: CpCall.h:284
Definition: CpCallManager.h:223
int ignoreKeyUp
Definition: CpCall.h:45
OsRWMutex mCallIdMutex
Definition: CpCall.h:250
Definition: Connection.h:58
int mCallType
Definition: CpCall.h:283
Definition: CpCall.h:92
UtlBoolean mDropping
Definition: CpCall.h:261
Definition: CpCall.h:108
CpCallManager * mpManager
Definition: CpCall.h:245
Definition: CpCall.h:77
int mNumMetaEventCalls
Definition: CpCall.h:264
Definition: CpCall.h:71
int interdigitSecs
Definition: CpCall.h:43
virtual UtlBoolean isInFocus() const
Definition: CpCall.h:226
int getLocalConnectionState()
Definition: CpCall.h:169
int mLocalConnectionState
Definition: CpCall.h:255
Definition: CpMultiStringMessage.h:33
CpMediaInterface * mpMediaInterface
Definition: CpCall.h:251
UtlString mCallId
Definition: CpCall.h:246
UtlBoolean mDtmfEnabled
Definition: CpCall.h:249
int mMetaEventId
Definition: CpCall.h:262
UtlString * mpMetaEventCallIds
Definition: CpCall.h:265
UtlString mTargetCallId
Definition: CpCall.h:285
#define CP_CALL_HISTORY_LENGTH
Definition: CallManager.h:41
int mHoldType
Definition: CpCall.h:254
handleWillingness
Definition: CpCall.h:101
Definition: CpCall.h:41
Definition: CpCall.h:56
UtlBoolean mLocalHeld
Definition: CpCall.h:257
int mMetaEventType
Definition: CpCall.h:263