OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

iax2con.h
Go to the documentation of this file.
1 /*
2 *
3 * Inter Asterisk Exchange 2
4 *
5 * Open Phone Abstraction Library (OPAL)
6 *
7 * Describes the IAX2 extension of the OpalConnection class.
8 *
9 * Copyright (c) 2005 Indranet Technologies Ltd.
10 *
11 * The contents of this file are subject to the Mozilla Public License
12 * Version 1.0 (the "License"); you may not use this file except in
13 * compliance with the License. You may obtain a copy of the License at
14 * http://www.mozilla.org/MPL/
15 *
16 * Software distributed under the License is distributed on an "AS IS"
17 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18 * the License for the specific language governing rights and limitations
19 * under the License.
20 *
21 * The Original Code is Open Phone Abstraction Library.
22 *
23 * The Initial Developer of the Original Code is Indranet Technologies Ltd.
24 *
25 * The author of this code is Derek J Smithies
26 *
27 * $Revision: 24606 $
28 * $Author: dereksmithies $
29 * $Date: 2010-07-28 22:51:05 -0500 (Wed, 28 Jul 2010) $
30 */
31
32 #ifndef OPAL_IAX2_IAX2CON_H
33 #define OPAL_IAX2_IAX2CON_H
34
35 #ifndef _PTLIB_H
36 #include <ptlib.h>
37 #endif
38
39 #include <opal/buildopts.h>
40
41 #if OPAL_IAX2
42
43 #include <opal/connection.h>
44 #include <rtp/jitter.h>
45
46 #include <iax2/frame.h>
47 #include <iax2/iedata.h>
48 #include <iax2/processor.h>
49 #include <iax2/callprocessor.h>
50 #include <iax2/safestrings.h>
51 #include <iax2/sound.h>
52
53 class IAX2EndPoint;
54
55
57
63 class IAX2Connection : public OpalConnection
64 {
65 PCLASSINFO(IAX2Connection, OpalConnection);
66
67 public:
70
73 IAX2Connection(
74 OpalCall & call,
75 IAX2EndPoint & endpoint,
76 const PString & token,
77 void *userData,
78 const PString & remoteParty,
79 const PString & remotePartyName = PString::Empty()
80 );
81
85 ~IAX2Connection();
87
91 void StartOperation();
92
101 virtual bool IsNetworkConnection() const { return true; }
102
110 virtual bool TransferConnection(
111 const PString & remoteParty
112 );
113
132 virtual void OnReleased();
133
144 OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
145
147 void EndCallNow(
148 CallEndReason reason = EndedByLocalUser
149 );
150
152 void SendDtmf(const PString & dtmf);
153
155 virtual PBoolean SendUserInputString(const PString & value );
156
158 virtual PBoolean SendUserInputTone(char tone, unsigned duration );
159
161 PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); }
162
171 virtual void AnsweringCall(
172 AnswerCallResponse response
173 );
174
182 void OnConnected();
183
195 virtual PBoolean SetConnected();
196
211 void OnEstablished();
212
227 virtual void Release( CallEndReason reason = EndedByLocalUser
228 );
229
241 PBoolean SetAlerting(
242 const PString & calleeName,
243 PBoolean withMedia
244 );
245
253 virtual OpalMediaStream * CreateMediaStream(
254 const OpalMediaFormat & mediaFormat,
255 unsigned sessionID,
256 PBoolean isSource
257 );
258
269 void SetCallToken(PString newToken);
270
272 PString GetCallToken() { return iax2Processor.GetCallToken(); }
273
276 void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
277
281 void PutSoundPacketToNetwork(PBYTEArray *sund);
282
285 void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
286
291 PBoolean ReadSoundPacket(RTP_DataFrame & packet);
292
294 IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); }
295
297 IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); }
298
300 const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); }
301
306 void OnSetUp();
307
308
316 PBoolean SetUpConnection();
317
318
322 PINDEX GetSupportedCodecs();
323
327 PINDEX GetPreferredCodec();
328
331 void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
332
333
341 unsigned int ChooseCodec();
342
350 virtual bool Hold(
351 bool fromRemote,
352 bool placeOnHold
353 );
354
359 virtual bool IsOnHold(
360 bool fromRemote
361 );
362
364 void RemoteHoldConnection();
365
367 void RemoteRetrieveConnection();
368
375 void SetUserName(PString & inUserName) { userName = inUserName; };
376
378 PString GetUserName() const { return userName; };
379
386 void SetPassword(PString & inPassword) { password = inPassword; };
387
389 PString GetPassword() const { return password; };
390
391
401 virtual PBoolean ForwardCall(
402 const PString & forwardParty
403 );
404
408 void IncomingEthernetFrame (IAX2Frame *frame);
409
413 //static PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame);
414
416 IAX2EndPoint & GetEndPoint() { return endpoint; }
417
420 void ReportStatistics();
421
422
423 protected:
424
426 PString userName;
427
429 PString password;
430
434
436 IAX2EndPoint &endpoint;
437
440 OpalMediaFormatList remoteMediaFormats;
441
444 OpalMediaFormatList localMediaFormats;
445
447 IAX2CallProcessor & iax2Processor;
448
450 PBoolean local_hold;
451
453 PBoolean remote_hold;
454
456
459 OpalJitterBuffer jitterBuffer;
460
468 RTP_DataFrame::PayloadTypes opalPayloadType;
469
470 friend class IAX2CallProcessor;
471 };
472
473
475
476
477 #endif // OPAL_IAX2
478
479 #endif // OPAL_IAX2_IAX2CON_H
480
481 /* The comment below is magic for those who use emacs to edit this file.
482 * With the comment below, the tab key does auto indent to 2 spaces.
483 *
484 * Local Variables:
485 * mode:c
486 * c-basic-offset:2
487 * End:
488 */