mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-13 08:31:10 +08:00
Merge pull request #2432 from iislucas/iislucas-webrtc
Added optional media constraints for WebRTC
This commit is contained in:
@@ -6,27 +6,27 @@ var mediaTrackConstraintArray: MediaTrackConstraint[] = [];
|
||||
var mediaTrackConstraints: MediaTrackConstraints = { mandatory: mediaTrackConstraintSet, optional: mediaTrackConstraintArray }
|
||||
|
||||
navigator.getUserMedia(mediaStreamConstraints,
|
||||
stream => {
|
||||
console.log('label:' + stream.label);
|
||||
console.log('ended:' + stream.ended);
|
||||
stream.onended = event => console.log('Stream ended');
|
||||
var objectUrl = URL.createObjectURL(stream);
|
||||
var wkObjectUrl = webkitURL.createObjectURL(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
stream => {
|
||||
console.log('label:' + stream.label);
|
||||
console.log('ended:' + stream.ended);
|
||||
stream.onended = (event:Event) => console.log('Stream ended');
|
||||
var objectUrl = URL.createObjectURL(stream);
|
||||
var wkObjectUrl = webkitURL.createObjectURL(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
|
||||
navigator.webkitGetUserMedia(mediaStreamConstraints,
|
||||
stream => {
|
||||
console.log('label:' + stream.label);
|
||||
console.log('ended:' + stream.ended);
|
||||
stream.onended = event => console.log('Stream ended');
|
||||
var objectUrl = URL.createObjectURL(stream);
|
||||
var wkObjectUrl = webkitURL.createObjectURL(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
stream => {
|
||||
console.log('label:' + stream.label);
|
||||
console.log('ended:' + stream.ended);
|
||||
stream.onended = (event:Event) => console.log('Stream ended');
|
||||
var objectUrl = URL.createObjectURL(stream);
|
||||
var wkObjectUrl = webkitURL.createObjectURL(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
|
||||
162
webrtc/MediaStream.d.ts
vendored
162
webrtc/MediaStream.d.ts
vendored
@@ -6,150 +6,158 @@
|
||||
// Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html
|
||||
|
||||
interface MediaStreamConstraints {
|
||||
audio: any;
|
||||
video: any;
|
||||
audio: any;
|
||||
video: any;
|
||||
}
|
||||
declare var MediaStreamConstraints: {
|
||||
prototype: MediaStreamConstraints;
|
||||
new (): MediaStreamConstraints;
|
||||
prototype: MediaStreamConstraints;
|
||||
new (): MediaStreamConstraints;
|
||||
}
|
||||
|
||||
interface MediaTrackConstraints {
|
||||
mandatory: MediaTrackConstraintSet;
|
||||
optional: MediaTrackConstraint[];
|
||||
mandatory: MediaTrackConstraintSet;
|
||||
optional: MediaTrackConstraint[];
|
||||
}
|
||||
declare var MediaTrackConstraints: {
|
||||
prototype: MediaTrackConstraints;
|
||||
new (): MediaTrackConstraints;
|
||||
prototype: MediaTrackConstraints;
|
||||
new (): MediaTrackConstraints;
|
||||
}
|
||||
|
||||
// ks - Not defined in the source doc.
|
||||
interface MediaTrackConstraintSet {
|
||||
}
|
||||
declare var MediaTrackConstraintSet: {
|
||||
prototype: MediaTrackConstraintSet;
|
||||
new (): MediaTrackConstraintSet;
|
||||
prototype: MediaTrackConstraintSet;
|
||||
new (): MediaTrackConstraintSet;
|
||||
}
|
||||
|
||||
// ks - Not defined in the source doc.
|
||||
interface MediaTrackConstraint {
|
||||
}
|
||||
declare var MediaTrackConstraint: {
|
||||
prototype: MediaTrackConstraint;
|
||||
new (): MediaTrackConstraints;
|
||||
prototype: MediaTrackConstraint;
|
||||
new (): MediaTrackConstraints;
|
||||
}
|
||||
|
||||
interface Navigator {
|
||||
getUserMedia(constraints: MediaStreamConstraints, successCallback: (stream: any) => void, errorCallback: (error: Error) => void);
|
||||
webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: (stream: any) => void, errorCallback: (error: Error) => void);
|
||||
getUserMedia(constraints: MediaStreamConstraints,
|
||||
successCallback: (stream: any) => void,
|
||||
errorCallback: (error: Error) => void) : void;
|
||||
webkitGetUserMedia(constraints: MediaStreamConstraints,
|
||||
successCallback: (stream: any) => void,
|
||||
errorCallback: (error: Error) => void): void;
|
||||
}
|
||||
|
||||
interface EventHandler { (event: Event): void; }
|
||||
|
||||
interface NavigatorUserMediaSuccessCallback { (stream: LocalMediaStream): void; }
|
||||
interface NavigatorUserMediaSuccessCallback {
|
||||
(stream: LocalMediaStream): void;
|
||||
}
|
||||
|
||||
interface NavigatorUserMediaError {
|
||||
PERMISSION_DENIED: number; // = 1;
|
||||
code: number;
|
||||
PERMISSION_DENIED: number; // = 1;
|
||||
code: number;
|
||||
}
|
||||
declare var NavigatorUserMediaError: {
|
||||
prototype: NavigatorUserMediaError;
|
||||
new (): NavigatorUserMediaError;
|
||||
PERMISSION_DENIED: number; // = 1;
|
||||
prototype: NavigatorUserMediaError;
|
||||
new (): NavigatorUserMediaError;
|
||||
PERMISSION_DENIED: number; // = 1;
|
||||
}
|
||||
|
||||
interface NavigatorUserMediaErrorCallback { (error: NavigatorUserMediaError): void; }
|
||||
interface NavigatorUserMediaErrorCallback {
|
||||
(error: NavigatorUserMediaError): void;
|
||||
}
|
||||
|
||||
interface MediaStreamTrackList {
|
||||
length: number;
|
||||
item: MediaStreamTrack;
|
||||
add(track: MediaStreamTrack): void;
|
||||
remove(track: MediaStreamTrack): void;
|
||||
onaddtrack: (event: Event) => void;
|
||||
onremovetrack: (event: Event) => void;
|
||||
length: number;
|
||||
item: MediaStreamTrack;
|
||||
add(track: MediaStreamTrack): void;
|
||||
remove(track: MediaStreamTrack): void;
|
||||
onaddtrack: (event: Event) => void;
|
||||
onremovetrack: (event: Event) => void;
|
||||
}
|
||||
declare var MediaStreamTrackList: {
|
||||
prototype: MediaStreamTrackList;
|
||||
new (): MediaStreamTrackList;
|
||||
prototype: MediaStreamTrackList;
|
||||
new (): MediaStreamTrackList;
|
||||
}
|
||||
declare var webkitMediaStreamTrackList: {
|
||||
prototype: MediaStreamTrackList;
|
||||
new (): MediaStreamTrackList;
|
||||
prototype: MediaStreamTrackList;
|
||||
new (): MediaStreamTrackList;
|
||||
}
|
||||
|
||||
interface MediaStream {
|
||||
label: string;
|
||||
id: string;
|
||||
getAudioTracks(): MediaStreamTrackList;
|
||||
getVideoTracks(): MediaStreamTrackList;
|
||||
ended: boolean;
|
||||
onended: (event: Event) => void;
|
||||
label: string;
|
||||
id: string;
|
||||
getAudioTracks(): MediaStreamTrackList;
|
||||
getVideoTracks(): MediaStreamTrackList;
|
||||
ended: boolean;
|
||||
onended: (event: Event) => void;
|
||||
}
|
||||
declare var MediaStream: {
|
||||
prototype: MediaStream;
|
||||
new (): MediaStream;
|
||||
new (trackContainers: MediaStream[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrackList[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrack[]): MediaStream;
|
||||
prototype: MediaStream;
|
||||
new (): MediaStream;
|
||||
new (trackContainers: MediaStream[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrackList[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrack[]): MediaStream;
|
||||
}
|
||||
declare var webkitMediaStream: {
|
||||
prototype: MediaStream;
|
||||
new (): MediaStream;
|
||||
new (trackContainers: MediaStream[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrackList[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrack[]): MediaStream;
|
||||
prototype: MediaStream;
|
||||
new (): MediaStream;
|
||||
new (trackContainers: MediaStream[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrackList[]): MediaStream;
|
||||
new (trackContainers: MediaStreamTrack[]): MediaStream;
|
||||
}
|
||||
|
||||
// an - not defined in source doc.
|
||||
interface SourceInfo {
|
||||
label: string;
|
||||
id: string;
|
||||
kind: string;
|
||||
facing: string;
|
||||
label: string;
|
||||
id: string;
|
||||
kind: string;
|
||||
facing: string;
|
||||
}
|
||||
declare var SourceInfo: {
|
||||
prototype: SourceInfo;
|
||||
prototype: SourceInfo;
|
||||
}
|
||||
|
||||
interface LocalMediaStream extends MediaStream {
|
||||
stop(): void;
|
||||
stop(): void;
|
||||
}
|
||||
|
||||
interface MediaStreamTrack {
|
||||
kind: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
LIVE: number; // = 0;
|
||||
MUTED: number; // = 1;
|
||||
ENDED: number; // = 2;
|
||||
readyState: number;
|
||||
onmute: (event: Event) => void;
|
||||
onunmute: (event: Event) => void;
|
||||
onended: (event: Event) => void;
|
||||
kind: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
LIVE: number; // = 0;
|
||||
MUTED: number; // = 1;
|
||||
ENDED: number; // = 2;
|
||||
readyState: number;
|
||||
onmute: (event: Event) => void;
|
||||
onunmute: (event: Event) => void;
|
||||
onended: (event: Event) => void;
|
||||
}
|
||||
declare var MediaStreamTrack: {
|
||||
prototype: MediaStreamTrack;
|
||||
new (): MediaStreamTrack;
|
||||
LIVE: number; // = 0;
|
||||
MUTED: number; // = 1;
|
||||
ENDED: number; // = 2;
|
||||
getSources: (callback: (sources: SourceInfo[]) => void) => void;
|
||||
prototype: MediaStreamTrack;
|
||||
new (): MediaStreamTrack;
|
||||
LIVE: number; // = 0;
|
||||
MUTED: number; // = 1;
|
||||
ENDED: number; // = 2;
|
||||
getSources: (callback: (sources: SourceInfo[]) => void) => void;
|
||||
}
|
||||
|
||||
interface streamURL extends URL {
|
||||
createObjectURL(stream: MediaStream): string;
|
||||
createObjectURL(stream: MediaStream): string;
|
||||
}
|
||||
//declare var URL: {
|
||||
// prototype: MediaStreamTrack;
|
||||
// new (): URL;
|
||||
// createObjectURL(stream: MediaStream): string;
|
||||
// prototype: MediaStreamTrack;
|
||||
// new (): URL;
|
||||
// createObjectURL(stream: MediaStream): string;
|
||||
//}
|
||||
|
||||
interface WebkitURL extends streamURL {
|
||||
}
|
||||
declare var webkitURL: {
|
||||
prototype: WebkitURL;
|
||||
new (): streamURL;
|
||||
createObjectURL(stream: MediaStream): string;
|
||||
prototype: WebkitURL;
|
||||
new (): streamURL;
|
||||
createObjectURL(stream: MediaStream): string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
/// <reference path="MediaStream.d.ts" />
|
||||
/// <reference path="RTCPeerConnection.d.ts" />
|
||||
|
||||
var config: RTCConfiguration = { iceServers: [{ url: "stun.l.google.com:19302" }] };
|
||||
var constraints: MediaConstraints = { mandatory: { OfferToReceiveAudio: true, OfferToReceiveVideo: true } };
|
||||
var config: RTCConfiguration =
|
||||
{ iceServers: [{ url: "stun.l.google.com:19302" }] };
|
||||
var constraints: RTCMediaConstraints =
|
||||
{ mandatory: { OfferToReceiveAudio: true, OfferToReceiveVideo: true } };
|
||||
|
||||
var peerConnection: RTCPeerConnection = new RTCPeerConnection(config, constraints);
|
||||
var peerConnection: RTCPeerConnection =
|
||||
new RTCPeerConnection(config, constraints);
|
||||
|
||||
navigator.getUserMedia({ audio: true, video: true },
|
||||
stream => {
|
||||
peerConnection.addStream(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
stream => {
|
||||
peerConnection.addStream(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
|
||||
peerConnection.onaddstream = ev => console.log(ev.type);
|
||||
peerConnection.ondatachannel = ev => console.log(ev.type);
|
||||
@@ -25,27 +28,31 @@ peerConnection.onremovestream = ev => console.log(ev.type);
|
||||
peerConnection.onstatechange = ev => console.log(ev.type);
|
||||
|
||||
peerConnection.createOffer(
|
||||
offer => {
|
||||
peerConnection.setLocalDescription(offer,
|
||||
() => console.log("set local description"),
|
||||
error => console.log("Error setting local description: " + error));
|
||||
},
|
||||
error => console.log("Error creating offer: " + error));
|
||||
offer => {
|
||||
peerConnection.setLocalDescription(offer,
|
||||
() => console.log("set local description"),
|
||||
error => console.log("Error setting local description: " + error));
|
||||
},
|
||||
error => console.log("Error creating offer: " + error));
|
||||
|
||||
var type: RTCSdpType = RTCSdpType.offer;
|
||||
var type: string = RTCSdpType[RTCSdpType.offer];
|
||||
var offer: RTCSessionDescriptionInit = { type: type, sdp: "some sdp" };
|
||||
var sessionDescription = new RTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(sessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log("Error setting local description from created answer: " + error + "; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error + "; offer.sdp=" + offer.sdp));
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var wkPeerConnection: webkitRTCPeerConnection = new webkitRTCPeerConnection(config, constraints);
|
||||
var wkPeerConnection: webkitRTCPeerConnection =
|
||||
new webkitRTCPeerConnection(config, constraints);
|
||||
|
||||
|
||||
335
webrtc/RTCPeerConnection.d.ts
vendored
335
webrtc/RTCPeerConnection.d.ts
vendored
@@ -2,229 +2,308 @@
|
||||
// Project: http://dev.w3.org/2011/webrtc/
|
||||
// Definitions by: Ken Smith <https://github.com/smithkl42/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
//
|
||||
// Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html
|
||||
//
|
||||
// For example code see:
|
||||
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js
|
||||
//
|
||||
// For a generic implementation see that deals with browser differences, see:
|
||||
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js
|
||||
|
||||
/// <reference path="MediaStream.d.ts" />
|
||||
/// <reference path='MediaStream.d.ts' />
|
||||
|
||||
// TODO(1): Get Typescript to have string-enum types as WebRtc is full of string
|
||||
// enums.
|
||||
// https://typescript.codeplex.com/discussions/549207
|
||||
|
||||
// TODO(2): get Typescript to have union types as WebRtc uses them.
|
||||
// https://typescript.codeplex.com/workitem/1364
|
||||
|
||||
interface RTCConfiguration {
|
||||
iceServers: RTCIceServer[];
|
||||
iceServers: RTCIceServer[];
|
||||
}
|
||||
declare var RTCConfiguration: {
|
||||
prototype: RTCConfiguration;
|
||||
new (): RTCConfiguration;
|
||||
prototype: RTCConfiguration;
|
||||
new (): RTCConfiguration;
|
||||
}
|
||||
|
||||
interface RTCIceServer {
|
||||
url: string;
|
||||
credential?: string;
|
||||
url: string;
|
||||
credential?: string;
|
||||
}
|
||||
declare var RTCIceServer: {
|
||||
prototype: RTCIceServer;
|
||||
new (): RTCIceServer;
|
||||
prototype: RTCIceServer;
|
||||
new (): RTCIceServer;
|
||||
}
|
||||
|
||||
// moz (Firefox) specific prefixes.
|
||||
interface mozRTCPeerConnection extends RTCPeerConnection {
|
||||
}
|
||||
declare var mozRTCPeerConnection: {
|
||||
prototype: mozRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig,
|
||||
constraints?:RTCMediaConstraints): mozRTCPeerConnection;
|
||||
}
|
||||
// webkit (Chrome) specific prefixes.
|
||||
interface webkitRTCPeerConnection extends RTCPeerConnection {
|
||||
}
|
||||
declare var webkitRTCPeerConnection: {
|
||||
prototype: webkitRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig, constraints?:MediaConstraints): webkitRTCPeerConnection;
|
||||
prototype: webkitRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig,
|
||||
constraints?:RTCMediaConstraints): webkitRTCPeerConnection;
|
||||
}
|
||||
|
||||
interface IceState {
|
||||
}
|
||||
declare var IceState: {
|
||||
prototype: IceState;
|
||||
new (): IceState;
|
||||
// For Chrome, look at the code here:
|
||||
// https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsession.cc&sq=package:chromium&dr=C&l=63
|
||||
interface RTCOptionalMediaConstraint {
|
||||
// When true, will use DTLS/SCTP data channels
|
||||
DtlsSrtpKeyAgreement?: boolean;
|
||||
// When true will use Rtp-based data channels (depreicated)
|
||||
RtpDataChannels?: boolean;
|
||||
}
|
||||
|
||||
// ks 12/20/12 - There's more here that doesn't seem to be documented very well yet.
|
||||
interface MediaConstraints {
|
||||
mandatory: MediaOfferConstraints;
|
||||
// http://www.w3.org/TR/2013/WD-webrtc-20130910/
|
||||
interface RTCMediaConstraints {
|
||||
mandatory?: RTCMediaOfferConstraints;
|
||||
optional?: RTCOptionalMediaConstraint[]
|
||||
}
|
||||
|
||||
interface MediaOfferConstraints {
|
||||
OfferToReceiveAudio: boolean;
|
||||
OfferToReceiveVideo: boolean;
|
||||
}
|
||||
|
||||
interface RTCSessionDescription {
|
||||
type?: RTCSdpType;
|
||||
sdp?: string;
|
||||
}
|
||||
declare var RTCSessionDescription: {
|
||||
prototype: RTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription;
|
||||
interface RTCMediaOfferConstraints {
|
||||
OfferToReceiveAudio: boolean;
|
||||
OfferToReceiveVideo: boolean;
|
||||
}
|
||||
|
||||
interface RTCSessionDescriptionInit {
|
||||
type: RTCSdpType;
|
||||
sdp: string;
|
||||
}
|
||||
declare var RTCSessionDescriptionInit: {
|
||||
prototype: RTCSessionDescriptionInit;
|
||||
new (): RTCSessionDescriptionInit;
|
||||
type: string; // RTCSdpType; See TODO(1)
|
||||
sdp: string;
|
||||
}
|
||||
|
||||
interface SdpType {
|
||||
interface RTCSessionDescription {
|
||||
type?: string; // RTCSdpType; See TODO(1)
|
||||
sdp?: string;
|
||||
}
|
||||
|
||||
interface RTCPeerState {
|
||||
declare var RTCSessionDescription: {
|
||||
prototype: RTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription;
|
||||
// TODO: Add serializer.
|
||||
// See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType)
|
||||
}
|
||||
|
||||
interface RTCDataChannelInit {
|
||||
reliable: boolean;
|
||||
ordered ?: boolean; // messages must be sent in-order.
|
||||
maxPacketLifeTime ?: number; // unsigned short
|
||||
maxRetransmits ?: number; // unsigned short
|
||||
protocol ?: string; // default = ''
|
||||
negotiated ?: boolean; // default = false;
|
||||
id ?: number; // unsigned short
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCSdpType {
|
||||
offer,
|
||||
pranswer,
|
||||
answer
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype
|
||||
'offer',
|
||||
'pranswer',
|
||||
'answer'
|
||||
}
|
||||
|
||||
interface RTCMessageEvent {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message
|
||||
// At present, this can be an: ArrayBuffer, a string, or a Blob.
|
||||
// See TODO(2)
|
||||
data: any;
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCDataChannelState {
|
||||
connecting,
|
||||
open,
|
||||
closing,
|
||||
closed
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState
|
||||
'connecting',
|
||||
'open',
|
||||
'closing',
|
||||
'closed'
|
||||
}
|
||||
|
||||
interface RTCDataChannel extends EventTarget {
|
||||
label: string;
|
||||
reliable: boolean;
|
||||
readyState: RTCDataChannelState;
|
||||
bufferedAmount: number;
|
||||
onopen: (event: Event)=> void;
|
||||
onerror: (event: Event)=> void;
|
||||
onclose: (event: Event)=> void;
|
||||
close(): void;
|
||||
onmessage: (event: Event)=> void;
|
||||
binaryType: string;
|
||||
send(data: string);
|
||||
send(data: ArrayBuffer);
|
||||
send(data: Blob);
|
||||
label: string;
|
||||
reliable: boolean;
|
||||
readyState: string; // RTCDataChannelState; see TODO(1)
|
||||
bufferedAmount: number;
|
||||
binaryType: string;
|
||||
|
||||
onopen: (event: Event) => void;
|
||||
onerror: (event: Event) => void;
|
||||
onclose: (event: Event) => void;
|
||||
onmessage: (event: RTCMessageEvent) => void;
|
||||
|
||||
close(): void;
|
||||
|
||||
send(data: string): void ;
|
||||
send(data: ArrayBuffer): void;
|
||||
send(data: ArrayBufferView): void;
|
||||
send(data: Blob): void;
|
||||
}
|
||||
declare var RTCDataChannel: {
|
||||
prototype: RTCDataChannel;
|
||||
new (): RTCDataChannel;
|
||||
prototype: RTCDataChannel;
|
||||
new (): RTCDataChannel;
|
||||
}
|
||||
|
||||
interface RTCDataChannelEvent extends Event {
|
||||
constructor (eventInitDict: RTCDataChannelEventInit);
|
||||
channel: RTCDataChannel;
|
||||
channel: RTCDataChannel;
|
||||
}
|
||||
declare var RTCDataChannelEvent: {
|
||||
prototype: RTCDataChannelEvent;
|
||||
new (eventInitDict: RTCDataChannelEventInit);
|
||||
prototype: RTCDataChannelEvent;
|
||||
new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent;
|
||||
}
|
||||
|
||||
interface RTCIceCandidateEvent extends Event{
|
||||
candidate: RTCIceCandidate;
|
||||
interface RTCIceCandidateEvent extends Event {
|
||||
candidate: RTCIceCandidate;
|
||||
}
|
||||
|
||||
interface RTCMediaStreamEvent extends Event {
|
||||
stream: MediaStream;
|
||||
stream: MediaStream;
|
||||
}
|
||||
|
||||
interface EventInit {
|
||||
}
|
||||
|
||||
interface RTCDataChannelEventInit extends EventInit {
|
||||
channel: RTCDataChannel;
|
||||
channel: RTCDataChannel;
|
||||
}
|
||||
|
||||
interface RTCVoidCallback {
|
||||
(): void;
|
||||
(): void;
|
||||
}
|
||||
interface RTCSessionDescriptionCallback {
|
||||
(sdp: RTCSessionDescription): void;
|
||||
(sdp: RTCSessionDescription): void;
|
||||
}
|
||||
interface RTCPeerConnectionErrorCallback {
|
||||
(errorInformation: string): void;
|
||||
(errorInformation: DOMError): void;
|
||||
}
|
||||
|
||||
/** This should be an enum */
|
||||
interface RTCIceGatheringState {
|
||||
string;
|
||||
// TODO(1)
|
||||
declare enum RTCIceGatheringState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum
|
||||
'new',
|
||||
'gathering',
|
||||
'complete'
|
||||
}
|
||||
|
||||
/** This should be an enum */
|
||||
interface RTCIceConnectionState {
|
||||
string;
|
||||
// TODO(1)
|
||||
declare enum RTCIceConnectionState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState
|
||||
'new',
|
||||
'checking',
|
||||
'connected',
|
||||
'completed',
|
||||
'failed',
|
||||
'disconnected',
|
||||
'closed'
|
||||
}
|
||||
|
||||
/** This should be an enum */
|
||||
interface RTCSignalingState{
|
||||
string;
|
||||
// TODO(1)
|
||||
declare enum RTCSignalingState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState
|
||||
'stable',
|
||||
'have-local-offer',
|
||||
'have-remote-offer',
|
||||
'have-local-pranswer',
|
||||
'have-remote-pranswer',
|
||||
'closed'
|
||||
}
|
||||
|
||||
// This is based on the current implementation of WebRtc in Chrome; the spec is
|
||||
// a little unclear on this.
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport
|
||||
interface RTCStatsReport {
|
||||
stat(id: string): string;
|
||||
}
|
||||
|
||||
interface RTCStatsCallback {
|
||||
(report: RTCStatsReport): void;
|
||||
}
|
||||
|
||||
interface RTCPeerConnection {
|
||||
createOffer(successCallback: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, constraints?: MediaConstraints): void;
|
||||
createAnswer(successCallback: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, constraints?: MediaConstraints): void;
|
||||
setLocalDescription(description: RTCSessionDescription, successCallback?: RTCVoidCallback, failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
localDescription: RTCSessionDescription;
|
||||
setRemoteDescription(description: RTCSessionDescription, successCallback?: RTCVoidCallback, failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
remoteDescription: RTCSessionDescription;
|
||||
signalingState: RTCSignalingState;
|
||||
updateIce(configuration?: RTCConfiguration, constraints?: MediaConstraints): void;
|
||||
addIceCandidate(candidate: RTCIceCandidate): void;
|
||||
iceGatheringState: RTCIceGatheringState;
|
||||
iceConnectionState: RTCIceConnectionState;
|
||||
getLocalStreams(): MediaStream[];
|
||||
getRemoteStreams(): MediaStream[];
|
||||
createDataChannel(label?: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
||||
ondatachannel: (event: Event)=> void;
|
||||
addStream(stream: MediaStream, constraints?: MediaConstraints): void;
|
||||
removeStream(stream: MediaStream): void;
|
||||
close(): void;
|
||||
onnegotiationneeded: (event: Event)=> void;
|
||||
onconnecting: (event: Event)=> void;
|
||||
onopen: (event: Event)=> void;
|
||||
onaddstream: (event: RTCMediaStreamEvent)=> void;
|
||||
onremovestream: (event: RTCMediaStreamEvent)=> void;
|
||||
onstatechange: (event: Event)=> void;
|
||||
onicechange: (event: Event)=> void;
|
||||
onicecandidate: (event: RTCIceCandidateEvent)=> void;
|
||||
onidentityresult: (event: Event)=> void;
|
||||
createOffer(successCallback: RTCSessionDescriptionCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
createAnswer(successCallback: RTCSessionDescriptionCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
setLocalDescription(description: RTCSessionDescription,
|
||||
successCallback?: RTCVoidCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
localDescription: RTCSessionDescription;
|
||||
setRemoteDescription(description: RTCSessionDescription,
|
||||
successCallback?: RTCVoidCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
remoteDescription: RTCSessionDescription;
|
||||
signalingState: string; // RTCSignalingState; see TODO(1)
|
||||
updateIce(configuration?: RTCConfiguration,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
addIceCandidate(candidate: RTCIceCandidate): void;
|
||||
iceGatheringState: string; // RTCIceGatheringState; see TODO(1)
|
||||
iceConnectionState: string; // RTCIceConnectionState; see TODO(1)
|
||||
getLocalStreams(): MediaStream[];
|
||||
getRemoteStreams(): MediaStream[];
|
||||
createDataChannel(label?: string,
|
||||
dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
||||
ondatachannel: (event: Event) => void;
|
||||
addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void;
|
||||
removeStream(stream: MediaStream): void;
|
||||
close(): void;
|
||||
onnegotiationneeded: (event: Event) => void;
|
||||
onconnecting: (event: Event) => void;
|
||||
onopen: (event: Event) => void;
|
||||
onaddstream: (event: RTCMediaStreamEvent) => void;
|
||||
onremovestream: (event: RTCMediaStreamEvent) => void;
|
||||
onstatechange: (event: Event) => void;
|
||||
onicechange: (event: Event) => void;
|
||||
onicecandidate: (event: RTCIceCandidateEvent) => void;
|
||||
onidentityresult: (event: Event) => void;
|
||||
onsignalingstatechange: (event: Event) => void;
|
||||
getStats: (successCallback: RTCStatsCallback,
|
||||
failureCallback: RTCPeerConnectionErrorCallback) => void;
|
||||
}
|
||||
declare var RTCPeerConnection: {
|
||||
prototype: RTCPeerConnection;
|
||||
new (configuration: RTCConfiguration, constraints?: MediaConstraints): RTCPeerConnection;
|
||||
prototype: RTCPeerConnection;
|
||||
new (configuration: RTCConfiguration,
|
||||
constraints?: RTCMediaConstraints): RTCPeerConnection;
|
||||
}
|
||||
|
||||
interface RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var RTCIceCandidate: {
|
||||
prototype: RTCIceCandidate;
|
||||
new (candidateInitDict?: RTCIceCandidate);
|
||||
prototype: RTCIceCandidate;
|
||||
new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate;
|
||||
}
|
||||
|
||||
interface RTCIceCandidateInit {
|
||||
candidate: string;
|
||||
sdpMid: string;
|
||||
sdpMLineIndex: number;
|
||||
candidate: string;
|
||||
sdpMid: string;
|
||||
sdpMLineIndex: number;
|
||||
}
|
||||
declare var RTCIceCandidateInit:{
|
||||
prototype: RTCIceCandidateInit;
|
||||
new (): RTCIceCandidateInit;
|
||||
prototype: RTCIceCandidateInit;
|
||||
new (): RTCIceCandidateInit;
|
||||
}
|
||||
|
||||
interface PeerConnectionIceEvent {
|
||||
peer: RTCPeerConnection;
|
||||
candidate: RTCIceCandidate;
|
||||
peer: RTCPeerConnection;
|
||||
candidate: RTCIceCandidate;
|
||||
}
|
||||
declare var PeerConnectionIceEvent: {
|
||||
prototype: PeerConnectionIceEvent;
|
||||
new (): PeerConnectionIceEvent;
|
||||
prototype: PeerConnectionIceEvent;
|
||||
new (): PeerConnectionIceEvent;
|
||||
}
|
||||
|
||||
interface RTCPeerConnectionConfig {
|
||||
iceServers: RTCIceServer[];
|
||||
iceServers: RTCIceServer[];
|
||||
}
|
||||
declare var RTCPeerConnectionConfig: {
|
||||
prototype: RTCPeerConnectionConfig;
|
||||
new (): RTCPeerConnectionConfig;
|
||||
prototype: RTCPeerConnectionConfig;
|
||||
new (): RTCPeerConnectionConfig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user