Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bandwidth/models/bxml/verbs/start_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
class StartStream(NestableVerb):

def __init__(
self, destination: str, stream_params: List[StreamParam] = [],
self, destination: str, destination_username: str,
destination_password: str, stream_params: List[StreamParam] = [],
name: str=None, mode: str=None, tracks: str=None,
stream_event_url: str=None,
stream_event_method: str=None,
Expand All @@ -27,6 +28,8 @@ def __init__(
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.
tracks (str, optional): The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
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.
destination_username (str, optional): The username to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
destination_password (str, optional): The password to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
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.
stream_event_method (str, optional): The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST.
username (str, optional): The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
Expand All @@ -37,6 +40,8 @@ def __init__(

"""
self.destination = destination
self.destination_username = destination_username
self.destination_password = destination_password
self.stream_params = stream_params
self.name = name
self.mode = mode
Expand All @@ -54,6 +59,8 @@ def __init__(
def _attributes(self):
return {
"destination": self.destination,
"destination_username": self.destination_username,
"destination_password": self.destination_password,
"name": self.name,
"mode": self.mode,
"tracks": self.tracks,
Expand Down
6 changes: 4 additions & 2 deletions test/unit/models/bxml/test_start_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def setUp(self):
mode = "bidirectional",
tracks = "inbound",
destination = "testurl.com",
destination_username = "dest_user",
destination_password = "dest_pass",
stream_event_url="eventurl.com",
stream_event_method= "POST",
username = "user",
Expand All @@ -41,10 +43,10 @@ def test_instance(self):
assert isinstance(self.start_stream, Verb)

def test_to_bxml(self):
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>'
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>'
assert expected == self.start_stream.to_bxml()

def test_add_verb(self):
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>'
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>'
self.start_stream.add_verb(self.stream_param2)
assert expected == self.start_stream.to_bxml()