com.bandwidth.voice.bxml.verbs.StartStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bandwidth-sdk Show documentation
Show all versions of bandwidth-sdk Show documentation
The official client SDK for Bandwidth's Voice, Messaging, MFA, and WebRTC APIs
package com.bandwidth.voice.bxml.verbs;
import lombok.Builder;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
/**
* The StartStream verb allows a segment of a call to be streamed to an external destination.
*/
@Builder
@XmlType(name = StartStream.TYPE_NAME)
public class StartStream implements Verb {
public static final String TYPE_NAME = "StartStream";
/**
* You may specify up to 12 elements nested within a tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
*/
@XmlElement(name = StreamParam.TYPE_NAME)
private final List streamParams;
/**
* (optional) A name to refer to this stream by. Used when sending [``][1]. If not provided, a random name will be generated and sent in the [`Media Stream Started`][2] webook.
*/
@XmlAttribute
private String name;
/**
* (optional) The part of the call to send a stream from. `inbound`, `outbound` or `both`. Default is `inbound`.
*/
@XmlAttribute
private String tracks;
/**
* (required) A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL encoded as base64 encoded PCMU/G711 audio. See below for more details on the websocket packet format.
*/
@XmlAttribute
private URI destination;
/**
* (optional) URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL.
*/
@XmlAttribute
private URI streamEventUrl;
/**
* (optional) The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST.
*/
@XmlAttribute
private Method streamEventMethod;
/**
* (optional) The username to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`).
*/
@XmlAttribute
protected String username;
/**
* (optional) The password to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`).
*/
@XmlAttribute
protected String password;
public static class StartStreamBuilder {
/**
* (optional) URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL.
*/
public StartStreamBuilder streamEventUrl(URI uri ){
this.streamEventUrl = uri;
return this;
}
/**
* (optional) URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL.
*/
public StartStreamBuilder streamEventUrl(String uri ){
return streamEventUrl(URI.create(uri));
}
/**
* (required) A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL encoded as base64 encoded PCMU/G711 audio. See below for more details on the websocket packet format.
*/
public StartStreamBuilder destination(URI uri ){
this.destination = uri;
return this;
}
/**
* (optional) A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL encoded as base64 encoded PCMU/G711 audio. See below for more details on the websocket packet format.
*/
public StartStreamBuilder destination(String uri ){
return destination(URI.create(uri));
}
/**
* (optional) The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST.
*/
public StartStreamBuilder streamEventMethod(Method method){
this.streamEventMethod = method;
return this;
}
/**
* (optional) The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST.
*/
public StartStreamBuilder streamEventMethod(String method){
return streamEventMethod(Method.fromValue(method));
}
/**
* (optional) You may specify up to 12 elements nested within a tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
*/
public StartStreamBuilder streamParams(StreamParam ... streamParams){
this.streamParams = Arrays.asList(streamParams);
return this;
}
/**
* (optional) You may specify up to 12 elements nested within a tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
*/
public StartStreamBuilder streamParams(List streamParams){
this.streamParams = streamParams;
return this;
}
}
}