50
52
* @file iaxvoiplink.h
51
* @brief VoIPLink contains a thread that listen to external events
53
* @brief VoIPLink contains a thread that listen to external events
52
54
* and contains IAX Call related functions
55
57
class IAXVoIPLink : public VoIPLink
61
* @param accountID The account containing the voip link
63
IAXVoIPLink(const AccountID& accountID);
71
* Listen to events sent by the call manager ( asterisk, etc .. )
77
* @return true if successful
83
* Terminate a voip link by clearing the call list
85
void terminate (void);
90
void terminateOneCall(const CallID& id);
93
* Send out registration
94
* @return bool The new registration state (are we registered ?)
96
int sendRegister (AccountID id);
99
* Destroy registration session
100
* @todo Send an IAX_COMMAND_REGREL to force unregistration upstream.
102
* @return bool true if we're registered upstream
105
int sendUnregister (AccountID id);
108
* Create a new outgoing call
109
* @param id The ID of the call
110
* @param toUrl The address to call
111
* @return Call* A pointer on the call
113
Call* newOutgoingCall(const CallID& id, const std::string& toUrl);
117
* @param id The ID of the call
118
* @return bool true on success
121
bool answer(const CallID& id);
125
* @param id The ID of the call
126
* @return bool true on success
129
bool hangup(const CallID& id);
133
* @param id The ID of the call
134
* @return bool true on success
137
bool peerHungup(const CallID& id);
141
* @param id The ID of the call
142
* @return bool true on success
145
bool cancel(const CallID& id UNUSED ) { return false; }
149
* @param id The ID of the call
150
* @return bool true on success
153
bool onhold(const CallID& id);
156
* Put a call off hold
157
* @param id The ID of the call
158
* @return bool true on success
161
bool offhold(const CallID& id);
165
* @param id The ID of the call
166
* @param to The recipient of the transfer
167
* @return bool true on success
170
bool transfer(const CallID& id, const std::string& to);
174
* @param id The ID of the call
175
* @return bool true on success
178
bool refuse (const CallID& id);
182
* @param id The ID of the call
183
* @param code The code of the DTMF
184
* @return bool true on success
187
bool carryingDTMFdigits(const CallID& id, char code);
189
bool sendMessage(const std::string& to UNUSED, const std::string& body UNUSED) { return false; }
191
bool isContactPresenceSupported() { return false; }
194
* Return the codec protocol used for this call
195
* @param id The call identifier
197
std::string getCurrentCodecName();
200
public: // iaxvoiplink only
202
void updateAudiolayer( void );
207
* Decode the message count IAX send.
208
* Returns only the new messages number
210
* @param msgcount The value sent by IAX in the REGACK message
211
* @return int The number of new messages waiting for the current registered user
213
int processIAXMsgCount( int msgcount );
217
* Get IAX Call from an id
219
* @return IAXCall pointer or 0
221
IAXCall* getIAXCall(const CallID& id);
226
void terminateIAXCall();
229
* Find a iaxcall by iax session number
230
* @param session an iax_session valid pointer
231
* @return iaxcall or 0 if not found
233
IAXCall* iaxFindCallBySession(struct iax_session* session);
236
* Handle IAX Event for a call
237
* @param event An iax_event pointer
238
* @param call An IAXCall pointer
240
void iaxHandleCallEvent(iax_event* event, IAXCall* call);
243
* Handle the VOICE events specifically
244
* @param event The iax_event containing the IAX_EVENT_VOICE
245
* @param call The associated IAXCall
247
void iaxHandleVoiceEvent(iax_event* event, IAXCall* call);
250
* Handle IAX Registration Reply event
251
* @param event An iax_event pointer
253
void iaxHandleRegReply(iax_event* event);
256
* Handle IAX pre-call setup-related events
257
* @param event An iax_event pointer
259
void iaxHandlePrecallEvent(iax_event* event);
262
* Work out the audio data from Microphone to IAX2 channel
264
void sendAudioFromMic(void);
267
* Send an outgoing call invite to iax
268
* @param call An IAXCall pointer
270
bool iaxOutgoingInvite(IAXCall* call);
272
/** Threading object */
273
EventThread* _evThread;
275
/** registration session : 0 if not register */
276
struct iax_session* _regSession;
278
/** Timestamp of when we should refresh the registration up with
279
* the registrar. Values can be: EPOCH timestamp, 0 if we want no registration, 1
280
* to force a registration. */
281
int _nextRefreshStamp;
283
/** Mutex for iax_ calls, since we're the only one dealing with the incorporated
284
* iax_stuff inside this class. */
285
ost::Mutex _mutexIAX;
287
/** Connection to audio card/device */
288
AudioLayer* audiolayer;
290
/** Mic-data related buffers */
291
SFLDataFormat* micData;
292
SFLDataFormat* micDataConverted;
293
unsigned char* micDataEncoded;
295
/** Speaker-data related buffers */
296
SFLDataFormat* spkrDataDecoded;
297
SFLDataFormat* spkrDataConverted;
299
/** Sample rate converter object */
300
SamplerateConverter* converter;
302
int converterSamplingRate;
304
/** number of sample */
307
/** number of sample before conversion (recording) */
313
/** Counter for IncomingCallNotification */
63
* @param accountID The account containing the voip link
65
IAXVoIPLink (const AccountID& accountID);
73
* Listen to events sent by the call manager ( asterisk, etc .. )
79
* @return true if successful
85
* Terminate a voip link by clearing the call list
87
void terminate (void);
92
void terminateOneCall (const CallID& id);
95
* Send out registration
96
* @return bool The new registration state (are we registered ?)
98
int sendRegister (AccountID id);
101
* Destroy registration session
102
* @todo Send an IAX_COMMAND_REGREL to force unregistration upstream.
104
* @return bool true if we're registered upstream
107
int sendUnregister (AccountID id);
110
* Create a new outgoing call
111
* @param id The ID of the call
112
* @param toUrl The address to call
113
* @return Call* A pointer on the call
115
Call* newOutgoingCall (const CallID& id, const std::string& toUrl);
119
* @param id The ID of the call
120
* @return bool true on success
123
bool answer (const CallID& id);
127
* @param id The ID of the call
128
* @return bool true on success
131
bool hangup (const CallID& id);
135
* @param id The ID of the call
136
* @return bool true on success
139
bool peerHungup (const CallID& id);
143
* @param id The ID of the call
144
* @return bool true on success
147
bool cancel (const CallID& id UNUSED) {
153
* @param id The ID of the call
154
* @return bool true on success
157
bool onhold (const CallID& id);
160
* Put a call off hold
161
* @param id The ID of the call
162
* @return bool true on success
165
bool offhold (const CallID& id);
169
* @param id The ID of the call
170
* @param to The recipient of the transfer
171
* @return bool true on success
174
bool transfer (const CallID& id, const std::string& to);
178
* @param id The ID of the call
179
* @return bool true on success
182
bool refuse (const CallID& id);
186
* @param id The ID of the call
187
* @param code The code of the DTMF
188
* @return bool true on success
191
bool carryingDTMFdigits (const CallID& id, char code);
194
bool sendTextMessage (sfl::InstantMessaging *module, const std::string& callID, const std::string& message, const std::string& from);
196
bool isContactPresenceSupported() {
201
* Return the codec protocol used for this call
202
* @param id The call identifier
204
std::string getCurrentCodecName();
207
public: // iaxvoiplink only
209
void updateAudiolayer (void);
214
* Decode the message count IAX send.
215
* Returns only the new messages number
217
* @param msgcount The value sent by IAX in the REGACK message
218
* @return int The number of new messages waiting for the current registered user
220
int processIAXMsgCount (int msgcount);
224
* Get IAX Call from an id
226
* @return IAXCall pointer or 0
228
IAXCall* getIAXCall (const CallID& id);
233
void terminateIAXCall();
236
* Find a iaxcall by iax session number
237
* @param session an iax_session valid pointer
238
* @return iaxcall or 0 if not found
240
IAXCall* iaxFindCallBySession (struct iax_session* session);
243
* Handle IAX Event for a call
244
* @param event An iax_event pointer
245
* @param call An IAXCall pointer
247
void iaxHandleCallEvent (iax_event* event, IAXCall* call);
250
* Handle the VOICE events specifically
251
* @param event The iax_event containing the IAX_EVENT_VOICE
252
* @param call The associated IAXCall
254
void iaxHandleVoiceEvent (iax_event* event, IAXCall* call);
257
* Handle IAX Registration Reply event
258
* @param event An iax_event pointer
260
void iaxHandleRegReply (iax_event* event);
263
* Handle IAX pre-call setup-related events
264
* @param event An iax_event pointer
266
void iaxHandlePrecallEvent (iax_event* event);
269
* Work out the audio data from Microphone to IAX2 channel
271
void sendAudioFromMic (void);
274
* Send an outgoing call invite to iax
275
* @param call An IAXCall pointer
277
bool iaxOutgoingInvite (IAXCall* call);
279
/** Threading object */
280
EventThread* _evThread;
282
/** registration session : 0 if not register */
283
struct iax_session* _regSession;
285
/** Timestamp of when we should refresh the registration up with
286
* the registrar. Values can be: EPOCH timestamp, 0 if we want no registration, 1
287
* to force a registration. */
288
int _nextRefreshStamp;
290
/** Mutex for iax_ calls, since we're the only one dealing with the incorporated
291
* iax_stuff inside this class. */
292
ost::Mutex _mutexIAX;
294
/** Connection to audio card/device */
295
AudioLayer* audiolayer;
297
/** Mic-data related buffers */
298
SFLDataFormat* micData;
299
SFLDataFormat* micDataConverted;
300
unsigned char* micDataEncoded;
302
/** Speaker-data related buffers */
303
SFLDataFormat* spkrDataDecoded;
304
SFLDataFormat* spkrDataConverted;
306
/** Sample rate converter object */
307
SamplerateConverter* converter;
309
int converterSamplingRate;
311
/** number of sample */
314
/** number of sample before conversion (recording) */
320
/** Counter for IncomingCallNotification */