Class: WebRTC::RTCIceCandidate
- Inherits:
-
Object
- Object
- WebRTC::RTCIceCandidate
- Defined in:
- lib/webrtc/ice_candidate.rb
Instance Attribute Summary collapse
-
#candidate ⇒ Object
readonly
Returns the value of attribute candidate.
-
#sdp_m_line_index ⇒ Object
readonly
Returns the value of attribute sdp_m_line_index.
-
#sdp_mid ⇒ Object
readonly
Returns the value of attribute sdp_mid.
-
#username_fragment ⇒ Object
readonly
Returns the value of attribute username_fragment.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(init = {}) ⇒ RTCIceCandidate
constructor
A new instance of RTCIceCandidate.
- #release ⇒ Object
- #to_h ⇒ Object
- #to_ptr ⇒ Object
Constructor Details
#initialize(init = {}) ⇒ RTCIceCandidate
Returns a new instance of RTCIceCandidate.
7 8 9 10 11 12 13 14 |
# File 'lib/webrtc/ice_candidate.rb', line 7 def initialize(init = {}) init = init.to_h if init.respond_to?(:to_h) @candidate = init[:candidate] || '' @sdp_mid = init[:sdp_mid] || init[:sdpMid] @sdp_m_line_index = init[:sdp_m_line_index] || init[:sdpMLineIndex] @username_fragment = init[:username_fragment] || init[:usernameFragment] @ptr = nil end |
Instance Attribute Details
#candidate ⇒ Object (readonly)
Returns the value of attribute candidate.
5 6 7 |
# File 'lib/webrtc/ice_candidate.rb', line 5 def candidate @candidate end |
#sdp_m_line_index ⇒ Object (readonly)
Returns the value of attribute sdp_m_line_index.
5 6 7 |
# File 'lib/webrtc/ice_candidate.rb', line 5 def sdp_m_line_index @sdp_m_line_index end |
#sdp_mid ⇒ Object (readonly)
Returns the value of attribute sdp_mid.
5 6 7 |
# File 'lib/webrtc/ice_candidate.rb', line 5 def sdp_mid @sdp_mid end |
#username_fragment ⇒ Object (readonly)
Returns the value of attribute username_fragment.
5 6 7 |
# File 'lib/webrtc/ice_candidate.rb', line 5 def username_fragment @username_fragment end |
Class Method Details
.from_ptr(ptr) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/webrtc/ice_candidate.rb', line 16 def self.from_ptr(ptr) return nil if ptr.nil? || ptr.null? candidate_str = FFI.webrtc_ice_candidate_get_candidate(ptr) sdp_mid_str = FFI.webrtc_ice_candidate_get_sdp_mid(ptr) sdp_m_line_index = FFI.webrtc_ice_candidate_get_sdp_mline_index(ptr) ice = new( candidate: candidate_str, sdp_mid: sdp_mid_str, sdp_m_line_index: sdp_m_line_index ) ice.instance_variable_set(:@ptr, ptr) ice end |
Instance Method Details
#release ⇒ Object
56 57 58 59 60 61 |
# File 'lib/webrtc/ice_candidate.rb', line 56 def release return unless @ptr && !@ptr.null? FFI.webrtc_ice_candidate_destroy(@ptr) @ptr = nil end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/webrtc/ice_candidate.rb', line 47 def to_h { candidate: candidate, sdpMid: sdp_mid, sdpMLineIndex: sdp_m_line_index, usernameFragment: username_fragment } end |
#to_ptr ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/webrtc/ice_candidate.rb', line 32 def to_ptr return @ptr if @ptr && !@ptr.null? error = FFI::Error.new @ptr = FFI.webrtc_ice_candidate_create( candidate, sdp_mid, sdp_m_line_index || 0, error ) raise OperationError, error[:message] if error[:code] != 0 @ptr end |