mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-30 10:11:45 +00:00
With recent enhancements to chan_websocket, the original plain-text
implementation of control messages and events is now too limiting. We
probably should have used JSON initially but better late than never. Going
forward, enhancements that require control message or event changes will
only be done to the JSON variants and the plain-text variants are now
deprecated but not yet removed.
* Added the chan_websocket.conf config file that allows setting which control
message format to use globally: "json" or "plain-text". "plain-text" is the
default for now to preserve existing behavior.
* Added a dialstring option `f(json|plain-text)` to allow the format to be
overridden on a call-by-call basis. Again, 'plain-text' is the default for
now to preserve existing behavior.
The JSON for commands sent by the app to Asterisk must be...
`{ "command": "<command>" ... }` where `<command>` is one of `ANSWER`, `HANGUP`,
`START_MEDIA_BUFFERING`, etc. The `STOP_MEDIA_BUFFERING` command takes an
additional, optional parameter to be returned in the corresponding
`MEDIA_BUFFERING_COMPLETED` event:
`{ "command": "STOP_MEDIA_BUFFERING", "correlation_id": "<correlation id>" }`.
The JSON for events sent from Asterisk to the app will be...
`{ "event": "<event>", "channel_id": "<channel_id>" ... }`.
The `MEDIA_START` event will now look like...
```
{
"event": "MEDIA_START",
"connection_id": "media_connection1",
"channel": "WebSocket/media_connection1/0x5140001a0040",
"channel_id": "1761245643.1",
"format": "ulaw",
"optimal_frame_size": 160,
"ptime": 20,
"channel_variables": {
"DIALEDPEERNUMBER": "media_connection1/c(ulaw)",
"MEDIA_WEBSOCKET_CONNECTION_ID": "media_connection1",
"MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": "160"
}
}
```
Note the addition of the channel variables which can't be supported
with the plain-text formatting.
The documentation will be updated with the exact formats for all commands
and events.
Resolves: #1546
Resolves: #1563
DeveloperNote: The chan_websocket plain-text control and event messages are now
deprecated (but remain the default) in favor of JSON formatted messages.
See https://docs.asterisk.org/Configuration/Channel-Drivers/WebSocket for
more information.
DeveloperNote: A "transport_data" parameter has been added to the
channels/externalMedia ARI endpoint which, for websocket, allows the caller
to specify parameters to be added to the dialstring for the channel. For
instance, `"transport_data": "f(json)"`.
120 lines
4.9 KiB
XML
120 lines
4.9 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE docs SYSTEM "appdocsxml.dtd">
|
|
<docs xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
<configInfo name="chan_websocket" language="en_US">
|
|
<synopsis>Configuration for chan_websocket</synopsis>
|
|
<description><para>
|
|
<emphasis>WebSocket Channel Driver</emphasis>
|
|
</para>
|
|
</description>
|
|
<configFile name="chan_websocket.conf">
|
|
<configObject name="global">
|
|
<since>
|
|
<version>20.18.0</version>
|
|
<version>22.8.0</version>
|
|
<version>23.2.0</version>
|
|
</since>
|
|
<synopsis>Global settings for chan_websocket</synopsis>
|
|
<configOption name="control_message_format" default="plain-text">
|
|
<since>
|
|
<version>20.18.0</version>
|
|
<version>22.8.0</version>
|
|
<version>23.2.0</version>
|
|
</since>
|
|
<synopsis>Determines the format used for sending and receiving
|
|
control mesages on the websocket.
|
|
</synopsis>
|
|
<description>
|
|
<enumlist>
|
|
<enum name="plain-text">
|
|
<para>The legacy plain text single-line message format.</para>
|
|
</enum>
|
|
<enum name="json">
|
|
<para>The new JSON format.</para>
|
|
</enum>
|
|
</enumlist>
|
|
</description>
|
|
</configOption>
|
|
</configObject>
|
|
</configFile>
|
|
</configInfo>
|
|
|
|
<info name="Dial_Resource" language="en_US" tech="WebSocket">
|
|
<para>WebSocket Dial Strings:</para>
|
|
<para><literal>Dial(WebSocket/connectionid[/websocket_options])</literal></para>
|
|
<para>WebSocket Parameters:</para>
|
|
<enumlist>
|
|
<enum name="connectionid">
|
|
<para>For outgoing WebSockets, this is the ID of the connection
|
|
in websocket_client.conf to use for the call. To accept incoming
|
|
WebSocket connections use the literal <literal>INCOMING</literal></para>
|
|
</enum>
|
|
<enum name="websocket_options">
|
|
<para>Options to control how the WebSocket channel behaves.</para>
|
|
<enumlist>
|
|
<enum name="c(codec) - Specify the codec to use in the channel">
|
|
<para></para>
|
|
<para> If not specified, the first codec from the caller's channel will be used.
|
|
</para>
|
|
</enum>
|
|
<enum name="n - Don't auto answer">
|
|
<para>Normally, the WebSocket channel will be answered when
|
|
connection is established with the remote app. If this
|
|
option is specified however, the channel will not be
|
|
answered until the <literal>ANSWER</literal> command is
|
|
received from the remote app or the remote app calls the
|
|
/channels/answer ARI endpoint.
|
|
</para>
|
|
</enum>
|
|
<enum name="f(format) - Control message format for this call">
|
|
<para>
|
|
format:
|
|
</para>
|
|
<xi:include xpointer="xpointer(/docs/configInfo[@name='chan_websocket']/configFile[@name='chan_websocket.conf']/configObject[@name='global']/configOption[@name='control_message_format']/description/enumlist)"/>
|
|
</enum>
|
|
<enum name="p - Passthrough mode">
|
|
<para>In passthrough mode, the channel driver won't attempt
|
|
to re-frame or re-time media coming in over the websocket from
|
|
the remote app. This can be used for any codec but MUST be used
|
|
for codecs that use packet headers or whose data stream can't be
|
|
broken up on arbitrary byte boundaries. In this case, the remote
|
|
app is fully responsible for correctly framing and timing media
|
|
sent to Asterisk and the MEDIA text commands that could be sent
|
|
over the websocket are disabled. Currently, passthrough mode is
|
|
automatically set for the opus, speex and g729 codecs.
|
|
</para>
|
|
</enum>
|
|
<enum name="v(uri_parameters) - Add parameters to the outbound URI">
|
|
<para>This option allows you to add additional parameters to the
|
|
outbound URI. The format is:
|
|
<literal>v(param1=value1,param2=value2...)</literal>
|
|
</para>
|
|
<para>You must ensure that no parameter name or value contains
|
|
characters not valid in a URL. The easiest way to do this is to
|
|
use the URIENCODE() dialplan function to encode them. Be aware
|
|
though that each name and value must be encoded separately. You
|
|
can't simply encode the whole string.</para>
|
|
</enum>
|
|
</enumlist>
|
|
</enum>
|
|
</enumlist>
|
|
<para>Examples:
|
|
</para>
|
|
<example title="Make an outbound WebSocket connection using connection 'connection1' and the 'sln16' codec.">
|
|
same => n,Dial(WebSocket/connection1/c(sln16))
|
|
</example>
|
|
<example title="Make an outbound WebSocket connection using connection 'connection1' and the 'opus' codec. Passthrough mode will automatically be set.">
|
|
same => n,Dial(WebSocket/connection1/c(opus))
|
|
</example>
|
|
<example title="Listen for an incoming WebSocket connection and don't auto-answer it.">
|
|
same => n,Dial(WebSocket/INCOMING/n)
|
|
</example>
|
|
<example title="Add URI parameters.">
|
|
same => n,Dial(WebSocket/connection1/v(${URIENCODE(vari able)}=${URIENCODE(${CHANNEL})},variable2=$(URIENCODE(${EXTEN})}))
|
|
</example>
|
|
<example title="Use the JSON control message format for this call.">
|
|
same => n,Dial(WebSocket/connection1/f(json))
|
|
</example>
|
|
</info>
|
|
</docs>
|