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
18 changes: 10 additions & 8 deletions lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ def initialize(stream_params = [], attributes = {})
super('StartStream', nil, stream_params, attributes)

@attribute_map = {
name: 'name', # Optional [String]: 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: 'mode', # Optional [String]: 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: 'tracks', # Optional [String]: The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
destination: 'destination', # Optional [String]: 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.
stream_event_url: 'streamEventUrl', # Optional [String]: 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: 'streamEventMethod', # Optional [String]: The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST.
username: 'username', # Optional [String]: The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
password: 'password', # Optional [String]: The password to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
name: 'name', # Optional [String]: 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: 'mode', # Optional [String]: 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: 'tracks', # Optional [String]: The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
destination: 'destination', # Optional [String]: 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.
destination_username: 'destination_username', # Optional [String]: The username to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
destination_password: 'destination_password', # Optional [String]: The password to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
stream_event_url: 'streamEventUrl', # Optional [String]: 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: 'streamEventMethod', # Optional [String]: The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST.
username: 'username', # Optional [String]: The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
password: 'password', # Optional [String]: The password to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
}
end

Expand Down
14 changes: 9 additions & 5 deletions spec/unit/models/bxml/verbs/start_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
mode: 'unidirectional',
tracks: 'inbound',
destination: 'https://initial.com',
destination_username: 'initial_destination_username',
destination_password: 'initial_destination_password',
stream_event_url: 'https://initial.com',
stream_event_method: 'POST',
username: 'initial_username',
Expand All @@ -19,6 +21,8 @@
mode: 'bidirectional',
tracks: 'outbound',
destination: 'https://new.com',
destination_username: 'new_destination_username',
destination_password: 'new_destination_password',
stream_event_url: 'https://new.com',
stream_event_method: 'GET',
username: 'new_username',
Expand All @@ -39,13 +43,13 @@
end

it 'tests the to_bxml method of the StartStream instance' do
expected = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\"/>\n"
expected = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\"/>\n"
expect(instance.to_bxml).to eq(expected)
end

it 'tests the set_attributes method of the StartStream instance' do
instance.set_attributes(new_attributes)
expected = "\n<StartStream name=\"new_name\" mode=\"bidirectional\" tracks=\"outbound\" destination=\"https://new.com\" streamEventUrl=\"https://new.com\" streamEventMethod=\"GET\" username=\"new_username\" password=\"new_password\"/>\n"
expected = "\n<StartStream name=\"new_name\" mode=\"bidirectional\" tracks=\"outbound\" destination=\"https://new.com\" destination_username=\"new_destination_username\" destination_password=\"new_destination_password\" streamEventUrl=\"https://new.com\" streamEventMethod=\"GET\" username=\"new_username\" password=\"new_password\"/>\n"
expect(instance.to_bxml).to eq(expected)
end
end
Expand All @@ -57,16 +61,16 @@
end

it 'tests the to_bxml method of the nested StartStream instance' do
expected = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n</StartStream>\n"
expected = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n</StartStream>\n"
expect(instance_nested.to_bxml).to eq(expected)
end

it 'tests the add_stream_param method of the nested StartStream instance' do
expected_single = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
expected_single = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
instance_nested.add_stream_params(stream_param_2)
expect(instance_nested.to_bxml).to eq(expected_single)

expected_multiple = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
expected_multiple = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
instance_nested.add_stream_params([stream_param_2, stream_param_2])
expect(instance_nested.to_bxml).to eq(expected_multiple)
end
Expand Down