Update RTCConfiguration interface to latest spec

This commit is contained in:
Danilo Bargen
2016-06-22 09:13:51 +02:00
parent 830586ef55
commit dc58831c27
2 changed files with 56 additions and 7 deletions
+22 -2
View File
@@ -3,8 +3,28 @@
let voidpromise: Promise<void>;
var config: RTCConfiguration =
{ iceServers: [{ urls: "stun.l.google.com:19302" }] };
var minimalConfig: RTCConfiguration = {};
var config: RTCConfiguration = {
iceServers: [
{
// Single url
urls: "stun.l.google.com:19302"
},
{
// List of urls and credentials
urls: ["another-stun.example.com"],
username: "dude",
credential: "pass",
credentialType: "token"
},
],
iceTransportPolicy: "relay",
bundlePolicy: "max-compat",
rtcpMuxPolicy: "negotiate",
peerIdentity: "dude",
certificates: [{expires: 1337}],
iceCandidatePoolSize: 5
};
var constraints: RTCMediaConstraints =
{ mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } };
+34 -5
View File
@@ -20,17 +20,46 @@
// TODO(2): get Typescript to have union types as WebRtc uses them.
// https://typescript.codeplex.com/workitem/1364
interface RTCConfiguration {
iceServers: RTCIceServer[];
// https://www.w3.org/TR/webrtc/#idl-def-RTCIceTransportPolicy
type RTCIceTransportPolicy = 'public' | 'relay' | 'all';
// https://www.w3.org/TR/webrtc/#idl-def-RTCBundlePolicy
type RTCBundlePolicy = 'balanced' | 'max-compat' | 'max-bundle';
// https://www.w3.org/TR/webrtc/#idl-def-RTCRtcpMuxPolicy
type RTCRtcpMuxPolicy = 'negotiate' | 'require';
// https://www.w3.org/TR/webrtc/#idl-def-RTCCertificate
interface RTCCertificate {
expires: number;
}
// https://www.w3.org/TR/webrtc/#idl-def-RTCConfiguration
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#RTCConfiguration_dictionary
interface RTCConfiguration {
iceServers ?: RTCIceServer[]; // optional according to mozilla docs
iceTransportPolicy ?: RTCIceTransportPolicy; // default = 'all'
bundlePolicy ?: RTCBundlePolicy; // default = 'balanced'
rtcpMuxPolicy ?: RTCRtcpMuxPolicy; // default = 'require'
peerIdentity ?: string; // default = null
certificates ?: RTCCertificate[]; // default is auto-generated
iceCandidatePoolSize ?: number; // default = 0
}
declare var RTCConfiguration: {
prototype: RTCConfiguration;
new (): RTCConfiguration;
};
// https://www.w3.org/TR/webrtc/#idl-def-RTCIceCredentialType
type RTCIceCredentialType = 'password' | 'token';
// https://www.w3.org/TR/webrtc/#idl-def-RTCIceServer
interface RTCIceServer {
urls: string;
urls: string | string[];
username?: string;
credential?: string;
credentialType?: RTCIceCredentialType; // default = 'password'
}
declare var RTCIceServer: {
prototype: RTCIceServer;
@@ -42,7 +71,7 @@ interface mozRTCPeerConnection extends RTCPeerConnection {
}
declare var mozRTCPeerConnection: {
prototype: mozRTCPeerConnection;
new (settings: RTCPeerConnectionConfig,
new (settings?: RTCConfiguration,
constraints?:RTCMediaConstraints): mozRTCPeerConnection;
};
// webkit (Chrome) specific prefixes.
@@ -50,7 +79,7 @@ interface webkitRTCPeerConnection extends RTCPeerConnection {
}
declare var webkitRTCPeerConnection: {
prototype: webkitRTCPeerConnection;
new (settings: RTCPeerConnectionConfig,
new (settings?: RTCConfiguration,
constraints?:RTCMediaConstraints): webkitRTCPeerConnection;
};