mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Fire negotiationneeded and icecandidate events
This commit is contained in:
parent
5bfa42094e
commit
841dd1eb4b
3 changed files with 56 additions and 6 deletions
|
@ -36,6 +36,7 @@ fullscreenerror
|
|||
gattserverdisconnected
|
||||
hashchange
|
||||
hidden
|
||||
icecandidate
|
||||
image
|
||||
input
|
||||
invalid
|
||||
|
@ -54,6 +55,7 @@ message
|
|||
monospace
|
||||
month
|
||||
mouseover
|
||||
negotiationneeded
|
||||
none
|
||||
number
|
||||
onchange
|
||||
|
|
|
@ -3,15 +3,21 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCConfiguration;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::{
|
||||
self, RTCPeerConnectionMethods,
|
||||
};
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::reflector::DomObject;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::rtcicecandidate::RTCIceCandidate;
|
||||
use crate::dom::rtcpeerconnectioniceevent::RTCPeerConnectionIceEvent;
|
||||
use crate::dom::window::Window;
|
||||
use crate::task::TaskCanceller;
|
||||
use crate::task_source::networking::NetworkingTaskSource;
|
||||
|
@ -109,11 +115,53 @@ impl RTCPeerConnection {
|
|||
})
|
||||
}
|
||||
|
||||
fn on_ice_candidate(&self, _candidate: IceCandidate) {
|
||||
// todo
|
||||
fn on_ice_candidate(&self, candidate: IceCandidate) {
|
||||
if self.closed.get() {
|
||||
return;
|
||||
}
|
||||
let candidate = RTCIceCandidate::new(
|
||||
&self.global(),
|
||||
candidate.candidate.into(),
|
||||
None,
|
||||
Some(candidate.sdp_mline_index as u16),
|
||||
None,
|
||||
);
|
||||
let event = RTCPeerConnectionIceEvent::new(
|
||||
&self.global(),
|
||||
atom!("icecandidate"),
|
||||
Some(&candidate),
|
||||
None,
|
||||
true,
|
||||
);
|
||||
event
|
||||
.upcast::<Event>()
|
||||
.fire(self.upcast());
|
||||
}
|
||||
|
||||
fn on_negotiation_needed(&self) {
|
||||
// todo
|
||||
if self.closed.get() {
|
||||
return;
|
||||
}
|
||||
let event = Event::new(
|
||||
&self.global(),
|
||||
atom!("negotiationneeded"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable,
|
||||
);
|
||||
event
|
||||
.upcast::<Event>()
|
||||
.fire(self.upcast());
|
||||
}
|
||||
}
|
||||
|
||||
impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||
/// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-icecandidate
|
||||
event_handler!(icecandidate, GetOnicecandidate, SetOnicecandidate);
|
||||
|
||||
/// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-onnegotiationneeded
|
||||
event_handler!(
|
||||
negotiationneeded,
|
||||
GetOnnegotiationneeded,
|
||||
SetOnnegotiationneeded
|
||||
);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ interface RTCPeerConnection : EventTarget {
|
|||
// RTCConfiguration getConfiguration();
|
||||
// void setConfiguration(RTCConfiguration configuration);
|
||||
// void close();
|
||||
// attribute EventHandler onnegotiationneeded;
|
||||
// attribute EventHandler onicecandidate;
|
||||
attribute EventHandler onnegotiationneeded;
|
||||
attribute EventHandler onicecandidate;
|
||||
// attribute EventHandler onicecandidateerror;
|
||||
// attribute EventHandler onsignalingstatechange;
|
||||
// attribute EventHandler oniceconnectionstatechange;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue