RtcPeerConnection#
Annotations: @SupportedBrowser.new(SupportedBrowser.CHROME), @Native.new("RTCPeerConnection,webkitRTCPeerConnection,mozRTCPeerConnection")
Inheritance
Object → EventTarget → RtcPeerConnection
Constructors#
RtcPeerConnection() factory#
Implementation
factory RtcPeerConnection(Map rtcIceServers, [Map? mediaConstraints]) {
var constructorName = JS(
'RtcPeerConnection',
'window[#]',
'RTCPeerConnection',
);
if (mediaConstraints != null) {
return JS(
'RtcPeerConnection',
'new #(#,#)',
constructorName,
convertDartToNative_SerializedScriptValue(rtcIceServers),
convertDartToNative_SerializedScriptValue(mediaConstraints),
);
} else {
return JS(
'RtcPeerConnection',
'new #(#)',
constructorName,
convertDartToNative_SerializedScriptValue(rtcIceServers),
);
}
}
Properties#
connectionState no setter#
Implementation
String? get connectionState native;
hashCode no setter inherited#
Inherited from Interceptor.
Implementation
int get hashCode => Primitives.objectHashCode(this);
iceConnectionState no setter#
Implementation
String? get iceConnectionState native;
iceGatheringState no setter#
Implementation
String? get iceGatheringState native;
localDescription no setter#
Implementation
RtcSessionDescription? get localDescription native;
on no setter inherited#
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
Inherited from EventTarget.
Implementation
Events get on => new Events(this);
onAddStream no setter#
Stream of addstream events handled by this RtcPeerConnection.
Implementation
Stream<MediaStreamEvent> get onAddStream => addStreamEvent.forTarget(this);
onConnectionStateChange no setter#
Stream of connectionstatechange events handled by this RtcPeerConnection.
Implementation
Stream<Event> get onConnectionStateChange =>
connectionStateChangeEvent.forTarget(this);
onDataChannel no setter#
Stream of datachannel events handled by this RtcPeerConnection.
Implementation
Stream<RtcDataChannelEvent> get onDataChannel =>
dataChannelEvent.forTarget(this);
onIceCandidate no setter#
Stream of icecandidate events handled by this RtcPeerConnection.
Implementation
Stream<RtcPeerConnectionIceEvent> get onIceCandidate =>
iceCandidateEvent.forTarget(this);
onIceConnectionStateChange no setter#
Stream of iceconnectionstatechange events handled by this RtcPeerConnection.
Implementation
Stream<Event> get onIceConnectionStateChange =>
iceConnectionStateChangeEvent.forTarget(this);
onNegotiationNeeded no setter#
Stream of negotiationneeded events handled by this RtcPeerConnection.
Implementation
Stream<Event> get onNegotiationNeeded =>
negotiationNeededEvent.forTarget(this);
onRemoveStream no setter#
Stream of removestream events handled by this RtcPeerConnection.
Implementation
Stream<MediaStreamEvent> get onRemoveStream =>
removeStreamEvent.forTarget(this);
onSignalingStateChange no setter#
Stream of signalingstatechange events handled by this RtcPeerConnection.
Implementation
Stream<Event> get onSignalingStateChange =>
signalingStateChangeEvent.forTarget(this);
onTrack no setter#
Stream of track events handled by this RtcPeerConnection.
Implementation
Stream<RtcTrackEvent> get onTrack => trackEvent.forTarget(this);
remoteDescription no setter#
Implementation
RtcSessionDescription? get remoteDescription native;
runtimeType no setter inherited#
Inherited from Interceptor.
Implementation
Type get runtimeType =>
getRuntimeTypeOfInterceptorNotArray(getInterceptor(this), this);
signalingState no setter#
Implementation
String? get signalingState native;
Methods#
addEventListener() inherited#
Inherited from EventTarget.
Implementation
void addEventListener(
String type,
EventListener? listener, [
bool? useCapture,
]) {
// TODO(leafp): This check is avoid a bug in our dispatch code when
// listener is null. The browser treats this call as a no-op in this
// case, so it's fine to short-circuit it, but we should not have to.
if (listener != null) {
_addEventListener(type, listener, useCapture);
}
}
addIceCandidate()#
Implementation
Future addIceCandidate(
Object candidate, [
VoidCallback? successCallback,
RtcPeerConnectionErrorCallback? failureCallback,
]) => promiseToFuture(
JS(
"",
"#.addIceCandidate(#, #, #)",
this,
candidate,
successCallback,
failureCallback,
),
);
addStream()#
Implementation
void addStream(MediaStream? stream, [Map? mediaConstraints]) {
if (mediaConstraints != null) {
var mediaConstraints_1 = convertDartToNative_Dictionary(mediaConstraints);
_addStream_1(stream, mediaConstraints_1);
return;
}
_addStream_2(stream);
return;
}
addTrack()#
Implementation
RtcRtpSender addTrack(MediaStreamTrack track, MediaStream streams) native;
close()#
Implementation
void close() native;
createAnswer()#
Implementation
Future<RtcSessionDescription> createAnswer([Map? options]) {
var options_dict = null;
if (options != null) {
options_dict = convertDartToNative_Dictionary(options);
}
return promiseToFuture<RtcSessionDescription>(
JS(
"creates:RtcSessionDescription;",
"#.createAnswer(#)",
this,
options_dict,
),
);
}
createDataChannel()#
Implementation
RtcDataChannel createDataChannel(String label, [Map? dataChannelDict]) {
if (dataChannelDict != null) {
var dataChannelDict_1 = convertDartToNative_Dictionary(dataChannelDict);
return _createDataChannel_1(label, dataChannelDict_1);
}
return _createDataChannel_2(label);
}
createDtmfSender()#
Implementation
@JSName('createDTMFSender')
RtcDtmfSender createDtmfSender(MediaStreamTrack track) native;
createOffer()#
Implementation
Future<RtcSessionDescription> createOffer([Map? options]) {
var options_dict = null;
if (options != null) {
options_dict = convertDartToNative_Dictionary(options);
}
return promiseToFuture<RtcSessionDescription>(
JS(
"creates:RtcSessionDescription;",
"#.createOffer(#)",
this,
options_dict,
),
);
}
dispatchEvent() inherited#
Inherited from EventTarget.
Implementation
bool dispatchEvent(Event event) native;
getLegacyStats()#
Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports new getStats API.
Implementation
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack? selector]) {
var completer = new Completer<RtcStatsResponse>();
_getStats((value) {
completer.complete(value);
}, selector);
return completer.future;
}
getLocalStreams()#
Implementation
List<MediaStream> getLocalStreams() native;
getReceivers()#
Implementation
List<RtcRtpReceiver> getReceivers() native;
getRemoteStreams()#
Implementation
List<MediaStream> getRemoteStreams() native;
getSenders()#
Implementation
List<RtcRtpSender> getSenders() native;
getStats()#
Implementation
Future<RtcStatsReport> getStats() => promiseToFuture<RtcStatsReport>(
JS("creates:RtcStatsReport;", "#.getStats()", this),
);
noSuchMethod() inherited#
Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dynamic object = 1;
object.add(42); // Statically allowed, run-time error
This invalid code will invoke the noSuchMethod method
of the integer 1 with an Invocation
representing the
.add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}
This code has no compile-time warnings or errors even though
the MockList class has no concrete implementation of
any of the List interface methods.
Calls to List methods are forwarded to noSuchMethod,
so this code will log an invocation similar to
Invocation.method(#add, [42])
and then throw.
If a value is returned from noSuchMethod,
it becomes the result of the original invocation.
If the value is not of a type that can be returned by the original
invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Interceptor.
Implementation
dynamic noSuchMethod(Invocation invocation) {
throw NoSuchMethodError.withInvocation(this, invocation);
}
removeEventListener() inherited#
Inherited from EventTarget.
Implementation
void removeEventListener(
String type,
EventListener? listener, [
bool? useCapture,
]) {
// TODO(leafp): This check is avoid a bug in our dispatch code when
// listener is null. The browser treats this call as a no-op in this
// case, so it's fine to short-circuit it, but we should not have to.
if (listener != null) {
_removeEventListener(type, listener, useCapture);
}
}
removeStream()#
Implementation
void removeStream(MediaStream? stream) native;
removeTrack()#
Implementation
void removeTrack(RtcRtpSender sender) native;
setConfiguration()#
Implementation
void setConfiguration(Map configuration) {
var configuration_1 = convertDartToNative_Dictionary(configuration);
_setConfiguration_1(configuration_1);
return;
}
setLocalDescription()#
Implementation
Future setLocalDescription(Map description) {
var description_dict = convertDartToNative_Dictionary(description);
return promiseToFuture(
JS("", "#.setLocalDescription(#)", this, description_dict),
);
}
setRemoteDescription()#
Implementation
Future setRemoteDescription(Map description) {
var description_dict = convertDartToNative_Dictionary(description);
return promiseToFuture(
JS("", "#.setRemoteDescription(#)", this, description_dict),
);
}
toString() inherited#
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Inherited from Interceptor.
Implementation
String toString() => Primitives.objectToHumanReadableString(this);
Operators#
operator ==() inherited#
The equality operator.
The default behavior for all Objects is to return true if and
only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.-
Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false. -
Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Interceptor.
Implementation
bool operator ==(Object other) => identical(this, other);
Static Properties#
supported no setter#
Checks if Real Time Communication (RTC) APIs are supported and enabled on the current platform.
Implementation
static bool get supported {
// Currently in Firefox some of the RTC elements are defined but throw an
// error unless the user has specifically enabled them in their
// about:config. So we have to construct an element to actually test if RTC
// is supported at the given time.
try {
new RtcPeerConnection({
"iceServers": [
{"url": "stun:localhost"},
],
});
return true;
} catch (_) {
return false;
}
return false;
}
Static Methods#
generateCertificate()#
Implementation
static Future generateCertificate(/*AlgorithmIdentifier*/ keygenAlgorithm) =>
JS('dynamic', 'generateCertificate(#)', keygenAlgorithm);
Constants#
addStreamEvent#
Static factory designed to expose addstream events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<MediaStreamEvent> addStreamEvent =
const EventStreamProvider<MediaStreamEvent>('addstream');
connectionStateChangeEvent#
Static factory designed to expose connectionstatechange events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> connectionStateChangeEvent =
const EventStreamProvider<Event>('connectionstatechange');
dataChannelEvent#
Static factory designed to expose datachannel events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<RtcDataChannelEvent> dataChannelEvent =
const EventStreamProvider<RtcDataChannelEvent>('datachannel');
iceCandidateEvent#
Static factory designed to expose icecandidate events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<RtcPeerConnectionIceEvent>
iceCandidateEvent = const EventStreamProvider<RtcPeerConnectionIceEvent>(
'icecandidate',
);
iceConnectionStateChangeEvent#
Static factory designed to expose iceconnectionstatechange events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> iceConnectionStateChangeEvent =
const EventStreamProvider<Event>('iceconnectionstatechange');
negotiationNeededEvent#
Static factory designed to expose negotiationneeded events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> negotiationNeededEvent =
const EventStreamProvider<Event>('negotiationneeded');
removeStreamEvent#
Static factory designed to expose removestream events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<MediaStreamEvent> removeStreamEvent =
const EventStreamProvider<MediaStreamEvent>('removestream');
signalingStateChangeEvent#
Static factory designed to expose signalingstatechange events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> signalingStateChangeEvent =
const EventStreamProvider<Event>('signalingstatechange');
trackEvent#
Static factory designed to expose track events to event
handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<RtcTrackEvent> trackEvent =
const EventStreamProvider<RtcTrackEvent>('track');