Project

General

Profile

SipMiddlewareApi » History » Version 215

Saúl Ibarra Corretgé, 11/09/2012 01:37 PM

1 147 Adrian Georgescu
h1. Middleware API
2 102 Adrian Georgescu
3 1 Adrian Georgescu
4
5
6 147 Adrian Georgescu
This chapter describes the _Middleware API_ for SIP SIMPLE client SDK that can be used for developing a user interface (e.g. Graphical User Interface). The Middleware provides a _non-blocking_ API  that communicates with the user interface asynchronously by using _Notifications_. For its configuration, the Middleware uses the [[SipConfigurationAPI|Configuration API]].
7 1 Adrian Georgescu
8 152 Tijmen de Mes
!={width:500px}sipsimple-middleware.png!
9 147 Adrian Georgescu
10
11
h2. SIPApplication
12
13
14 181 Tijmen de Mes
Implemented in source:sipsimple/application.py
15 1 Adrian Georgescu
16
Implements a high-level application responsable for starting and stopping various sub-systems required to implement a fully featured SIP User Agent application. The SIPApplication class is a Singleton and can be instantiated from any part of the code, obtaining a reference to the same object. The SIPApplication takes care of initializing the following components:
17 147 Adrian Georgescu
* the twisted thread
18
* the configuration system, via the [[SipConfigurationAPI#ConfigurationManager|ConfigurationManager]]
19
* the core [[SipCoreApiDocumentation#Engine|Engine]] using the settings in the configuration
20
* the [[SipMiddlewareApi#AccountManager|AccountManager]], using the accounts in the configuration
21
* the [[SipMiddlewareApi#SessionManager|SessionManager]], in order to handle incoming sessions
22
* two [[SipMiddlewareApi#AudioBridge|AudioBridges]], using the settings in the configuration
23 1 Adrian Georgescu
24
The attributes in this class can be set and accessed on both this class and its subclasses, as they are implemented using descriptors which keep single value for each attribute, irrespective of the class from which that attribute is set/accessed. Usually, all attributes should be considered read-only.
25
26
27 178 Tijmen de Mes
*methods*
28 1 Adrian Georgescu
29 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
30
>Instantiates a new SIPApplication.
31 1 Adrian Georgescu
32 147 Adrian Georgescu
*start*(_self_, *storage*)
33
>Starts the @SIPApplication@ which initializes all the components in the correct order. The @storage@ is saved as an attribute which other entities like the @Configuration Manager@ will use to take the appropriate backend. If any error occurs with loading the configuration, the exception raised by the @ConfigurationManager@ is propagated by this method and @SIPApplication@ can be started again. After this, any fatal errors will result in the SIPApplication being stopped and unusable, which means the whole application will need to stop. This method returns as soon as the twisted thread has been started, which means the application must wait for the @SIPApplicationDidStart@ notification in order to know that the application started.
34 1 Adrian Georgescu
35 147 Adrian Georgescu
*stop*(_self_)
36
>Stop all the components started by the SIPApplication. This method returns immediately, but a @SIPApplicationDidEnd@ notification is sent when all the components have been stopped.
37 1 Adrian Georgescu
38
39 179 Tijmen de Mes
*attributes*
40 1 Adrian Georgescu
41 147 Adrian Georgescu
*running*
42 154 Tijmen de Mes
>@True@ if the SIPApplication is running (it has been started and it has not been told to stop), @False@ otherwise.
43 1 Adrian Georgescu
44 147 Adrian Georgescu
*storage*
45
>Holds an object which implements the @ISIPSimpleStorage@ interface which will be used to provide a storage facility to other middleware components.
46 1 Adrian Georgescu
47 147 Adrian Georgescu
*local_nat_type*
48
>String containing the detected local NAT type.
49 1 Adrian Georgescu
50 147 Adrian Georgescu
*alert_audio_mixer*
51
>The @AudioMixer@ object created on the alert audio device as defined by the configuration (by SIPSimpleSettings.audio.alert_device).
52 1 Adrian Georgescu
53 147 Adrian Georgescu
*alert_audio_bridge*
54
>An @AudioBridge@ where @IAudioPort@ objects can be added to playback sound to the alert device.
55 1 Adrian Georgescu
56 147 Adrian Georgescu
*alert_audio_device*
57
>An @AudioDevice@ which corresponds to the alert device as defined by the configuration. This will always be part of the alert_audio_bridge.
58 1 Adrian Georgescu
59 147 Adrian Georgescu
*voice_audio_mixer*
60
>The @AudioMixer@ object created on the voice audio device as defined by the configuration (by SIPSimpleSettings.audio.input_device and SIPSimpleSettings.audio.output_device).
61 1 Adrian Georgescu
62 147 Adrian Georgescu
*voice_audio_bridge*
63
>An @AudioBridge@ where @IAudioPort@ objects can be added to playback sound to the output device or record sound from the input device.
64 1 Adrian Georgescu
65 147 Adrian Georgescu
*voice_audio_device*
66
>An @AudioDevice@ which corresponds to the voice device as defined by the configuration. This will always be part of the voice_audio_bridge.
67 1 Adrian Georgescu
68
69 179 Tijmen de Mes
*notifications *
70 1 Adrian Georgescu
71
72
73
*SIPApplicationWillStart*
74 147 Adrian Georgescu
>This notification is sent just after the configuration has been loaded and the twisted thread started, but before any other components have been initialized.
75 158 Tijmen de Mes
76 153 Tijmen de Mes
>+_timestamp_+:
77 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
78 147 Adrian Georgescu
79 1 Adrian Georgescu
*SIPApplicationDidStart*
80 147 Adrian Georgescu
>This notification is sent when all the components have been initialized. Note: it doesn't mean that all components have succeeded, for example, the account might not have registered by this time, but the registration process will have started.
81 158 Tijmen de Mes
82 153 Tijmen de Mes
>+_timestamp_+:
83 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
84 1 Adrian Georgescu
85 147 Adrian Georgescu
*SIPApplicationWillEnd*
86 1 Adrian Georgescu
>This notification is sent as soon as the @stop()@ method has been called.
87 158 Tijmen de Mes
88 153 Tijmen de Mes
>+_timestamp_+:
89 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
90 1 Adrian Georgescu
91 147 Adrian Georgescu
*SIPApplicationDidEnd*
92
>This notification is sent when all the components have been stopped. All components have been given reasonable time to shutdown gracefully, such as the account unregistering. However, because of factors outside the control of the middleware, such as network problems, some components might not have actually shutdown gracefully; this is needed because otherwise the SIPApplication could hang indefinitely (for example because the system is no longer connected to a network and it cannot be determined when it will be again).
93 158 Tijmen de Mes
94 153 Tijmen de Mes
>+_timestamp_+:
95 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
96 147 Adrian Georgescu
97 1 Adrian Georgescu
*SIPApplicationFailedToStartTLS*
98 147 Adrian Georgescu
>This notification is sent when a problem arises with initializing the TLS transport. In this case, the Engine will be started without TLS support and this notification contains the error which identifies the cause for not being able to start the TLS transport.
99 158 Tijmen de Mes
100 153 Tijmen de Mes
>+_timestamp_+:
101 157 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
102 158 Tijmen de Mes
103 153 Tijmen de Mes
>+_error_+:
104 157 Tijmen de Mes
>>The exception raised by the Engine which identifies the cause for not being able to start the TLS transport.
105 1 Adrian Georgescu
106
107
108 147 Adrian Georgescu
h2. Storage API
109
110
111
Different middleware components may need to store data, i.e. configuration files or XCAP documents. The @Storage API@ defines a collection of backends which other components will use to store their data.
112
113
114
h3. API Definition
115
116
117
The @Storage API@ currently requires the following attributes to be defined as per the @ISIPSimpleStorage@ interface:
118
119
*configuration_backend*
120
>The backend used for storing the configuration.
121
122
*xcap_storage_factory*
123
>Factory used to create XCAP storage backends for each account.
124
125
126
h3. Provided implementations
127
128
129
Two storage implementations are provided: *FileStorage* and *MemoryStorage* both located in the *sipsimple.storage* module.
130
131
132
h2. SIP Sessions
133
134
135
SIP sessions are supported by the @sipsimple.session.Session@ class and independent stream classes, which need to implement the @sipsimple.streams.IMediaStream@ interface. The @Session@ class takes care of the signalling, while the streams offer the actual media support which is negotiated by the @Session@. The streams which are implemented in the SIP SIMPLE middleware are provided in modules within the @sipsimple.streams@ package, but they are accessible for import directly from @sipsimple.streams@. Currently, the middleware implements two types of streams, one for RTP data, with a concrete implementation in the @AudioStream@ class, and one for MSRP sessions, with concrete implementations in the @ChatStream@, @FileTransferStream@ and @DesktopSharingStream@ classes. However, the application can provide its own stream implementation, provided they respect the @IMediaStream@ interface.
136
137
The @sipsimple.streams@ module also provides a mechanism for automatically registering media streams in order for them to be used for incoming sessions. This is explained in more detail in [[SipMiddlewareApi#MediaStreamRegistry|MediaStreamRegistry]].
138
139
140
141
h3. SessionManager
142
143
144 182 Tijmen de Mes
Implemented in source:sipsimple/session.py
145 1 Adrian Georgescu
146 147 Adrian Georgescu
The @sipsimple.session.SessionManager@ class is a singleton, which acts as the central aggregation point for sessions within the middleware.
147 1 Adrian Georgescu
Although it is mainly used internally, the application can use it to query information about all active sessions.
148
The SessionManager is implemented as a singleton, meaning that only one instance of this class exists within the middleware. The SessionManager is started by the SIPApplication and takes care of handling incoming sessions and closing all sessions when SIPApplication is stopped.
149
150
151 179 Tijmen de Mes
*attributes*
152 1 Adrian Georgescu
153
154
155 147 Adrian Georgescu
*sessions*
156
>A property providing a copy of the list of all active @Sesssion@ objects within the application, meaning any @Session@ object that exists globally within the application and is not in the @NULL@ or @TERMINATED@ state.
157 1 Adrian Georgescu
158
159 179 Tijmen de Mes
*methods*
160 1 Adrian Georgescu
161
162
163 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_)
164
>Instantiate a new @SessionManager@ object.
165 1 Adrian Georgescu
166 147 Adrian Georgescu
167
*start*(_self_)
168
>Start the @SessionManager@ in order to be able to handle incoming sessions. This method is called automatically when SIPApplication is started. The application should not call this method directly.
169
170
*stop*(_self_)
171
>End all connected sessions. This method is called automatically when SIPApplication is stopped. The application should not call this method directly.
172
173
174
h3. Session
175
176
177 182 Tijmen de Mes
Implemented in source:sipsimple/session.py
178 1 Adrian Georgescu
179 147 Adrian Georgescu
A @sipsimple.session.Session@ object represents a complete SIP session between the local and a remote endpoints. Both incoming and outgoing sessions are represented by this class.
180 1 Adrian Georgescu
181 155 Tijmen de Mes
A @Session@ instance is a stateful object, meaning that it has a @state@ attribute and that the lifetime of the session traverses different states, from session creation to termination. State changes are triggered by methods called on the object by the application or by received network events. These states and their transitions are represented in the following diagram:
182 1 Adrian Georgescu
183 156 Tijmen de Mes
!sipsimple-core-invite-state-machine-2.png!
184 1 Adrian Georgescu
185 147 Adrian Georgescu
Although these states are crucial to the correct operation of the @Session@ object, an application using this object does not need to keep track of these states, as a set of notifications is also emitted, which provide all the necessary information to the application.
186 1 Adrian Georgescu
187 147 Adrian Georgescu
The @Session@ is completely independent of the streams it contains, which need to be implementations of the @sipsimple.streams.IMediaStream@ interface. This interface provides the API by which the @Session@ communicates with the streams. This API should not be used by the application, unless it also provides stream implementations or a SIP INVITE session implementation.
188 1 Adrian Georgescu
189
190 179 Tijmen de Mes
*methods*
191 1 Adrian Georgescu
192
193
194 147 Adrian Georgescu
*<notextile>__init__</notextile>*(_self_, *account*)
195
>Creates a new @Session@ object in the @None@ state.
196 158 Tijmen de Mes
197 1 Adrian Georgescu
>+_account_+:
198 157 Tijmen de Mes
>>The local account to be associated with this @Session@.
199 1 Adrian Georgescu
200 147 Adrian Georgescu
*connect*(_self_, *to_header*, *routes*, *streams*, *is_focus*=@False@, *subject*=@None@)
201
>Will set up the @Session@ as outbound and propose the new session to the specified remote party and move the state machine to the @outgoing@ state.
202
>Before contacting the remote party, a @SIPSessionNewOutgoing@ notification will be emitted.
203
>If there is a failure or the remote party rejected the offer, a @SIPSessionDidFail@ notification will be sent.
204
>Any time a ringing indication is received from the remote party, a @SIPSessionGotRingIndication@ notification is sent.
205
>If the remote party accepted the session, a @SIPSessionWillStart@ notification will be sent, followed by a @SIPSessionDidStart@ notification when the session is actually established.
206
>This method may only be called while in the @None@ state.
207 158 Tijmen de Mes
208 1 Adrian Georgescu
>+_to_header_+:
209 157 Tijmen de Mes
>>A @sipsimple.core.ToHeader@ object representing the remote identity to initiate the session to.
210 158 Tijmen de Mes
211 147 Adrian Georgescu
>+_routes_+:
212 157 Tijmen de Mes
>>An iterable of @sipsimple.util.Route@ objects, specifying the IP, port and transport to the outbound proxy.
213
>>These routes will be tried in order, until one of them succeeds.
214 158 Tijmen de Mes
215 147 Adrian Georgescu
>+_streams_+:
216 157 Tijmen de Mes
>>A list of stream objects which will be offered to the remote endpoint.
217 158 Tijmen de Mes
218 147 Adrian Georgescu
>+_is_focus_+:
219 1 Adrian Georgescu
>>Boolean flag indicating if the @isfocus@ parameter should be added to the @Contact@ header according to RFC 4579.
220 158 Tijmen de Mes
221 147 Adrian Georgescu
>+_subject_+:
222
>>Session subject. If not None a @Subject@ header will be added with the specified value.
223 158 Tijmen de Mes
224 1 Adrian Georgescu
*send_ring_indication*(_self_)
225 147 Adrian Georgescu
>Sends a 180 provisional response in the case of an incoming session.
226
227
*accept*(_self_, *streams*)
228
>Calling this methods will accept an incoming session and move the state machine to the @accepting@ state.
229
>When there is a new incoming session, a @SIPSessionNewIncoming@ notification is sent, after which the application can call this method on the sender of the notification.
230 1 Adrian Georgescu
>After this method is called, @SIPSessionWillStart@ followed by @SIPSessionDidStart@ will be emitted, or @SIPSessionDidFail@ on an error.
231 147 Adrian Georgescu
>This method may only be called while in the @incoming@ state.
232
  
233
>+_streams_+:
234 158 Tijmen de Mes
>>A list of streams which needs to be a subset of the proposed streams which indicates which streams are to be accepted. All the other proposed streams will be rejected.
235 147 Adrian Georgescu
236
*reject*(_self_, *code*=@603@, *reason*=@None@)
237
>Reject an incoming session and move it to the @terminating@ state, which eventually leads to the @terminated@ state.
238 1 Adrian Georgescu
>Calling this method will cause the @Session@ object to emit a @SIPSessionDidFail@ notification once the session has been rejected.
239 147 Adrian Georgescu
>This method may only be called while in the @incoming@ state.
240
  
241 1 Adrian Georgescu
>+_code_+:
242 158 Tijmen de Mes
>>An integer which represents the SIP status code in the response which is to be sent. Usually, this is either 486 (Busy) or 603 (Decline/Busy Everywhere).
243 147 Adrian Georgescu
  
244
>+_reason_+:
245 158 Tijmen de Mes
>>The string which is to be sent as the SIP status reason in the response, or None if PJSIP's default reason for the specified code is to be sent.
246 147 Adrian Georgescu
247 1 Adrian Georgescu
*accept_proposal*(_self_, *streams*)
248
>When the remote party proposes to add some new streams, signaled by the @SIPSessionGotProposal@ notification, the application can use this method to accept the stream(s) being proposed.
249 147 Adrian Georgescu
>After calling this method a @SIPSessionGotAcceptProposal@ notification is sent, unless an error occurs while setting up the new stream, in which case a @SIPSessionHadProposalFailure@ notification is sent and a rejection is sent to the remote party. As with any action which causes the streams in the session to change, a @SIPSessionDidRenegotiateStreams@ notification is also sent.
250 1 Adrian Georgescu
>This method may only be called while in the @received_proposal@ state.
251
  
252 147 Adrian Georgescu
>+_streams_+:
253 158 Tijmen de Mes
>>A list of streams which needs to be a subset of the proposed streams which indicates which streams are to be accepted. All the other proposed streams will be rejected.
254 147 Adrian Georgescu
255
*reject_proposal*(_self_, *code*=@488@, *reason*=@None@)
256
>When the remote party proposes new streams that the application does not want to accept, this method can be used to reject the proposal, after which a @SIPSessionGotRejectProposal@ or @SIPSessionHadProposalFailure@ notification is sent.
257
>This method may only be called while in the @received_proposal@ state.
258 1 Adrian Georgescu
  
259 147 Adrian Georgescu
>+_code_+:
260 158 Tijmen de Mes
>>An integer which represents the SIP status code in the response which is to be sent. Usually, this is 488 (Not Acceptable Here).
261 147 Adrian Georgescu
  
262 1 Adrian Georgescu
>+_reason_+:
263 158 Tijmen de Mes
>>The string which is to be sent as the SIP status reason in the response, or None if PJSIP's default reason for the specified code is to be sent.
264 1 Adrian Georgescu
265 147 Adrian Georgescu
*add_stream*(_self_, *stream*)
266
>Proposes a new stream to the remote party.
267
>Calling this method will cause a @SIPSessionGotProposal@ notification to be emitted.
268
>After this, the state machine will move into the @sending_proposal@ state until either a @SIPSessionGotAcceptProposal@, @SIPSessionGotRejectProposal@ or @SIPSessionHadProposalFailure@ notification is sent, informing the application if the remote party accepted the proposal. As with any action which causes the streams in the session to change, a @SIPSessionDidRenegotiateStreams@ notification is also sent.
269
>This method may only be called while in the @connected@ state.
270 1 Adrian Georgescu
271 147 Adrian Georgescu
*remove_stream*(_self_, *stream*)
272
>Stop the stream and remove it from the session, informing the remote party of this. Although technically this is also done via an SDP negotiation which may fail, the stream will always get remove (if the remote party refuses the re-INVITE, the result will be that the remote party will have a different view of the active streams than the local party).
273
>This method may only be called while in the @connected@ state.
274 1 Adrian Georgescu
275 147 Adrian Georgescu
*cancel_proposal*(_self_)
276
>This method cancels a proposal of adding a stream to the session by sending a CANCEL request. A @SIPSessionGotRejectProposal@ notification will be sent with code 487.
277 1 Adrian Georgescu
278 147 Adrian Georgescu
*hold*(_self_)
279
>Put the streams of the session which support the notion of hold on hold.
280
>This will cause a @SIPSessionDidChangeHoldState@ notification to be sent.
281
>This method may be called in any state and will send the re-INVITE as soon as it is possible.
282 1 Adrian Georgescu
283 147 Adrian Georgescu
*unhold*(_self_)
284
>Take the streams of the session which support the notion of hold out of hold.
285
>This will cause a @SIPSessionDidChangeHoldState@ notification to be sent.
286
>This method may be called in any state and will send teh re-INVITE as soon as it is possible.
287 1 Adrian Georgescu
288 147 Adrian Georgescu
*end*(_self_)
289
>This method may be called any time after the @Session@ has started in order to terminate the session by sending a BYE request.
290
>Right before termination a @SIPSessionWillEnd@ notification is sent, after termination @SIPSessionDidEnd@ is sent.
291 1 Adrian Georgescu
292 147 Adrian Georgescu
*transfer*(_self_, *target_uri*,  *replaced_session*=@None@)
293
>Proposes a blind call transfer to a new target URI or assisted transfer to an URI belonging to an already established session. 
294 1 Adrian Georgescu
295 147 Adrian Georgescu
*accept_transfer*(_self_)
296
>Accepts an incoming call transfer request.
297 1 Adrian Georgescu
298 147 Adrian Georgescu
*reject_transfer*(_self_, *code*=@486@, *reason_=@None@)
299
>Rejects an incoming call transfer request.
300 1 Adrian Georgescu
301
302
303 179 Tijmen de Mes
*attributes*
304 1 Adrian Georgescu
305
306
307 147 Adrian Georgescu
*state*
308
>The state the object is currently in, being one of the states from the diagram above.
309 1 Adrian Georgescu
310 147 Adrian Georgescu
*account*
311
>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ object that the @Session@ is associated with.
312
>On an outbound session, this is the account the application specified on object instantiation.
313 1 Adrian Georgescu
314 147 Adrian Georgescu
*direction*
315
>A string indicating the direction of the initial negotiation of the session.
316
>This can be either @None@, "incoming" or "outgoing".
317 1 Adrian Georgescu
318 147 Adrian Georgescu
*transport*
319
>A string representing the transport this @Session@ is using: @"udp"@, @"tcp"@ or @"tls"@.
320 1 Adrian Georgescu
321 147 Adrian Georgescu
*start_time*
322
>The time the session started as a @datetime.datetime@ object, or @None@ if the session was not yet started.
323 1 Adrian Georgescu
324 147 Adrian Georgescu
*stop_time*
325
>The time the session stopped as a @datetime.datetime@ object, or @None@ if the session has not yet terminated.
326 1 Adrian Georgescu
327 147 Adrian Georgescu
*on_hold*
328
>Boolean indicating whether the session was put on hold, either by the local or the remote party.
329 1 Adrian Georgescu
330 147 Adrian Georgescu
*remote_user_agent*
331
>A string indicating the remote user agent, if it provided one.
332
>Initially this will be @None@, it will be set as soon as this information is received from the remote party (which may be never).
333 1 Adrian Georgescu
334 147 Adrian Georgescu
*local_identity*
335
>The @sipsimple.core.FrozenFromHeader@ or @sipsimple.core.FrozenToHeader@ identifying the local party, if the session is active, @None@ otherwise.
336 1 Adrian Georgescu
337 147 Adrian Georgescu
*remote_identity*
338
>The @sipsimple.core.FrozenFromHeader@ or @sipsimple.core.FrozenToHeader@ identifying the remote party, if the session is active, @None@ otherwise.
339 1 Adrian Georgescu
340 147 Adrian Georgescu
*streams*
341
>A list of the currently active streams in the @Session@.
342 1 Adrian Georgescu
343 147 Adrian Georgescu
*proposed_streams*
344
>A list of the currently proposed streams in the @Session@, or @None@ if there is no proposal in progress.
345 1 Adrian Georgescu
346 147 Adrian Georgescu
*conference*
347
>A @ConferenceHandler@ object instance (or Null). It can be later used to add/remove participants from a remote conference.
348 1 Adrian Georgescu
349 147 Adrian Georgescu
*subject*
350
>The session subject as a unicode object.
351 1 Adrian Georgescu
352
*replaced_session*
353 147 Adrian Georgescu
>A @Session@ object instance (or Null). It can be used for assisted call transfer.
354
355
*transfer_handler*
356 1 Adrian Georgescu
>A @TransferHandler@ object instance (or Null). It is used for managing the call transfer process.
357
358
*transfer_info*
359
>A @TransferInfo@ object instance (or Null). It is used for describing the details of a call transfer operation.
360
361
362 179 Tijmen de Mes
*notifications*
363 147 Adrian Georgescu
364
365 1 Adrian Georgescu
366 147 Adrian Georgescu
*SIPSessionNewIncoming*
367
>Will be sent when a new incoming @Session@ is received.
368
>The application should listen for this notification to get informed of incoming sessions.
369 1 Adrian Georgescu
  
370 55 Adrian Georgescu
>+_timestamp_+:
371 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
372 147 Adrian Georgescu
  
373
>+_streams_+:
374 158 Tijmen de Mes
>>A list of streams that were proposed by the remote party.
375 147 Adrian Georgescu
376
*SIPSessionNewOutgoing*
377
>Will be sent when the application requests a new outgoing @Session@.
378 1 Adrian Georgescu
  
379 147 Adrian Georgescu
>+_timestamp_+:
380 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
381 147 Adrian Georgescu
  
382
>+_streams_+:
383 158 Tijmen de Mes
>>A list of streams that were proposed to the remote party.
384 147 Adrian Georgescu
385 67 Luci Stanescu
*SIPSessionGotRingIndication*
386 147 Adrian Georgescu
>Will be sent when an outgoing @Session@ receives an indication that a remote device is ringing.
387 94 Adrian Georgescu
  
388 147 Adrian Georgescu
>+_timestamp_+:
389 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
390 147 Adrian Georgescu
391
*SIPSessionGotProvisionalResponse*
392 67 Luci Stanescu
>Will be sent whenever the @Session@ receives a provisional response as a result of sending a (re-)INVITE.
393 147 Adrian Georgescu
  
394
>+_timestamp_+:
395 158 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
396 1 Adrian Georgescu
  
397 147 Adrian Georgescu
>+_code_+:
398 158 Tijmen de Mes
>>The SIP status code received.
399 147 Adrian Georgescu
  
400 94 Adrian Georgescu
>+_reason_+:
401 158 Tijmen de Mes
>>The SIP status reason received.
402 1 Adrian Georgescu
403 147 Adrian Georgescu
*SIPSessionWillStart*
404
>Will be sent just before a @Session@ completes negotiation.
405
>In terms of SIP, this is sent after the final response to the @INVITE@, but before the @ACK@.
406
  
407
>+_timestamp_+:
408 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
409 1 Adrian Georgescu
410 147 Adrian Georgescu
*SIPSessionDidStart*
411
>Will be sent when a @Session@ completes negotiation and all the streams have started.
412
>In terms of SIP this is sent after the @ACK@ was sent or received.
413 1 Adrian Georgescu
  
414
>+_timestamp_+:
415 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
416 147 Adrian Georgescu
  
417 1 Adrian Georgescu
>+_streams_+:
418 159 Tijmen de Mes
>>The list of streams which now form the active streams of the @Session@.
419 1 Adrian Georgescu
420
*SIPSessionDidFail*
421 147 Adrian Georgescu
>This notification is sent whenever the session fails before it starts.
422
>The failure reason is included in the data attributes.
423
>This notification is never followed by @SIPSessionDidEnd@.
424 1 Adrian Georgescu
  
425
>+_timestamp_+:
426 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
427 147 Adrian Georgescu
  
428
>+_originator_+:
429 159 Tijmen de Mes
>>A string indicating the originator of the @Session@. This will either be "local" or "remote".
430 1 Adrian Georgescu
  
431 147 Adrian Georgescu
>+_code_+:
432 159 Tijmen de Mes
>>The SIP error code of the failure.
433 147 Adrian Georgescu
  
434 1 Adrian Georgescu
>+_reason_+:
435 159 Tijmen de Mes
>>A SIP status reason.
436 147 Adrian Georgescu
  
437
>+_failure_reason_+:
438 159 Tijmen de Mes
>>A string which represents the reason for the failure, such as @"user_request"@, @"missing ACK"@, @"SIP core error..."@.
439 1 Adrian Georgescu
440 147 Adrian Georgescu
*SIPSessionWillEnd*
441
>Will be sent just before terminating a @Session@.
442 1 Adrian Georgescu
  
443
>+_timestamp_+:
444 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
445 147 Adrian Georgescu
446
*SIPSessionDidEnd*
447 1 Adrian Georgescu
>Will be sent always when a @Session@ ends as a result of remote or local session termination.
448 147 Adrian Georgescu
  
449
>+_timestamp_+:
450 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
451 1 Adrian Georgescu
  
452
>+_originator_+:
453 159 Tijmen de Mes
>>A string indicating who originated the termination. This will either be "local" or "remote".
454 147 Adrian Georgescu
  
455
>+_end_reason_+:
456 159 Tijmen de Mes
>>A string representing the termination reason, such as @"user_request"@, @"SIP core error..."@.
457 1 Adrian Georgescu
458 147 Adrian Georgescu
*SIPSessionDidChangeHoldState*
459
>Will be sent when the session got put on hold or removed from hold, either by the local or the remote party.
460 1 Adrian Georgescu
  
461
>+_timestamp_+:
462 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
463 147 Adrian Georgescu
  
464
>+_originator_+:
465 159 Tijmen de Mes
>>A string indicating who originated the hold request, and consequently in which direction the session got put on hold.
466 147 Adrian Georgescu
  
467
>+_on_hold_+:
468 159 Tijmen de Mes
>>@True@ if there is at least one stream which is on hold and @False@ otherwise.
469 1 Adrian Georgescu
  
470 147 Adrian Georgescu
>+_partial_+:
471 159 Tijmen de Mes
>>@True@ if there is at least one stream which is on hold and one stream which supports hold but is not on hold and @False@ otherwise.
472 147 Adrian Georgescu
473
*SIPSessionGotProposal*
474 1 Adrian Georgescu
>Will be sent when either the local or the remote party proposes to add streams to the session.
475 147 Adrian Georgescu
  
476 1 Adrian Georgescu
>+_timestamp_+:
477 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
478 147 Adrian Georgescu
  
479
>+_originator_+:
480 159 Tijmen de Mes
>>The party that initiated the stream proposal, can be either "local" or "remote".
481 147 Adrian Georgescu
  
482
>+_streams_+:
483 159 Tijmen de Mes
>>A list of streams that were proposed.
484 147 Adrian Georgescu
485
*SIPSessionGotRejectProposal*
486
>Will be sent when either the local or the remote party rejects a proposal to have streams added to the session.
487 1 Adrian Georgescu
  
488 147 Adrian Georgescu
>+_timestamp_+:
489 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
490 147 Adrian Georgescu
  
491 1 Adrian Georgescu
>+_originator_+:
492 159 Tijmen de Mes
>>The party that initiated the stream proposal, can be either "local" or "remote".
493 147 Adrian Georgescu
  
494
>+_code_+:
495 159 Tijmen de Mes
>>The code with which the proposal was rejected.
496 147 Adrian Georgescu
  
497
>+_reason_+:
498 159 Tijmen de Mes
>>The reason for rejecting the stream proposal.
499 1 Adrian Georgescu
  
500 147 Adrian Georgescu
>+_streams_+:
501 159 Tijmen de Mes
>>The list of streams which were rejected.
502 147 Adrian Georgescu
503
*SIPSessionGotAcceptProposal*
504
>Will be sent when either the local or the remote party accepts a proposal to have stream( added to the session.
505
  
506 1 Adrian Georgescu
>+_timestamp_+:
507 159 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
508 147 Adrian Georgescu
  
509
>+_originator_+:
510 160 Tijmen de Mes
>>The party that initiated the stream proposal, can be either "local" or "remote".
511 1 Adrian Georgescu
  
512
>+_streams_+:
513 160 Tijmen de Mes
>>The list of streams which were accepted.
514 147 Adrian Georgescu
  
515
>+_proposed_streams_+:
516 160 Tijmen de Mes
>>The list of streams which were originally proposed.
517 147 Adrian Georgescu
518
*SIPSessionHadProposalFailure*
519
>Will be sent when a re-INVITE fails because of an internal reason (such as a stream not being able to start).
520 1 Adrian Georgescu
  
521 147 Adrian Georgescu
>+_timestamp_+:
522 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
523 147 Adrian Georgescu
  
524
>+_failure_reason_+:
525 160 Tijmen de Mes
>>The error which caused the proposal to fail.
526 1 Adrian Georgescu
  
527 147 Adrian Georgescu
>+_streams_+:
528 160 Tijmen de Mes
>>The streams which were part of this proposal.
529 147 Adrian Georgescu
530
*SIPSessionDidRenegotiateStreams*
531
>Will be sent when a media stream is either activated or deactivated.
532
>An application should listen to this notification in order to know when a media stream can be used.
533
  
534
>+_timestamp_+:
535 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
536 147 Adrian Georgescu
  
537
>+_action_+:
538 160 Tijmen de Mes
>>A string which is either @"add"@ or @"remove"@ which specifies what happened to the streams the notificaton referes to
539 1 Adrian Georgescu
  
540 147 Adrian Georgescu
>+_streams_+:
541 160 Tijmen de Mes
>>A list with the streams which were added or removed.
542 1 Adrian Georgescu
543 147 Adrian Georgescu
*SIPSessionDidProcessTransaction*
544
>Will be sent whenever a SIP transaction is complete in order to provide low-level details of the progress of the INVITE dialog.
545
  
546 160 Tijmen de Mes
>>+_timestamp_+:
547 165 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
548 147 Adrian Georgescu
  
549
>+_originator_+:
550 160 Tijmen de Mes
>>The initiator of the transaction, @"local"@ or @"remote"@.
551 147 Adrian Georgescu
  
552 1 Adrian Georgescu
>+_method_+:
553 160 Tijmen de Mes
>>The method of the request.
554 147 Adrian Georgescu
  
555
>+_code_+:
556 160 Tijmen de Mes
>>The SIP status code of the response.
557 1 Adrian Georgescu
  
558 147 Adrian Georgescu
>+_reason_+:
559 160 Tijmen de Mes
>>The SIP status reason of the response.
560 147 Adrian Georgescu
  
561 1 Adrian Georgescu
>+_ack_received_+:
562 165 Tijmen de Mes
>>This attribute is only present for INVITE transactions and has one of the values @True@, @False@ or @"unknown"@. The last value may occur then PJSIP does not let us know whether the ACK was received or not.
563 147 Adrian Georgescu
564
*SIPSessionTransferNewOutgoing*
565 160 Tijmen de Mes
>>Will be sent whenever a SIP session initiates an outgoing call transfer request.
566 147 Adrian Georgescu
  
567
>+_timestamp_+:
568 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
569 147 Adrian Georgescu
  
570
>+_transfer_destination_+:
571 160 Tijmen de Mes
>>The destination SIP URI of the call transfer request.
572 147 Adrian Georgescu
  
573 1 Adrian Georgescu
>+_transfer_source_+:
574 160 Tijmen de Mes
>>The source SIP URI of the call transfer request.
575 147 Adrian Georgescu
576 1 Adrian Georgescu
*SIPSessionTransferDidStart*
577
>Will be sent whenever a call transfer has been started.
578 147 Adrian Georgescu
  
579
>+_timestamp_+:
580 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
581 147 Adrian Georgescu
582
*SIPSessionTransferDidFail*
583
>Will be sent whenever a call transfer request has failed.
584
  
585
>+_timestamp_+:
586 160 Tijmen de Mes
>>A @datetime.datetime@ object indicating when the notification was sent.
587 147 Adrian Georgescu
  
588
>+_code_+:
589 160 Tijmen de Mes
>>The SIP failure code reported by the SIP stack.
590 147 Adrian Georgescu
  
591
>+_reason_+:
592 160 Tijmen de Mes
>>The reason of the failure as a string.
593 147 Adrian Georgescu
594
595 161 Tijmen de Mes
As an example for how to use the @Session@ object, the following provides a basic Python program that initiates an outgoing SIP session request see [[SipSessionExample|Minimalist Session Example code]].
596 166 Tijmen de Mes
597
598
599
h3. IMediaStream
600
601
602 186 Tijmen de Mes
Implemented in source:"sipsimple/streams/__init__.py"
603 166 Tijmen de Mes
604
This interface describes the API which the @Session@ uses to communicate with the streams. All streams used by the @Session@ +must+ respect this interface.
605
606
607 179 Tijmen de Mes
*methods*
608 166 Tijmen de Mes
609
610
611
*<notextile>__init__</notextile>*(_self_, _account_)
612
>Initializes the generic stream instance.
613
614
*new_from_sdp*(_cls_, _account_, _remote_sdp_, _stream_index_)
615
>A classmethod which returns an instance of this stream implementation if the sdp is accepted by the stream or None otherwise.
616
  
617
>+_account_+:
618
>>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ object the session which this stream would be part of is associated with.
619
  
620
>+_remote_sdp_+:
621
>>The @FrozenSDPSession@ which was received by the remote offer.
622
  
623
>+_stream_index_+:
624
>>An integer representing the index within the list of media streams within the whole SDP which this stream would be instantiated for. 
625
626
*get_local_media*(_self_, _for_offer_)
627
>Return an @SDPMediaStream@ which represents an offer for using this stream if @for_offer@ is @True@ and a response to an SDP proposal otherwise.
628
  
629
>+_for_offer_+:
630
>>@True@ if the @SDPMediaStream@ will be used for an SDP proposal and @False@ if for a response.
631
632
*initialize*(_self_, _session_, _direction_)
633
>Initializes the stream. This method will get called as soon as the stream is known to be at least offered as part of the @Session@. If initialization goes fine, the stream must send a @MediaStreamDidInitialize@ notification or a @MediaStreamDidFail@ notification otherwise.
634
  
635
>+_session_+:
636
>>The @Session@ object this stream will be part of.
637
  
638
>+_direction_+:
639
>>@"incoming"@ if the stream was created because of a received proposal and @"outgoing"@ if a proposal was sent. Note that this need not be the same as the initial direction of the @Session@ since streams can be proposed in either way using re-INVITEs.
640
641
*start*(_self_, _local_sdp_, _remote_sdp_, _stream_index_)
642
>Starts the stream. This method will be called as soon is known to be used in the @Session@ (eg. only called for an incoming proposal if the local party accepts the proposed stream). If starting succeeds, the stream must send a @MediaStreamDidStart@ notification or a @MediaStreamDidFail@ notification otherwise.
643
  
644
>+_local_sdp_+:
645
>>The @FrozenSDPSession@ which is used by the local endpoint.
646
  
647
>+_remote_sdp_+:
648
>>The @FrozenSDPSession@ which is used by the remote endpoint.
649
  
650
>+_stream_index_+:
651
>>An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
652
653
*validate_update*(_self_, _remote_sdp_, _stream_index_)
654
>This method will be called when a re-INVITE is received which changes the parameters of the stream within the SDP. The stream must return @True@ if the changes are acceptable or @False@ otherwise. If any changed streams return @False@ for a re-INVITE, the re-INVITE will be refused with a negative response. This means that streams must not changed any internal data when this method is called as the update is not guaranteed to be applied even if the stream returns @True@. 
655
  
656
>+_remote_sdp_+:
657
>>The @FrozenSDPSession@ which is used by the remote endpoint.
658
  
659
>+_stream_index_+:
660
>>An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
661
662
*update*(_self_, _local_sdp_, _remote_sdp_, _stream_index_)
663
>This method is called when the an SDP negotiation initiated by either the local party or the remote party succeeds. The stream must update its internal state according to the new SDP in use.
664
  
665
>+_local_sdp_+:
666
>>The @FrozenSDPSession@ which is used by the local endpoint.
667
  
668
>+_remote_sdp_+:
669
>>The @FrozenSDPSession@ which is used by the remote endpoint.
670
  
671
>+_stream_index_+:
672
>>An integer representing the index within the list of media streams within the whole SDP which this stream is represented by. 
673
674
*hold*(_self_)
675
>Puts the stream on hold if supported by the stream. Typically used by audio and video streams. The stream must immediately stop sending/receiving data and calls to @get_local_media()@ following calls to this method must return an SDP which reflects the new hold state.
676
677
*unhold*(_self_)
678
>Takes the stream off hold. Typically used by audio and video streams. Calls to @get_local_media()@ following calls to this method must return an SDP which reflects the new hold state.
679
680
*deactivate*(_self_)
681
>This method is called on a stream just before the stream will be removed from the @Session@ (either as a result of a re-INVITE or a BYE). This method is needed because it avoids a race condition with streams using stateful protocols such as TCP: the stream connection might be terminated before the SIP signalling announces this due to network routing inconsistencies and the other endpoint would not be able to distinguish between this case and an error which caused the stream transport to fail. The stream must not take any action, but must consider that the transport being closed by the other endpoint after this method was called as a normal situation rather than an error condition.
682
683
*end*(_self_)
684
>Ends the stream. This must close the underlying transport connection. The stream must send a @MediaStreamWillEnd@ just after this method is called and a @MediaStreamDidEnd@ as soon as the operation is complete. This method is always be called by the @Session@ on the stream if at least the @initialize()@ method has been called. This means that once a stream sends the @MediaStreamDidFail@ notification, the @Session@ will still call this method.
685
686
687 179 Tijmen de Mes
*attributes*
688 166 Tijmen de Mes
689
690
691
*type* (class attribute)
692
>A string identifying the stream type (eg: @"audio"@, @"video"@).
693
694
*priority* (class attribute)
695
>An integer value indicating the stream priority relative to the other streams types (higher numbers have higher priority).
696
697
*hold_supported*
698
>True if the stream supports hold
699
700
*on_hold_by_local*
701
>True if the stream is on hold by the local party
702
703
*on_hold_by_remote*
704
>True if the stream is on hold by the remote
705
706
*on_hold*
707
>True if either on_hold_by_local or on_hold_by_remote is true
708
709
710 179 Tijmen de Mes
*notifications*
711 166 Tijmen de Mes
712
713
These notifications must be generated by all streams in order for the @Session@ to know the state of the stream.
714
715
716
*MediaStreamDidInitialize*
717
>Sent when the stream has been successfully initialized.
718
719
*MediaStreamDidStart*
720
>Sent when the stream has been successfully started.
721
722
*MediaStreamDidFail*
723
>Sent when the stream has failed either as a result of calling one of its methods, or during the normal operation of the stream (such as the transport connection being closed).
724
725
*MediaStreamWillEnd*
726
>Sent immediately after the @end()@ method is called.
727
728
*MediaStreamDidEnd*
729
>Sent when the @end()@ method finished closing the stream.
730 167 Tijmen de Mes
731
h3. MediaStreamRegistrar
732
733
734
This is a convenience metaclass which automatically registers a defined class with the @MediaStreamRegistry@. In order to use this class, one simply needs to use it as the metaclass of the new stream.
735
736 191 Tijmen de Mes
<pre><code class="python">
737 167 Tijmen de Mes
from zope.interface import implements
738
739
from sipsimple.streams import IMediaStream, MediaStreamRegistrar
740
741
742
class MyStream(object):
743
  __metaclass__ = MediaStreamRegistrar
744
745
  implements(IMediaStream)
746
  
747
[...] 
748 191 Tijmen de Mes
</code></pre>
749 167 Tijmen de Mes
750
h3. AudioStream
751
752
753 182 Tijmen de Mes
Implemented in source:sipsimple/streams/rtp.py
754 167 Tijmen de Mes
755
The @AudioStream@ is an implementation of @IMediaStream@ which supports audio data using the @AudioTransport@ and @RTPTransport@ of the SIP core. As such, it provides all features of these objects, including ICE negotiation. An example SDP created using the @AudioStream@ is provided below:
756
757
<pre>
758
Content-Type: application/sdp
759
Content-Length:  1093
760
761
v=0
762
o=- 3467525278 3467525278 IN IP4 192.168.1.6
763
s=blink-0.10.7-beta
764
c=IN IP4 80.101.96.20
765
t=0 0
766
m=audio 55328 RTP/AVP 104 103 102 3 9 0 8 101
767
a=rtcp:55329 IN IP4 80.101.96.20
768
a=rtpmap:104 speex/32000
769
a=rtpmap:103 speex/16000
770
a=rtpmap:102 speex/8000
771
a=rtpmap:3 GSM/8000
772
a=rtpmap:9 G722/8000
773
a=rtpmap:0 PCMU/8000
774
a=rtpmap:8 PCMA/8000
775
a=rtpmap:101 telephone-event/8000
776
a=fmtp:101 0-15
777
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:esI6DbLY1+Aceu0JNswN9Z10DcFx5cZwqJcu91jb
778
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:SHuEMm1BYJqOF4udKl73EaCwnsI57pO86bYKsg70
779
a=ice-ufrag:2701ed80
780
a=ice-pwd:6f8f8281
781
a=candidate:S 1 UDP 31 80.101.96.20 55328 typ srflx raddr 192.168.1.6 rport 55328
782
a=candidate:H 1 UDP 23 192.168.1.6 55328 typ host
783
a=candidate:H 1 UDP 23 10.211.55.2 55328 typ host
784
a=candidate:H 1 UDP 23 10.37.129.2 55328 typ host
785
a=candidate:S 2 UDP 30 80.101.96.20 55329 typ srflx raddr 192.168.1.6 rport 55329
786
a=candidate:H 2 UDP 22 192.168.1.6 55329 typ host
787
a=candidate:H 2 UDP 22 10.211.55.2 55329 typ host
788
a=candidate:H 2 UDP 22 10.37.129.2 55329 typ host
789
a=sendrecv
790
</pre>
791
792
As an implementation of @IAudioPort@, an @AudioStream@ can be added to an @AudioBridge@ to send or to read audio data to/from other audio objects. It is connected to the voice @AudioMixer@ (@SIPApplication.voice_audio_mixer@) so it can only be added to bridges using the same @AudioMixer@. It also contains an @AudioBridge@ on the @bridge@ attribute which always contains an @AudioDevice@ corresponding to the input and output devices; when the stream is active (started and not on hold), the bridge also contains the stream itself and when recording is active, the stream contains a @WaveRecorder@ which records audio data.
793
794
795 179 Tijmen de Mes
*methods*
796 167 Tijmen de Mes
797
798
799
*start_recording*(_self_, *filename*=@None@)
800
>If an audio stream is present within this session, calling this method will record the audio to a @.wav@ file.
801
>Note that when the session is on hold, nothing will be recorded to the file.
802
>Right before starting the recording a @SIPSessionWillStartRecordingAudio@ notification will be emitted, followed by a @SIPSessionDidStartRecordingAudio@.
803
>This method may only be called while the stream is started.
804
  
805 1 Adrian Georgescu
>+_filename_+:
806 168 Tijmen de Mes
>>The name of the @.wav@ file to record to.
807
>>If this is set to @None@, a default file name including the session participants and the timestamp will be generated using the directory defined in the configuration.
808 167 Tijmen de Mes
809
*stop_recording*(_self_)
810
>This will stop a previously started recording.
811
>Before stopping, a @SIPSessionWillStopRecordingAudio@ notification will be sent, followed by a @SIPSessionDidStopRecordingAudio@.
812
813
*send_dtmf*(_self_, *digit*)
814
>If the audio stream is started, sends a DTMF digit to the remote party.
815
  
816
>+_digit_+:
817
>>This should a string of length 1, containing a valid DTMF digit value (0-9, A-D, * or #).
818
819
820 179 Tijmen de Mes
*attributes*
821 167 Tijmen de Mes
822
823
824
*sample_rate*
825
>If the audio stream was started, this attribute contains the sample rate of the audio negotiated.
826
827
*codec*
828
>If the audio stream was started, this attribute contains the name of the audio codec that was negotiated.
829
830
*srtp_active*
831
>If the audio stream was started, this boolean attribute indicates if SRTP is currently being used on the stream.
832
833
*ice_active*
834
>@True@ if the ICE candidates negotiated are being used, @False@ otherwise.
835
836
*local_rtp_address*
837
>If an audio stream is present within the session, this attribute contains the local IP address used for the audio stream.
838
839
*local_rtp_port*
840
>If an audio stream is present within the session, this attribute contains the local UDP port used for the audio stream.
841
842
*remote_rtp_address_sdp*
843
>If the audio stream was started, this attribute contains the IP address that the remote party gave to send audio to.
844
845
*remote_rtp_port_sdp*
846
>If the audio stream was started, this attribute contains the UDP port that the remote party gave to send audio to.
847
848
*remote_rtp_address_received*
849
>If the audio stream was started, this attribute contains the remote IP address from which the audio stream is being received.
850
851
*remote_rtp_port_received*
852
>If the audio stream was started, this attribute contains the remote UDP port from which the audio stream is being received.
853
854
*local_rtp_candidate_type*
855
>The local ICE candidate type which was selected by the ICE negotiation if it succeeded and @None@ otherwise.
856
857
*remote_rtp_candidate_type*
858
>The remote ICE candidate type which was selected by the ICE negotiation if it succeeded and @None@ otherwise.
859
860
*recording_filename*
861
>If the audio stream is currently being recorded to disk, this property contains the name of the @.wav@ file being recorded to.
862
863
864 179 Tijmen de Mes
*notifications*
865 167 Tijmen de Mes
866
867
868
*AudioStreamDidChangeHoldState*
869
>Will be sent when the hold state is changed as a result of either a SIP message received on the network or the application calling the @hold()/unhold()@ methods on the @Session@ this stream is part of.
870
  
871
>+_timestamp_+:
872
>>A @datetime.datetime@ object indicating when the notification was sent.
873
  
874
>+_originator_+:
875
>>A string representing the party which requested the hold change, @"local"@ or @"remote"@
876
  
877
>+_on_hold_+:
878
>>A boolean indicating the new hold state from the point of view of the originator.
879
880
*AudioStreamWillStartRecordingAudio_
881
>Will be sent when the application requested that the audio stream be recorded to a @.wav@ file, just before recording starts.
882
  
883
>+_timestamp_+:
884
>>A @datetime.datetime@ object indicating when the notification was sent.
885
  
886
>+_filename_+:
887
>>The full path to the @.wav@ file being recorded to.
888
889
*AudioStreamDidStartRecordingAudio*
890
>Will be sent when the application requested that the audio stream be recorded to a @.wav@ file, just after recording started.
891
  
892
>+_timestamp_+:
893
>>A @datetime.datetime@ object indicating when the notification was sent.
894
  
895
>+_filename_+:
896
>>The full path to the @.wav@ file being recorded to.
897
898
*AudioStreamWillStopRecordingAudio*
899
>Will be sent when the application requested ending the recording to a @.wav@ file, just before recording stops.
900
  
901
>+_timestamp_+:
902
>>A @datetime.datetime@ object indicating when the notification was sent.
903
  
904
>+_filename_+:
905
>>The full path to the @.wav@ file being recorded to.
906
907
*AudioStreamDidStopRecordingAudio*
908
>Will be sent when the application requested ending the recording to a @.wav@ file, just after recording stoped.
909
  
910
>+_timestamp_+:
911
>>A @datetime.datetime@ object indicating when the notification was sent.
912
  
913
>+_filename_+:
914
>>The full path to the @.wav@ file being recorded to.
915
916
*AudioStreamDidChangeRTPParameters*
917
>This notification is sent when the RTP parameters are changed, such as codec, sample rate, RTP port etc.
918
  
919
>+_timestamp_+:
920
>>A @datetime.datetime@ object indicating when the notification was sent.
921
922
*AudioStreamGotDTMF*
923
>Will be send if there is a DMTF digit received from the remote party on the audio stream. 
924
  
925
>+_timestamp_+:
926
>>A @datetime.datetime@ object indicating when the notification was sent.
927
  
928
>+_digit_+:
929
>>The DTMF digit that was received, in the form of a string of length 1.
930
931
*AudioStreamICENegotiationStateDidChange*
932
>This notification is proxied from the @RTPTransport@ and as such has the same data as the @RTPTransportICENegotiationStateDidChange@.
933
934
*AudioStreamICENegotiationDidSucceed*
935
>This notification is proxied from the @RTPTransport@ and as such has the same data as the @RTPTransportICENegotiationDidSucceed@.
936
937
*AudioStreamICENegotiationDidFail*
938
>This notification is proxied from the @RTPTransport@ and as such has the same data as the @RTPTransportICENegotiationDidFail@.
939
940
*AudioStreamDidTimeout*
941
>This notification is proxied from the @RTPTransport@. It's sent when the RTP transport did not receive any data after the specified amount of time (rtp.timeout setting in the @Account@).
942 169 Tijmen de Mes
943
h3. MSRPStreamBase
944
945 1 Adrian Georgescu
946 183 Tijmen de Mes
Implemented in source:sipsimple/streams/msrp.py
947 169 Tijmen de Mes
948
The @MSRPStreamBase@ is used as a base class for streams using the MSRP protocol. Within the SIP SIMPLE middleware, this hold for the @ChatStream@, @FileTransferStream@ and @DesktopSharingStream@ classes, however the application can also make use of this class to implement some other streams based on the MSRP protocol as a transport.
949
950
951 179 Tijmen de Mes
*methods*
952 169 Tijmen de Mes
953
 
954
Of the methods defined by the @IMediaStream@ interface, only the @new_from_sdp@ method is not implemented in this base class and needs to be provided by the subclasses. Also, the subclasses can defined methods of the form @_handle_XXX@, where XXX is a MSRP method name in order to handle incoming MSRP requests. Also, since this class registers as an observer for itself, it will receive the notifications it sends so subclasses can define methods having the signature @_NH_<notification name>(self, notification)@ as used throughout the middleware in order to do various things at the different points within the life-cycle of the stream.
955
956
957 179 Tijmen de Mes
*attributes*
958 169 Tijmen de Mes
959
960
The attributes defined in the @IMediaStream@ interface which are not provided by this class are:
961
* type
962
* priority
963
964
In addition, the following attributes need to be defined in the subclass in order for the @MSRPStreamBase@ class to take the correct decisions
965
966
*media_type*
967
>The media type as included in the SDP (eg. @"message"@, @"application"@).
968
969
*accept_types*
970
>A list of the MIME types which should be accepted by the stream (this is also sent within the SDP).
971
972
*accept_wrapped_types*
973
>A list of the MIME types which should be accepted by the stream while wrapped in a @message/cpim@ envelope.
974
975
*use_msrp_session*
976
>A boolean indicating whether or not an @MSRPSession@ should be used.
977
978
979 179 Tijmen de Mes
*notifications*
980 169 Tijmen de Mes
981
982
While not technically notifications of @MSRPStreamBase@, these notifications are sent from the middleware on behalf of the @MSRPTransport@ used by a stream in the former case, and anonymously in the latter.
983
984
985
*MSRPTransportTrace*
986
>This notification is sent when an MSRP message is received for logging purposes.
987
  
988
>+_timestamp_+:
989
>>A @datetime.datetime@ object indicating when the notification was sent.
990
  
991
>+_direction_+:
992
>>The direction of the message, @"incoming"@ or @"outgoing"@.
993
  
994
>+_data_+:
995
>>The MSRP message as a string.
996
997
*MSRPLibraryLog*
998
>This notification is sent anonymously whenever the MSRP library needs to log any information.
999
  
1000
>+_timestamp_+:
1001
>>A @datetime.datetime@ object indicating when the notification was sent.
1002
  
1003
>+_message_+:
1004
>>The log message as a string.
1005
  
1006
>+_level_+:
1007
>>The log level at which the message was written. One of the levels @DEBUG@, @INFO@, @WARNING@, @ERROR@, @CRITICAL@ from the @application.log.level@ object which is part of the @python-application@ library.
1008 170 Tijmen de Mes
1009
h3. ChatStream
1010
1011
1012 182 Tijmen de Mes
Implemented in source:sipsimple/streams/msrp.py
1013 170 Tijmen de Mes
1014
@sipsimple.streams.msrp.ChatStream@ implements session-based Instant Messaging (IM) over MSRP. This class performs the following functions:
1015
1016
* automatically wraps outgoing messages with Message/CPIM if that's necessary according to accept-types
1017
* unwraps incoming Message/CPIM messages; for each incoming message, the @ChatStreamGotMessage@ notification is posted
1018
* composes iscomposing payloads and reacts to those received by sending the @ChatStreamGotComposingIndication@ notification
1019
1020
An example of an SDP created using this class follows:
1021
1022
<pre>
1023
Content-Type: application/sdp
1024
Content-Length:   283
1025
1026
v=0
1027
o=- 3467525214 3467525214 IN IP4 192.168.1.6
1028
s=blink-0.10.7-beta
1029
c=IN IP4 192.168.1.6
1030
t=0 0
1031
m=message 2855 TCP/TLS/MSRP *
1032
a=path:msrps://192.168.1.6:2855/ca7940f12ddef14c3c32;tcp
1033
a=accept-types:message/cpim text/* application/im-iscomposing+xml
1034
a=accept-wrapped-types:*
1035
</pre>
1036
1037
1038 179 Tijmen de Mes
*methods*
1039 170 Tijmen de Mes
1040
1041
1042
*<notextile>__init__</notextile>*(_self_, *account*, *direction*=@'sendrecv'@)
1043
>Initializes the ChatStream instance.
1044
1045
1046
*send_message*(_self_, *content*, *content_type*=@'text/plain'@, *recipients*=@None@, *courtesy_recipients*=@None@, *subject*=@None@, _timestamp_=@None@, *required*=@None@, *additional_headers*=@None@)
1047
>Sends an IM message. Prefer Message/CPIM wrapper if it is supported. If called before the connection was established, the messages will be
1048
>queued until the stream starts.
1049
>Returns the generated MSRP message ID.
1050
  
1051
content:
1052
>>The content of the message.
1053
  
1054
>+_content_type_+:
1055
>>Content-Type of wrapped message if Message/CPIM is used (Content-Type of MSRP message is always Message/CPIM in that case);
1056
>otherwise, Content-Type of MSRP message.
1057
  
1058
>+_recipients_+:
1059
>>The list of @CPIMIdentity@ objects which will be used for the @To@ header of the CPIM wrapper. Used to override the default which depends on the remote identity.
1060
>May only differ from the default one if the remote party supports private messages. If it does not, a @ChatStreamError@ will be raised.
1061
  
1062
>+_courtesy_recipients_+:
1063
>>The list of @CPIMIdentity@ objects which will be used for the @cc@ header of the CPIM wrapper.
1064
>May only be specified if the remote party supports private messages and CPIM is supported. If it does not, a @ChatStreamError@ will be raised.
1065
  
1066
>+_subject_+:
1067
>>A string or @MultilingualText@ which specifies the subject and its translations to be added to the CPIM message. If CPIM is not supported, a @ChatStreamError@ will be raised.
1068
  
1069
>+_required_+:
1070
>>A list of strings describing the required capabilities that the other endpoint must support in order to understand this CPIM message. If CPIM is not supported, a @ChatStreamError@ will be raised.
1071
  
1072
>+_additional_headers_+:
1073
>>A list of MSRP header objects which will be added to this CPIM message. If CPIM is not supported, a @ChatStreamError@ will be raised.
1074
  
1075
>+_timestamp_+:
1076
>>A @datetime.datetime@ object representing the timestamp to put on the CPIM wrapper of the message.
1077
>When set to @None@, a default one representing the current moment will be added.
1078
1079
 These MSRP headers are used to enable end-to-end success reports and to disable hop-to-hop successful responses:
1080
<pre>
1081
Failure-Report: partial
1082
Success-Report: yes
1083
</pre>
1084
1085
1086
*send_composing_indication*(_self_, _state_, _refresh_, _last_active=None_, _recipients=None_)
1087
>Sends an is-composing message to the listed recipients.
1088
  
1089
>+_state_+:
1090
>>The state of the endpoint, @"active"@ or @"idle"@.
1091
  
1092
>+_refresh_+:
1093
>>How often the local endpoint will send is-composing indications to keep the state from being reverted to @"idle"@.
1094
  
1095
>+_last_active_+:
1096
>>A @datatime.datetime@ object representing the moment when the local endpoint was last active.
1097
  
1098
>+_recipients_+:
1099
>>The list of @CPIMIdentity@ objects which will be used for the @To@ header of the CPIM wrapper. Used to override the default which depends on the remote identity.
1100
>May only differ from the default one if the remote party supports private messages. If it does not, a @ChatStreamError@ will be raised.
1101
1102
1103 192 Saúl Ibarra Corretgé
*set_local_nickname*(_self_, _nickname_)
1104
>Sets the nickname to be used in this MSRP session.
1105
  
1106
>+_nickname_+:
1107
>>The nickname to be set. It may rise @ChatStreamError@ if the sream is not initialized or nicknames are not supported.
1108
  
1109
1110 179 Tijmen de Mes
*notifications*
1111 170 Tijmen de Mes
1112
1113
1114
*ChatStreamGotMessage*
1115
>Sent whenever a new incoming message is received,
1116
  
1117
>+_timestamp_+:
1118
>>A @datetime.datetime@ object indicating when the notification was sent.
1119
  
1120
>+_message_+:
1121
>>A @ChatMessage@ or @CPIMMessage@ instance, depending on whether a CPIM message was received or not.
1122
1123
*ChatStreamDidDeliverMessage*
1124
>Sent when a successful report is received.
1125
  
1126
>+_timestamp_+:
1127
>>A @datetime.datetime@ object indicating when the notification was sent.
1128
  
1129
>+_message_id_+:
1130
>>Text identifier of the message.
1131
  
1132
>+_code_+:
1133
>>The status code received. Will always be 200 for this notification.
1134
  
1135
>+_reason_+:
1136
>>The status reason received.
1137
  
1138
>+_chunk_+:
1139
>>A @msrplib.protocol.MSRPData@ instance providing all the MSRP information about the report.
1140
1141
*ChatStreamDidNotDeliverMessage*
1142
>Sent when a failure report is received.
1143
  
1144
>+_timestamp_+:
1145
>>A @datetime.datetime@ object indicating when the notification was sent.
1146
  
1147
>+_message_id_+:
1148
>>Text identifier of the message.
1149
  
1150
>+_code_+:
1151
>>The status code received.
1152
  
1153
>+_reason_+:
1154
>>The status reason received.
1155
  
1156
>+_chunk_+:
1157
>>A @msrplib.protocol.MSRPData@ instance providing all the MSRP information about the report.
1158
1159
*ChatStreamDidSendMessage*
1160
>Sent when an outgoing message has been sent.
1161
  
1162
>+_timestamp_+:
1163
>>A @datetime.datetime@ object indicating when the notification was sent.
1164
  
1165
>+_message_+:
1166
>>A @msrplib.protocol.MSRPData@ instance providing all the MSRP information about the sent message.
1167
1168
*ChatStreamGotComposingIndication*
1169
>Sent when a is-composing payload is received.
1170
  
1171
>+_timestamp_+:
1172
>>A @datetime.datetime@ object indicating when the notification was sent.
1173
  
1174
>+_state_+:
1175
>>The state of the endpoint, @"active"@ or @"idle"@.
1176
  
1177
>+_refresh_+:
1178
>>How often the remote endpoint will send is-composing indications to keep the state from being reverted to @"idle"@. May be @None@.
1179
  
1180
>+_last_active_+:
1181
>>A @datatime.datetime@ object representing the moment when the remote endpoint was last active. May be @None@.
1182
  
1183
>+_content_type_+:
1184
>>The MIME type of message being composed. May be @None@.
1185
  
1186
>+_sender_+:
1187
>>The @ChatIdentity@ or @CPIMIdentity@ instance which identifies the sender of the is-composing indication.
1188
  
1189
>+_recipients_+:
1190
>>The @ChatIdentity@ or @CPIMIdentity@ instances list which identifies the recipients of the is-composing indication.
1191 171 Tijmen de Mes
1192
h3. FileTransferStream
1193
1194
1195 182 Tijmen de Mes
Implemented in source:sipsimple/streams/msrp.py
1196 171 Tijmen de Mes
1197
The @FileTransferStream@ supports file transfer over MSRP according to RFC5547. An example of SDP constructed using this stream follows:
1198
1199
<pre>
1200
Content-Type: application/sdp
1201
Content-Length:   383
1202
1203
v=0
1204
o=- 3467525166 3467525166 IN IP4 192.168.1.6
1205
s=blink-0.10.7-beta
1206
c=IN IP4 192.168.1.6
1207
t=0 0
1208
m=message 2855 TCP/TLS/MSRP *
1209
a=path:msrps://192.168.1.6:2855/e593357dc9abe90754bd;tcp
1210
a=sendonly
1211
a=accept-types:*
1212
a=accept-wrapped-types:*
1213
a=file-selector:name:"reblink.pdf" type:com.adobe.pdf size:268759 hash:sha1:60:A1:BE:8D:71:DB:E3:8E:84:C9:2C:62:9E:F2:99:78:9D:68:79:F6
1214
</pre>
1215
1216
1217 179 Tijmen de Mes
*methods*
1218 171 Tijmen de Mes
1219
1220
1221
*<notextile>__init__</notextile>*(_self_, *account*, *file_selector*=@None@)
1222
>Instantiate a new @FileTransferStream@. If this is constructed by the application for an outgoing file transfer, the @file_selector@ argument must be present.
1223
  
1224
>+_account_+:
1225
>>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ instance which will be associated with the stream.
1226
  
1227
>+_file_selector_+:
1228
>>The @FileSelector@ instance which represents the file which is to be transferred.
1229
1230
1231 179 Tijmen de Mes
*notifications*
1232 171 Tijmen de Mes
1233
1234
1235
*FileTransferStreamDidDeliverChunk*
1236
>This notification is sent for an outgoing file transfer when a success report is received about part of the file being transferred.
1237
  
1238
>+_timestamp_+:
1239
>>A @datetime.datetime@ object indicating when the notification was sent.
1240
  
1241
>+_message_id_+:
1242
>>The MSRP message ID of the file transfer session.
1243
  
1244
>+_chunk_+:
1245
>>An @msrplib.protocol.MSRPData@ instance represented the received REPORT.
1246
  
1247
>+_code_+:
1248
>>The status code received. Will always be 200 for this notification.
1249
  
1250
>+_reason_+:
1251
>>The status reason received.
1252
  
1253
>+_transferred_bytes_+:
1254
>>The number of bytes which have currently been successfully transferred.
1255
  
1256
>+_file_size_+:
1257
>>The size of the file being transferred.
1258
1259
*FileTransferStreamDidNotDeliverChunk*
1260
  
1261
>+_timestamp_+:
1262
>>A @datetime.datetime@ object indicating when the notification was sent.
1263
>This notification is sent for an outgoing file transfer when a failure report is received about part of the file being transferred.
1264
  
1265
>+_message_id_+:
1266
>>The MSRP message ID of the file transfer session.
1267
  
1268
>+_chunk_+:
1269
>>An @msrplib.protocol.MSRPData@ instance represented the received REPORT.
1270
  
1271
>+_code_+:
1272
>>The status code received.
1273
  
1274
>+_reason_+:
1275
>>The status reason received.
1276
1277
*FileTransferStreamDidFinish*
1278
>This notification is sent when the incoming or outgoing file transfer is finished.
1279
  
1280
>+_timestamp_+:
1281
>>A @datetime.datetime@ object indicating when the notification was sent.
1282
1283
*FileTransferStreamGotChunk*
1284
>This notificaiton is sent for an incoming file transfer when a chunk of file data is received.
1285
  
1286
>+_timestamp_+:
1287
>>A @datetime.datetime@ object indicating when the notification was sent.
1288
  
1289
>+_content_+:
1290
>>The file part which was received, as a @str@.
1291
  
1292
>+_content_type_+:
1293
>>The MIME type of the file which is being transferred.
1294
  
1295
>+_transferred_bytes_+:
1296
>>The number of bytes which have currently been successfully transferred.
1297
  
1298
>+_file_size_+:
1299
>>The size of the file being transferred.
1300
1301
1302
1303
h3. IDesktopSharingHandler
1304
1305
1306
This interface is used to describe the interface between a @IDesktopSharingHandler@, which is responsible for consuming and producing RFB data, and the @DesktopSharingStream@ which is responsible for transporting the RFB data over MSRP. The middleware provides four implementations of this interface:
1307
* InternalVNCViewerHandler
1308
* InternalVNCServerHandler
1309
* ExternalVNCViewerHandler
1310
* ExternalVNCServerHandler
1311
1312
1313 179 Tijmen de Mes
*methods*
1314 171 Tijmen de Mes
1315
 
1316
1317
*initialize*(_self_, *stream*)
1318
>This method will be called by the @DesktopSharingStream@ when the stream has been started and RFB data can be transported. The stream has two attributes which are relevant to the @IDesktopSharingHandler@: incoming_queue and outgoing_queue. These attributes are @eventlet.coros.queue@ instances which are used to transport RFB data between the stream and the handler.
1319
1320
1321 179 Tijmen de Mes
*attributes*
1322 171 Tijmen de Mes
1323
1324
1325
*type*
1326
  @"active"@ or @"passive"@ depending on whether the handler represents a VNC viewer or server respectively.
1327
1328
1329 179 Tijmen de Mes
*notifications*
1330 171 Tijmen de Mes
1331
1332
1333
*DesktopSharingHandlerDidFail*
1334
>This notification must be sent by the handler when an error occurs to notify the stream that it should fail.
1335
  
1336
>+_context_+:
1337
>>A string describing when the handler failed, such as @"reading"@, @"sending"@ or @"connecting"@.
1338
  
1339
>+_failure_+:
1340
>>A @twisted.python.failure.Failure@ instance describing the exception which led to the failure.
1341
  
1342
>+_reason_+:
1343
>>A string describing the failure reason.
1344 172 Tijmen de Mes
1345
h3. InternalVNCViewerHandler
1346
1347
1348
This is a concrete implementation of the @IDesktopSharingHandler@ interface which can be used for a VNC viewer implemented within the application.
1349
1350
1351 179 Tijmen de Mes
*methods*
1352 172 Tijmen de Mes
1353
1354
1355
*send*(_self_, *data*)
1356
>Sends the specified data to the stream in order for it to be transported over MSRP to the remote endpoint.
1357
  
1358
>+_data_+:
1359
>>The RFB data to be transported over MSRP, in the form of a @str@.
1360
1361
1362 179 Tijmen de Mes
*notifications*
1363 172 Tijmen de Mes
1364
1365
1366
*DesktopSharingStreamGotData*
1367
>This notification is sent when data is received over MSRP.
1368
  
1369
>+_data_+:
1370
>>The RFB data from the remote endpoint, in the form of a @str@.
1371
1372
1373
h3. InternalVNCServerHandler
1374
1375
1376
This is a concrete implementation of the @IDesktopSharingHandler@ interface which can be used for a VNC server implemented within the application.
1377
1378
1379 179 Tijmen de Mes
*methods*
1380 172 Tijmen de Mes
1381
1382
1383
*send*(_self_, *data*)
1384
>Sends the specified data to the stream in order for it to be transported over MSRP to the remote endpoint.
1385
  
1386
>+_data_+:
1387
>>The RFB data to be transported over MSRP, in the form of a @str@.
1388
1389
1390 179 Tijmen de Mes
*notifications*
1391 172 Tijmen de Mes
1392
1393
1394
*DesktopSharingStreamGotData*
1395
>This notification is sent when data is received over MSRP.
1396
  
1397
>+_data_+:
1398
>>The RFB data from the remote endpoint, in the form of a @str@.
1399
1400
1401
h3. ExternalVNCViewerHandler
1402
1403
1404
This implementation of @IDesktopSharingHandler@ can be used for an external VNC viewer which connects to a VNC server using TCP.
1405
1406
1407 179 Tijmen de Mes
*methods*
1408 172 Tijmen de Mes
1409
1410
1411
*<notextile>__init__</notextile>*(_self_, *address*=@("localhost", 0)@, *connect_timeout*=@3@)
1412
>This instantiates a new @ExternalVNCViewerHandler@ which is listening on the provided address, ready for the external VNC viewer to connect to it via TCP. After this method returns, the attribute @address@ can be used to find out exactly on what address and port the handler is listening on. The handler will only accept one conenction on this address.
1413
  
1414
>+_address_+:
1415
>>A tuple containing an IP address/hostname and a port on which the handler should listen. Any data received on this socket will then be forwarded to the stream and any data received from the stream will be forwarded to this socket.
1416
1417
1418 179 Tijmen de Mes
*attributes*
1419 172 Tijmen de Mes
1420
1421
1422
*address*
1423
>A tuple containing an IP address and a port on which the handler is listening.
1424
1425
1426
h3. ExternalVNCServerHandler
1427
1428
1429
This implementation of @IDesktopSharingHandler@ can be used for an external VNC server to which handler will connect using TCP.
1430
1431
1432 179 Tijmen de Mes
*methods*
1433 172 Tijmen de Mes
1434
1435
1436
*<notextile>__init__</notextile>*(_self_, *address*, *connect_timeout*=@3@)
1437
>This instantiates a new @ExternalVNCServerHandler@ which will connect to the provided address on which a VNC server must be listening before the stream using this handler starts.
1438
  
1439
>+_address_+:
1440
>>A tuple containing an IP address/hostname and a port on which the VNC server will be listening. Any data received on this socket will then be forwared to the stream and any data received form the stream will be forwarded to this socket.
1441
  
1442
>+_connect_timeout_+:
1443
>>How long to wait to connect to the VNC server before giving up.
1444
1445
1446
1447
h3. DesktopSharingStream
1448
1449
1450 182 Tijmen de Mes
Implemented in source:sipsimple/streams/msrp.py
1451 172 Tijmen de Mes
1452
This stream implements desktop sharing using MSRP as a transport protocol for RFB data.
1453
1454
There is no standard defining this usage but is fairly easy to implement in clients that already support MSRP. To traverse a NAT-ed router, a "MSRP relay":http://msrprelay.org configured for the called party domain is needed. Below is an example of the Session Description Protocol used for establishing a Desktop sharing session:
1455
1456
<pre>
1457
m=application 2855 TCP/TLS/MSRP *
1458
a=path:msrps://10.0.1.19:2855/b599b22d1b1d6a3324c8;tcp
1459
a=accept-types:application/x-rfb
1460
a=rfbsetup:active
1461
</pre>
1462
1463
1464
1465 179 Tijmen de Mes
*methods*
1466 172 Tijmen de Mes
1467
1468
1469
*<notextile>__init__</notextile>*(_self_, *acount*, *handler*)
1470
>Instantiate a new @DesktopSharingStream@.
1471
  
1472
>+_account_+:
1473
>>The @sipsimple.account.Account@ or @sipsimple.account.BonjourAccount@ instance this stream is associated with.
1474
  
1475
>+_handler_+:
1476
>>An object implementing the @IDesktopSharingHandler@ interface which will act as the handler for RFB data.
1477
1478
1479 179 Tijmen de Mes
*attributes*
1480 172 Tijmen de Mes
1481
1482
1483
*handler*
1484
>This is a writable property which can be used to get or set the object implementing @IDesktopSharingHandler@ which acts as the handler for RFB data. For incoming @DesktopSharingStreams@, this must be set by the application before the stream starts.
1485
1486
*incoming_queue*
1487
>A @eventlet.coros.queue@ instance on which incoming RFB data is written. The handler should wait for data on this queue.
1488
1489
*outgoing_queue*
1490
>A @eventlet.coros.queue@ instance on which outgoing RFB data is written. The handler should write data on this queue.
1491
1492
1493
h3. ConferenceHandler
1494
1495
1496
This class is internal to the @Session@ and provied the user with the ability to invite participants to a conference hosted by the remote endpoint.
1497
1498
Adding and removing participants is performed using a @REFER@ request as explained in RFC 4579, section 5.5.
1499
1500
In addition, the @ConferenceHandler@ will subscribe to the @conference@ event in order to get information about participants in the conference.
1501
1502
1503 179 Tijmen de Mes
*methods*
1504 172 Tijmen de Mes
1505
1506
*add_participant*(_self_, *participant_uri*)
1507
>Send a @REFER@ request telling the server to invite the participant specified in @participant_uri@ to join the ongoing conference.
1508
1509
*remove_participant*(_self_, *participant_uri*)
1510
>Send a @REFER@ request telling the server to remove the participant specified in @participant_uri@ from the ongoing conference.
1511
1512
1513 179 Tijmen de Mes
*notifications*
1514 172 Tijmen de Mes
1515
1516
 All notifications are sent with the @Session@ object as the sender.
1517
1518
*SIPSessionGotConferenceInfo*
1519
>This notification is sent when a @NOTIFY@ is received with a valid conferene payload.
1520
  
1521
>+_timestamp_+:
1522
>>A @datetime.datetime@ object indicating when the notification was sent.
1523
  
1524
>+_conference_info_+:
1525
>>The @Conference@ payload object.
1526
1527
*SIPConferenceDidAddParticipant*
1528
>This notification is sent when a participant was successfully added to the conference.
1529
  
1530
>+_timestamp_+:
1531
>>A @datetime.datetime@ object indicating when the notification was sent.
1532
  
1533
>+_participant_+:
1534
>>URI of the participant added to the conference.
1535
1536
*SIPConferenceDidNotAddParticipant*
1537
>This notification is sent when a participant could not be added to the conference.
1538
  
1539
>+_timestamp_+:
1540
>>A @datetime.datetime@ object indicating when the notification was sent.
1541
  
1542
>+_participant_+:
1543
>>URI of the participant added to the conference.
1544
  
1545
>+_code_+:
1546
>>SIP response code for the failure.
1547
  
1548
>+_reason_+:
1549
>>Reason for the failure.
1550
1551
*SIPConferenceDidRemoveParticipant*
1552
>This notification is sent when a participant was successfully removed from the conference.
1553
  
1554
>+_timestamp_+:
1555
>>A @datetime.datetime@ object indicating when the notification was sent.
1556
  
1557
>+_participant_+:
1558
>>URI of the participant removed from the conference.
1559
1560
*SIPConferenceDidNotRemoveParticipant*
1561
>This notification is sent when a participant could not be removed from the conference.
1562
  
1563
>+_timestamp_+:
1564
>>A @datetime.datetime@ object indicating when the notification was sent.
1565
  
1566
>+_participant_+:
1567
>>URI of the participant removed from the conference.
1568
  
1569
>+_code_+:
1570
>>SIP response code for the failure.
1571
  
1572
>+_reason_+:
1573
>>Reason for the failure.
1574
1575
*SIPConferenceGotAddParticipantProgress*
1576
>This notification is sent when a @NOTIFY@ is received indicating the status of the add participant operation.
1577
  
1578
>+_timestamp_+:
1579
>>A @datetime.datetime@ object indicating when the notification was sent.
1580
  
1581
>+_participant_+:
1582
>>URI of the participant whose operation is in progress.
1583
  
1584
>+_code_+:
1585
>>SIP response code for progress.
1586
  
1587
>+_reason_+:
1588
>>Reason associated with the response code.
1589
1590
*SIPConferenceGotRemoveParticipantProgress*
1591
>This notification is sent when a @NOTIFY@ is received indicating the status of the remove participant operation.
1592
  
1593
>+_timestamp_+:
1594
>>A @datetime.datetime@ object indicating when the notification was sent.
1595
  
1596
>+_participant_+:
1597
>>URI of the participant whose operation is in progress.
1598
  
1599
>+_code_+:
1600
>>SIP response code for progress.
1601
  
1602
>+_reason_+:
1603
>>Reason associated with the response code.
1604 173 Tijmen de Mes
1605
1606
h2. Address Resolution
1607
1608
1609
The SIP SIMPLE middleware offers the @sipsimple.lookup@ module which contains an implementation for doing DNS lookups for SIP proxies, MSRP relays, STUN servers and XCAP servers. The interface offers both an asynchronous and synchronous interface. The asynchronous interface is based on notifications, while the synchronous one on green threads. In order to call the methods in a asynchronous manner, you just need to call the method and wait for the notification which is sent on behalf of the DNSLookup instance. The notifications sent by the DNSLookup object are DNSLookupDidSucceed and DNSLookupDidFail. In order to call the methods in a synchronous manner, you need to call the wait method on the object returned by the methods of DNSLookup. This wait method needs to be called from a green thread and will either return the result of the lookup or raise an exception.
1610
1611
The DNSLookup object uses DNSManager, an object that will use the system nameservers and it will fallback to Google's nameservers (8.8.8.8 and 8.8.4.4) in case of failure. 
1612
1613
1614
h3. DNS Manager
1615
1616
1617
This object provides @DNSLookup@ with the nameserver list that will be used to perform DNS lookups. It will probe the system local nameservers and check if they are able to do proper lookups (by querying sip2sip.info domain). If the local nameservers are not able to do proper lookups Google nameservers will be used and another probing operation will be scheduled. Local nameservers are always preferred.
1618
1619
1620 179 Tijmen de Mes
*methods*
1621 173 Tijmen de Mes
1622
1623
*<notextile>__init__</notextile>*(_self_)
1624
>Instantiate the DNSManager object (it's a Singleton).
1625
1626
*start*(_self_)
1627
>Start the DNSManager. It will start the probing process to determine the suitable nameservers to use.
1628
1629
*stop*(_self_)
1630
>Stop the DNS resolution probing.
1631 174 Tijmen de Mes
1632
1633 179 Tijmen de Mes
*notifications*
1634 174 Tijmen de Mes
1635
1636
*DNSResolverDidInitialize*
1637
>This notification is sent when the nameservers to use for probing (and further DNS lookups) have been set for the first time.
1638
  
1639
>+_timestamp_+:
1640
>>A @datetime.datetime@ object indicating when the notification was sent.
1641
  
1642
>+_nameservers_+:
1643
>>The list of nameservers that was set on the DNS Manager.
1644
1645
*DNSNameserversDidChange*
1646
>This notification is sent when the nameservers to use for probing (and further DNS lookups) have changed as a result of the probing process.
1647
  
1648
>+_timestamp_+:
1649
>>A @datetime.datetime@ object indicating when the notification was sent.
1650
  
1651
>+_nameservers_+:
1652
>>The list of nameservers that was set on the DNS Manager.
1653
1654
1655
1656
h3. DNS Lookup
1657
1658
1659
This object implements DNS lookup support for SIP proxies according to RFC3263 and MSRP relay and STUN server lookup using SRV records. The object initially does NS record queries in order to determine the authoritative nameservers for the domain requested; these authoritative nameservers will then be used for NAPTR, SRV and A record queries. If this fails, the locally configured nameservers are used. The reason for doing this is that some home routers have broken NAPTR and/or SRV query support.
1660
1661 179 Tijmen de Mes
*methods*
1662 174 Tijmen de Mes
1663
*<notextile>__init__</notextile>*(_self_)
1664
>Instantiate a new DNSLookup object.
1665
1666
*lookup_service*(_self_, *uri*, *service*, *timeout*=@3.0@, *lifetime*=@15.0@)
1667
>Perform an SRV lookup followed by A lookups for MSRP relays or STUN servers depending on the @service@ parameter. If SRV queries on the @uri.host@ domain fail, an A lookup is performed on it and the default port for the service is returned. Only the @uri.host@ attribute is used. The return value is a list of (host, port) tuples.
1668
  
1669
>+_uri_+:
1670
>>A @(Frozen)SIPURI@ from which the @host@ attribute is used for the query domain.
1671
  
1672
>+_service_+:
1673
>>The service to lookup servers for, @"msrprelay"@ or @"stun"@.
1674
  
1675
>+_timeout_+:
1676
>>How many seconds to wait for a response from a nameserver.
1677
  
1678
>+_lifetime_+:
1679
>>How many seconds to wait for a response from all nameservers in total.
1680
1681
*lookup_sip_proxy*(_self_, *uri*, *supported_transports*, *timeout*=@3.0@, *lifetime*=@15.0@)
1682
>Perform a RFC3263 compliant DNS lookup for a SIP proxy using the URI which is considered to point to a host if either the @host@ attribute is an IP address, or the @port@ is present. Otherwise, it is considered a domain for which NAPTR, SRV and A lookups are performed. If NAPTR or SRV queries fail, they fallback to using SRV and A queries. If the transport parameter is present in the URI, this will be used as far as it is part of the supported transports. If the URI has a @sips@ schema, then only the TLS transport will be used as far as it doesn't conflict with the supported transports or the transport parameter. The return value is a list of @Route@ objects containing the IP address, port and transport to use for routing in the order of preference given by the supported_transports argument.
1683
  
1684
>+_uri_+:
1685
>>A @(Frozen)SIPURI@ from which the @host@, @port@, @parameters@ and @secure@ attributes are used.
1686
  
1687
>+_supported_transports_+:
1688
>>A sublist of @['udp', 'tcp', 'tls']@ in the application's order of preference.
1689
  
1690
>+_timeout_+:
1691
>>How many seconds to wait for a response from a nameserver.
1692
  
1693
>+_lifetime_+:
1694
>>How many seconds to wait for a response from all nameservers in total.
1695
1696
*lookup_xcap_server*(_self_, *uri*, *timeout*=@3.0@, *lifetime*=@15.0@)
1697
>Perform a TXT DNS query on xcap.<uri.host> and return all values of the TXT record which are URIs with a scheme of http or https. Only the @uri.host@ attribute is used. The return value is a list of strings representing HTTP URIs.
1698
  
1699
>+_uri_+:
1700
>>A @(Frozen)SIPURI@ from which the @host@ attribute is used for the query domain.
1701
  
1702
>+_timeout_+:
1703
>>How many seconds to wait for a response from a nameserver.
1704
  
1705
>+_lifetime_+:
1706
>>How many seconds to wait for a response from all nameservers in total.
1707
1708
1709
1710 179 Tijmen de Mes
*notifications*
1711 174 Tijmen de Mes
1712
1713
1714
*DNSLookupDidSucceed*
1715
>This notification is sent when one of the lookup methods succeeds in finding a result.
1716
  
1717
>+_timestamp_+:
1718
>>A @datetime.datetime@ object indicating when the notification was sent.
1719
  
1720
>+_result_+:
1721
>>The result of the DNS lookup in the format described in each method.
1722
1723
*DNSLookupDidFail*
1724
>This notification is sent when one of the lookup methods fails in finding a result.
1725
  
1726
>+_timestamp_+:
1727
>>A @datetime.datetime@ object indicating when the notification was sent.
1728
  
1729
>+_error_+:
1730
>>A @str@ object describing the error which resulted in the DNS lookup failure.
1731
1732
*DNSLookupTrace*
1733
>This notification is sent several times during a lookup process for each individual DNS query.
1734
  
1735
>+_timestamp_+:
1736
>>A @datetime.datetime@ object indicating when the notification was sent.
1737
  
1738
>+_query_type_+:
1739
>>The type of the query, @"NAPTR"@, @"SRV"@, @"A"@, @"NS"@ etc.
1740
  
1741
>+_query_name_+:
1742
>>The name which was queried.
1743
  
1744
>+_answer_+:
1745
>>The answer returned by dnspython, or @None@ if an error occurred.
1746
  
1747
>+_error_+:
1748
>>The exception which caused the query to fail, or @None@ if no error occurred.
1749
  
1750
>+_context_+:
1751
>>The name of the method which was called on the @DNSLookup@ object.
1752
  
1753
>+_service_+:
1754
>>The service which was queried for, only available when context is @"lookup_service"@.
1755
  
1756
>+_uri_+:
1757
>>The uri which was queried for.
1758
  
1759
>+_nameservers_+:
1760
>>The list of nameservers that was used to perform the lookup.
1761 175 Tijmen de Mes
1762
1763
1764
h3. Route
1765
1766
1767
This is a convinience object which contains sufficient information to identify a route to a SIP proxy. This object is returned by @DNSLookup.lookup_sip_proxy@ and can be used with the @Session@ or a @(Frozen)RouteHeader@ can be easily constructed from it to pass to one of the objects in the SIP core handling SIP dialogs/transactions (@Invitation@, @Subscription@, @Request@, @Registration@, @Message@, @Publication@). This object has three attributes which can be set in the constructor or after it was instantiated. They will only be documented as arguments to the constructor.
1768
1769
1770 179 Tijmen de Mes
*methods*
1771 175 Tijmen de Mes
1772
1773
1774
*<notextile>__init__</notextile>*(_self_, *address*, *port*=None, *transport*=@'udp'@)
1775
>Creates the Route object with the specified parameters as attributes.
1776
>Each of these attributes can be accessed on the object once instanced.
1777
  
1778
>+_address_+:
1779
>>The IPv4 address that the request in question should be sent to as a string.
1780
  
1781
>+_port_+:
1782
>>The port to send the requests to, represented as an int, or None if the default port is to be used.
1783
  
1784
>+_transport_+:
1785
>>The transport to use, this can be a string of either "udp", "tcp" or "tls" (case insensitive).
1786
1787
*get_uri*(_self_)
1788
>Returns a @SIPURI@ object which contains the adress, port and transport as parameter. This can be used to easily construct a @RouteHeader@:
1789 176 Tijmen de Mes
<pre>
1790 175 Tijmen de Mes
    route = Route("1.2.3.4", port=1234, transport="tls")
1791
    route_header = RouteHeader(route.get_uri())
1792 1 Adrian Georgescu
</pre>
1793 176 Tijmen de Mes
1794
h2. SIP Accounts
1795
1796
1797 182 Tijmen de Mes
Account Management is implemented in source:sipsimple/account.py (@sipsimple.account@ module) and offers support for SIP accounts registered at SIP providers and SIP bonjour accounts which are discovered using mDNS.
1798 176 Tijmen de Mes
1799
1800
h3. AccountManager
1801
1802
1803
The @sipsimple.account.AccountManager@ is the entity responsible for loading and keeping track of the existing accounts. It is a singleton and can be instantiated anywhere, obtaining the same instance. It cannot be used until its @start@ method has been called.
1804
1805
1806 179 Tijmen de Mes
*methods*
1807 176 Tijmen de Mes
1808
1809
1810
*<notextile>__init__</notextile>*(_self_)
1811
>The @__init__@ method allows the @AccountManager@ to be instantiated without passing any parameters. A reference to the @AccountManager@ can be obtained anywhere before it is started.
1812
1813
*start*(_self_)
1814
>This method will load all the existing accounts from the configuration. If the Engine is running, the accounts will also activate. This method can only be called after the [[SipConfigurationAPI#ConfigurationManager|ConfigurationManager]] has been started. A *SIPAccountManagerDidAddAccount* will be sent for each account loaded. This method is called automatically by the SIPApplication when it initializes all the components of the middleware.
1815
1816
*stop*(_self_)
1817
>Calling this method will deactivate all accounts managed by the @AccountManager@. This method is called automatically by the SIPApplication when it stops.
1818
1819
*has_account*(_self_, *id*)
1820
>This method returns @True@ if an account which has the specifed SIP ID (must be a string) exists and @False@ otherwise.
1821
1822
*get_account*(_self_, *id*)
1823
>Returns the account (either an @Account@ instance or the @BonjourAccount@ instance) with the specified SIP ID. Will raise a @KeyError@ if such an account does not exist.
1824
1825
*get_accounts*(_self_)
1826
>Returns a list containing all the managed accounts.
1827
1828
*iter_accounts*(_self_)
1829
>Returns an iterator through all the managed accounts.
1830
1831
*find_account*(_self_, *contact_uri*)
1832
>Returns an account with matches the specified @contact_uri@ which must be a @sipsimple.core.SIPURI@ instance. Only the accounts with the enabled flag set will be considered. Returns None if such an account does not exist.
1833
1834
1835 179 Tijmen de Mes
*notifications*
1836 176 Tijmen de Mes
1837
1838
*SIPAccountManagerDidAddAccount*
1839
>This notification is sent when a new account becomes available to the @AccountManager@. The notification is also sent when the accounts are loaded from the configuration.
1840
  
1841
>+_timestamp_+:
1842
>>A @datetime.datetime@ object indicating when the notification was sent.
1843
  
1844
>+_account_+:
1845
>>The account object which was added.
1846
1847
*SIPAccountManagerDidRemoveAccount*
1848
>This notification is sent when an account is deleted using the @delete@ method.
1849
  
1850
>+_timestamp_+:
1851
>>A @datetime.datetime@ object indicating when the notification was sent.
1852
  
1853
>+_account_+:
1854
>>The account object which was deleted.
1855
1856
*SIPAccountManagerDidChangeDefaultAccount*
1857
>This notification is sent when the default account changes.
1858
  
1859
>+_timestamp_+:
1860
>>A @datetime.datetime@ object indicating when the notification was sent.
1861
  
1862
>+_old_account_+:
1863
>> This is the account object which used to be the default account.
1864
  
1865
>+_account_+:
1866
>> This is the account object which is the new default account.
1867
1868
h3. Account
1869
1870
1871
The @sipsimple.account.Account@ objects represent the SIP accounts which are registered at SIP providers. It has a dual purpose: it acts as both a container for account-related settings and as a complex object which can be used to interact with various per-account functions, such as presence, registration etc. This page documents the latter case, while the former is explained in the [[SipConfigurationAPI#Account|Configuration API]].
1872
1873
There is exactly one instance of @Account@ per SIP account used and it is uniquely identifiable by its SIP ID, in the form _user@domain_. It is a singleton, in the sense that instantiating @Account@ using an already used SIP ID will return the same object. However, this is not the recommended way of accessing accounts, as this can lead to creation of new ones; the recommended way is by using the [[SipMiddlewareApi#AccountManager|AccountManager]]. The next sections will use a lowercase, monospaced @account@ to represent an instance of @Account@.
1874
1875
1876 179 Tijmen de Mes
*states*
1877 176 Tijmen de Mes
1878
1879
The @Account@ objects have a setting flag called @enabled@ which, if set to @False@ will deactivate it: none of the internal functions will work in this case; in addition, the application using the middleware should not do anything with a disabled account. After changing it's value, the @save()@ method needs to be called, as the flag is a setting and will not be used until this method is called:
1880
<pre>
1881
account.enabled = True
1882
account.save()
1883
</pre>
1884
1885
The @Account@ objects will activate automatically when they are loaded/created if the @enabled@ flag is set to @True@ and the @sipsimple.engine.Engine@ is running; if it is not running, the accounts will activate after the engine starts.
1886
1887
In order to create a new account, just create a new instance of @Account@ with an id which doesn't belong to any other account.
1888
1889
The other functions of @Account@ which run automatically have other enabled flags as well. They will only be activated when both the global enabled flag is set and the function-specific one. These are:
1890
1891 1 Adrian Georgescu
1892 193 Saúl Ibarra Corretgé
*Account.sip.register.enabled*
1893 176 Tijmen de Mes
>This flag controls the automatic registration of the account. The notifications *SIPAccountRegistrationDidSucceed*, *SIPAccountRegistrationDidFail* and *SIPAccountRegistrationDidEnd* are used to inform the status of this registration.
1894 1 Adrian Georgescu
1895 176 Tijmen de Mes
*Account.presence.enabled*
1896 193 Saúl Ibarra Corretgé
>This flag controls the automatic subscription to buddies for the _presence_ and _dialog_ events and the publication of data for the _presence_ event.
1897 176 Tijmen de Mes
1898
*Account.message_summary.enabled*
1899 193 Saúl Ibarra Corretgé
>This flag controls the automatic subscription to the _message-summary_ event in order to find out about voicemail messages.
1900 176 Tijmen de Mes
1901
The @save()@ method needs to be called after changing these flags in order for them to take effect. The methods available on @Account@ objects are inherited from [[SipConfigurationAPI#SettingsObject|SettingsObject]].
1902
1903
1904 179 Tijmen de Mes
*attributes*
1905 176 Tijmen de Mes
1906
1907
The following attributes can be used on an Account object and need to be considered read-only.
1908
1909
1910
*id*
1911
>This attribute is of type @sipsimple.configuration.datatypes.SIPAddress@ (a subclass of @str@) and contains the SIP id of the account. It can be used as a normal string in the form _user@domain_, but it also allows access to the components via the attributes @username@ and @domain@.
1912
  <pre>
1913
  account.id # 'alice@example.com'
1914
  account.id.username # 'alice'
1915
  account.id.domain # 'example.com'
1916
</pre>
1917
1918
*contact*
1919 194 Saúl Ibarra Corretgé
>This attribute can be used to construct the Contact URI for SIP requests sent on behalf of this account. It's type is @sipsimple.core.ContactURIFactory@. It can be indexed by a URi type plus a string representing a transport (@'udp'@, @'tcp'@, @'tls'@) or a @sipsimple.util.Route@ object which will return a @sipsimple.core.SIPURI@ object with the appropriate IP, port and transport. URI types are: @NoGRUU@, @PublicGRUU@, @TemporaryGRUU@, @PublicGRUUIfAvailable@ and @TemporaryGRUUIfAvailable@. They can be imported from @sipsimple.core@. The username part is a randomly generated 8 character string consisting of lowercase letters; but it can be chosen by passing it to +init+ when building the @ContactURIFactory@ object.
1920 176 Tijmen de Mes
  <pre>
1921
  account.contact # 'ContactURIFactory(username=hnfkybrt)'
1922
  account.contact.username # 'hnfkybrt'
1923
  account.contact['udp'] # <SIPURI "sip:hnfkybrt@10.0.0.1:53024">
1924
  account.contact['tls'] # <SIPURI "sip:hnfkybrt@10.0.0.1:54478;transport=tls">
1925
</pre>
1926
1927
*credentials*
1928
>This attribute is of type @sipsimple.core.Credentials@ which is built from the @id.username@ attribute and the @password@ setting of the Account. Whenever this setting is changed, this attribute is updated.
1929
  <pre>
1930
  account.credentials # <Credentials for 'alice'>
1931
</pre>
1932
1933 195 Saúl Ibarra Corretgé
*tls_credentials*
1934
> This attribute of type @X509Credentials@ returns the TLS credentials object which is later used when establishing MSRP connections, for example.
1935
1936 176 Tijmen de Mes
*uri*
1937
>This attribute is of type @sipsimple.core.SIPURI@ which can be used to form a @FromHeader@ associated with this account. It contains the SIP ID of the account.
1938
  <pre>
1939
  account.uri # <SIPURI "sip:alice@example.com">
1940
</pre>
1941 195 Saúl Ibarra Corretgé
1942
*voicemail_uri*
1943
> This attribute contains a string object representing the URI which is set as the subscription target for the message-summary event.
1944
1945
*other*
1946
1947
*registered*
1948
> Returns @True@ if the account has registred, @False@ otherwise.
1949
1950
*mwi_active*
1951
> Returns @True@ if the account has an active subscription to the message-summary event, @False@ otherwise.
1952
1953
*presence_state*
1954
> Property which can be used to get or set the presence state for the account. The presence state needs to be a @PIDF@ object from the @sipsimple.payloads@ module. The account itself takes care of the publication process.
1955
1956
*dialog_state*
1957
> Property which can be used to get or set the dialog state for the account. The dialog state needs to be a @DialogInfo@ object from the @sipsimple.payloads@ module. The account itself takes care of the publication process.
1958 176 Tijmen de Mes
1959
1960 179 Tijmen de Mes
*notifications*
1961 176 Tijmen de Mes
1962
1963
1964
*CFGSettingsObjectDidChange*
1965
>This notification is sent when the @save()@ method is called on the account after some of the settings were changed. As the notification belongs to the @SettingsObject@ class, it is exaplained in detail in [[SipConfigurationAPI#SettingsObjectNotifications|SettingsObject Notifications]].
1966
1967
*SIPAccountWillActivate*
1968
>This notification is sent when the @Account@ is about to be activated, but before actually performing any activation task. See @SIPAccountDidActivate@ for more detail.
1969
1970
*SIPAccountDidActivate*
1971
>This notification is sent when the @Account@ activates. This can happen when the @Account@ is loaded if it's enabled flag is set and the Engine is running, and at any later time when the status of the Engine changes or the enabled flag is modified.
1972
1973
*SIPAccountWillDeactivate*
1974
>This notification is sent when the @Account@ is about to be deactivated, but before performing any deactivation task. See @SIPAccountDidDeactivate@ for more detail.
1975
1976
*SIPAccountDidDeactivate*
1977
>This notification is sent when the @Account@ deactivates. This can happend when the @Engine@ is stopped or when the enabled flag of the account is set to @False@.
1978
1979
*SIPAccountWillRegister*
1980
>This notification is sent when the account is about to register for the first time.
1981
1982
*SIPAccountRegistrationWillRefresh*
1983
>This notification is sent when a registration is about to be refreshed.
1984
1985
*SIPAccountRegistrationDidSucceed*
1986
>This notification is sent when a REGISTER request sent for the account succeeds (it is also sent for each refresh of the registration). The data contained in this notification is:
1987
  
1988
>+_contact_header_+:
1989
>>The Contact header which was registered.
1990
  
1991
>+_contact_header_list_+:
1992
>>A list containing all the contacts registered for this SIP account.
1993
  
1994
>+_expires_+:
1995
>>The amount in seconds in which this registration will expire.
1996
  
1997
>+_registrar_+:
1998
>>The @sipsimple.util.Route@ object which was used.
1999
2000
*SIPAccountRegistrationDidFail*
2001
>This notification is sent when a REGISTER request sent for the account fails. It can fail either because a negative response was returned or because PJSIP considered the request failed (e.g. on timeout). The data contained in this notification is:
2002
  
2003
>+_error_+:
2004
>>The reason for the failure of the REGISTER request.
2005
  
2006 196 Saúl Ibarra Corretgé
>+_retry_after_+:
2007 176 Tijmen de Mes
>>The amount in seconds as a @float@ after which the registration will be tried again.
2008
2009
*SIPAccountRegistrationDidEnd*
2010
>This notification is sent when a registration is ended (the account is unregistered). The data contained in this notification is:
2011
  
2012
>+_registration_+:
2013
>>The @sipsimple.core.Registration@ object which ended.
2014 1 Adrian Georgescu
2015 176 Tijmen de Mes
*SIPAccountRegistrationDidNotEnd*
2016
>This notification is sent when a registration fails to end (the account is not unregistered). The data contained in this notification is:
2017
  
2018
>+_code_+:
2019
>>The SIP status code received.
2020
  
2021
>+_reason_+:
2022
>>The SIP status reason received.
2023
  
2024
>+_registration_+:
2025
>>The @sipsimple.core.Registration@ object which ended.
2026
2027
*SIPAccountRegistrationGotAnswer*
2028
>>This notification is sent whenever a response is received to a sent REGISTER request for this account. The data contained in this notification is:
2029
  
2030
>+_code_+:
2031
>>The SIP status code received.
2032
  
2033
>+_reason_+:
2034
>>The SIP status reason received.
2035
  
2036
>+_registration_+:
2037
>>The @sipsimple.core.Registration@ object which was used.
2038
  
2039
>+_registrar_+:
2040
>>The @sipsimple.util.Route@ object which was used.
2041
2042 196 Saúl Ibarra Corretgé
*SIPAccountGotMessageSummary*
2043 176 Tijmen de Mes
>This notification is sent when a NOTIFY is received with a message-summary payload. The data contained in this notification is:
2044
  
2045
>+_message_summary_+:
2046
>>A @sipsimple.payloads.messagesummary.MessageSummary@ object with the parsed payload from the NOTIFY request.
2047 196 Saúl Ibarra Corretgé
2048 197 Saúl Ibarra Corretgé
*SIPAccountGotPresenceWinfo*
2049
>This notification is sent when a NOTIFY is received with a presence.winfo payload. The data contained in this notification is:
2050
  
2051
>+_version_+:
2052
>> The version number of the received document.
2053
2054
>+_state_+:
2055
>> Indicates if the received state is full or partial.
2056
2057
>+_watcher_list_+:
2058
>>A @sipsimple.payloads.watcherinfo.WatcherList@ object with the parsed information from the NOTIFY request.
2059
2060
*SIPAccountGotDialogWinfo*
2061
>This notification is sent when a NOTIFY is received with a dialog.winfo payload. The data contained in this notification is:
2062
  
2063
>+_version_+:
2064
>> The version number of the received document.
2065
2066
>+_state_+:
2067
>> Indicates if the received state is full or partial.
2068
2069
>+_watcher_list_+:
2070
>>A @sipsimple.payloads.watcherinfo.WatcherList@ object with the parsed information from the NOTIFY request.
2071
2072 198 Saúl Ibarra Corretgé
*SIPAccountGotPresenceState*
2073
>This notification is sent when a NOTIFY is received with a presence payload. The data contained in this notification is:
2074
2075
>+_version_+:
2076
>> The version number of the received document.
2077
2078
>+_full_state_+:
2079
>> Boolean flag indicating if the received state is full or partial.
2080
2081
>+_resource_map_+:
2082
>> Dictionary mapping SIP URIs to @sipsimple.payloads.rlsnotify.Resource@ instances which contain all presence documents associated with them.
2083
2084
*SIPAccountGotDialogState*
2085
>This notification is sent when a NOTIFY is received with a dialog payload. The data contained in this notification is:
2086
2087
>+_version_+:
2088
>> The version number of the received document.
2089
2090
>+_full_state_+:
2091
>> Boolean flag indicating if the received state is full or partial.
2092
2093
>+_resource_map_+:
2094
>> Dictionary mapping SIP URIs to @sipsimple.payloads.rlsnotify.Resource@ instances which contain all dialog-info documents associated with them.
2095
2096
2097
  
2098 176 Tijmen de Mes
2099
h3. BonjourAccount
2100
2101
2102
The @sipsimple.account.BonjourAccount@ represents the SIP account used for P2P mode; it does not interact with any server. The class is a singleton, as there can only be one such account on a system. Similar to the @Account@, it is used both as a complex object, which implements the functions for bonjour mode, as well as a container for the related settings.
2103
2104
2105 179 Tijmen de Mes
*states*
2106 176 Tijmen de Mes
2107
2108
The @BonjourAccount@ has an @enabled@ flag which controls whether this account will be used or not. If it is set to @False@, none of the internal functions will be activated and, in addition, the account should not be used by the application. The bonjour account can only activated if the Engine is running; once it is started, if the enabled flag is set, the account will activate. When the @BonjourAccount@ is activated, it will broadcast the contact address on the LAN and discover its neighbours sending notifications as this happens.
2109
2110
2111 179 Tijmen de Mes
*attributes*
2112 176 Tijmen de Mes
2113
2114
The following attributes can be used on a BonjourAccount object and need to be considered read-only.
2115
2116
2117
*id*
2118
>This attribute is of type @sipsimple.configuration.datatypes.SIPAddress@ (a subclass of @str@) and contains the SIP id of the account, which is @'bonjour@local'@. It can be used as a normal string, but it also allows access to the components via the attributes @username@ and @domain@.
2119
  <pre>
2120
  bonjour_account.id # 'bonjour@local'
2121
  bonjour_account.id.username # 'bonjour'
2122
  bonjour_account.id.domain # 'local'
2123
</pre>
2124
2125
*contact*
2126
>This attribute can be used to construct the Contact URI for SIP requests sent on behalf of this account. It's type is @sipsimple.account.ContactURIFactory@. It can be indexed by a string representing a transport (@'udp'@, @'tcp'@, @'tls'@) or a @sipsimple.util.Route@ object which will return a @sipsimple.core.SIPURI@ object with the appropriate IP, port and transport. The username part is a randomly generated 8 character string consisting of lowercase letters; but it can be chosen by passing it to +init+ when building the @ContactURIFactory@ object.
2127
  <pre>
2128
  bonjour_account.contact # 'ContactURIFactory(username=lxzvgack)'
2129
  bonjour_account.contact.username # 'lxzvgack'
2130
  bonjour_account.contact['udp'] # <SIPURI "sip:lxzvgack@10.0.0.1:53024">
2131
  bonjour_account.contact['tls'] # <SIPURI "sip:lxzvgack@10.0.0.1:54478;transport=tls">
2132
</pre>
2133
2134
*credentials*
2135
>This attribute is of type @sipsimple.core.Credentials@ object which is built from the @contact.username@ attribute; the password is set to the empty string.
2136
  <pre>
2137
  bonjour_account.credentials # <Credentials for 'alice'>
2138
</pre>
2139
2140
*uri*
2141
>This attribute is of type @sipsimple.core.SIPURI@ which can be used to form a @FromHeader@ associated with this account. It contains the contact address of the bonjour account:
2142
  <pre>
2143
  bonjour_account.uri # <SIPURI "sip:lxzvgack@10.0.0.1">
2144
</pre>
2145
2146
2147 179 Tijmen de Mes
*notifications*
2148 176 Tijmen de Mes
2149
2150
*BonjourAccountDidAddNeighbour*
2151
>This notification is sent when a new Bonjour neighbour is discovered.
2152
  
2153
>+_service_description_+:
2154
>>BonjourServiceDescription object uniquely identifying this neighbour in the mDNS library.
2155
  
2156
>+_display_name_+:
2157
>>The name of the neighbour as it is published.
2158
  
2159
>+_host_+:
2160
>>The hostname of the machine from which the Bonjour neighbour registered its contact address.
2161
  
2162
>+_uri_+:
2163
>>The contact URI of the Bonjour neighbour, as a @FrozenSIPURI@ object.
2164
  
2165
>+_timestamp_+:
2166
>>A @datetime.datetime@ object indicating when the notification was sent.
2167
2168
*BonjourAccountDidUpdateNeighbour*
2169
>This notification is sent when an existing Bonjour neighbour has updates its published data.
2170
  
2171
>+_service_description_+:
2172
>>BonjourServiceDescription object uniquely identifying this neighbour in the mDNS library.
2173
  
2174
>+_display_name_+:
2175
>>The name of the neighbour as it is published.
2176
  
2177
>+_host_+:
2178
>>The hostname of the machine from which the Bonjour neighbour registered its contact address.
2179
  
2180
>+_uri_+:
2181
>>The contact URI of the Bonjour neighbour, as a @FrozenSIPURI@ object.
2182
  
2183
>+_timestamp_+:
2184
>>A @datetime.datetime@ object indicating when the notification was sent.
2185
2186
*BonjourAccountDidRemoveNeighbour*
2187
>This notification is sent when a Bonjour neighbour unregisters.
2188
  
2189
>+_service_description_+:
2190
>>The BonjourServiceDescription object, which uniquely identifies a neighbour, that got unregistered.
2191
2192
*BonjourAccountDiscoveryDidFail*
2193
>This notification is sent once per transport when the Bonjour account has failed to perform the discovery process for the indicated transport.
2194
  
2195
>+_reason_+:
2196
>>String defining the reason of the failure.
2197
  
2198
>+_transport_+:
2199
>>String specifying the transport for which the discovery failed.
2200
  
2201
>+_timestamp_+:
2202
>>A @datetime.datetime@ object indicating when the notification was sent.
2203
2204
*BonjourAccountDiscoveryFailure*
2205
>This notification is sent once per transport when the Bonjour account has encountered a problem while browsing the list of neighbours for the indicated transport.
2206
  
2207
>+_error_+:
2208
>>String defining the error of the failure.
2209
  
2210
>+_transport_+:
2211
>>String specifying the transport for which the neighbour resoution failed.
2212
  
2213
>+_timestamp_+:
2214
>>A @datetime.datetime@ object indicating when the notification was sent.
2215
2216
*BonjourAccountRegistrationDidEnd*
2217
>This notification is sent once per transport when the Bonjour account unregisters its contact address for the indicated transport using mDNS.
2218
  
2219
>+_transport_+:
2220
>>String specifying the transport for which the registration ended.
2221
  
2222
>+_timestamp_+:
2223
>>A @datetime.datetime@ object indicating when the notification was sent.
2224
2225
*BonjourAccountRegistrationDidFail*
2226
>This notification is sent once per transport when the Bonjour account fails to register its contact address for the indicated transport using mDNS.
2227
  
2228
>+_reason_+:
2229
>>A human readable error message.
2230
  
2231
>+_transport_+:
2232
>>String specifying the transport for which the registration failed.
2233
  
2234
>+_timestamp_+:
2235
>>A @datetime.datetime@ object indicating when the notification was sent.
2236
2237
*BonjourAccountRegistrationUpdateDidFail*
2238
>This notification is sent once per transport when the Bonjour account fails to update its data for the indicated transport using mDNS.
2239
  
2240
>+_reason_+:
2241
>>A human readable error message.
2242
  
2243
>+_transport_+:
2244
>>String specifying the transport for which the registration update failed.
2245
  
2246
>+_timestamp_+:
2247
>>A @datetime.datetime@ object indicating when the notification was sent.
2248
2249
*BonjourAccountRegistrationDidSucceed*
2250
>This notification is sent once per transport when the Bonjour account successfully registers its contact address for the indicated transport using mDNS.
2251
  
2252
>+_name_+:
2253
>>The contact address registered.
2254
  
2255
>+_transport_+:
2256
>>String specifying the transport for which the registration succeeded.
2257
  
2258
>+_timestamp_+:
2259
>>A @datetime.datetime@ object indicating when the notification was sent.
2260
2261
*BonjourAccountWillInitateDiscovery*
2262
>This notification is sent when the Bonjour account is about to start the discovery process for the indicated transport.
2263
  
2264
>+_transport_+:
2265
>>String specifying the transport for which the discovery will be started.
2266
  
2267
>+_timestamp_+:
2268
>>A @datetime.datetime@ object indicating when the notification was sent.
2269
2270
  *BonjourAccountWillRegister*
2271
>This notification is sent just before the Bonjour account starts the registering process for the indicated transport.
2272
  
2273
>+_transport_+:
2274
>>String specifying the transport for which the registration will be started.
2275
>+_timestamp_+:
2276
>>A @datetime.datetime@ object indicating when the notification was sent.
2277
2278
*CFGSettingsObjectDidChange*
2279
>This notification is sent when the @save()@ method is called on the account after some of the settings were changed. As the notification belongs to the @SettingsObject@ class, it is exaplained in detail in [[SipConfigurationAPI#SettingsObjectNotifications|SettingsObject Notifications]].
2280
>+_timestamp_+:
2281
>>A @datetime.datetime@ object indicating when the notification was sent.
2282
2283
*SIPAccountWillActivate*
2284
>This notification is sent when the @BonjourAccount@ is about to be activated, but before actually performing any activation task. See @SIPAccountDidActivate@ for more detail.
2285
  
2286
>+_timestamp_+:
2287
>>A @datetime.datetime@ object indicating when the notification was sent.
2288
2289
*SIPAccountDidActivate*
2290
>This notification is sent when the @BonjourAccount@ activates. This can happen when the @BonjourAccount@ is loaded if it's enabled flag is set and the Engine is running, and at any later time when the status of the Engine changes or the enabled flag is modified.
2291
  
2292
>+_timestamp_+:
2293
>>A @datetime.datetime@ object indicating when the notification was sent.
2294
2295
*SIPAccountWillDeactivate*
2296
>This notification is sent when the @BonjourAccount@ is about to be deactivated, but before performing any deactivation task. See @SIPAccountDidDeactivate@ for more detail.
2297
>+_timestamp_+:
2298
>>A @datetime.datetime@ object indicating when the notification was sent.
2299
2300
*SIPAccountDidDeactivate*
2301
>This notification is sent when the @BonjourAccount@ deactivates. This can happend when the @Engine@ is stopped or when the enabled flag of the account is set to @False@.
2302
>+_timestamp_+:
2303
>>A @datetime.datetime@ object indicating when the notification was sent.
2304
2305
2306
2307
h2. Audio
2308
2309
2310
The high-level audio API hides the complexity of using the low-level PJMEDIA interface. This is implemented in the @sipsimple.audio@ module and contains the following components:
2311
* IAudioPort: an interface describing an object capable of producing and/or consuming audio data.
2312
* AudioDevice: an object conforming to the IAudioPort interface which describes a physical audio device.
2313
* AudioBridge: a collection of objects conforming to IAudioPort which connects all of them in a full mesh.
2314
* WavePlayer: an object conforming to the IAudioPort interface which can playback the audio data from a @.wav@ file.
2315
* WaveRecorder: an object conforming to the IAudioPort interface which can record audio data to a @.wav@ file.
2316
2317
2318
h3. IAudioPort
2319
2320
2321
The IAudioPort interface describes an object capable of producing and/or consuming audio data. This can be a dynamic object, which changes its role during its lifetime and notifies such changes using a notification, which is part of the interface.
2322
2323
2324 179 Tijmen de Mes
*attributes*
2325 176 Tijmen de Mes
2326
2327
2328
*mixer*
2329
>The @AudioMixer@ this audio object is connected to. Only audio objects connected to the same mixer will be able to send audio data from one to another.
2330
2331
*consumer_slot*
2332
>An integer representing the slot (see [[SipCoreApiDocumentation#AudioMixer|AudioMixer]]) which this object uses to consume audio data, or @None@ if this object is not a consumer.
2333
2334
*producer_slot*
2335
>An integer representing the slot (see [[SipCoreApiDocumentation#AudioMixer|AudioMixer]]) which this object uses to produce audio data, or @None@ if this object is not a producer.
2336
2337
2338 179 Tijmen de Mes
*notifications*
2339 176 Tijmen de Mes
2340
 
2341
2342
*AudioPortDidChangeSlots*
2343
>This notification needs to be sent by implementations of this interface when the slots it has change, so as to let the @AudioBridges@ it is part of know that reconnections need to be made.
2344
  
2345
>+_consumer_slot_changed_+:
2346
>>A bool indicating whether the consumer slot was changed.
2347
  
2348
>+_producer_slot_changed_+:
2349
>>A bool indicating whether the producer slot was changed.
2350
  
2351
>+_old_consumer_slot_+:
2352
>>The old slot for consuming audio data. Only required if consumer_slot_changed is @True@.
2353
  
2354
>+_new_consumer_slot_+:
2355
>>The new slot for consuming audio data. Only required if consumer_slot_changed is @True@.
2356
  
2357
>+_old_producer_slot_+:
2358
>>The old slot for producing audio data. Only required if producer_slot_changed is @True@.
2359
  
2360
>+_new_producer_slot_+:
2361
>>The new slot for producing audio data. Only required if producer_slot_changed is @True@.
2362
2363
2364
h3. AudioDevice
2365
2366
2367
The AudioDevice represents the physical audio device which is part of a @AudioMixer@, implementing the @IAudioPort@ interface. As such, it can be uniquely identified by the mixer it represents.
2368
2369
2370 179 Tijmen de Mes
*methods*
2371 176 Tijmen de Mes
2372
2373
2374
*<notextile>__init__</notextile>*(_self_, *mixer*, *input_muted*=@False@, *output_muted*=@False@):
2375
>>Instantiates a new AudioDevice which represents the physical device associated with the specified @AudioMixer@.
2376
  
2377
>+_mixer_+:
2378
>>The @AudioMixer@ whose physical device this object represents.
2379
  
2380
>+_input_muted_+:
2381
>>A boolean which indicates whether this object should act as a producer of audio data.
2382
  
2383
>+_output_muted_+:
2384
>>A boolean which indicates whether this object should act as a consumer of audio data.
2385
2386
2387 179 Tijmen de Mes
*attributes*
2388 176 Tijmen de Mes
2389
2390
2391
*input_muted*
2392
>A writable property which controls whether this object should act as a producer of audio data. An @AudioPortDidChange@ slots notification is sent when this attribute is changed to force connections to be reconsidered within the @AudioBridges@ this object is part of.
2393
2394
*output_muted*
2395
>A writable property which controls whether this object should act as a consumer of audio data. An @AudioPortDidChange@ slots notification is sent when this attribute is changed to force connections to be reconsidered within  the @AudioBridges@ this object is part of.
2396
2397
2398
h3. AudioBridge
2399
2400
2401
The @AudioBridge@ is the basic component which is able to connect @IAudioPort@ implementations. It acts as a container which connects as the producers to all the consumers which are part of it. An object which is both a producer and a consumer of audio data will not be connected to itself. Being an implementation of @IAudioPort@ itself, an @AudioBridge@ can be part of another @AudioBridge@. The @AudioBridge@ does not keep strong references to the ports it contains and once the port's reference count reaches 0, it is automatically removed from the @AudioBridge@.
2402
> Note: although this is not enforced, there should never be any cycles when connecting @AudioBridges@.
2403
2404
2405 179 Tijmen de Mes
*methods*
2406 176 Tijmen de Mes
2407
2408
2409
*<notextile>__init__</notextile>*(_self_, *mixer*)
2410
>Instantiate a new @AudioBridge@ which uses the specified @AudioMixer@ for mixing.
2411
2412
*add*(_self_, *port*)
2413
>Add an implementation of @IAudioPort@ to this AudioBridge. This will connect the new port to all the existing ports of the bridge. A port cannot be added more than once to an @AudioBridge@; thus, this object acts like a set.
2414
2415
*remove*(_self_, *port*)
2416
>Remove a port from this @AudioBridge@. The port must have previously been added to the @AudioBridge@, otherwise a @ValueError@ is raised.
2417
2418
2419
h3. WavePlayer
2420
2421
2422
A @WavePlayer@ is an implementation of @IAudioPort@ which is capable of producing audio data read from a @.wav@ file. This object is completely reusable, as it can be started and stopped any number of times.
2423
2424
2425 179 Tijmen de Mes
*methods*
2426 176 Tijmen de Mes
2427
2428
2429
*<notextile>__init__</notextile>*(_self_, *mixer*, *filename*, *volume*=@100@, *loop_count*=@1@, *pause_time*=@0@, *initial_play*=@True@)
2430
>Instantiate a new @WavePlayer@ which is capable of playing a @.wav@ file repeatedly. All the parameters are available as attributes of the object, but should not be changed once the object has been started.
2431
  
2432
>+_mixer_+:
2433
>>The @AudioMixer@ this object is connected to.
2434
  
2435
>+_filename_+:
2436
>>The full path to the @.wav@ file from which audio data is to be read.
2437
  
2438
>+_volume_+:
2439
>>The volume at which the file should be played.
2440
  
2441
>+_loop_count_+:
2442
>>The number of times the file should be played, or @0@ for infinity.
2443
  
2444
>+_pause_time_+:
2445
>>How many seconds to wait between successive plays of the file. 
2446
  
2447
>+_initial_play_+:
2448
>>Whether or not the file to play once the @WavePlayer@ is started, or to wait @pause_time@ seconds before the first play.
2449
2450
*start*(_self_)
2451
>Start playing the @.wav@ file.
2452
2453
*stop*(_self_)
2454
>Stop playing the @.wav@ file immediately.
2455
2456
*play*(_self_)
2457
>Play the @.wav@ file. This method is an alternative to the start/stop methods, it runs on a waitable green thread. One may call @play().wait()@ in order to green-block waiting for the file playback to end.
2458
2459
2460 179 Tijmen de Mes
*attributes*
2461 176 Tijmen de Mes
2462
2463
2464
*is_active*
2465
>A boolean indicating whether or not this @WavePlayer@ is currently playing.
2466
2467
2468 179 Tijmen de Mes
*notifications*
2469 176 Tijmen de Mes
2470
2471
2472
*WavePlayerDidStart*
2473
>This notification is sent when the @WavePlayer@ starts playing the file the first time after the @start()@ method has been called.
2474
  
2475
>+_timestamp_+:
2476
>>A @datetime.datetime@ object indicating when the notification was sent.
2477
2478
*WavePlayerDidEnd*
2479
>This notification is sent when the @WavePlayer@ is done playing either as a result of playing the number of times it was told to, or because the @stop()@ method has been called.
2480
  
2481
>+_timestamp_+:
2482
>>A @datetime.datetime@ object indicating when the notification was sent.
2483
2484
*WavePlayerDidFail*
2485
>This notification is sent when the @WavePlayer@ is not capable of playing the @.wav@ file.
2486
  
2487
>+_timestamp_+:
2488
>>A @datetime.datetime@ object indicating when the notification was sent.
2489
  
2490
>+_error_+:
2491
>>The exception raised by the @WaveFile@ which identifies the cause for not being able to play the @.wav@ file.
2492
2493
2494
h3. WaveRecorder
2495
2496
2497
A @WaveRecorder@ is an implementation of @IAudioPort@ is is capable of consuming audio data and writing it to a @.wav@ file. Just like @WavePlayer@, this object is reusable: once stopped it can be started again, but if the filename attribute is not changed, the previously written file will be overwritten.
2498
2499
2500 179 Tijmen de Mes
*methods*
2501 176 Tijmen de Mes
2502
2503
2504
*<notextile>__init__</notextile>*(_self_, *mixer*, *filename*)
2505
>Instantiate a new @WaveRecorder@.
2506
  
2507
>+_mixer_+:
2508
>>The @AudioMixer@ this @WaveRecorder@ is connected to.
2509
  
2510
>+_filename_+:
2511
>>The full path to the @.wav@ file where this object should write the audio data. The file must be writable. The directories up to the file will be created if possible when the @start()@ method is called.
2512
2513
*start*(_self_)
2514
>Start consuming audio data and writing it to the @.wav@ file. If this object is not part of an @AudioBridge@, not audio data will be written.
2515
2516
*stop*(_self_)
2517
>Stop consuming audio data and close the @.wav@ file.
2518
2519
2520 179 Tijmen de Mes
*attributes*
2521 176 Tijmen de Mes
2522
2523
2524
*is_active*
2525
>A boolean indicating whether or not this @WaveRecorder@ is currently recording audio data.
2526
2527
2528
2529
h2. Conference
2530
2531
2532
Conference support is implemented in the @sipsimple.conference@ module. Currently, only audio conferencing is supported.
2533
2534
2535
h3. AudioConference
2536
2537
2538
This class contains the basic implementation for audio conferencing. It acts as a container for @AudioStream@ objects which it will connect in a full mesh, such that all participants can hear all other participants.
2539
2540
2541 179 Tijmen de Mes
*methods*
2542 176 Tijmen de Mes
2543
2544
2545
*<notextile>__init__</notextile>*(_self_)
2546
>Instantiates a new @AudioConference@ which is ready to contain @AudioStream@ objects.
2547
2548
*add*(_self_, *stream*)
2549
>Add the specified @AudioStream@ object to the conference.
2550
2551
*remove*(_self_, *stream*)
2552
>Removes the specified @AudioStream@ object from the conference. Raises a @ValueError@ if the stream is not part of the conference.
2553
2554
*hold*(_self_)
2555
>Puts the conference "on hold". This means that the audio device will be disconnected from the conference: all the participants will be able to continue the conference, but the local party will no longer contribute any audio data and will not receive any audio data using the input and output devices respectively. This does not affect the hold state of the streams in any way.
2556
2557
*unhold*(_self_)
2558
>Removes the conference "from hold". This means that the audio device will be reconnected to the conference: all the participants will start to hear the local party and the local party will start to hear all the participants. This does not affect the hold state of the streams in any way.
2559
2560
2561 179 Tijmen de Mes
*attributes*
2562 176 Tijmen de Mes
2563
2564
2565
*bridge*
2566
>An @AudioBridge@ which this conference uses to connect all audio streams. It can be used by the application to play a wav file using a @WavePlayer@ to all the participants or record the whole conference using a @WaveRecorder@.
2567
2568
*on_hold*
2569
>A boolean indicating whether or not the conference is "on hold".
2570
2571
*streams*
2572
>The list of streams which are part of this conference. The application must not manipulate this list in any way.
2573
2574 207 Saúl Ibarra Corretgé
h2. Addressbook API
2575
2576
Implemented in source:"sipsimple/addressbook.py"
2577
2578 211 Saúl Ibarra Corretgé
The Addressbook API is used to manage the contact list in SIP SIMPLE SDK. It stores contacts locally and uses the XCAP API underneath to synchronize the contacts between instances (if XCAP support is available).
2579 207 Saúl Ibarra Corretgé
2580 214 Saúl Ibarra Corretgé
2581 207 Saúl Ibarra Corretgé
h3. AddressbookManager
2582 1 Adrian Georgescu
2583 215 Saúl Ibarra Corretgé
The AccountManager is a singleton which is started automatically by the middleware. It's the central point to the addressbook. It stores the contacts and takes care of the synchronization. Upon starts it loads all contacts and policies first and groups afterwards.
2584 207 Saúl Ibarra Corretgé
2585
*methods:*
2586
2587
*has_contact*(_self_, *id*)
2588
>Returns True if the given id belongs to a existing contact, False otherwise.
2589
2590
*get_contact*(_self_, *id*)
2591
>Returns the @Contact@ instance for the given id.
2592
2593
*get_contacts*(_self_)
2594
>Returns the full list of contacts.
2595
2596
*has_group*(_self_, *id*)
2597
>Returns True if the given id belongs to a existing group, False otherwise.
2598
2599
*get_group*(_self_, *id*)
2600
>Returns the @Group@ instance for the given id.
2601
2602
*get_groups*(_self_)
2603
>Returns the full list of groups.
2604
2605
*has_policy*(_self_, *id*)
2606
>Returns True if the given id belongs to a existing policy, False otherwise.
2607
2608
*get_policy*(_self_, *id*)
2609
>Returns the @Policy@ instance for the given id.
2610
2611
*get_policies*(_self_)
2612
>Returns the full list of policies.
2613
2614
*transaction*(_self_)
2615
>Returns an instance of @MultiAccountTransaction@, which can be used as a context manager to apply multiple changes to the addressbook in a single shot.
2616
2617
2618
*notifications:*
2619
2620
*AddressbookManagerDidAddContact*
2621
>This notification is sent when the AddressbookManager adds a new contact.
2622
  
2623
>+_contact_+:
2624
>>The added @Contact@ object.
2625
2626
*AddressbookManagerDidRemoveContact*
2627
>This notification is sent when the AddressbookManager removes a contact.
2628
  
2629
>+_contact_+:
2630
>>The removed @Contact@ object.
2631
2632
*AddressbookManagerDidAddGroup*
2633
>This notification is sent when the AddressbookManager adds a new group.
2634
  
2635
>+_group_+:
2636
>>The added @Group@ object.
2637
2638
*AddressbookManagerDidRemoveGroup*
2639
>This notification is sent when the AddressbookManager removes a group.
2640
  
2641
>+_group_+:
2642
>>The removed @Group@ object.
2643
2644
*AddressbookManagerDidAddPolicy*
2645
>This notification is sent when the AddressbookManager adds a new policy.
2646
  
2647
>+_policy_+:
2648
>>The added @Policy@ object.
2649
2650
*AddressbookManagerDidRemovePolicy*
2651
>This notification is sent when the AddressbookManager removes a policy.
2652
  
2653
>+_policy_+:
2654 1 Adrian Georgescu
>>The removed @Policy@ object.
2655 208 Saúl Ibarra Corretgé
2656
2657 213 Saúl Ibarra Corretgé
h3. Contact
2658 208 Saúl Ibarra Corretgé
2659
@Contact@ objects represent a person with a name and a list of URIs that can be used to communicate with him.
2660
2661
*attributes:*
2662
2663
>+_name_+:
2664
>>A human readable name for the contact.
2665
2666
>+_uris_+:
2667
>>A @ContactURIList@ object containing all URIs belonging to this contact.
2668
2669
>+_dialog_+:
2670 209 Saúl Ibarra Corretgé
>>Dialog subscription settings and policy. 
2671 208 Saúl Ibarra Corretgé
2672
>+_presence_+:
2673 209 Saúl Ibarra Corretgé
>>Presence subscription settings and policy.
2674 208 Saúl Ibarra Corretgé
2675
*methods:*
2676
2677
*save*(_self_)
2678
>Saves the object to persistent local storage and remote XCAP storage.
2679
2680
*delete*(_self_)
2681
>Removes the contact from persistent storage, both local and remote.
2682
2683
2684
*notifications:*
2685
2686
*AddressbookContactWasActivated*
2687
>This notification is sent when a contact is either created or loaded from the configuration and it's ready to be used.
2688
  
2689
*AddressbookContactWasCreated*
2690
>This notification is sent when a contact is created for the first time.
2691
  
2692
*AddressbookContactDidChange*
2693
>This notification is sent when a contact has changed any of its settings. Changes could be caused by local calls to save() or remote changes.
2694
2695 1 Adrian Georgescu
>+_modified_+:
2696
>>Dictionary containing the changed attributes.
2697
2698
*AddressbookContactWasDeleted*
2699
>This notification is sent when a contact is deleted.
2700 209 Saúl Ibarra Corretgé
2701
2702 213 Saúl Ibarra Corretgé
h4. ContactURI
2703 1 Adrian Georgescu
2704 210 Saúl Ibarra Corretgé
@ContactURI@ objects represent a single URI used in a contact.
2705
2706
*attributes:*
2707
2708
>+_uri_+:
2709
>>The actual URI, expressed as a unicode object
2710
2711
>+_type_+:
2712
>>A string indicating the URI type.
2713
2714
2715 213 Saúl Ibarra Corretgé
h3. Policy
2716 210 Saúl Ibarra Corretgé
2717 209 Saúl Ibarra Corretgé
@Policy@ objects represent a policy for a given URI, which is not to be displayed as a @Contact@.
2718
2719
*attributes:*
2720
2721
>+_name_+:
2722
>>A human readable name for the policy element.
2723
2724
>+_uri_+:
2725
>>URI to which this policy applies.
2726
2727
>+_dialog_+:
2728
>>Dialog subscription settings and policy. 
2729
2730
>+_presence_+:
2731
>>Presence subscription settings and policy.
2732
2733
*methods:*
2734
2735
*save*(_self_)
2736
>Saves the object to persistent local storage and remote XCAP storage.
2737
2738
*delete*(_self_)
2739
>Removes the contact from persistent storage, both local and remote.
2740
2741
2742
*notifications:*
2743
2744
*AddressbookPolicyWasActivated*
2745
>This notification is sent when a policy is either created or loaded from the configuration and it's ready to be used.
2746
  
2747
*AddressbookPolicyWasCreated*
2748
>This notification is sent when a policy is created for the first time.
2749
  
2750
*AddressbookPolicyDidChange*
2751
>This notification is sent when a policy has changed any of its settings. Changes could be caused by local calls to save() or remote changes.
2752
2753
>+_modified_+:
2754
>>Dictionary containing the changed attributes.
2755
2756 1 Adrian Georgescu
*AddressbookPolicyWasDeleted*
2757
>This notification is sent when a policy is deleted.
2758 210 Saúl Ibarra Corretgé
2759
2760 213 Saúl Ibarra Corretgé
h3. Group
2761 210 Saúl Ibarra Corretgé
2762
@Group@ objects contain a list of contacts. A @Contact@ may be part of multiple groups.
2763
2764
*attributes:*
2765
2766
>+_name_+:
2767
>>A human readable name for the group.
2768
2769
>+_contacts_+:
2770
>>List of contacts belonging to this group.
2771
2772
*methods:*
2773
2774
*save*(_self_)
2775
>Saves the object to persistent local storage and remote XCAP storage.
2776
2777
*delete*(_self_)
2778
>Removes the contact from persistent storage, both local and remote.
2779
2780
2781
*notifications:*
2782
2783
*AddressbookGroupWasActivated*
2784
>This notification is sent when a group is either created or loaded from the configuration and it's ready to be used.
2785
  
2786
*AddressbookGroupWasCreated*
2787
>This notification is sent when a policy is created for the first time.
2788
  
2789
*AddressbookGroupDidChange*
2790
>This notification is sent when a group has changed any of its settings. Changes could be caused by local calls to save() or remote changes.
2791
2792
>+_modified_+:
2793
>>Dictionary containing the changed attributes.
2794
2795
*AddressbookGroupWasDeleted*
2796
>This notification is sent when a group is deleted.