Skip to content

Commit 64cf6b2

Browse files
author
Xander Dumaine
committed
Add constructor options documentation
1 parent 0290ae3 commit 64cf6b2

File tree

1 file changed

+102
-3
lines changed

1 file changed

+102
-3
lines changed

README.md

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Want to see it in action? Check out the demo: https://talky.io/
1414
<!DOCTYPE html>
1515
<html>
1616
<head>
17-
<script src="http://simplewebrtc.com/latest-v2.js"></script>
17+
<script src="http://simplewebrtc.com/latest-v2.js"></script>
1818
<style>
1919
#remoteVideos video {
2020
height: 150px;
@@ -60,7 +60,7 @@ webrtc.on('readyToCall', function () {
6060

6161
`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
6262

63-
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.
63+
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.
6464

6565
## Filetransfer
6666
Sending files between individual participants is supported. See http://simplewebrtc.com/filetransfer.html for a demo.
@@ -73,7 +73,7 @@ Sometimes you need to do more advanced stuff. See http://simplewebrtc.com/notsos
7373

7474
## Got questions?
7575

76-
Join the SimpleWebRTC discussion list:
76+
Join the SimpleWebRTC discussion list:
7777

7878
http://lists.andyet.com/mailman/listinfo/simplewebrtc
7979

@@ -82,3 +82,102 @@ or the Gitter channel:
8282
https://gitter.im/HenrikJoreteg/SimpleWebRTC
8383

8484
## API
85+
86+
### Constructor
87+
88+
`new SimpleWebRTC(options)`
89+
90+
- `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
94+
- `bool debug` - *optional* flag to set the instance to debug mode
95+
- `[string|DomElement] locaVidelEl` - ID or Element to contain the local video element
96+
- `[string|DomElement] remoteVideosEl` - ID or Element to contain the
97+
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
102+
- `number peerVolumeWhenSpeaking` - *optional(=.0.25)* value used in
103+
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).
105+
- `object receiveMedia` - *optional* RTCPeerConnection options. Defaults to `{ offerToReceiveAudio: 1, offerToReceiveVideo: 1 }`.
106+
- `object localVideo` - *optional* options for attaching the local video stream to the page. Defaults to
107+
```javascript
108+
{
109+
autoplay: true, // automatically play the video stream on the page
110+
mirror: true, // flip the local video to mirror mode (for UX)
111+
muted: true // mute local video stream to prevent echo
112+
}
113+
```
114+
- `object logger` - *optional* alternate logger for the instance; any object that implements `log`, `warn`, and `error` methods.
115+
116+
### Fields
117+
118+
`capabilities` - the [`webrtcSupport`](https://github.com/HenrikJoreteg/webrtcsupport) object that describes browser capabilities, for convenience
119+
120+
`config` - the configuration options extended from options passed to the constructor
121+
122+
`connection` - the socket (or alternate) signaling connection
123+
124+
`webrtc` - the underlying WebRTC session manager
125+
126+
### Events
127+
128+
`'connectionReady', sessionId`
129+
130+
`'createdPeer', peer`
131+
132+
`'stunservers', stunServers`
133+
134+
`'turnservers', turnservers`
135+
136+
`'localScreenAdded', el`
137+
138+
### Methods
139+
140+
`leaveRoom()`
141+
142+
`disconnect()`
143+
144+
`handlePeerStreamAdded(peer)`
145+
146+
`handlePeerStreamRemoved(peer)`
147+
148+
`getDomId(peer)`
149+
150+
`setVolumeForAll(volume)`
151+
152+
`joinRoom(name, callback)`
153+
154+
`getEl(idOrEl)`
155+
156+
`startLocalVideo()`
157+
158+
`stopLocalVideo()`
159+
160+
`getLocalVideoContainer()`
161+
162+
`getRemoteVideoContainer()`
163+
164+
`shareScreen(callback)`
165+
166+
`getLocalScreen()`
167+
168+
`stopScreenShare()`
169+
170+
`testReadiness()`
171+
172+
`createRoom(name, callback)`
173+
174+
`sendFile()`
175+
176+
### Connection
177+
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:
179+
180+
- `on(ev, fn)` - A method to invoke `fn` when event `ev` is triggered
181+
- `emit()` - A method to send/emit arbitrary arguments on the connection
182+
- `getSessionId()` - A method to get a unique session Id for the connection
183+
- `disconnect()` - A method to disconnect the connection

0 commit comments

Comments
 (0)