Skip to content

Commit a8ea952

Browse files
authored
SWI-8402 Add New StartStream Attributes (#259)
1 parent 5f83918 commit a8ea952

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

bandwidth/models/bxml/verbs/start_stream.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
class StartStream(NestableVerb):
1515

1616
def __init__(
17-
self, destination: str, stream_params: List[StreamParam] = [],
17+
self, destination: str, destination_username: str,
18+
destination_password: str, stream_params: List[StreamParam] = [],
1819
name: str=None, mode: str=None, tracks: str=None,
1920
stream_event_url: str=None,
2021
stream_event_method: str=None,
@@ -27,6 +28,8 @@ def __init__(
2728
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.
2829
tracks (str, optional): The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
2930
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.
31+
destination_username (str, optional): The username to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
32+
destination_password (str, optional): The password to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
3033
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.
3134
stream_event_method (str, optional): The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST.
3235
username (str, optional): The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
@@ -37,6 +40,8 @@ def __init__(
3740
3841
"""
3942
self.destination = destination
43+
self.destination_username = destination_username
44+
self.destination_password = destination_password
4045
self.stream_params = stream_params
4146
self.name = name
4247
self.mode = mode
@@ -54,6 +59,8 @@ def __init__(
5459
def _attributes(self):
5560
return {
5661
"destination": self.destination,
62+
"destination_username": self.destination_username,
63+
"destination_password": self.destination_password,
5764
"name": self.name,
5865
"mode": self.mode,
5966
"tracks": self.tracks,

test/unit/models/bxml/test_start_stream.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def setUp(self):
2929
mode = "bidirectional",
3030
tracks = "inbound",
3131
destination = "testurl.com",
32+
destination_username = "dest_user",
33+
destination_password = "dest_pass",
3234
stream_event_url="eventurl.com",
3335
stream_event_method= "POST",
3436
username = "user",
@@ -41,10 +43,10 @@ def test_instance(self):
4143
assert isinstance(self.start_stream, Verb)
4244

4345
def test_to_bxml(self):
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>'
46+
expected = '<StartStream destination="testurl.com" destination_username="dest_user" destination_password="dest_pass" name="stream1" mode="bidirectional" tracks="inbound" streamEventUrl="eventurl.com" streamEventMethod="POST" username="user" password="pass"><StreamParam name="name1" value="value1" /></StartStream>'
4547
assert expected == self.start_stream.to_bxml()
4648

4749
def test_add_verb(self):
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>'
50+
expected = '<StartStream destination="testurl.com" destination_username="dest_user" destination_password="dest_pass" 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>'
4951
self.start_stream.add_verb(self.stream_param2)
5052
assert expected == self.start_stream.to_bxml()

0 commit comments

Comments
 (0)