WebRTC Plugin for Cordova
NOTE: This project is not production ready.
This project aims to implement the full WebRTC API on Cordova.
- Shim implementations:
- getUserMedia (not really part of WebRTC, but needed to get for audio/video input)
- Android 4.0+ coming soon
cordova plugin add cordova-plugin-webrtc
Just use exactly the same WebRTC code as you would be using for a browser page! Bear in mind the following quirks:
- Only use the WebRTC related APIs after getting cordova's deviceReady event.
<webrtc-video>tag instead of
<video>if you dont want any video player skin to be shown. If you do that, you'll need to use el.setAttribute('src', ...) instead of el.src for the MutableObserver to detect changes in the 'src' element. Example:
// ------- for <video> tags -------navigator;// ------- for <webrtc-video> tags -------navigator;
- Use pc.dispose() to clear the native peer connection object after closing it.
- Canvas operations not supported over the WebRTC video elements.
- getUserMedia only returns front camera.
- getUserMedia overrides native implementation (if it exists). Do not use it for anything else.
- Audio tracks will be enabled even if the video tag is not in the DOM.
- No MediaStream callbacks
To make this implementation work almost seamless with the WebRTC standard, we use some hacks that allow us to overlay the native WebRTC video views on the page.
- Use MutationObserver to listen for changing tags.
- Implement MediaStream on top of Blob, so it is compatible with URL.createObjectURL.
How to build for development
You shall already have the npm tool (required for cordova). Just do:
npm install bower install gulp build
WebRTC working samples (tested)
Note, the samples were only modified for its scripts only execute after cordova's deviceReady event is triggered.
Currently tested and working samples:
- Basic getUserMedia demo
- Audio-only peer connection
- Transmit text
We use the github issue tracker and pull request frameworks to accept contributions.
To do list
- All kinds of tests
- Support for other platforms
- Better object cleanup
This software is released under the Apache 2.0 License.
© 2015 Remotium, Inc. All rights reserved