Appearance
RtcPeerConnection ​
class RtcPeerConnection extends EventTargetAnnotations: @SupportedBrowser.new(SupportedBrowser.CHROME), @Native.new("RTCPeerConnection,webkitRTCPeerConnection,mozRTCPeerConnection")
Inheritance
Object → EventTarget → RtcPeerConnection
Constructors ​
RtcPeerConnection() factory ​
factory RtcPeerConnection(
Map<dynamic, dynamic> rtcIceServers, [
Map<dynamic, dynamic>? mediaConstraints,
])Implementation
dart
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 ​
String? get connectionStateImplementation
dart
String? get connectionState native;hashCode no setter inherited ​
int get hashCodeInherited from Interceptor.
Implementation
dart
int get hashCode => Primitives.objectHashCode(this);iceConnectionState no setter ​
String? get iceConnectionStateImplementation
dart
String? get iceConnectionState native;iceGatheringState no setter ​
String? get iceGatheringStateImplementation
dart
String? get iceGatheringState native;localDescription no setter ​
RtcSessionDescription? get localDescriptionImplementation
dart
RtcSessionDescription? get localDescription native;on no setter inherited ​
Events get onThis 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
dart
Events get on => new Events(this);onAddStream no setter ​
Stream<MediaStreamEvent> get onAddStreamStream of addstream events handled by this RtcPeerConnection.
Implementation
dart
Stream<MediaStreamEvent> get onAddStream => addStreamEvent.forTarget(this);onConnectionStateChange no setter ​
Stream of connectionstatechange events handled by this RtcPeerConnection.
Implementation
dart
Stream<Event> get onConnectionStateChange =>
connectionStateChangeEvent.forTarget(this);onDataChannel no setter ​
Stream<RtcDataChannelEvent> get onDataChannelStream of datachannel events handled by this RtcPeerConnection.
Implementation
dart
Stream<RtcDataChannelEvent> get onDataChannel =>
dataChannelEvent.forTarget(this);onIceCandidate no setter ​
Stream<RtcPeerConnectionIceEvent> get onIceCandidateStream of icecandidate events handled by this RtcPeerConnection.
Implementation
dart
Stream<RtcPeerConnectionIceEvent> get onIceCandidate =>
iceCandidateEvent.forTarget(this);onIceConnectionStateChange no setter ​
Stream of iceconnectionstatechange events handled by this RtcPeerConnection.
Implementation
dart
Stream<Event> get onIceConnectionStateChange =>
iceConnectionStateChangeEvent.forTarget(this);onNegotiationNeeded no setter ​
Stream of negotiationneeded events handled by this RtcPeerConnection.
Implementation
dart
Stream<Event> get onNegotiationNeeded =>
negotiationNeededEvent.forTarget(this);onRemoveStream no setter ​
Stream<MediaStreamEvent> get onRemoveStreamStream of removestream events handled by this RtcPeerConnection.
Implementation
dart
Stream<MediaStreamEvent> get onRemoveStream =>
removeStreamEvent.forTarget(this);onSignalingStateChange no setter ​
Stream of signalingstatechange events handled by this RtcPeerConnection.
Implementation
dart
Stream<Event> get onSignalingStateChange =>
signalingStateChangeEvent.forTarget(this);onTrack no setter ​
Stream<RtcTrackEvent> get onTrackStream of track events handled by this RtcPeerConnection.
Implementation
dart
Stream<RtcTrackEvent> get onTrack => trackEvent.forTarget(this);remoteDescription no setter ​
RtcSessionDescription? get remoteDescriptionImplementation
dart
RtcSessionDescription? get remoteDescription native;runtimeType no setter inherited ​
Type get runtimeTypeInherited from Interceptor.
Implementation
dart
Type get runtimeType =>
getRuntimeTypeOfInterceptorNotArray(getInterceptor(this), this);signalingState no setter ​
String? get signalingStateImplementation
dart
String? get signalingState native;Methods ​
addEventListener() inherited ​
void addEventListener(
String type,
(dynamic Function(Event event))? listener, [
bool? useCapture,
])Inherited from EventTarget.
Implementation
dart
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() ​
Future<dynamic> addIceCandidate(
Object candidate, [
(void Function())? successCallback,
(void Function(DomException exception))? failureCallback,
])Implementation
dart
Future addIceCandidate(
Object candidate, [
VoidCallback? successCallback,
RtcPeerConnectionErrorCallback? failureCallback,
]) => promiseToFuture(
JS(
"",
"#.addIceCandidate(#, #, #)",
this,
candidate,
successCallback,
failureCallback,
),
);addStream() ​
void addStream(MediaStream? stream, [Map<dynamic, dynamic>? mediaConstraints])Implementation
dart
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() ​
RtcRtpSender addTrack(MediaStreamTrack track, MediaStream streams)Implementation
dart
RtcRtpSender addTrack(MediaStreamTrack track, MediaStream streams) native;close() ​
void close()Implementation
dart
void close() native;createAnswer() ​
Future<RtcSessionDescription> createAnswer([Map<dynamic, dynamic>? options])Implementation
dart
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() ​
RtcDataChannel createDataChannel(
String label, [
Map<dynamic, dynamic>? dataChannelDict,
])Implementation
dart
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() ​
RtcDtmfSender createDtmfSender(MediaStreamTrack track)Implementation
dart
@JSName('createDTMFSender')
RtcDtmfSender createDtmfSender(MediaStreamTrack track) native;createOffer() ​
Future<RtcSessionDescription> createOffer([Map<dynamic, dynamic>? options])Implementation
dart
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
dart
bool dispatchEvent(Event event) native;getLegacyStats() ​
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack? selector])Temporarily exposes _getStats and old getStats as getLegacyStats until Chrome fully supports new getStats API.
Implementation
dart
Future<RtcStatsResponse> getLegacyStats([MediaStreamTrack? selector]) {
var completer = new Completer<RtcStatsResponse>();
_getStats((value) {
completer.complete(value);
}, selector);
return completer.future;
}getLocalStreams() ​
List<MediaStream> getLocalStreams()Implementation
dart
List<MediaStream> getLocalStreams() native;getReceivers() ​
List<RtcRtpReceiver> getReceivers()Implementation
dart
List<RtcRtpReceiver> getReceivers() native;getRemoteStreams() ​
List<MediaStream> getRemoteStreams()Implementation
dart
List<MediaStream> getRemoteStreams() native;getSenders() ​
List<RtcRtpSender> getSenders()Implementation
dart
List<RtcRtpSender> getSenders() native;getStats() ​
Future<RtcStatsReport> getStats()Implementation
dart
Future<RtcStatsReport> getStats() => promiseToFuture<RtcStatsReport>(
JS("creates:RtcStatsReport;", "#.getStats()", this),
);noSuchMethod() inherited ​
dynamic noSuchMethod(Invocation invocation)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:
dart
dynamic object = 1;
object.add(42); // Statically allowed, run-time errorThis 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:
dart
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
dart
dynamic noSuchMethod(Invocation invocation) {
throw NoSuchMethodError.withInvocation(this, invocation);
}removeEventListener() inherited ​
void removeEventListener(
String type,
(dynamic Function(Event event))? listener, [
bool? useCapture,
])Inherited from EventTarget.
Implementation
dart
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() ​
void removeStream(MediaStream? stream)Implementation
dart
void removeStream(MediaStream? stream) native;removeTrack() ​
void removeTrack(RtcRtpSender sender)Implementation
dart
void removeTrack(RtcRtpSender sender) native;setConfiguration() ​
void setConfiguration(Map<dynamic, dynamic> configuration)Implementation
dart
void setConfiguration(Map configuration) {
var configuration_1 = convertDartToNative_Dictionary(configuration);
_setConfiguration_1(configuration_1);
return;
}setLocalDescription() ​
Implementation
dart
Future setLocalDescription(Map description) {
var description_dict = convertDartToNative_Dictionary(description);
return promiseToFuture(
JS("", "#.setLocalDescription(#)", this, description_dict),
);
}setRemoteDescription() ​
Implementation
dart
Future setRemoteDescription(Map description) {
var description_dict = convertDartToNative_Dictionary(description);
return promiseToFuture(
JS("", "#.setRemoteDescription(#)", this, description_dict),
);
}toString() inherited ​
String toString()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
dart
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
dart
bool operator ==(Object other) => identical(this, other);Static Properties ​
supported no setter ​
bool get supportedChecks if Real Time Communication (RTC) APIs are supported and enabled on the current platform.
Implementation
dart
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() ​
Future<dynamic> generateCertificate(dynamic keygenAlgorithm)Implementation
dart
static Future generateCertificate(/*AlgorithmIdentifier*/ keygenAlgorithm) =>
JS('dynamic', 'generateCertificate(#)', keygenAlgorithm);Constants ​
addStreamEvent ​
const EventStreamProvider<MediaStreamEvent> addStreamEventStatic factory designed to expose addstream events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<MediaStreamEvent> addStreamEvent =
const EventStreamProvider<MediaStreamEvent>('addstream');connectionStateChangeEvent ​
const EventStreamProvider<Event> connectionStateChangeEventStatic factory designed to expose connectionstatechange events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<Event> connectionStateChangeEvent =
const EventStreamProvider<Event>('connectionstatechange');dataChannelEvent ​
const EventStreamProvider<RtcDataChannelEvent> dataChannelEventStatic factory designed to expose datachannel events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<RtcDataChannelEvent> dataChannelEvent =
const EventStreamProvider<RtcDataChannelEvent>('datachannel');iceCandidateEvent ​
const EventStreamProvider<RtcPeerConnectionIceEvent> iceCandidateEventStatic factory designed to expose icecandidate events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<RtcPeerConnectionIceEvent>
iceCandidateEvent = const EventStreamProvider<RtcPeerConnectionIceEvent>(
'icecandidate',
);iceConnectionStateChangeEvent ​
const EventStreamProvider<Event> iceConnectionStateChangeEventStatic factory designed to expose iceconnectionstatechange events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<Event> iceConnectionStateChangeEvent =
const EventStreamProvider<Event>('iceconnectionstatechange');negotiationNeededEvent ​
const EventStreamProvider<Event> negotiationNeededEventStatic factory designed to expose negotiationneeded events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<Event> negotiationNeededEvent =
const EventStreamProvider<Event>('negotiationneeded');removeStreamEvent ​
const EventStreamProvider<MediaStreamEvent> removeStreamEventStatic factory designed to expose removestream events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<MediaStreamEvent> removeStreamEvent =
const EventStreamProvider<MediaStreamEvent>('removestream');signalingStateChangeEvent ​
const EventStreamProvider<Event> signalingStateChangeEventStatic factory designed to expose signalingstatechange events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<Event> signalingStateChangeEvent =
const EventStreamProvider<Event>('signalingstatechange');trackEvent ​
const EventStreamProvider<RtcTrackEvent> trackEventStatic factory designed to expose track events to event handlers that are not necessarily instances of RtcPeerConnection.
See EventStreamProvider for usage information.
Implementation
dart
static const EventStreamProvider<RtcTrackEvent> trackEvent =
const EventStreamProvider<RtcTrackEvent>('track');