Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVX-5446 Making amendments to force mute feature to disable mute state #237

Merged
merged 11 commits into from
Jan 28, 2022
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
31 changes: 25 additions & 6 deletions lib/opentok/streams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,43 @@ def force_mute(session_id, stream_id)
response = @client.force_mute_stream(session_id, stream_id)
end

# Force all streams connected to an OpenTok session to mute themselves.
# Force all streams connected to an OpenTok session (except for an optional list of streams),
# to mute published audio.
#
# In addition to existing streams, any streams that are published after the call to
# this method are published with audio muted. You can remove the mute state of a session
# by calling the disable_force_mute() method.
#
# @param [String] session_id The session ID of the OpenTok session.
# @param [String] session_id The session ID.
# @param [Hash] opts An optional hash defining options for muting action. For example:
# @option opts [true, false] :active Whether streams published after this call, in
# addition to the current streams in the session, should be muted (true) or not (false).
# @option opts [Array] :excluded_streams The stream IDs for streams that should not be muted.
# This is an optional property. If you omit this property, all streams in the session will be muted.
#
# @example
# {
# "active": true,
# "excluded_streams": [
# "excluded_streams" => [
# "excludedStreamId1",
# "excludedStreamId2"
# ]
# }
#
def force_mute_all(session_id, opts = {})
opts['active'] = 'true'
response = @client.force_mute_session(session_id, opts)
end

# Disables the active mute state of the session. After you call this method, new streams
# published to the session will no longer have audio muted.
#
# After you call the force_mute_all() method, any streams published after
# the call are published with audio muted. Call the disable_force_mute() method
# to remove the mute state of a session, so that new published streams are not
# automatically muted.
#
# @param [String] session_id The session ID.
#
def disable_force_mute(session_id)
opts = {'active' => 'false'}
response = @client.force_mute_session(session_id, opts)
end

Expand Down
1 change: 1 addition & 0 deletions lib/opentok/token_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "base64"
require "addressable/uri"
require "openssl"
require "active_support"
require "active_support/time"

module OpenTok
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions spec/opentok/streams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@
expect(response.code).to eq(200)
end

it "forces all streams in a session to be muted", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
it "forces all current and future streams in a session to be muted", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
response = streams.force_mute_all(session_id)
expect(response.code).to eq(200)
end

it "forces all current streams in a session and future streams joining the session to be muted", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
response = streams.force_mute_all(session_id, { "active" => "true" })
it "forces all current and future streams in a session to be muted except for the specified excluded streams", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
response = streams.force_mute_all(session_id, { "excludedStreams" => ["b1963d15-537f-459a-be89-e00fc310b82b"] })
expect(response.code).to eq(200)
end

it "forces all current streams in a session to be muted except for the specified excluded streams", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
response = streams.force_mute_all(session_id, { "excludedStreams" => ["b1963d15-537f-459a-be89-e00fc310b82b"] })
it "disables the 'mute state' of a session", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
response = streams.disable_force_mute(session_id)
expect(response.code).to eq(200)
end
end