|
| 1 | + |
| 2 | +package com.bandwidth.voice.bxml.verbs; |
| 3 | + |
| 4 | +import lombok.Builder; |
| 5 | + |
| 6 | +import java.net.URI; |
| 7 | +import javax.xml.bind.annotation.XmlAttribute; |
| 8 | +import javax.xml.bind.annotation.XmlType; |
| 9 | + |
| 10 | +/** |
| 11 | + * The StartStream verb allows a segment of a call to be streamed to an external destination. |
| 12 | + */ |
| 13 | +@Builder |
| 14 | +@XmlType(name = StartStream.TYPE_NAME) |
| 15 | +public class StartStream implements Verb { |
| 16 | + public static final String TYPE_NAME = "StartStream"; |
| 17 | + |
| 18 | + |
| 19 | + /** |
| 20 | + * <i>(optional)</i> A name to refer to this stream by. Used when sending [`<StopStream>`][1]. If not provided, a random name will be generated and sent in the [`Media Stream Started`][2] webook. |
| 21 | + */ |
| 22 | + @XmlAttribute |
| 23 | + private String name; |
| 24 | + |
| 25 | + /** |
| 26 | + * <i>(optional)</i> The part of the call to send a stream from. `inbound`, `outbound` or `both`. Default is `inbound`. |
| 27 | + */ |
| 28 | + @XmlAttribute |
| 29 | + private String tracks; |
| 30 | + |
| 31 | + /** |
| 32 | + * <i>(required)</i> 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. |
| 33 | + */ |
| 34 | + @XmlAttribute |
| 35 | + private URI destination; |
| 36 | + |
| 37 | + /** |
| 38 | + * <i>(optional)</i> URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. |
| 39 | + */ |
| 40 | + @XmlAttribute |
| 41 | + private URI streamEventUrl; |
| 42 | + |
| 43 | + /** |
| 44 | + * <i>(optional)</i> The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST. |
| 45 | + */ |
| 46 | + @XmlAttribute |
| 47 | + private Method streamEventMethod; |
| 48 | + |
| 49 | + /** |
| 50 | + * <i>(optional)</i> The username to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). |
| 51 | + */ |
| 52 | + @XmlAttribute |
| 53 | + protected String username; |
| 54 | + |
| 55 | + /** |
| 56 | + * <i>(optional)</i> The password to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). |
| 57 | + */ |
| 58 | + @XmlAttribute |
| 59 | + protected String password; |
| 60 | + |
| 61 | + |
| 62 | + public static class StartStreamBuilder { |
| 63 | + |
| 64 | + /** |
| 65 | + * <b>(optional)</b> URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. |
| 66 | + */ |
| 67 | + public StartStreamBuilder streamEventUrl(URI uri ){ |
| 68 | + this.streamEventUrl = uri; |
| 69 | + return this; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * <b>(optional)</b> URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. |
| 74 | + */ |
| 75 | + public StartStreamBuilder streamEventUrl(String uri ){ |
| 76 | + return streamEventUrl(URI.create(uri)); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * <b>(required)</b> 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. |
| 81 | + */ |
| 82 | + public StartStreamBuilder destination(URI uri ){ |
| 83 | + this.destination = uri; |
| 84 | + return this; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * <b>(optional)</b> 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. |
| 89 | + */ |
| 90 | + public StartStreamBuilder destination(String uri ){ |
| 91 | + return destination(URI.create(uri)); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * <i>(optional)</i> The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST. |
| 96 | + */ |
| 97 | + public StartStreamBuilder streamEventMethod(Method method){ |
| 98 | + this.streamEventMethod = method; |
| 99 | + return this; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * <i>(optional)</i> The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST. |
| 104 | + */ |
| 105 | + public StartStreamBuilder streamEventMethod(String method){ |
| 106 | + return streamEventMethod(Method.fromValue(method)); |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | +} |
0 commit comments