You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`url` <spanclassName="required-arg">required</span> | Absolute or relative URL. A WebSocket connection to the url will be established and audio will start flowing towards the Websocket server. The only supported protocol is `wss`. For security reasons `ws` is NOT supported. |
115
+
|`authBearerToken` <spanclassName="optional-arg">optional</span> | A authentication Bearer token that can be supplied when starting a stream. The remote server can then authenticate the websocket connection request from the supplied token. More information can be found in the [WebSocket connection](#websocket-connection) section. |
115
116
|`codec` <spanclassName="optional-arg">optional</span> | The codecs attribute allows you to control the set codec to be used on the stream. **Possible Values**: `L16@24000h` & `L16@16000h`|
116
117
|`name` <spanclassName="optional-arg">optional</span> | Unique name for the Stream, per Call. It is used to stop a Stream by name. |
118
+
|`realtime` <spanclassName="optional-arg">optional</span> | If `true`, and the stream is [`bidirectional`](/compatibility-api/cxml/voice/connect#bidirectional-media-stream), the stream offers a realtime experience to the call parties by managing packet delays and bursts. If `false`, the use benefits from buffered audio, which can be played out with delay. Default: `false`|
117
119
|`track` <spanclassName="optional-arg">optional</span> | This attribute can be one of: `inbound_track`, `outbound_track`, `both_tracks` . Defaults to `inbound_track`. For `both_tracks` there will be both `inbound_track` and `outbound_track` events. |
118
120
|`statusCallback` <spanclassName="optional-arg">optional</span> | Absolute or relative URL. SignalWire will make a HTTP GET or POST request to this URL when a Stream is started, stopped or there is an error. |
119
121
|`statusCallbackMethod` <spanclassName="optional-arg">optional</span> | GET or POST. The type of HTTP request to use when requesting a statusCallback. Default is POST. |
@@ -133,6 +135,7 @@ You can utilize our REST API to both [start][stream_start] and [stop][stream_sto
133
135
|`url` <spanclassName="required-arg">required</span> | Absolute or relative URL. A WebSocket connection to the url will be established and audio will start flowing towards the Websocket server. The only supported protocol is `wss`. For security reasons `ws` is NOT supported. |
134
136
|`codec` <spanclassName="optional-arg">optional</span> | The codecs attribute allows you to control the set codec to be used on the stream. **Possible Values**: `L16@24000h` & `L16@16000h`|
135
137
|`name` <spanclassName="required-arg">required</span> | Unique name for the Stream, per Call. It is used to stop a Stream by name. |
138
+
|`realtime` <spanclassName="optional-arg">optional</span> | If `true`, and the stream is [`bidirectional`](/compatibility-api/cxml/voice/connect#bidirectional-media-stream), the stream offers a realtime experience to the call parties by managing packet delays and bursts. If `false`, the use benefits from buffered audio, which can be played out with delay. Default: `false`|
136
139
|`track` <spanclassName="optional-arg">optional</span> | This attribute can be one of: `inbound_track`, `outbound_track`, `both_tracks` . Defaults to `inbound_track`. For `both_tracks` there will be both `inbound_track` and `outbound_track` events. |
137
140
|`statusCallback` <spanclassName="optional-arg">optional</span> | Absolute or relative URL. SignalWire will make a HTTP GET or POST request to this URL when a Stream is started, stopped or there is an error. |
138
141
|`statusCallbackMethod` <spanclassName="optional-arg">optional</span> | GET or POST. The type of HTTP request to use when requesting a statusCallback. Default is POST. |
@@ -148,7 +151,7 @@ You can utilize our REST API to [create][conference_create] and [update][confere
148
151
</TabItem>
149
152
</Tabs>
150
153
151
-
## `StatusCallback`Parameters
154
+
## `StatusCallback`parameters
152
155
153
156
For a `statusCallback`, SignalWire will send a request with the following parameters:
154
157
@@ -162,14 +165,32 @@ For a `statusCallback`, SignalWire will send a request with the following parame
162
165
|`StreamError` <spanclassName="optional-arg">string</span> | If an error has occurred, this will contain a detailed error message. |
163
166
|`Timestamp` <spanclassName="optional-arg">string</span> | The time of the event in ISO 8601 format. |
164
167
165
-
## WebSocket Messages
166
168
167
-
There are 5 separate types of events that occur during the Stream's life cycle.
168
-
These events are represented via WebSocket Messages: `Connected`, `Start`, `Media`, `DTMF` and `Stop`.
169
-
Each message sent is a JSON string.
170
-
The type of event which is occurring can be identified by using the `event` property of every JSON object.
171
169
172
-
### Connected Message
170
+
## WebSocket connection
171
+
172
+
When establishing a stream, SignalWire initiates a WebSocket connection to your specified URL endpoint. The connection begins with an HTTP upgrade request containing the following headers:
173
+
174
+
| Header | Description |
175
+
| :----| :----- |
176
+
| Host | The destination server hosting the WebSocket endpoint (e.g., "example.com") |
177
+
| Upgrade | Protocol upgrade request indicating a switch to WebSocket (value: "websocket") |
178
+
| Connection | Connection type for the upgrade (value: "Upgrade") |
179
+
| Sec-WebSocket-Key | Base64-encoded random value used for the WebSocket handshake |
180
+
| Sec-WebSocket-Version | WebSocket protocol version (value: "13") |
181
+
| Authorization | Bearer token for authentication if `authBearerToken` attribute is provided (format: "Bearer token_here") |
182
+
183
+
Once the WebSocket connection is established, SignalWire will send various events throughout the stream's lifecycle.
184
+
These events are delivered as JSON-formatted WebSocket messages, each containing an `event` property that identifies the message type.
185
+
186
+
The stream supports five distinct event types:
187
+
-**Connected** - Initial handshake message confirming the connection
188
+
-**Start** - Stream metadata and configuration details
189
+
-**Media** - Audio data packets
190
+
-**DTMF** - Touch-tone digit events
191
+
-**Stop** - Stream termination notification
192
+
193
+
### Connected message
173
194
174
195
The first message sent once a WebSocket connection is established is the Connected event.
175
196
This message describes the protocol to expect in the following messages.
@@ -180,7 +201,7 @@ This message describes the protocol to expect in the following messages.
180
201
| protocol | Defines the protocol for the WebSocket connections lifetime. eg: "Call" |
181
202
| version | Semantic version of the protocol. |
182
203
183
-
Example Connected Message
204
+
Example Connected message
184
205
185
206
```json
186
207
{
@@ -190,7 +211,7 @@ Example Connected Message
190
211
}
191
212
```
192
213
193
-
### Start Message
214
+
### Start message
194
215
195
216
This message contains important information about the Stream and is sent immediately after the `Connected` message.
196
217
It is only sent once at the start of the Stream.
@@ -210,7 +231,7 @@ It is only sent once at the start of the Stream.
210
231
| start.mediaFormat.sampleRate | The Sample Rate in Hertz of the upcoming audio data. Default value is 8000, which is the rate of PCMU. |
211
232
| start.mediaFormat.channels | The number of channels in the input audio data. Default value is 1. For `both_tracks` it will be 2. |
212
233
213
-
Example Start Message
234
+
Example Start message
214
235
215
236
```json
216
237
{
@@ -235,7 +256,7 @@ Example Start Message
235
256
}
236
257
```
237
258
238
-
### Media Message
259
+
### Media message
239
260
240
261
This message type encapsulates the raw audio data.
241
262
@@ -249,7 +270,7 @@ This message type encapsulates the raw audio data.
249
270
| media.timestamp | Presentation Timestamp in Milliseconds from the start of the stream. |
250
271
| media.payload | Raw audio encoded in base64. |
251
272
252
-
Example Media Messages
273
+
Example media messages
253
274
254
275
Outbound
255
276
@@ -280,11 +301,11 @@ Inbound
280
301
}
281
302
```
282
303
283
-
### Stop Message
304
+
### Stop message
284
305
285
306
A stop message will be sent when the Stream is either stopped or the Call has ended.
286
307
287
-
Example Stop Message
308
+
Example stop message
288
309
289
310
```json
290
311
{
@@ -298,7 +319,7 @@ Example Stop Message
298
319
| event | The string value of `stop`. |
299
320
| sequenceNumber | Number used to keep track of message sending order. First message starts with number "1" and then is incremented for each message. |
300
321
301
-
### DTMF Message
322
+
### DTMF message
302
323
303
324
A DTMF message will be sent when the Stream receives a DTMF tone.
304
325
@@ -311,7 +332,7 @@ A DTMF message will be sent when the Stream receives a DTMF tone.
311
332
| dtmf.duration | The duration of the DTMF in milliseconds. |
312
333
| dtmf.digit | The digit, as a string, that corresponds to the DTMF. |
313
334
314
-
Example DTMF Message
335
+
Example DTMF message
315
336
316
337
```json
317
338
{
@@ -325,7 +346,7 @@ Example DTMF Message
325
346
}
326
347
```
327
348
328
-
### Clear Message
349
+
### Clear message
329
350
330
351
Send the clear event message if you would like to interrupt the audio that has been sent various media event messages. This will empty all buffered audio.
331
352
@@ -334,7 +355,7 @@ Send the clear event message if you would like to interrupt the audio that has b
334
355
| event | The string value of `clear`. |
335
356
| streamSid | The unique identifier of the stream as a string. |
336
357
337
-
Example Clear Message
358
+
Example Clear message
338
359
```json
339
360
{
340
361
"event": "clear",
@@ -410,7 +431,7 @@ This can be done by using the nested `<Parameter>` cXML noun. These parameters w
410
431
</Response>
411
432
```
412
433
413
-
## Notes on Usage
434
+
## Notes on usage
414
435
415
436
- The url does not support query string parameters. To pass custom key value pairs to the WebSocket, make use of Custom Parameters instead.
416
437
- There is a one to one mapping of a stream to a websocket connection, therefore there will be at most one call being streamed over a single websocket connection. Information will be provided so that you can handle handle multiple inbound connections and manage the association between the unique stream identifier (StreamSid) and the connection.
Copy file name to clipboardExpand all lines: website/docs/main/compatibility-api/guides/voice/python/utilizing-websockets-and-call-streams/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ Then we can use asyncio to create a non-blocking for loop that iterates over the
55
55
Finally, we will parse our messages based on their `event` designation.
56
56
57
57
The `start` event provides details such as the callSid, streamSid, the tracks we can expect, and more. We will only use the `callSid` to name and organize our recordings.
58
-
A full example of what a `start` even returns can be found in our `<stream>` documentation [here](/compatibility-api/cxml/voice/stream#websocket-messages).
58
+
A full example of what a `start` even returns can be found in our `<stream>` documentation [here](/compatibility-api/cxml/voice/stream#websocket-connection).
59
59
60
60
The `media` events hold the base64-encoded audio that we will use to compile our wave files. We can do this by decoding the base64 and appending the decoded payload to the appropriate list.
0 commit comments