Class: WebRTC::RTCConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/webrtc/configuration.rb

Constant Summary collapse

ICE_TRANSPORT_POLICIES =
%i[all relay].freeze
BUNDLE_POLICIES =
%i[balanced max_compat max_bundle].freeze
RTCP_MUX_POLICIES =
%i[require].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RTCConfiguration

Returns a new instance of RTCConfiguration.



12
13
14
15
16
17
18
19
20
21
# File 'lib/webrtc/configuration.rb', line 12

def initialize(options = {})
  @ice_servers = normalize_ice_servers(options[:ice_servers] || options[:iceServers] || [])
  @ice_transport_policy = options[:ice_transport_policy] || options[:iceTransportPolicy] || :all
  @bundle_policy = options[:bundle_policy] || options[:bundlePolicy] || :balanced
  @rtcp_mux_policy = options[:rtcp_mux_policy] || options[:rtcpMuxPolicy] || :require
  @certificates = options[:certificates] || []
  @ice_candidate_pool_size = options[:ice_candidate_pool_size] || options[:iceCandidatePoolSize] || 0

  validate!
end

Instance Attribute Details

#bundle_policyObject

Returns the value of attribute bundle_policy.



9
10
11
# File 'lib/webrtc/configuration.rb', line 9

def bundle_policy
  @bundle_policy
end

#certificatesObject

Returns the value of attribute certificates.



9
10
11
# File 'lib/webrtc/configuration.rb', line 9

def certificates
  @certificates
end

#ice_candidate_pool_sizeObject

Returns the value of attribute ice_candidate_pool_size.



9
10
11
# File 'lib/webrtc/configuration.rb', line 9

def ice_candidate_pool_size
  @ice_candidate_pool_size
end

#ice_serversObject

Returns the value of attribute ice_servers.



9
10
11
# File 'lib/webrtc/configuration.rb', line 9

def ice_servers
  @ice_servers
end

#ice_transport_policyObject

Returns the value of attribute ice_transport_policy.



9
10
11
# File 'lib/webrtc/configuration.rb', line 9

def ice_transport_policy
  @ice_transport_policy
end

#rtcp_mux_policyObject

Returns the value of attribute rtcp_mux_policy.



9
10
11
# File 'lib/webrtc/configuration.rb', line 9

def rtcp_mux_policy
  @rtcp_mux_policy
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
31
# File 'lib/webrtc/configuration.rb', line 23

def to_h
  {
    iceServers: @ice_servers.map(&:to_h),
    iceTransportPolicy: @ice_transport_policy,
    bundlePolicy: @bundle_policy,
    rtcpMuxPolicy: @rtcp_mux_policy,
    iceCandidatePoolSize: @ice_candidate_pool_size
  }
end