Skip to content

Commit 049754e

Browse files
authored
SWI-7430 Add mode to StartStream Verb (#181)
1 parent 188d819 commit 049754e

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

src/main/java/com/bandwidth/sdk/model/bxml/StartStream.java

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,43 @@
3333
@EqualsAndHashCode
3434
/**
3535
*
36-
* @param name (str, optional): A name to refer to this stream by. Used when sending <StopStream>. If not provided, it will default to the generated stream id as sent in the Media Stream Started webhook.
37-
* @param tracks (str, optional): The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
38-
* @param destination (str, optional): A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL as base64-encoded PCMU/G711 audio. See below for more details on the websocket packet format.
39-
* @param streamEventUrl (str, optional): URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL.
40-
* @param streamEventMethod (str, optional): The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST.
41-
* @param username (str, optional): The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
42-
* @param password (str, optional): The password to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
36+
* @param name (str, optional): A name to refer to this stream by.
37+
* Used when sending <StopStream>. If not provided, it
38+
* will default to the generated stream id as sent in
39+
* the Media Stream Started webhook.
40+
* @param mode (str, optional): The mode to use for the stream.
41+
* unidirectional or bidirectional. Specifies whether
42+
* the audio being streamed over the WebSocket is
43+
* bidirectional (the service can both read and write
44+
* audio over the WebSocket) or unidirectional
45+
* (one-way, read-only). Default is unidirectional.
46+
* @param tracks (str, optional): The part of the call to send a
47+
* stream from. inbound, outbound or both. Default is
48+
* inbound.
49+
* @param destination (str, optional): A websocket URI to send the stream
50+
* to. The audio from the specified tracks will be sent
51+
* via websocket to this URL as base64-encoded
52+
* PCMU/G711 audio. See below for more details on the
53+
* websocket packet format.
54+
* @param streamEventUrl (str, optional): URL to send the associated Webhook
55+
* events to during this stream's lifetime. Does not
56+
* accept BXML. May be a relative URL.
57+
* @param streamEventMethod (str, optional): The HTTP method to use for the
58+
* request to streamEventUrl. GET or POST. Default
59+
* value is POST.
60+
* @param username (str, optional): The username to send in the HTTP
61+
* request to streamEventUrl. If specified, the URLs
62+
* must be TLS-encrypted (i.e., https).
63+
* @param password (str, optional): The password to send in the HTTP
64+
* request to streamEventUrl. If specified, the URLs
65+
* must be TLS-encrypted (i.e., https).
4366
*
44-
* Nested Verbs:
45-
* @param StreamParam: (optional) You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag.
46-
* These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started.
67+
* Nested Verbs:
68+
* @param StreamParam: (optional) You may specify up to 12 <StreamParam/>
69+
* elements nested within a <StartStream> tag.
70+
* These elements define optional user specified
71+
* parameters that will be sent to the destination URL
72+
* when the stream is first started.
4773
*
4874
*/
4975
public class StartStream implements Verb {
@@ -53,6 +79,9 @@ public class StartStream implements Verb {
5379
@XmlAttribute
5480
protected String name;
5581

82+
@XmlAttribute
83+
protected String mode;
84+
5685
@XmlAttribute
5786
@Default
5887
protected CallDirectionEnum tracks = CallDirectionEnum.INBOUND;

src/test/java/com/bandwidth/sdk/unit/models/bxml/StartStreamVerbTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class StartStreamVerbTest {
3737
.build();
3838
StartStream startStream = StartStream.builder()
3939
.name("stream1")
40+
.mode("unidirectional")
4041
.tracks(CallDirectionEnum.INBOUND)
4142
.destination("testurl.com")
4243
.streamEventUrl("eventurl.com")
@@ -49,7 +50,7 @@ public class StartStreamVerbTest {
4950
@Test
5051
public void startStreamVerbWorks() throws JAXBException {
5152
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
52-
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><StartStream name=\"stream1\" tracks=\"INBOUND\" destination=\"testurl.com\" streamEventUrl=\"eventurl.com\" streamEventMethod=\"POST\" username=\"user\" password=\"pass\"><StreamParam name=\"name1\" value=\"value1\"/><StreamParam name=\"name2\" value=\"value2\"/></StartStream></Bxml>";
53+
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><StartStream name=\"stream1\" mode=\"unidirectional\" tracks=\"INBOUND\" destination=\"testurl.com\" streamEventUrl=\"eventurl.com\" streamEventMethod=\"POST\" username=\"user\" password=\"pass\"><StreamParam name=\"name1\" value=\"value1\"/><StreamParam name=\"name2\" value=\"value2\"/></StartStream></Bxml>";
5354

5455
assertThat(new Bxml().with(startStream).toBxml(jaxbContext), is(expectedBxml));
5556
}

0 commit comments

Comments
 (0)