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
14 changes: 12 additions & 2 deletions bandwidth/tests/test_bxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,27 @@ def test_generate_transfer_bxml_verb(self):
assert actual == expected

def test_start_stream_bxml_verb(self):
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartStream destination="https://www.test.com/stream" name="test_stream" tracks="inbound" streamEventUrl="https://www.test.com/event" streamEventMethod="POST" username="username" password="password"/></Response>'
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartStream destination="https://www.test.com/stream" name="test_stream" tracks="inbound" streamEventUrl="https://www.test.com/event" streamEventMethod="POST" username="username" password="password"><StreamParam name="name1" value="value1"/><StreamParam name="name2" value="value2"/></StartStream></Response>'
response = Response()
stream_param_1 = StreamParam(
name="name1",
value="value1"
)
stream_param_2 = StreamParam(
name="name2",
value="value2"
)
start_stream = StartStream(
destination='https://www.test.com/stream',
name='test_stream',
tracks='inbound',
streamEventUrl='https://www.test.com/event',
streamEventMethod='POST',
username='username',
password='password'
password='password',
streamParams=[stream_param_1, stream_param_2]
)

response.add_verb(start_stream)
actual = response.to_bxml()

Expand Down
1 change: 1 addition & 0 deletions bandwidth/voice/bxml/verbs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
from .tag import Tag
from .sip_uri import SipUri
from .start_stream import StartStream
from .stream_param import StreamParam
from .stop_stream import StopStream
8 changes: 6 additions & 2 deletions bandwidth/voice/bxml/verbs/start_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

class StartStream(AbstractBxmlVerb):

def __init__(self, destination, name=None, tracks=None, streamEventUrl=None, streamEventMethod=None, username=None, password=None):
def __init__(self, destination, name=None, tracks=None, streamEventUrl=None, streamEventMethod=None, username=None, password=None, streamParams=None):
"""
Initializes the PlayAudio class with the following parameters
Initializes the StartStream class with the following parameters

:param str destination: A websocket URI to send the stream to
:param str name: A name to refer to this stream by
Expand All @@ -34,6 +34,7 @@ def __init__(self, destination, name=None, tracks=None, streamEventUrl=None, str
self.streamEventMethod = streamEventMethod
self.username = username
self.password = password
self.stream_params = streamParams

def to_etree_element(self):
"""
Expand All @@ -55,6 +56,9 @@ def to_etree_element(self):
root.set("username", self.username)
if self.password is not None:
root.set("password", self.password)
if self.stream_params is not None:
for stream_param in self.stream_params:
root.append(stream_param.to_etree_element())
return root

def to_bxml(self):
Expand Down
2 changes: 1 addition & 1 deletion bandwidth/voice/bxml/verbs/stop_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class StopStream(AbstractBxmlVerb):

def __init__(self, name):
"""
Initializes the PlayAudio class with the following parameters
Initializes the StopStream class with the following parameters

:param str name: The name of the stream to stop
"""
Expand Down
40 changes: 40 additions & 0 deletions bandwidth/voice/bxml/verbs/stream_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
start_stream.py

Representation of Bandwidth's start stream BXML verb

@copyright Bandwidth INC
"""

from lxml import etree

from .base_verb import AbstractBxmlVerb

STREAM_PARAM_TAG = "StreamParam"


class StreamParam(AbstractBxmlVerb):

def __init__(self, name, value):
"""
Initializes the StreamParam class with the following parameters

:param str name: The name of this parameter, up to 256 characters.
:param str value: The value of this parameter, up to 2048 characters.
"""
self.name = name
self.value = value

def to_etree_element(self):
"""
Converts the class into an etree element. Used for other verb classes to build xml

:return etree.Element: The etree Element representing this class
"""
root = etree.Element(STREAM_PARAM_TAG)
root.set("name", self.name)
root.set("value", self.value)
return root

def to_bxml(self):
return etree.tostring(self.to_etree_element()).decode()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='bandwidth-sdk',
version='14.1.0',
version='14.2.0',
description='Bandwidth\'s set of APIs',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down