Skip to content

Commit 2644730

Browse files
authored
SWI-7428 Add mode attribute to StartStream (#243)
* SWI-7428 Add `mode` attribute to `StartStream` * str instead of enum to remain conssitent
1 parent 1ed3484 commit 2644730

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

bandwidth/models/bxml/verbs/start_stream.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ class StartStream(NestableVerb):
1515

1616
def __init__(
1717
self, destination: str, stream_params: List[StreamParam] = [],
18-
name: str=None, tracks: str=None,
18+
name: str=None, mode: str=None, tracks: str=None,
1919
stream_event_url: str=None,
2020
stream_event_method: str=None,
2121
username: str=None, password: str=None,
2222
):
23-
"""Initialize a <Transfer> verb
23+
"""Initialize a <StartStream> verb
2424
2525
Args:
2626
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.
27+
mode (str, optional): The mode to use for the stream. unidirectional or bidirectional. Specifies whether the audio being streamed over the WebSocket is bidirectional (the service can both read and write audio over the WebSocket) or unidirectional (one-way, read-only). Default is unidirectional.
2728
tracks (str, optional): The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
2829
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.
2930
stream_event_url (str, optional): URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL.
@@ -38,6 +39,7 @@ def __init__(
3839
self.destination = destination
3940
self.stream_params = stream_params
4041
self.name = name
42+
self.mode = mode
4143
self.tracks = tracks
4244
self.stream_event_url = stream_event_url
4345
self.stream_event_method = stream_event_method
@@ -53,6 +55,7 @@ def _attributes(self):
5355
return {
5456
"destination": self.destination,
5557
"name": self.name,
58+
"mode": self.mode,
5659
"tracks": self.tracks,
5760
"streamEventUrl": self.stream_event_url,
5861
"streamEventMethod": self.stream_event_method,

test/unit/models/bxml/test_start_stream.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def setUp(self):
2626
self.start_stream = StartStream(
2727
stream_params=[self.stream_param1],
2828
name = "stream1",
29+
mode = "bidirectional",
2930
tracks = "inbound",
3031
destination = "testurl.com",
3132
stream_event_url="eventurl.com",
@@ -40,10 +41,10 @@ def test_instance(self):
4041
assert isinstance(self.start_stream, Verb)
4142

4243
def test_to_bxml(self):
43-
expected = '<StartStream destination="testurl.com" name="stream1" tracks="inbound" streamEventUrl="eventurl.com" streamEventMethod="POST" username="user" password="pass"><StreamParam name="name1" value="value1" /></StartStream>'
44+
expected = '<StartStream destination="testurl.com" name="stream1" mode="bidirectional" tracks="inbound" streamEventUrl="eventurl.com" streamEventMethod="POST" username="user" password="pass"><StreamParam name="name1" value="value1" /></StartStream>'
4445
assert expected == self.start_stream.to_bxml()
4546

4647
def test_add_verb(self):
47-
expected = '<StartStream destination="testurl.com" name="stream1" tracks="inbound" streamEventUrl="eventurl.com" streamEventMethod="POST" username="user" password="pass"><StreamParam name="name1" value="value1" /><StreamParam name="name2" value="value2" /></StartStream>'
48+
expected = '<StartStream destination="testurl.com" name="stream1" mode="bidirectional" tracks="inbound" streamEventUrl="eventurl.com" streamEventMethod="POST" username="user" password="pass"><StreamParam name="name1" value="value1" /><StreamParam name="name2" value="value2" /></StartStream>'
4849
self.start_stream.add_verb(self.stream_param2)
4950
assert expected == self.start_stream.to_bxml()

0 commit comments

Comments
 (0)