sipXcallLib home page


PtGatewayInterface.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 _PtGatewayInterface_h_
13 #define _PtGatewayInterface_h_
14 
15 // SYSTEM INCLUDES
16 // APPLICATION INCLUDES
17 // DEFINES
18 // MACROS
19 // EXTERNAL FUNCTIONS
20 // EXTERNAL VARIABLES
21 // CONSTANTS
22 // STRUCTS
23 // TYPEDEFS
24 // FORWARD DECLARATIONS
26 class PtAudioCodec;
27 
28 //: Abstract gateway interface used to obtain call setup information from
29 //: a media gateway.
30 // To implement a media gateway using PTAPI one implements this class by
31 // deriving from it, creating an instance and registering it on the
32 // PtTerminal which represents the gateway via the
33 // PtTerminal::setGatewayInterface method. All of the methods on this
34 // class must be implemented.
35 // <BR>
36 // A call setup with the the gateway (incoming or out going) starts with
37 // the call to the <I>reserveLine</I> method. The gateway uses this method to
38 // indicate that whether it has resources to accept or initiate a call.
39 // Regardless of whether the gateway has resources for a line, the gateway
40 // must return a line handle which the gateway may use to correlate
41 // subsequent calls to methods on this class related to the same
42 // line/terminalConnection. If <I>reserveLine</I> returned with an availability
43 // other than LINE_AVAILABLE, the provider server will call the releaseLine
44 // method and the other side of the call will get appropriate indication.
45 // <BR>
46 // If <I>reserveLine</I> returned with an availability of LINE_AVAILABLE,
47 // the provider service will call the <I>getLineCapabilities</I>
48 // method to get the encoding capabilities for both sending and receiving
49 // of RTP packets. If a codec is found which is compatible with the other
50 // end of the call the provider will subsequently call the <I>startLineRtpSend</I>
51 // and <I>startLineRtpReceive</I> methods. However the order and timing in which
52 // these two methods are called will vary depending upon which side
53 // initiated the call and the implementation of the phone at the other end.
54 // <BR>
55 // When either side disconnects the call, the provider server will then
56 // invoke the stopLineRtpSend and stopLineRtpReceive methods. Again the
57 // order in which these are invoked may vary. Finally the releaseLine
58 // method will be invoked to indicate that the line is no longer needed.
59 // <BR>
60 // <H3>Other PTAPI Interfaces Relevent to Gateways</H3>
61 // For incoming calls (from other phones controlled by the PTAPI provider)
62 // to the gateway, methods on this interface will be called starting
63 // with <I>reserveLine</I>. However the gateway may want to implement a
64 // PtTerminalConnectionListener to register on the associated PtTerminal
65 // as well, to get call state information on calls to and from the gateway.
66 // <BR>
67 // For outgoing calls (to other phones controlled by the PTAPI provider)
68 // from the gateway, the gateway creates a call via PtProvider::createCall
69 // then sets up a call via the PtCall::connect method. The provider service
70 // will make subsequent calls to the methods in this class starting with
71 // <I>reserveLine</I>.
72 // <BR>
73 // Calls may be terminated by the gateway via the PtConnection::disconnect
74 // method, regardless of which side initiated the call.
75 
77 {
78 /* //////////////////////////// PUBLIC //////////////////////////////////// */
79 public:
80 
82  {
87  }
88  //: Availability states for the gateway
93 
94 
95 /* ============================ CREATORS ================================== */
96 
98  //:Default constructor
99 
100  virtual
102  //:Destructor
103 
104 /* ============================ MANIPULATORS ============================== */
105 
106  virtual PtStatus reserveLine(PtTerminalConnection& rGatewayTerminalConnection,
107  const char* destinationAddress,
108  PtGatewayAvailability& rAvailablity,
109  void*& rReservationHandle) = 0;
110  //: Request to reserve a line on the gateway to the given PBX or PSTN
111  //: phone
112  // The OpenPhone SDK calls this method to reserve a line
113  // on this gateway. The gateway checks that a line is available and
114  // that the identified destination phone is not busy.
115  // Note: releaseLine is called even when a call to <I>reserveLine</I> indicates
116  // that a line is not available. <I>reserveLine</I> should therefore always
117  // return a reservationHandle which is meaningful to releaseLine.
118  // This method must be implemented by the
119  // gateway or PBX if call setup is to be performed via the API.
124 
125  virtual PtStatus getLineCapabilities(void* reservationHandle,
126  PtMediaCapabilities& rCapabilities,
127  char rtpReceiveIpAddress[],
128  int maxAddressLength,
129  int& rRtpReceivePort) = 0;
130  //: Get the codec capabilities for the reserved line
131  // This method must be implemented by the
132  // gateway or PBX if call setup is to be performed via the API.
133  // Note: This method may be called more than once
134  // during a single call on the same line to re-negotiate codecs.
140 
141  virtual PtStatus startLineRtpSend(void* reservationHandle, const PtAudioCodec& rSendCodec,
142  const char* sendAddress, int sendPort) = 0;
143  //: Start sending audio via RTP and RTCP for the line indicated
144  // This method must be implemented by the
145  // gateway or PBX if call setup is to be performed via the API.
146  // Note: This method may be called more than once
147  // during a single call on the same line to change codecs.
152 
153  virtual PtStatus startLineRtpReceive(void* reservationHandle, const PtAudioCodec& rReceiveCodec) = 0;
154  //: Start receiving audio via RTP and RTCP for the line indicated
155  // This method must be implemented by the
156  // gateway or PBX if call setup is to be performed via the API.
157  // Note: that although it is specified what encoding method the gateway should
158  // expect in received RTP packets, it is recommended for robustness that
159  // the gateway handle any of the encodings specified in the capabilities
160  // of the getLineCapabilities method.
161  // Note: This method may be called more than once
162  // during a single call on the same line to change codecs.
165 
166  virtual PtStatus stopLineRtpSend(void* reservationHandle) = 0;
167  //: Stop sending RTP and RTCP for the line indicated
168  // This method must be implemented by the
169  // gateway or PBX if call setup is to be performed via the API.
171 
172  virtual PtStatus stopLineRtpReceive(void* reservationHandle) = 0;
173  //: Stop receiving RTP and RTCP for the line indicated
174  // This method must be implemented by the
175  // gateway or PBX if call setup is to be performed via the API.
177 
178  virtual PtStatus releaseLine(void* reservationHandle) = 0;
179  //: Notify the gateway that line is no longer needed.
180  // Note: this method is called even when a call to <I>reserveLine</I> indicates
181  // that a line is not available. <I>reserveLine</I> should therefore always
182  // return a reservationHandle which is meaningful to releaseLine.
183  // This method must be implemented by the
184  // gateway or PBX if call setup is to be performed via the API.
186 
187 /* ============================ ACCESSORS ================================= */
188 
189 
190 /* ============================ INQUIRY =================================== */
191 
192 /* //////////////////////////// PROTECTED ///////////////////////////////// */
193 protected:
194 
195 /* //////////////////////////// PRIVATE /////////////////////////////////// */
196 private:
197  PtGatewayInterface(const PtGatewayInterface& rPtGatewayInterface);
198  //:Copy constructor (disabled)
199 
201  //:Assignment operator (disabled)
202 
203 };
204 
205 /* ============================ INLINE METHODS ============================ */
206 
207 #endif // _PtGatewayInterface_h_
PtStatus
Definition: PtDefs.h:49
Definition: PtGatewayInterface.h:84
Definition: PtGatewayInterface.h:83
Definition: PtGatewayInterface.h:85
virtual ~PtGatewayInterface()
virtual PtStatus reserveLine(PtTerminalConnection &rGatewayTerminalConnection, const char *destinationAddress, PtGatewayAvailability &rAvailablity, void *&rReservationHandle)=0
PtGatewayInterface & operator=(const PtGatewayInterface &rhs)
virtual PtStatus releaseLine(void *reservationHandle)=0
param: (in) reservationHandle - handle indicating the line on which to stop receiving RTP and RTCP ...
PtGatewayAvailability
Definition: PtGatewayInterface.h:81
enum PtGatewayInterface::PtGatewayAvailability PtGatewayInterface()
enumcode: UNKNOWN - error state enumcode: LINE_AVAILABLE - a line is available on this gateway on whi...
virtual PtStatus stopLineRtpReceive(void *reservationHandle)=0
param: (in) reservationHandle - handle indicating the line on which to stop sending RTP and RTCP ...
Definition: PtTerminalConnection.h:139
virtual PtStatus startLineRtpReceive(void *reservationHandle, const PtAudioCodec &rReceiveCodec)=0
param: (in) reservationHandle - handle indicating the line on which to start sending RTP and RTCP par...
Definition: PtAudioCodec.h:40
Definition: PtGatewayInterface.h:76
virtual PtStatus startLineRtpSend(void *reservationHandle, const PtAudioCodec &rSendCodec, const char *sendAddress, int sendPort)=0
param: (in) reservationHandle - handle indicating the line on which to obtain capabilities param: (ou...
virtual PtStatus getLineCapabilities(void *reservationHandle, PtMediaCapabilities &rCapabilities, char rtpReceiveIpAddress[], int maxAddressLength, int &rRtpReceivePort)=0
param: (in) rGatewayTerminalConnection - the terminal connection on this gateway for the call...
Definition: PtGatewayInterface.h:86
virtual PtStatus stopLineRtpSend(void *reservationHandle)=0
param: (in) reservationHandle - handle indicating the line on which to start receiving RTP and RTCP p...
Definition: PtMediaCapabilities.h:31