Project

General

Profile

SipMiddlewareApi » History » Version 5

Redmine Admin, 03/13/2009 08:11 AM

1 1 Adrian Georgescu
= Middleware API =
2
3
[[TOC(WikiStart, Sip*, depth=3)]]
4
5
This chapter describes the high level Python API that can be used by a developer to easily build a front-end on top of SIP SIMPLE client library. By using this Python API you can easily create a desktop graphical client or a server application for real-time communications based on SIP standards.
6
7
[[Image(sipsimple-middleware.png, 500px)]]
8
9 3 Adrian Georgescu
 * [wiki:SipSettingsAPI Settings API] - configuration framework that will replace the current configuration file config.ini, all middleware components will have read/write access to settings throught it
10 1 Adrian Georgescu
11
== Classes ==
12
13
=== SessionManager ===
14
15
The {{{sipsimple.session.SessionManager}}} class is a singleton which acts as the central aggregation point for sessions within the middleware.
16
The application can use it to query information about the active sessions and set global configuration options relevant to sessions, such as transport options and ringtones.
17
In order to achieve the latter, the {{{SessionManager}}} instance contains three configuration attributes that can be inspected and modified at runtime.
18
When a {{{Session}}} is created, either as by the application on an outbound session or by the middleware as an inbound session, these configuration attributes will be copied from the {{{SessionManager}}}.
19
20
> The SessionManager will be integrated with both the configuration framework and the accountmanager, meaning that the part of this API regarding configuration is is subject to change.
21
22
==== attributes ====
23
24
 '''sessions'''::
25
  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.
26
 '''ringtone_config'''::
27
  A {{{RingtoneConfiguration}}} object, which manages the ringtones that should be played on new inbound and outbound sessions.
28
 '''rtp_config'''::
29
  A {{{RTPConfiguration}}} object, which indicates which options should be used when creating a new RTP transport for use by an audio stream.
30
 '''msrp_config'''::
31
  A {{{MSRPConfiguration}}} object, which provides the options that should be used when creating a new MSRP transport used for chat.
32
33
==== methods ====
34
35
 '''!__init!__'''(''self'')::
36
  This either returns a new {{{SessionManager}}} object with default configuration objects, or returns a copy of the already existing instance.
37
38
=== RingtoneConfiguration ===
39
40
A {{{sipsimple.session.RingtoneConfiguration}}} object is contained in the {{{SessionManager}}} and acts as a registration point for both default ringtones and ringtones per incoming SIP URI.
41
42
==== attributes ====
43
44
 '''default_inbound_ringtone'''::
45
  A string pointing to a {{{.wav}}} file on the filesystem that should be played on an incoming session when the remote SIP URI cannot be matched to any of the registered ones.
46
  If this is set to {{{None}}}, no ringtone is played in this situation.
47
 '''outbound_ringtone'''::
48
  A string pointing to a {{{.wav}}} file on the filesystem that should be played when an outbound session receives a ringing indication from the remote party.
49
  If this is set to {{{None}}}, no ringtone is played in this situation.
50
51
==== methods ====
52
53
 '''!__init!__'''(''self'')::
54
  Creates a new {{{RingtoneConfiguration}}} object with both attributes set to {{{None}}} and no SIP URIs registered.
55
 '''add_ringtone_for_sipuri'''(''self'', '''sipuri''', '''ringtone''')::
56
  Registers a ringtone, in the form of a string pointing to a {{{.wav}}} file, to be played back when a incoming session is received from a remote party with the specified SIP URI, in the form of a {{{sipsimple.core.SIPURI}}} object.
57
  This will possibly override a previously registered ringtone.
58
 '''remove_sipuri'''(''self'', '''sipuri''')::
59
  Removes the ringtone of a previously registered SIP URI.
60
 '''get_ringtone_for_sipuri'''(''self'', '''sipuri''')::
61
  Retrieve the ringtone to use when receiving an inbound session from the specified SIP URI, as a {{{sipsimple.core.SIPURI}}} object.
62
  If no ringtone was registed, this will return {{{default_inbound_ringtone}}}.
63
64
=== RTPConfiguration ===
65
66
A {{{sipsimple.session.RTPConfiguration}}} object contains parameters that should be used when creating a new RTP transport, used by a {{{Session}}} object for an audio stream.
67
68
==== attributes ====
69
70
 '''local_rtp_address'''::
