forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaStream.d.ts
165 lines (148 loc) · 4.47 KB
/
MediaStream.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Type definitions for WebRTC
// Project: http://dev.w3.org/2011/webrtc/
// Definitions by: Ken Smith <https://github.com/smithkl42/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html
interface MediaStreamConstraints {
audio: any;
video: any;
}
declare var MediaStreamConstraints: {
prototype: MediaStreamConstraints;
new (): MediaStreamConstraints;
};
interface MediaTrackConstraints {
mandatory: MediaTrackConstraintSet;
optional: MediaTrackConstraint[];
}
declare var MediaTrackConstraints: {
prototype: MediaTrackConstraints;
new (): MediaTrackConstraints;
};
// ks - Not defined in the source doc.
interface MediaTrackConstraintSet {
}
declare var MediaTrackConstraintSet: {
prototype: MediaTrackConstraintSet;
new (): MediaTrackConstraintSet;
};
// ks - Not defined in the source doc.
interface MediaTrackConstraint {
}
declare var MediaTrackConstraint: {
prototype: MediaTrackConstraint;
new (): MediaTrackConstraints;
};
interface Navigator {
getUserMedia(constraints: MediaStreamConstraints,
successCallback: (stream: any) => void,
errorCallback: (error: Error) => void) : void;
webkitGetUserMedia(constraints: MediaStreamConstraints,
successCallback: (stream: any) => void,
errorCallback: (error: Error) => void): void;
mozGetUserMedia(constraints: MediaStreamConstraints,
successCallback: (stream: any) => void,
errorCallback: (error: Error) => void): void;
}
interface EventHandler { (event: Event): void; }
interface NavigatorUserMediaSuccessCallback {
(stream: LocalMediaStream): void;
}
interface NavigatorUserMediaError {
PERMISSION_DENIED: number; // = 1;
code: number;
}
declare var NavigatorUserMediaError: {
prototype: NavigatorUserMediaError;
new (): NavigatorUserMediaError;
PERMISSION_DENIED: number; // = 1;
};
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;
}
declare var MediaStreamTrackList: {
prototype: MediaStreamTrackList;
new (): MediaStreamTrackList;
};
declare var webkitMediaStreamTrackList: {
prototype: MediaStreamTrackList;
new (): MediaStreamTrackList;
};
interface MediaStream extends EventTarget{
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;
};
declare var webkitMediaStream: {
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;
}
declare var SourceInfo: {
prototype: SourceInfo;
};
interface LocalMediaStream extends MediaStream {
stop(): void;
}
interface MediaStreamTrack extends EventTarget{
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;
};
interface streamURL extends URL {
createObjectURL(stream: MediaStream): string;
}
//declare var URL: {
// prototype: MediaStreamTrack;
// new (): URL;
// createObjectURL(stream: MediaStream): string;
//}
interface WebkitURL extends streamURL {
}
declare var webkitURL: {
prototype: WebkitURL;
new (): streamURL;
createObjectURL(stream: MediaStream): string;
};