import plivo
client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.calls.get_all_streams('ebe4ab56-9b72-4c3e-9870-5f4262847407')
{
  "api_id": "87399872-13cb-11ee-9da1-0242ac110003",
  "meta": {
    "limit": 20,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 1
  },
  "objects": [
    {
      "audio_track": "both",
      "bidirectional": false,
      "bill_duration": 21,
      "billed_amount": "0.00300",
      "call_uuid": "816e0b22-6913-4b43-88a9-6d3054b77df9",
      "created_at": "2023-06-26 02:44:50.617032+00:00",
      "end_time": "2023-06-26 08:14:50+05:30",
      "plivo_auth_id": "MAY2RJNZKZNJMWOXXXX",
      "resource_uri": "/v1/Account/MAY2RJNZKZNJMWOXXXX/Call/816e0b22-6913-4b43-88a9-6d3054b77df9/Stream/4543157e-60d3-4c3a-b9d8-189c47686bf0/",
      "rounded_bill_duration": 60,
      "service_url": "ws://13.127.140.35:19088/ws",
      "start_time": "2023-06-26 08:14:29+05:30",
      "stream_id": "4543157e-60d3-4c3a-b9d8-189c47686bf0"
    }
  ]
}

This method lets you initiate an audio stream for an active call and send that stream to a secure WebSocket URL.

API Endpoint

POST
https://api.plivo.com/v1/Account/{auth_id}/Call/{call_uuid}/Stream/

Attributes

AttributesDescription
service_url (string, required)WebSocket URL to which the audio stream is initiated.
Example: wss://mystream.ngrok.io/audiostream
If a valid URL is not provided or an active stream already exists at the URL, a 400 error is returned.
bidirectional (boolean)Specifies if the WebSocket supports bidirectional audio streaming (read and write).
If true, Plivo accepts additional parameters for incoming audio:
  • event: Takes playAudio as the value
  • media: JSON object with:
    – contentType: audio/x-l16, audio/x-mulaw
    – sampleRate: 8000, 16000
    – payload: Base64-encoded raw audio
audio_track (string)The audio track of the call to stream.
Allowed values:
  • inbound (default): Only audio received by Plivo is streamed
  • outbound: Only audio sent by Plivo is streamed
  • both: Both directions are streamed
Note: If bidirectional is true, audio_track must not be outbound or both.
stream_timeout (integer)Maximum duration (in seconds) for audio streaming.
Streaming stops after this duration without affecting the rest of the call.
Must be a positive integer.
Default: 86400 (24 hours).
status_callback_url (string)URL to notify when specific stream events occur:
  • Stream is connected and audio begins
  • Stream is stopped or times out
  • Stream fails to connect or gets disconnected
status_callback_method (string)HTTP method to use for the status_callback_url.
Allowed values: GET, POST
Default: POST.
content_type (string)Preferred audio codec and sample rate.
Allowed values:
  • audio/x-l16;rate=8000 (default)
  • audio/x-l16;rate=16000
  • audio/x-mulaw;rate=8000
extra_headers (string)Key-value pairs passed to the WebSocket service with each request.
Format: "key1=value1,key2=value2"
Must be under 512 bytes in total.
Only alphanumeric characters [A-Z], [a-z], [0-9] are allowed in keys and values.

When the bidirectional value is set to true, the audio_track value should not be set to outbound or both.

import plivo
client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.calls.get_all_streams('ebe4ab56-9b72-4c3e-9870-5f4262847407')
{
  "api_id": "87399872-13cb-11ee-9da1-0242ac110003",
  "meta": {
    "limit": 20,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 1
  },
  "objects": [
    {
      "audio_track": "both",
      "bidirectional": false,
      "bill_duration": 21,
      "billed_amount": "0.00300",
      "call_uuid": "816e0b22-6913-4b43-88a9-6d3054b77df9",
      "created_at": "2023-06-26 02:44:50.617032+00:00",
      "end_time": "2023-06-26 08:14:50+05:30",
      "plivo_auth_id": "MAY2RJNZKZNJMWOXXXX",
      "resource_uri": "/v1/Account/MAY2RJNZKZNJMWOXXXX/Call/816e0b22-6913-4b43-88a9-6d3054b77df9/Stream/4543157e-60d3-4c3a-b9d8-189c47686bf0/",
      "rounded_bill_duration": 60,
      "service_url": "ws://13.127.140.35:19088/ws",
      "start_time": "2023-06-26 08:14:29+05:30",
      "stream_id": "4543157e-60d3-4c3a-b9d8-189c47686bf0"
    }
  ]
}