71
  The IP address to use for the RTP endpoint.
72
 '''use_srtp'''::
73
  A boolean indicating whether SRTP should be used.
74
 '''srtp_forced'''::
75
  A boolean indicating whether SRTP should be mandatory, if SRTP is to be used.
76
 '''use_ice'''::
77
  A boolean indicating whether ICE should be used.
78
 '''ice_stun_address'''::
79
  The IP adress of the STUN server that should be contacted to retrieve an ICE candidate.
80
  This attribute is only relevant if ICE is used.
81
  If this is the case and this attribute is set to {{{None}}}, no STUN candidate shall be retrieved for ICE.
82
 '''ice_stun_port''::
83
  The port of the STUN server to be used for retrieving an ICE candidate.
84
  The same condition apply to this attribute as for {{{ice_stun_address}}}.
85
86
==== methods ====
87
88
 '''!__init!__'''(''self'', '''local_rtp_address'''=<default_host_ip>, '''use_srtp'''={{{False}}}, '''srtp_forced'''={{{False}}}, '''use_ice'''={{{False}}}, '''ice_stun_address'''={{{None}}}, '''ice_stun_port'''=3478)::
89
  This creates a new {{{RTPConfiguration}}} object with sensible defaults, setting all the attributes to the specified values.
90
  The default value for the {{{local_rtp_address}}} attribute is the default outbound IP of this host, detected at application start.
91
92
=== MSRPConfiguration ===
93
94
A {{{sipsimple.session.MSRPConfiguration}}} object governs the parameters used for creating an MSRP connection when establishing a chat within a session.
95
96
==== attributes ====
97
98
 '''local_ip'''::
99
  The local IP address to put in the MSRP URI.
100
  If this is set to None, an IP will be automatically detected.
101
 '''local_port'''::
102
  The local port to use for MSRP.
103
  If this is set to None, an a port will be automatically allocated.
104
 '''local_use_tls'''::
105
  A boolean indicating whether to use TLS in the local MSRP URI.
106
 '''use_relay_incoming'''::
107
  A boolean indicating whether to use a MSRP relay for incoming sessions.
108
 '''use_relay_outgoing'''::
109
  A boolean indicating whether to use a MSRP relay for outgoing sessions.
110
 '''relay_host'''::
111
  The IP address of the MSRP relay to use, set by the above conditions.
112
 '''relay_port'''::
113
  The TCP port to use on the MSRP relay.
114
 '''relay_use_tls'''::
115
  A boolean indicating whether the connection to the MSRP relay specified should use TLS.
116
117
==== methods ====
118
119
 '''!__init!__'''(''self'', '''local_ip'''={{{None}}}, '''local_port'''={{{None}}}, '''local_use_tls'''={{{True}}}, '''use_relay_incoming'''={{{True}}}, '''use_relay_outgoing'''={{{False}}}, '''relay_host'''={{{None}}}, '''relay_port'''={{{None}}}, '''relay_use_tls'''={{{None}}})::
120
  This creates a new {{{MSRPConfiguration}}} object with sensible defaults, setting all the attributes to the specified values.
121
122
=== Session ===
123
124
A {{{sipsimple.session.Session}}} object represents a complete SIP session between the local and a remote endpoints, including media streams.
125
The currently supported media streams are audio and MSRP chat.
126
Both incoming and outgoing sessions are represented by this class.
127
128
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.
129
State changes are triggered by methods called on the object by the application or by received network events.
130
Every time this attribute changes, a {{{SCSessionChangedState}}} notification is sent by the object.
131
These states and their transitions are represented in the following diagram:
132
133 2 Adrian Georgescu
[[Image(sipsimple-session-state-machine.png)]]
134 1 Adrian Georgescu
135
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 different set of notifications is also emitted, which provide all the necessary information to the application.
136
137
==== attributes ====
138
139
 '''state'''::
140
  The state the object is currently in, being one of the states from the diagram above.
141
 '''direction'''::
142
  A string indicating the direction of the initial negotiation of the session.
143
  This can be either {{{None}}}, "incoming" or "outgoing".
144
 '''start_time'''::
145
  The time the session started as a {{{datetime.datetime}}} object, or {{{None}}} if the session was not yet started.
146
 '''stop_time'''::
147
  The time the session stopped as a {{{datetime.datetime}}} object, or {{{None}}} if the session has not yet terminated.
148
 '''on_hold_by_local'''::
149
  Boolean indicating whether the session was put on hold by the local party.
150
 '''on_hold_by_remote'''::
151
  Boolean indicating whether the session was put on hold by the remote party.
152
 '''on_hold'''::
153
  Boolean indicating whether the session was put on hold, either by the local or the remote party.
154
 '''remote_user_agent'''::
155
  A string indicating the remote user agent, if it provided one.
156
  Initially this will be {{{None}}}, it will be set as soon as this information is received from the remote party (which may be never).
157
 '''local_uri'''::
158
  The {{{sipsimple.core.SIPURI}}} of the local party, if the session is active.
159
 '''remote_uri'''::
160
  The {{{sipsimple.core.SIPURI}}} of the remote party, if the session is active.
161
 '''caller_uri'''::
162
  The {{{sipsimple.core.SIPURI}}} of the calling party, if the session is active.
163
  Depending on the direction, this is either {{{local_uri}}} or {{{remote_uri}}}.
164
 '''callee_uri'''::
165
  The {{{sipsimple.core.SIPURI}}} of the called party, if the session is active.
166
  Depending on the direction, this is either {{{local_uri}}} or {{{remote_uri}}}.
167
 '''credentials'''::
168
  A copy of the {{{sipsimple.core.Credentials}}} object passed when the {{{new()}}} method was called.
169
  On incoming or inactive sessions this is {{{None}}}.
170
 '''route'''::
171
  A copy of the {{{sipsimple.core.Route}}} object passed when the {{{new()}}} method was called.
172
  On incoming or inactive sessions this is {{{None}}}.
173
 '''audio_transport'''::
174
  The {{{sipsimple.core.AudioTransport}}} object used by the session, if it currently contains an audio stream.
175
  Normally the application will not need to access this directly.
176
 '''has_audio'''::
177
  A boolean property indicating if this {{{Session}}} currently has an audio stream.
178
 '''audio_sample_rate'''::
179
  If the audio stream was started, this attribute contains the sample rate of the audio negotiated.
180
 '''audio_codec'''::
181
  If the audio stream was started, this attribute contains the name of the audio codec that was negotiated.
182
 '''audio_srtp_active'''::
183
  If the audio stream was started, this boolean attribute indicates if SRTP is currently being used on the stream.
184
 '''audio_local_rtp_address'''::
185
  If an audio stream is present within the session, this attribute contains the local IP address used for the audio stream.
186
 '''audio_local_rtp_port'''::
187
  If an audio stream is present within the session, this attribute contains the local UDP port used for the audio stream.
188
 '''audio_remote_rtp_address_sdp'''::
189
  If the audio stream was started, this attribute contains the IP address that the remote party gave to send audio to.
190
 '''audio_remote_rtp_port_sdp'''::
191
  If the audio stream was started, this attribute contains the UDP port that the remote party gave to send audio to.
192
 '''audio_remote_rtp_address_received'''::
193
  If the audio stream was started, this attribute contains the remote IP address from which the audio stream is being received.
194
 '''audio_remote_rtp_port_received'''::
195
  If the audio stream was started, this attribute contains the remote UDP port from which the audio stream is being received.
196
 '''audio_was_received'''::
197
  This boolean property indicates if audio was actually received on the audio stream contained within this session.
198
 '''audio_recording_file_name'''::
199
  If the audio stream is currently being recorded to disk, this property contains the name of the {{{.wav}}} file being recorded to.
200
 '''chat_transport'''::
201
  The {{{sipsimple.msrp.MSRPChat}}} object used by the session as chat transport, if the session currently contains a chat stream.
202
  Normally the application will not need to access this directly.
203
 '''has_chat'''::
204
  A boolean property indicating if this {{{Session}}} currently has a chat stream.
205
206
==== methods ====
207
208
 '''!__init!__'''(''self'')::
209
  Creates a new {{{Session}}} object in the {{{NULL}}} state.
210
 '''new'''(''self'', '''callee_uri''', '''credentials''', '''route''', '''audio'''={{{False}}}, '''chat'''={{{False}}})::
211
  Will set up the {{{Session}}} as outbound and propose the new session to the specified remote party and move the state machine to the {{{CALLING}}} state.
212
  Before contacting the remote party, a {{{SCSessionNewOutgoing}}} notification will be emitted.
213
  If there is a failure or the remote party rejected the offer, a {{{SCSessionDidFail}}} notification will be sent, followed by a {{{SCSessionDidEnd}}}.
214
  Any time a ringing indication is received from the remote party, a {{{SCSessionGotRingIndication}}} notification is sent.
215
  If the remote party accepted the session, a {{{SCSessionWillStart}}} notification will be sent, followed by a {{{SCSessionDidStart}}} notification when the session is actually established.
216
  This method may only be called while in the {{{NULL}}} state.
217
  [[BR]]''callee_uri'':[[BR]]
218
  A {{{sipsimple.core.SIPURI}}} object representing the remote host to initiate the session to.
219
  [[BR]]''credentials'':[[BR]]
220
  A {{{sipsimple.core.Credentials}}} object, encapsulating the local SIP URI and the password for it, if set.
221
  [[BR]]''route'':[[BR]]
222
  A {{{sipsimple.core.Route}}} object, specifying the IP, port and transport to the outbound proxy.
223
  [[BR]]''audio'':[[BR]]
224
  A boolean indicating whether an audio stream should be initially included in this session.
225
  [[BR]]''chat'':[[BR]]
226
  A boolean indicating whether a chat stream should be initially included in this session.
227
 '''accept'''(''self'', '''audio'''={{{False}}}, '''chat'''={{{False}}}, '''password'''={{{None}}})::
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 {{{SCSessionNewIncoming}}} notification is sent, after which the application can call this method on the sender of the notification.
230
  After this method is called, {{{SCSessionWillStart}}} followed by {{{SCSessionDidStart}}} will be emitted, or {{{SCSessionDidFail}}} followed by {{{SCSessionDidEnd}}} on an error.
231
  This method may only be called while in the {{{INCOMING}}} state.
232
  [[BR]]''audio'':[[BR]]
233
  A boolean indicating whether an audio stream should be accepted for this session.
234
  Note that this may only be set to {{{True}}} if an audio stream was actually proposed by the remote party.
235
  [[BR]]''chat'':[[BR]]
236
  A boolean indicating whether a chat stream should be accepted for this session.
237
  Note that this may only be set to {{{True}}} if a chat stream was actually proposed by the remote party.
238
  [[BR]]''password'':[[BR]]
239
  The password for the local SIP URI to which the session was proposed.
240
  This is only used for reserving a session at the MSRP relay.
241
 '''reject'''(''self'')::
242
  Reject an incoming session and move it to the {{{TERMINATING}}} state, which eventually leads to the {{{TERMINATED}}} state.
243
  Calling this method will cause the {{{Session}}} object to emit a {{{SCSessionWillEnd}}} notification, followed by a {{{SCSessionDidEnd}}} notification.
244
  This method may only be called while in the {{{INCOMING}}} state.
245
 '''hold'''(''self'')::
246
  Put the session on hold.
247
  This will cause a {{{SCGotHoldRequest}}} notification to be sent.
248
  This method may only be called while in the {{{ESTABLISHED}}} state.
249
 '''unhold'''(''self'')::
250
  Take the session out of hold.
251
  This will cause a {{{SCGotUnholdRequest}}} notification to be sent.
252
  This method may only be called while in the {{{ESTABLISHED}}} state.
253
 '''start_recording_audio'''(''self'', '''path''', '''file_name'''={{{None}}})::
254
  If an audio stream is present within this session, calling this method will record the audio to a {{{.wav}}} file.
255
  Note that when the session is on hold, nothing will be recorded to the file.
256
  Right before starting the recording a {{{SCSessionWillStartRecordingAudio}}} notification will be emitted, followed by a {{{SCSessionDidStartRecordingAudio}}}.
257
  This method may only be called while in the {{{ESTABLISHED}}} state.
258
  [[BR]]''path'':[[BR]]
259
  The path to the directory to place the {{{.wav}}} file in.
260
  [[BR]]''file_name'':[[BR]]
261
  The name of the {{{.wav}}} file to record to.
262
  If this is set to {{{None}}}, a default file name including the session participants and the timestamp will be generated.
263
 '''stop_recording_audio'''(''self'')::
264
  This will stop a previously started recording.
265
  Before stopping, a {{{SCSessionWillStopRecordingAudio}}} notification will be sent, followed by a {{{SCSessionDidStopRecordingAudio}}}.
266
  This method may only be called while in the {{{ESTABLISHED}}} state.
267
 '''send_dtmf'''(''self'', '''digit''')::
268
  If this session currently has an active audio stream, send a DTMF digit to the remote party over it.
269
  This method may only be called while in the {{{ESTABLISHED}}} state.
270
  [[BR]]''digit'':[[BR]]
271
  This should a string of length 1, containing a valid DTMF digit value.
272
 '''send_message'''(''self'', '''content''', '''content_type'''="text/plain", '''to_uri'''={{{None}}}, '''dt'''={{{None}}}):
273
  If this session currently has an active MSRP chat with the remote party, send a message over with the with the specified parameters.
274
  This will result in either a {{{SCSessionDidDeliverMessage}}} or a {{{SCSessionDidNotDeliverMessage}}} notification being sent.
275
  These notifications include a unique ID as data attribute which is also returned by this method.
276
  This method may only be called while in the {{{ESTABLISHED}}} state.
277
  [[BR]]''content'':[[BR]]
278
  The body of the MSRP message as a string.
279
  [[BR]]''content_type'':[[BR]]
280
  The Content-Type of the body as a string
281
  [[BR]]''to_uri'':[[BR]]]
282
  The {{{sipsimple.core.SIPURI}}} that should be put in the {{{To:}}} header of the CPIM wrapper of the message.
283
  This defaults to the SIP URI of the remote party of the session if the argument is set to {{{None}}}
284
  [[BR]]''dt'':[[BR]]
285
  A {{{datetime.datetime}}} object representing the timestamp to put on the CPIM wrapper of the message.
286
  When set to {{{None}}}, this defaults to now.
287
 '''add_audio'''(''self'')::
288
  Propose the remote party to add an audio stream to this session.
289
  Calling this method will cause a {{{SCSessionGotStreamProposal}}} notification to be emitted.
290
  After this, the state machine will move into the {{{PROPOSING}}} state until either a {{{SCSessionAcceptedStreamProposal}}} or {{{SCSessionRejectedStreamProposal}}} notification is sent, informing the application if the remote party accepted the proposal.
291
  This method may only be called while in the {{{ESTABLISHED}}} state on a {{{Session}}} object that does not currently have an audio stream.
292
 '''remove_audio'''(''self'')::
293
  Stop the audio stream currently active within the session and inform the remote party of this.
294
  This method may only be called while in the {{{ESTABLISHED}}} state on a {{{Session}}} object that has an audio stream.
295
 '''add_chat'''(''self'')::
296
  Propose the remote party to add a chat stream to this session.
297
  Calling this method will cause a {{{SCSessionGotStreamProposal}}} notification to be emitted.
298
  After this, the state machine will move into the {{{PROPOSING}}} state until either a {{{SCSessionAcceptedStreamProposal}}} or {{{SCSessionRejectedStreamProposal}}} notification is sent, informing the application if the remote party accepted the proposal.
299
  This method may only be called while in the {{{ESTABLISHED}}} state on a {{{Session}}} object that does not currently have a chat stream.
300
 '''remove_chat'''(''self'')::
301
  Stop the chat stream currently active within the session and inform the remote party of this.
302
  This method may only be called while in the {{{ESTABLISHED}}} state on a {{{Session}}} object that has a chat stream.
303
 '''accept_proposal'''(''self'')::
304
  When the remote party proposes to add a new stream, signaled by the {{{SCSessionGotStreamProposal}}} notification, the application can use this method to accept the stream(s) being proposed.
305
  After calling this method a {{{SCSessionAcceptedStreamProposal}}} notification is sent, unless an error occurs while setting up the new stream, in which case a {{{SCSessionRejectedStreamProposal}}} notification is sent and a rejection is sent to the remote party.
306
  This method may only be called while in the {{{PROPOSED}}} state.
307
 '''reject_proposal'''(''self'')::
308
  When the remote party proposes (a) stream(s) that the application does not want to accept, this method can be used to reject the proposal, after which a {{{SCSessionRejectedStreamProposal}}} notification is sent.
309
  This method may only be called while in the {{{PROPOSED}}} state.
310
 '''terminate'''(''self'')::
311
  This method may be called any time when the {{{Session}}} object is active (i.e. not in the {{{NULL}}}, {{{TERMINATING}}} or {{{TERMINATED}}} states) in order to terminate the session.
312
  Right before termination a {{{SCSessionWillEnd}}} notification is sent, after termination {{{SCSessionDidEnd}}} is sent.
313
314
==== notifications ====
315
316
 '''SCSessionChangedState'''::
317
  Will be sent whenever the {{{Session}}} object changes its state.
318
  [[BR]]''timestamp'':[[BR]]
319
  A {{{datetime.datetime}}} object indicating when the notification was sent.
320
  [[BR]]''prev_state'':[[BR]]
321
  The previous state state the object was in.
322
  [[BR]]''state'':[[BR]]
323
  The new state the object is in.
324
 '''SCSessionNewIncoming'''::
325
  Will be sent when a new incoming {{{Session}}} is received.
326
  The application should listen for this notification from all objects specifically to get informed of incoming sessions.
327
  [[BR]]''timestamp'':[[BR]]
328
  A {{{datetime.datetime}}} object indicating when the notification was sent.
329
  [[BR]]''has_audio'':[[BR]]
330
  A boolean indicating if the remote party proposed an audio stream within this session.
331
  [[BR]]''has_chat'':[[BR]]
332
  A boolean indicating if the remote party proposed a chat stream within this session.
333
 '''SCSessionNewOutgoing'''::
334
  Will be sent when the applcation requests a new outgoing {{{Session}}}.
335
  [[BR]]''timestamp'':[[BR]]
336
  A {{{datetime.datetime}}} object indicating when the notification was sent.
337
 '''SCSessionGotRingIndication'''::
338
  Will be sent when an outgoing {{{Session}}} receives an indication that a remote device is ringing.
339
  [[BR]]''timestamp'':[[BR]]
340
  A {{{datetime.datetime}}} object indicating when the notification was sent.
341
 '''SCSessionWillStart'''::
342
  Will be sent just before a {{{Session}}} completes negotiation.
343
  In terms of SIP, this is sent after the final response to the {{{INVITE}}}, but before the {{{ACK}}}.
344
  [[BR]]''timestamp'':[[BR]]
345
  A {{{datetime.datetime}}} object indicating when the notification was sent.
346
 '''SCSessionDidStart'''::
347
  Will be sent when a {{{Session}}} completes negotiation.
348
  In terms of SIP this is sent after the {{{ACK}}} was sent or received.
349
  [[BR]]''timestamp'':[[BR]]
350
  A {{{datetime.datetime}}} object indicating when the notification was sent.
351
 '''SCSessionDidFail'''::
352
  This notification is sent whenever the session fails.
353
  The failure reason is included in the data attributes.
354
  This notification is always followed by {{{SCSessionDidEnd}}}.
355
  [[BR]]''timestamp'':[[BR]]
356
  A {{{datetime.datetime}}} object indicating when the notification was sent.
357
  [[BR]]''originator'':[[BR]]
358
  A string indicating the origin of the failure.
359
  This will either be "local" or "remote".
360
  [[BR]]''code'':[[BR]]
361
  The SIP error code of the failure.
362
  If this is 0, the error was an internal exception.
363
  [[BR]]''reason'':[[BR]]
364
  A string explaining the reason of the failure.
365
 '''SCSessionWillEnd'''::
366
  Will be sent just before terminating a {{{Session}}} at the request of the application.
367
  [[BR]]''timestamp'':[[BR]]
368
  A {{{datetime.datetime}}} object indicating when the notification was sent.
369
 '''SCSessionDidEnd'''::
370
  Will be sent always when a {{{Session}}} ends, either because of a failure (in which case it is preceded by {{{SCSessionDidFail}}}), remote or local session termination.
371
  [[BR]]''timestamp'':[[BR]]
372
  A {{{datetime.datetime}}} object indicating when the notification was sent.
373
  [[BR]]''originator'':[[BR]]
374
  A string indicating who originated the termination.
375
  This will either be "local" or "remote".
376
 '''SCSessionGotHoldRequest'''::
377
  Will be sent when the session got put on hold, either by the local or the remote party.
378
  [[BR]]''timestamp'':[[BR]]
379
  A {{{datetime.datetime}}} object indicating when the notification was sent.
380
  [[BR]]''originator'':[[BR]]
381
  A string indicating who originated the hold request, and consequently in which direction the session got put on hold.
382
 '''SCSessionGotUnholdRequest'''::
383
  Will be sent when the session got taken out of hold, either by the local or the remote party.
384
  [[BR]]''timestamp'':[[BR]]
385
  A {{{datetime.datetime}}} object indicating when the notification was sent.
386
  [[BR]]''originator'':[[BR]]
387
  A string indicating who sent the original hold request, and consequently in which direction the session got taken out of hold.
388
 '''SCSessionWillStartRecordingAudio'''::
389
  Will be sent when the application requested that the audio stream active within the session be record to a {{{.wav}}} file, just before recording starts.
390
  [[BR]]''timestamp'':[[BR]]
391
  A {{{datetime.datetime}}} object indicating when the notification was sent.
392
  [[BR]]''file_name'':[[BR]]
393
  The name of the recording {{{.wav}}} file, including full path.
394
 '''SCSessionDidStartRecordingAudio'''::
395
  Will be sent when the application requested that the audio stream active within the session be record to a {{{.wav}}} file, just after recording starts.
396
  [[BR]]''timestamp'':[[BR]]
397
  A {{{datetime.datetime}}} object indicating when the notification was sent.
398
  [[BR]]''file_name'':[[BR]]
399
  The name of the recording {{{.wav}}} file, including full path.
400
 '''SCSessionWillStopRecordingAudio'''::
401
  Will be sent when the application requested ending the recording to a {{{.wav}}} file, just before recording stops.
402
  [[BR]]''timestamp'':[[BR]]
403
  A {{{datetime.datetime}}} object indicating when the notification was sent.
404
  [[BR]]''file_name'':[[BR]]
405
  The name of the recording {{{.wav}}} file, including full path.
406
 '''SCSessionDidStopRecordingAudio'''::
407
  Will be sent when the application requested ending the recording to a {{{.wav}}} file, just before recording stops.
408
  [[BR]]''timestamp'':[[BR]]
409
  A {{{datetime.datetime}}} object indicating when the notification was sent.
410
  [[BR]]''file_name'':[[BR]]
411
  The name of the recording {{{.wav}}} file, including full path.
412
 '''SCSessionGotNoAudio'''::
413
  This notification will be sent if 5 seconds after the audio stream starts, no audio was received from the remote party.
414
  [[BR]]''timestamp'':[[BR]]
415
  A {{{datetime.datetime}}} object indicating when the notification was sent.
416
 '''SCSessionGotDTMF'''::
417
  Will be send if there is a DMTF digit received from the remote party on the audio stream. 
418
  [[BR]]''timestamp'':[[BR]]
419
  A {{{datetime.datetime}}} object indicating when the notification was sent.
420
  [[BR]]''digit'':[[BR]]
421
  The DTMF digit that was received, in the form of a string of length 1.
422
 '''SCSessionGotMessage'''::
423
  Will be sent whenever a MSRP message is received on the chat stream of the session.
424
  [[BR]]''content'':[[BR]]
425
  The body of the message.
426
  [[BR]]''content_type'':[[BR]]
427
  The Content-Type of the body.
428
  [[BR]]''cpim_headers'':[[BR]]
429
  A dictionary of headers included in the CPIM wrapper.
430
  [[BR]]''message'':[[BR]]
431 5 Redmine Admin
  Raw MSRP message, an msrplib.protocol.MSRPData instance
432 1 Adrian Georgescu
 '''SCSessionDidDeliverMessage'''::
433
  Will be sent when a previously sent MSRP chat message got delivered to the remote party.
434
  [[BR]]''message_id'':[[BR]]
435
  The unique identifier of this message as a string, as previously returned by the {{{send_message()}}} method.
436
  [[BR]]''code'':[[BR]]
437
  The response code of the confirmation report.
438
  [[BR]]''reason'':[[BR]]
439
  The reason string of the confirmation report.
440
  [[BR]]''message'':[[BR]]
441 5 Redmine Admin
  Raw MSRP message, an msrplib.protocol.MSRPData instance
442 1 Adrian Georgescu
 '''SCSessionDidDeliverMessage'''::
443
  Will be sent when a previously sent MSRP chat message did not get delivered to the remote party.
444
  [[BR]]''message_id'':[[BR]]
445
  The unique identifier of this message as a string, as previously returned by the {{{send_message()}}} method.
446
  [[BR]]''code'':[[BR]]
447
  The response code of the confirmation report.
448
  [[BR]]''reason'':[[BR]]
449
  The reason string of the confirmation report.
450
  [[BR]]''message'':[[BR]]
451 5 Redmine Admin
  Raw MSRP message, an msrplib.protocol.MSRPData instance
452 1 Adrian Georgescu
 '''SCSessionGotStreamProposal'''::
453
  Will be sent when either the local or the remote party proposes to add a stream to the session.
454
  [[BR]]''timestamp'':[[BR]]
455
  A {{{datetime.datetime}}} object indicating when the notification was sent.
456
  [[BR]]''proposer'':[[BR]]
457
  The party that did the stream proposal, can be either "local" or "remote".
458
  [[BR]]''adds_audio'':[[BR]]
459
  A boolean indicating if the proposal would add an audio stream.
460
  [[BR]]''adds_chat'':[[BR]]
461
  A boolean indicating if the proposal would add a chat stream.
462
 '''SCSessionRejectedStreamProposal'''::
463
  Will be sent when either the local or the remote party rejects a proposal to have (a) stream(s) added to the session.
464
  [[BR]]''timestamp'':[[BR]]
465
  A {{{datetime.datetime}}} object indicating when the notification was sent.
466
  [[BR]]''proposer'':[[BR]]
467
  The party that did the stream proposal, can be either "local" or "remote".
468
  [[BR]]''reason'':[[BR]]
469
  The reason for rejecting the stream proposal.
470
 '''SCSessionRejectedStreamProposal'''::
471
  Will be sent when either the local or the remote party accepts a proposal to have (a) stream(s) added to the session.
472
  [[BR]]''timestamp'':[[BR]]
473
  A {{{datetime.datetime}}} object indicating when the notification was sent.
474
  [[BR]]''proposer'':[[BR]]
475
  The party that did the stream proposal, can be either "local" or "remote".
476
477
==== examples ====
478
479
=== MSRPChat ===
480
481
==== Methods ====
482
==== Attributes ====
483
484
=== MSRPFileTransfer ===
485
486
==== Methods ====
487
==== Attributes ====
488
== Notifications ==
489
490
The notifications bus is implemented using [http://pypi.python.org/pypi/python-application/ python-application] notifications system.
491
492
Each software component that needs to communicate with the rest of the system can subscribe to or publish messages. The format of a message on the notification bus is ABClassNameVerbNoun. Attached to each message data can be appended, the data need to be understood by an interested observer. The messages exchanged on the notifications bus and their context are described below. 
493
494
=== SIP Registration ===
495
496
 * SCRegistrationDidSucceed
497
 * SCRegistrationDidFail
498
 * SCRegistrationWillEnd
499
 * SCRegistrationDidEnd
500
501
=== SIP Subscription ===
502
503
 * SCSubscriptionDidSucceed
504
 * SCSubscriptionDidFail
505
 * SCSubscriptionWillEnd
506
 * SCSubscriptionDidEnd
507
 * SCSubscriptionGotNotify
508
509
=== SIP Publication ===
510
511
 * SCPublicationDidSucceed
512
 * SCPublicationDidFail
513
 * SCPublicationWillEnd
514
 * SCPublicationDidEnd
515
516
=== MSRP IM Chat  ===  
517
518
 * MSRPChatDidInitialize
519
 * MSRPChatDidStart
520
 * MSRPChatDidFail
521
 * MSRPChatWillEnd
522
 * MSRPChatDidEnd
523
 * MSRPChatGotMessage      
524
 * MSRPChatDidDeliverMessage
525
 * MSRPChatDidNotDeliverMessage
526
527
=== MSRP File Transfer ===  
528
529
 * MSRPFileTransferDidInitialize       
530
 * MSRPFileTransferDidStart            
531
 * MSRPFileTransferDidFail       
532
 * MSRPFileTransferGotFile       
533
 * MSRPFileTransferDidDeliverFile     
534
 * MSRPFileTransferDidNotDeliverFile   
535
 * MSRPFileTransferWillEnd       
536
 * MSRPFileTransferDidEnd