Class: WebRTC::RTCIceTransport

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

Constant Summary collapse

STATES =
%i[new checking connected completed failed disconnected closed].freeze
GATHERING_STATES =
%i[new gathering complete].freeze
ROLES =
%i[controlling controlled unknown].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RTCIceTransport

Returns a new instance of RTCIceTransport.



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

def initialize(options = {})
  @state = :new
  @gathering_state = :new
  @role = options[:role] || :unknown
  @component = options[:component] || :rtp
  @local_candidates = []
  @remote_candidates = []
  @local_parameters = nil
  @remote_parameters = nil
  @callbacks = {}
  @ptr = options[:ptr]
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



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

def component
  @component
end

#gathering_stateObject (readonly)

Returns the value of attribute gathering_state.



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

def gathering_state
  @gathering_state
end

#roleObject (readonly)

Returns the value of attribute role.



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

def role
  @role
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

Instance Method Details

#get_local_candidatesObject



24
25
26
# File 'lib/webrtc/ice_transport.rb', line 24

def get_local_candidates
  @local_candidates.dup
end

#get_local_parametersObject



32
33
34
# File 'lib/webrtc/ice_transport.rb', line 32

def get_local_parameters
  @local_parameters
end

#get_remote_candidatesObject



28
29
30
# File 'lib/webrtc/ice_transport.rb', line 28

def get_remote_candidates
  @remote_candidates.dup
end

#get_remote_parametersObject



36
37
38
# File 'lib/webrtc/ice_transport.rb', line 36

def get_remote_parameters
  @remote_parameters
end

#get_selected_candidate_pairObject



40
41
42
43
44
45
46
47
# File 'lib/webrtc/ice_transport.rb', line 40

def get_selected_candidate_pair
  return nil if @local_candidates.empty? || @remote_candidates.empty?

  RTCIceCandidatePair.new(
    local: @local_candidates.first,
    remote: @remote_candidates.first
  )
end

#on_gathering_state_change(&block) ⇒ Object



53
54
55
# File 'lib/webrtc/ice_transport.rb', line 53

def on_gathering_state_change(&block)
  @callbacks[:gathering_state_change] = block
end

#on_selected_candidate_pair_change(&block) ⇒ Object



57
58
59
# File 'lib/webrtc/ice_transport.rb', line 57

def on_selected_candidate_pair_change(&block)
  @callbacks[:selected_candidate_pair_change] = block
end

#on_state_change(&block) ⇒ Object



49
50
51
# File 'lib/webrtc/ice_transport.rb', line 49

def on_state_change(&block)
  @callbacks[:state_change] = block
end