Files
asterisk/rest-api/api-docs/bridges.json
George Joseph 6cf62b6032 bridging: Fix multiple bridging issues causing SEGVs and FRACKs.
Issues:

* The bridging core allowed multiple bridges to be created with the same
  unique bridgeId at the same time.  Only the last bridge created with the
  duplicate name was actually saved to the core bridges container.

* The bridging core was creating a stasis topic for the bridge and saving it
  in the bridge->topic field but not increasing its reference count.  In the
  case where two bridges were created with the same uniqueid (which is also
  the topic name), the second bridge would get the _existing_ topic the first
  bridge created.  When the first bridge was destroyed, it would take the
  topic with it so when the second bridge attempted to publish a message to
  it it either FRACKed or SEGVd.

* The bridge destructor, which also destroys the bridge topic, is run from the
  bridge manager thread not the caller's thread.  This makes it possible for
  an ARI developer to create a new one with the same uniqueid believing the
  old one was destroyed when, in fact, the old one's destructor hadn't
  completed. This could cause the new bridge to get the old one's topic just
  before the topic was destroyed.  When the new bridge attempted to publish
  a message on that topic, asterisk could either FRACK or SEGV.

* The ARI bridges resource also allowed multiple bridges to be created with
  the same uniqueid but it kept the duplicate bridges in its app_bridges
  container.  This created a situation where if you added two bridges with
  the same "bridge1" uniqueid, all operations on "bridge1" were performed on
  the first bridge created and the second was basically orphaned.  If you
  attempted to delete what you thought was the second bridge, you actually
  deleted the first one created.

Changes:

* A new API `ast_bridge_topic_exists(uniqueid)` was created to determine if
  a topic already exists for a bridge.

* `bridge_base_init()` in bridge.c and `ast_ari_bridges_create()` in
  resource_bridges.c now call `ast_bridge_topic_exists(uniqueid)` to check
  if a bridge with the requested uniqueid already exists and will fail if it
  does.

* `bridge_register()` in bridges.c now checks the core bridges container to
  make sure a bridge doesn't already exist with the requested uniqueid.
  Although most callers of `bridge_register()` will have already called
  `bridge_base_init()`, which will now fail on duplicate bridges, there
  is no guarantee of this so we must check again.

* The core bridges container allocation was changed to reject duplicate
  uniqueids instead of silently replacing an existing one. This is a "belt
  and suspenders" check.

* A global mutex was added to bridge.c to prevent concurrent calls to
  `bridge_base_init()` and `bridge_register()`.

* Even though you can no longer create multiple bridges with the same uniqueid
  at the same time, it's still possible that the bridge topic might be
  destroyed while a second bridge with the same uniqueid was trying to use
  it. To address this, the bridging core now increments the reference count
  on bridge->topic when a bridge is created and decrements it when the
  bridge is destroyed.

* `bridge_create_common()` in res_stasis.c now checks the stasis app_bridges
  container to make sure a bridge with the requested uniqueid doesn't already
  exist.  This may seem like overkill but there are so many entrypoints to
  bridge creation that we need to be safe and catch issues as soon in the
  process as possible.

* The stasis app_bridges container allocation was changed to reject duplicate
  uniqueids instead of adding them. This is a "belt and suspenders" check.

* The `bridge show all` CLI command now shows the bridge name as well as the
  bridge id.

* Response code 409 "Conflict" was added as a possible response from the ARI
  bridge create resources to signal that a bridge with the requested uniqueid
  already exists.

* Additional debugging was added to multiple bridging and stasis files.

Resolves: #211
2025-02-20 18:34:25 +00:00

834 lines
21 KiB
JSON

