Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-native-webrtc
Advanced tools
A WebRTC module for React Native.
please see #79 for discussions.
and wiki page to see revisions
react-native-webrtc | WebRTC(ios) | WebRTC(android) | npm published |
---|---|---|---|
<= 0.9.0 | branch ~47 beta (11177) | branch ~47 beta (11139) | :heavy_check_mark: |
0.10.0 | branch 52 stable (12798) | branch 52 stable (12798) | :heavy_check_mark: |
0.11.0 | branch 52 stable (12798) | branch 52 stable (12798) | :heavy_check_mark: |
0.12.0 | branch 53 stable (13317) | branch 53 stable (13317) | :warning: |
since 0.10.0, we upgrade webrtc library to branch 52 stable release, and store library on Git Large File Storage
you may need to install git lfs
to automatically download library when git clone
or npm install
.
belows are brief memo, please go to Git LFS official website for details.
Linux: download git-lfs tar file
and execute install.sh
inside it.
Mac: brew install git-lfs
or port install git-lfs
then git lfs install
Now, you can use WebRTC like in browser.
In your index.ios.js
/index.android.js
, you can require WebRTC to import RTCPeerConnection, RTCSessionDescription, etc.
var WebRTC = require('react-native-webrtc');
var {
RTCPeerConnection,
RTCMediaStream,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStreamTrack,
getUserMedia,
} = WebRTC;
Anything about using RTCPeerConnection, RTCSessionDescription and RTCIceCandidate is like browser.
Support most WebRTC APIs, please see the Document.
var configuration = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]};
var pc = new RTCPeerConnection(configuration);
MediaStreamTrack.getSources(sourceInfos => {
var videoSourceId;
for (var i = 0; i < sourceInfos.length; i++) {
var sourceInfo = sourceInfos[i];
if(sourceInfo.kind == "video" && sourceInfo.facing == "front") {
videoSourceId = sourceInfo.id;
}
}
getUserMedia({
"audio": true,
"video": {
optional: [{sourceId: videoSourceId}]
}
}, function (stream) {
pc.addStream(stream);
}, logError);
});
pc.createOffer(function(desc) {
pc.setLocalDescription(desc, function () {
// Send pc.localDescription to peer
}, function(e) {});
}, function(e) {});
pc.onicecandidate = function (event) {
// send event.candidate to peer
};
// also support setRemoteDescription, createAnswer, addIceCandidate, onnegotiationneeded, oniceconnectionstatechange, onsignalingstatechange, onaddstream
However, render video stream should be used by React way.
Rendering RTCView.
var container;
var RCTWebRTCDemo = React.createClass({
getInitialState: function() {
return {videoURL: null};
},
componentDidMount: function() {
container = this;
},
render: function() {
return (
<View>
<RTCView streamURL={this.state.videoURL}/>
</View>
);
}
});
And set stream to RTCView
container.setState({videoURL: stream.toURL()});
The demo project is https://github.com/oney/RCTWebRTCDemo
And you will need a signaling server. I have written a signaling server https://react-native-webrtc.herokuapp.com/ (the repository is https://github.com/oney/react-native-webrtc-server).
You can open this website in browser, and then set it as signaling server in the app, and run the app. After you enter the same room ID, the video stream will be connected.
Use react-native-incall-manager to keep screen on, mute microphone, etc.
This repository doesn't have a plan to get sponsorship.(This can be discussed afterwards by collaborators). If you would like to pay bounty to fix some bugs or get some features, be free to open a issue that adds [BOUNTY]
category in title. Add other bounty website link like this will be better.
FAQs
WebRTC for React Native
The npm package react-native-webrtc receives a total of 9,794 weekly downloads. As such, react-native-webrtc popularity was classified as popular.
We found that react-native-webrtc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.