Audio Stream
Initiate an audio Stream
This method lets you initiate an audio stream for an active call and send that stream to a secure WebSocket URL.
API Endpoint
POST
Attributes
Attributes | Description |
---|---|
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.