{
"_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
"_author": "David M. Lee, II <dlee@digium.com>",
"_svn_revision": "$Revision$",
"apiVersion": "2.0.0",
"swaggerVersion": "1.1",
"basePath": "http://localhost:8088/ari",
"resourcePath": "/api-docs/bridges.{format}",
"since": [
"12.0.0"
],
"requiresModules": [
"res_stasis_recording",
"res_stasis_playback"
],
"apis": [
{
"path": "/bridges",
"description": "Active bridges",
"operations": [
{
"httpMethod": "GET",
"since": [
"12.0.0"
],
"summary": "List all active bridges in Asterisk.",
"nickname": "list",
"responseClass": "List[Bridge]"
},
{
"httpMethod": "POST",
"since": [
"12.0.0"
],
"summary": "Create a new bridge.",
"notes": "This bridge persists until it has been shut down, or Asterisk has been shut down.",
"nickname": "create",
"responseClass": "Bridge",
"parameters": [
{
"name": "type",
"description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu, video_single, sdp_label).",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "bridgeId",
"description": "Unique ID to give to the bridge being created.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "name",
"description": "Name to give to the bridge being created.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 409,
"reason": "Bridge with the same bridgeId already exists"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}",
"description": "Individual bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.2.0"
],
"summary": "Create a new bridge.",
"notes": "This bridge persists until it has been shut down, or Asterisk has been shut down.",
"nickname": "createWithId",
"responseClass": "Bridge",
"parameters": [
{
"name": "type",
"description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_sfu, video_single, sdp_label) to set.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "bridgeId",
"description": "Unique ID to give to the bridge being created.",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "name",
"description": "Set the name of the bridge.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 409,
"reason": "Bridge with the same bridgeId already exists"
}
]
},
{
"httpMethod": "GET",
"since": [
"12.0.0"
],
"summary": "Get bridge details.",
"nickname": "get",
"responseClass": "Bridge",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
}
]
},
{
"httpMethod": "DELETE",
"since": [
"12.0.0"
],
"summary": "Shut down a bridge.",
"notes": "If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand.",
"nickname": "destroy",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/addChannel",
"description": "Add a channel to a bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.0.0"
],
"summary": "Add a channel to a bridge.",
"nickname": "addChannel",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "channel",
"description": "Ids of channels to add to bridge",
"paramType": "query",
"required": true,
"allowMultiple": true,
"dataType": "string"
},
{
"name": "role",
"description": "Channel's role in the bridge",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "absorbDTMF",
"description": "Absorb DTMF coming from this channel, preventing it to pass through to the bridge",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "boolean",
"defaultValue": false
},
{
"name": "mute",
"description": "Mute audio from this channel, preventing it to pass through to the bridge",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "boolean",
"defaultValue": false
},
{
"name": "inhibitConnectedLineUpdates",
"description": "Do not present the identity of the newly connected channel to other bridge members",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "boolean",
"defaultValue": false
}
],
"errorResponses": [
{
"code": 400,
"reason": "Channel not found"
},
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge not in Stasis application; Channel currently recording"
},
{
"code": 422,
"reason": "Channel not in Stasis application"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/removeChannel",
"description": "Remove a channel from a bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.0.0"
],
"summary": "Remove a channel from a bridge.",
"nickname": "removeChannel",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "channel",
"description": "Ids of channels to remove from bridge",
"paramType": "query",
"required": true,
"allowMultiple": true,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 400,
"reason": "Channel not found"
},
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge not in Stasis application"
},
{
"code": 422,
"reason": "Channel not in this bridge"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/videoSource/{channelId}",
"description": "Set a channel as the video source in a multi-party bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"13.13.0",
"14.2.0"
],
"summary": "Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants.",
"nickname": "setVideoSource",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "channelId",
"description": "Channel's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge or Channel not found"
},
{
"code": 409,
"reason": "Channel not in Stasis application"
},
{
"code": 422,
"reason": "Channel not in this Bridge"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/videoSource",
"description": "Removes any explicit video source",
"operations": [
{
"httpMethod": "DELETE",
"since": [
"13.13.0",
"14.2.0"
],
"summary": "Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bridges with two or fewer participants. When no explicit video source is set, talk detection will be used to determine the active video stream.",
"nickname": "clearVideoSource",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/moh",
"description": "Play music on hold to a bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.0.0"
],
"summary": "Play music on hold to a bridge or change the MOH class that is playing.",
"nickname": "startMoh",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "mohClass",
"description": "Channel's id",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge not in Stasis application"
}
]
},
{
"httpMethod": "DELETE",
"since": [
"12.0.0"
],
"summary": "Stop playing music on hold to a bridge.",
"notes": "This will only stop music on hold being played via POST bridges/{bridgeId}/moh.",
"nickname": "stopMoh",
"responseClass": "void",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge not in Stasis application"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/play",
"description": "Play media to the participants of a bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.0.0"
],
"summary": "Start playback of media on a bridge.",
"notes": "The media URI may be any of a number of URI's. Currently sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.)",
"nickname": "play",
"responseClass": "Playback",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "media",
"description": "Media URIs to play.",
"paramType": "query",
"required": true,
"allowMultiple": true,
"dataType": "string"
},
{
"name": "lang",
"description": "For sounds, selects language for sound.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "offsetms",
"description": "Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "int",
"defaultValue": 0,
"allowableValues": {
"valueType": "RANGE",
"min": 0
}
},
{
"name": "skipms",
"description": "Number of milliseconds to skip for forward/reverse operations.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "int",
"defaultValue": 3000,
"allowableValues": {
"valueType": "RANGE",
"min": 0
}
},
{
"name": "playbackId",
"description": "Playback Id.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge not in a Stasis application"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/play/{playbackId}",
"description": "Play media to a bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.3.0"
],
"summary": "Start playback of media on a bridge.",
"notes": "The media URI may be any of a number of URI's. Currently sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.)",
"nickname": "playWithId",
"responseClass": "Playback",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "playbackId",
"description": "Playback ID.",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "media",
"description": "Media URIs to play.",
"paramType": "query",
"required": true,
"allowMultiple": true,
"dataType": "string"
},
{
"name": "lang",
"description": "For sounds, selects language for sound.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "offsetms",
"description": "Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "int",
"defaultValue": 0,
"allowableValues": {
"valueType": "RANGE",
"min": 0
}
},
{
"name": "skipms",
"description": "Number of milliseconds to skip for forward/reverse operations.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "int",
"defaultValue": 3000,
"allowableValues": {
"valueType": "RANGE",
"min": 0
}
}
],
"errorResponses": [
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge not in a Stasis application"
}
]
}
]
},
{
"path": "/bridges/{bridgeId}/record",
"description": "Record audio on a bridge",
"operations": [
{
"httpMethod": "POST",
"since": [
"12.0.0"
],
"summary": "Start a recording.",
"notes": "This records the mixed audio from all channels participating in this bridge.",
"nickname": "record",
"responseClass": "LiveRecording",
"parameters": [
{
"name": "bridgeId",
"description": "Bridge's id",
"paramType": "path",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "name",
"description": "Recording's filename",
"paramType": "query",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "format",
"description": "Format to encode audio in",
"paramType": "query",
"required": true,
"allowMultiple": false,
"dataType": "string"
},
{
"name": "maxDurationSeconds",
"description": "Maximum duration of the recording, in seconds. 0 for no limit.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "int",
"defaultValue": 0,
"allowableValues": {
"valueType": "RANGE",
"min": 0
}
},
{
"name": "maxSilenceSeconds",
"description": "Maximum duration of silence, in seconds. 0 for no limit.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "int",
"defaultValue": 0,
"allowableValues": {
"valueType": "RANGE",
"min": 0
}
},
{
"name": "ifExists",
"description": "Action to take if a recording with the same name already exists.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string",
"defaultValue": "fail",
"allowableValues": {
"valueType": "LIST",
"values": [
"fail",
"overwrite",
"append"
]
}
},
{
"name": "beep",
"description": "Play beep when recording begins",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "boolean",
"defaultValue": false
},
{
"name": "terminateOn",
"description": "DTMF input to terminate recording.",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string",
"defaultValue": "none",
"allowableValues": {
"valueType": "LIST",
"values": [
"none",
"any",
"*",
"#"
]
}
}
],
"errorResponses": [
{
"code": 400,
"reason": "Invalid parameters"
},
{
"code": 404,
"reason": "Bridge not found"
},
{
"code": 409,
"reason": "Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail"
},
{
"code": 422,
"reason": "The format specified is unknown on this system"
}
]
}
]
}
],
"models": {
"Bridge": {
"id": "Bridge",
"description": "The merging of media from one or more channels.\n\nEveryone on the bridge receives the same audio.",
"properties": {
"id": {
"type": "string",
"description": "Unique identifier for this bridge",
"required": true
},
"technology": {
"type": "string",
"description": "Name of the current bridging technology",
"required": true
},
"bridge_type": {
"type": "string",
"description": "Type of bridge technology",
"required": true,
"allowableValues": {
"valueType": "LIST",
"values": [
"mixing",
"holding"
]
}
},
"bridge_class": {
"type": "string",
"description": "Bridging class",
"required": true
},
"creator": {
"type": "string",
"description": "Entity that created the bridge",
"required": true
},
"name": {
"type": "string",
"description": "Name the creator gave the bridge",
"required": true
},
"channels": {
"type": "List[string]",
"description": "Ids of channels participating in this bridge",
"required": true
},
"video_mode": {
"type": "string",
"description": "The video mode the bridge is using. One of 'none', 'talker', 'sfu', or 'single'.",
"required": false
},
"video_source_id": {
"type": "string",
"description": "The ID of the channel that is the source of video in this bridge, if one exists.",
"required": false
},
"creationtime": {
"required": true,
"type": "Date",
"description": "Timestamp when bridge was created"
}
}
}
}
}