You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -58,18 +58,26 @@ webrtc.on('readyToCall', function () {
58
58
### Available options
59
59
60
60
61
-
`peerConnectionConfig` - Set this to specify your own STUN and TURN servers. By default, SimpleWebRTC uses Google's public STUN server (`stun.l.google.com:19302`), which is intended for public use according to: https://twitter.com/HenrikJoreteg/status/354105684591251456
61
+
`peerConnectionConfig` - Set this to specify your own STUN and TURN servers. By
62
+
default, SimpleWebRTC uses Google's public STUN server
63
+
(`stun.l.google.com:19302`), which is intended for public use according to:
Note that you will most likely also need to run your own TURN servers. See http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/ for a basic tutorial.
66
+
Note that you will most likely also need to run your own TURN servers. See
67
+
http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/ for a basic
68
+
tutorial.
64
69
65
70
## Filetransfer
66
-
Sending files between individual participants is supported. See http://simplewebrtc.com/filetransfer.html for a demo.
71
+
Sending files between individual participants is supported. See
72
+
http://simplewebrtc.com/filetransfer.html for a demo.
67
73
68
-
Note that this is not file sharing between a group which requires a completly different approach.
74
+
Note that this is not file sharing between a group which requires a completely
75
+
different approach.
69
76
70
77
## It's not always that simple...
71
78
72
-
Sometimes you need to do more advanced stuff. See http://simplewebrtc.com/notsosimple.html for some examples.
79
+
Sometimes you need to do more advanced stuff. See
80
+
http://simplewebrtc.com/notsosimple.html for some examples.
-`object options` - options object provided to constructor consisting of:
91
-
-`string url` - *required* url for signaling server. Defaults to signaling server URL which can be used for development. You must use your own signaling server for production.
92
-
-`object sockio` - *optional* object to be passed as options to the signaling server connection.
93
-
-`Connection connection` - *optional* connection object for signaling. See `Connection` below. Defaults to a new SocketIoConnection
99
+
-`string url` - *required* url for signaling server. Defaults to signaling
100
+
server URL which can be used for development. You must use your own signaling
101
+
server for production.
102
+
-`object sockio` - *optional* object to be passed as options to the signaling
103
+
server connection.
104
+
-`Connection connection` - *optional* connection object for signaling. See
105
+
`Connection` below. Defaults to a new SocketIoConnection
94
106
-`bool debug` - *optional* flag to set the instance to debug mode
95
-
-`[string|DomElement] locaVidelEl` - ID or Element to contain the local video element
107
+
-`[string|DomElement] locaVidelEl` - ID or Element to contain the local video
108
+
element
96
109
-`[string|DomElement] remoteVideosEl` - ID or Element to contain the
97
110
remote video elements
98
-
-`bool autoRequestMedia` - *optional(=false)* option to automatically request user media. Use `true` to request automatically, or `false` to request media later with `startLocalVideo`
99
-
-`bool enableDataChannels`*optional(=true)* option to enable/disable data channels (used for volume levels or direct messaging)
100
-
-`bool autoRemoveVideos` - *optional(=true)* option to automatically remove video elements when streams are stopped.
101
-
-`bool adjustPeerVolume` - *optional(=false)* option to reduce peer volume when the local participant is speaking
111
+
-`bool autoRequestMedia` - *optional(=false)* option to automatically request
112
+
user media. Use `true` to request automatically, or `false` to request media
113
+
later with `startLocalVideo`
114
+
-`bool enableDataChannels`*optional(=true)* option to enable/disable data
115
+
channels (used for volume levels or direct messaging)
116
+
-`bool autoRemoveVideos` - *optional(=true)* option to automatically remove
117
+
video elements when streams are stopped.
118
+
-`bool adjustPeerVolume` - *optional(=false)* option to reduce peer volume
119
+
when the local participant is speaking
102
120
-`number peerVolumeWhenSpeaking` - *optional(=.0.25)* value used in
103
121
conjunction with `adjustPeerVolume`. Uses values between 0 and 1.
104
-
-`object media` - media options to be passed to `getUserMedia`. Defaults to `{ video: true, audio: true }`. Valid configurations described [on MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) with official spec [at w3c](http://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia).
-`object localVideo` - *optional* options for attaching the local video
130
+
stream to the page. Defaults to
107
131
```javascript
108
132
{
109
133
autoplay:true, // automatically play the video stream on the page
110
134
mirror:true, // flip the local video to mirror mode (for UX)
111
135
muted:true// mute local video stream to prevent echo
112
136
}
113
137
```
114
-
-`object logger` - *optional* alternate logger for the instance; any object that implements `log`, `warn`, and `error` methods.
138
+
-`object logger` - *optional* alternate logger for the instance; any object
139
+
that implements `log`, `warn`, and `error` methods.
115
140
116
141
### Fields
117
142
118
-
`capabilities` - the [`webrtcSupport`](https://github.com/HenrikJoreteg/webrtcsupport) object that describes browser capabilities, for convenience
143
+
`capabilities` - the
144
+
[`webrtcSupport`](https://github.com/HenrikJoreteg/webrtcsupport) object that
145
+
describes browser capabilities, for convenience
119
146
120
-
`config` - the configuration options extended from options passed to the constructor
147
+
`config` - the configuration options extended from options passed to the
148
+
constructor
121
149
122
150
`connection` - the socket (or alternate) signaling connection
123
151
124
152
`webrtc` - the underlying WebRTC session manager
125
153
126
154
### Events
127
155
128
-
`'connectionReady', sessionId`
156
+
To set up event listeners, use the SimpleWebRTC instance created with the
157
+
constructor. Example:
129
158
130
-
`'createdPeer', peer`
159
+
```javascript
160
+
var webrtc =newSimpleWebRTC(options);
131
161
132
-
`'stunservers', stunServers`
162
+
webrtc.on('connectionReady', function (sessionId) {
133
163
134
-
`'turnservers', turnservers`
164
+
})
165
+
```
166
+
167
+
`'connectionReady', sessionId` - emitted when the signaling connection emits the
168
+
`connect` event, with the unique id for the session.
169
+
170
+
`'createdPeer', peer` - emitted three times:
171
+
172
+
- when joining a room with existing peers, once for each peer
173
+
- when a new peer joins a joined room
174
+
- when sharing screen, once for each peer
175
+
176
+
-`peer` - the object representing the peer and underlying peer connection
177
+
178
+
`'stunservers', [...args]` - emitted when the signaling connection emits the
179
+
same event
180
+
181
+
`'turnservers', [...args]` - emitted when the signaling connection emits the
182
+
same event
183
+
184
+
`'localScreenAdded', el` - emitted after triggering the start of screen sharing
185
+
186
+
-`el` the element that contains the local screen stream
187
+
188
+
`leftRoom, roomName` - emitted after successfully leaving the current room,
189
+
ending all peers, and stopping the local screen stream
190
+
191
+
`videoAdded, videoEl, peer` - emitted when a peer stream is added
192
+
193
+
-`videoEl` - the video element associated with the stream that was added
194
+
-`peer` - the peer associated with the stream that was added
195
+
196
+
`videoRemoved, videoEl, peer` - emitted when a peer stream is removed
135
197
136
-
`'localScreenAdded', el`
198
+
-`videoEl` - the video element associated with the stream that was removed
199
+
-`peer` - the peer associated with the stream that was removed
137
200
138
201
### Methods
139
202
140
-
`leaveRoom()`
203
+
`leaveRoom()` - leaves the currently joined room and stops local screen share
141
204
142
-
`disconnect()`
205
+
`disconnect()` - calls `disconnect` on the signaling connection and deletes it
143
206
144
-
`handlePeerStreamAdded(peer)`
207
+
`shareScreen(callback)` - initiates screen capture request to browser, then
208
+
adds the stream to the conference
145
209
146
-
`handlePeerStreamRemoved(peer)`
210
+
`getLocalScreen()` - returns the local screen stream
147
211
148
-
`getDomId(peer)`
212
+
`stopScreenShare()` - stops the screen share stream and removes it from the room
149
213
150
-
`setVolumeForAll(volume)`
214
+
`testReadiness()` - tests that the connection is ready and that (if media is
215
+
enabled) streams have started
151
216
152
-
`joinRoom(name, callback)`
217
+
`createRoom(name, callback)` - emits the `create` event on the connection with
218
+
`name` and (if provided) invokes `callback` on response
153
219
154
-
`getEl(idOrEl)`
220
+
`joinRoom(name, callback)` - joins the conference in room `name`. Callback is
221
+
invoked with `callback(err, roomDescription)` where `roomDescription` is yielded
222
+
by the connection on the `join` event. See signalmaster for more details.
155
223
156
-
`startLocalVideo()`
224
+
`startLocalVideo()` - starts the local media with the `media` options provided
225
+
in the config passed to the constructor
157
226
158
-
`stopLocalVideo()`
227
+
`stopLocalVideo()` - stops all local media streams
159
228
160
-
`getLocalVideoContainer()`
229
+
`setVolumeForAll(volume)` - used to set the volume level for all peers
161
230
162
-
`getRemoteVideoContainer()`
231
+
-`volume` - the volume level, between 0 and 1
163
232
164
-
`shareScreen(callback)`
233
+
`handlePeerStreamAdded(peer)` - used internally to attach media stream to the
234
+
DOM and perform other setup
165
235
166
-
`getLocalScreen()`
236
+
`handlePeerStreamRemoved(peer)` - used internally to remove the video container
237
+
from the DOM and emit `videoRemoved`
167
238
168
-
`stopScreenShare()`
239
+
`getDomId(peer)` - used internally to get the DOM id associated with a peer
169
240
170
-
`testReadiness()`
241
+
`getEl(idOrEl)` - helper used internally to get an element where `idOrEl` is
242
+
either an element, or an id of an element
171
243
172
-
`createRoom(name, callback)`
244
+
`getLocalVideoContainer()` - used internally to get the container that will hold
245
+
the local video element
173
246
174
-
`sendFile()`
247
+
`getRemoteVideoContainer()` - used internally to get the container that holds
248
+
the remote video elements
175
249
176
250
### Connection
177
251
178
-
By default, SimpleWebRTC uses a Socket.io connection to communicate with the signaling server. However, you can provide an alternate connection object to use. All that your alternate connection need provide are four methods:
252
+
By default, SimpleWebRTC uses a [socket.io](http://socket.io/) connection to
253
+
communicate with the signaling server. However, you can provide an alternate
254
+
connection object to use. All that your alternate connection need provide are
255
+
four methods:
179
256
180
257
-`on(ev, fn)` - A method to invoke `fn` when event `ev` is triggered
181
258
-`emit()` - A method to send/emit arbitrary arguments on the connection
0 commit comments