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
7 changes: 5 additions & 2 deletions bandwidth/models/bxml/verbs/start_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ class StartStream(NestableVerb):

def __init__(
self, destination: str, stream_params: List[StreamParam] = [],
name: str=None, tracks: str=None,
name: str=None, mode: str=None, tracks: str=None,
stream_event_url: str=None,
stream_event_method: str=None,
username: str=None, password: str=None,
):
"""Initialize a <Transfer> verb
"""Initialize a <StartStream> verb

Args:
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.
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.
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.
Expand All @@ -38,6 +39,7 @@ def __init__(
self.destination = destination
self.stream_params = stream_params
self.name = name
self.mode = mode
self.tracks = tracks
self.stream_event_url = stream_event_url
self.stream_event_method = stream_event_method
Expand All @@ -53,6 +55,7 @@ def _attributes(self):
return {
"destination": self.destination,
"name": self.name,
"mode": self.mode,
"tracks": self.tracks,
"streamEventUrl": self.stream_event_url,
"streamEventMethod": self.stream_event_method,
Expand Down
5 changes: 3 additions & 2 deletions test/unit/models/bxml/test_start_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def setUp(self):
self.start_stream = StartStream(
stream_params=[self.stream_param1],
name = "stream1",
mode = "bidirectional",
tracks = "inbound",
destination = "testurl.com",
stream_event_url="eventurl.com",
Expand All @@ -40,10 +41,10 @@ def test_instance(self):
assert isinstance(self.start_stream, Verb)

def test_to_bxml(self):
expected = '<StartStream destination="testurl.com" name="stream1" tracks="inbound" streamEventUrl="eventurl.com" streamEventMethod="POST" username="user" password="pass"><StreamParam name="name1" value="value1" /></StartStream>'
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>'
assert expected == self.start_stream.to_bxml()

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