All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bandwidth.voice.bxml.verbs.StartStream Maven / Gradle / Ivy


package com.bandwidth.voice.bxml.verbs;

import lombok.Builder;

import java.net.URI;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

/**
 * 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";


    /**
     * (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));
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy