Skip to content

Commit 4549659

Browse files
committed
DX-2701 Add <StartStream> and <StopStream> BXML Verbs
1 parent b91c19d commit 4549659

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require_relative 'xml_verb'
2+
3+
module Bandwidth
4+
module Voice
5+
# The StartStream verb allows a segment of a call to be sent off to another destination for additional processing
6+
class StartStream
7+
include XmlVerb
8+
9+
def to_bxml(xml)
10+
xml.PlayAudio(compact_hash({
11+
'destination' => destination,
12+
'name' => name,
13+
'streamEventUrl' => streamEventUrl,
14+
'streamEventMethod' => streamEventMethod,
15+
'username' => username,
16+
'password' => password
17+
}))
18+
end
19+
end
20+
end
21+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require_relative 'xml_verb'
2+
3+
module Bandwidth
4+
module Voice
5+
# The StopStream verb is used to stop a stream that was started with a previous `<StartStream>` verb
6+
class StopStream
7+
include XmlVerb
8+
9+
def to_bxml(xml)
10+
xml.PlayAudio(compact_hash({
11+
'name' => name
12+
}))
13+
end
14+
end
15+
end
16+
end

test/integration/test_integration.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,4 +688,28 @@ def test_webrtc_generate_transfer_bxml_verb
688688
actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
689689
assert_equal(expected, actual)
690690
end
691+
692+
def test_start_and_stop_stream_bxml_verbs
693+
start_stream_expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartStream destination="https://www/test/com/stream" name="test_stream" streamEventUrl="https://www.test.com/event" streamEventMethod="POST" username="username" password="password"/></Response>'
694+
start_stream_response = Bandwidth::Voice::Response.new()
695+
start_stream = Bandwidth::Voice::StartStream.new({
696+
:destination => "https://www/test/com/stream",
697+
:name => "test_stream",
698+
:streamEventUrl => "https://www/test/com/event",
699+
:streamEventMethod => "POST",
700+
:username => "username",
701+
:password => "password"
702+
})
703+
start_stream_response.push(start_stream)
704+
705+
stop_stream_expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopStream name="test_stream"/></Response>'
706+
stop_stream_response = Bandwidth::Voice::Response.new()
707+
stop_stream = Bandwidth::Voice::StopStream.new({
708+
:name => "test_stream"
709+
})
710+
stop_stream_response.push(stop_stream)
711+
712+
assert_equal(start_stream_expected, start_stream_response.to_bxml())
713+
assert_equal(stop_stream_expected, stop_stream_response.to_bxml())
714+
end
691715
end

0 commit comments

Comments
 (0)