Goals:
- Obtain list of available inputs
- Obtain list of supported video and audio constraints
- Get User media
- Detect custom screenshare extension
- Request screenshare extension
- ES6 Syntax
- Travis CI
The following API enpoints are available:
- listDevices
- listDevicesP
- listInputDevices
- listInputDevicesP
- listSupportedConstraints
- checkExtension
- checkExtensionP
- getScreen
- getScreenP
- getMedia
- setTestConstraints
- stopAllTracks
Each of the following sections explains the mode of use of each of the functions and objects made available in the module.
To start using the module clone the repo into your node_modules
folder:
npm install git+https://github.com/ferborva/webrtc-int.git --save
Then require/import it into your front-end project:
eg. import WebStreams from 'webrtc-int';
For the module to work you will need to leverage a build system which makes use of Babel (ES6 to compatibile syntax) and Browserify/Webpack or one alike.
Good examples of ready to use development systems are the EmberCLI and Meteor Project. Indeed there are many more that can be used.
The module offers API endpoints which use either Promise based results or Task objects to the user in order to offer a greater flexibility in the use. Notice that the Task versions are objects where as the Promise versions are functions that have to be invoked before they are managed.
Type: Task
WebStreams.listDevices
.fork(error => {
// Handle error
}, results => {
// Handle Array of results
})
Type: Function
Return: Promise
WebStreams.listDevicesP()
.then(results => {
// Handle Array of results
}, error => {
// Handle error
})
Type: Task
WebStreams.listInputDevices
.fork(error => {
// Handle error
}, results => {
// Handle Array of results
})
Type: Function
Return: Promise
WebStreams.listInputDevicesP()
.then(results => {
// Handle Array of results
}, error => {
// Handle error
})
List Device possible Error messages. These apply to the above calls:
- Get User Media not supported
- Enumerate devices not supported
- InternalError on enumerateDevices API
Type: Function
Return: Array
const results = WebStreams.listSupportedConstraints()
Type: Task (Predicate)
WebStreams.checkExtension
.fork(error => {
// Handle error
}, ok => {
// Handle ok
})
Type: Function
Return: Promise (Predicate)
WebStreams.checkExtensionP()
.then(ok => {
// Handle ok
}, error => {
// Handle error
})
Type: Task
WebStreams.getScreen
.fork(error => {
// Handle error
}, result => {
// Handle MediaStream result
})
Type: Function
Return: Promise
WebStreams.getScreenP()
.then(result => {
// Handle MediaStream result
}, error => {
// Handle error
})
Get Screen Share possible Error messages. These apply to the above calls:
- Screen Share extension is not installed or disabled
- Screen Share extension not responding
- Screen Share permission denied by user
- Get User Media not supported
- Only secure origins are allowed
- InternalError on getUserMedia API
Type: Function
Param: constraints ; Type: Object ; Values: MediaStreamConstraints dictionary
Return: Promise
WebStreams.getMedia(constraints)
.then(result => {
// Handle MediaStream result
}, error => {
// Handle error
})
Examples of constraints:
const ex1 = {
video: true
}
const ex2 = {
audio: true
}
const ex3 = {
video: true,
audio: true
}
const ex4 = {
video: {
width: 160,
height: 120
},
audio: {
echoCancellation: true
}
}
Test Mode
Available for low resolution options. To use the test mode constraints call getMedia
with:
const constraints = {testMode: true}
WebStreams.getMedia(constraints)
.then(result => {
// Handle MediaStream result
}, error => {
// Handle error
})
Get User Media possible Error messages:
- Get User Media not supported
- At least one of audio and video must be requested
- Only secure origins are allowed
- InternalError on getUserMedia API
Type: Function
Param: constraints ; Type: Object ; Values: MediaStreamConstraints dictionary
Return: Object
WebStreams.setTestConstraints(constraints)
By default the testing constraints used are:
{
video: {
height: 120,
width: 160,
frameRate: {
ideal: 5,
max: 10
},
facingMode: 'user'
},
audio: {
echoCancellation: true,
volume: 1
}
}
Type: Function
Return: Either Type
WebStreams.stopAllTracks()
This function will go through all the cached MediaStreams, look for the active tracks on them and stop the tracks. Helper function used to clear the browser's "recording" state.
Unit tests are run using Mocha. You can install it with the following command:
npm install -g mocha
and run the tests with:
mocha
or npm test
- compose
- composeK
- filter
- map
- flatten
- isNil
- prop
- chain
- test
- curry
Build command:
./scripts/build -- src/chain.js src/filter.js src/map.js src/flatten.js src/curry.js src/isNil.js src/prop.js src/is.js src/test.js src/compose.js src/composeK.js > dist/ramda.custom.js