react-native-webrtc | A WebRTC module for React Native
kandi X-RAY | react-native-webrtc Summary
kandi X-RAY | react-native-webrtc Summary
A WebRTC module for React Native.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Called when a media stream is added
- Returns a streamUUID that can be used to identify a stream
- Get the media stream for a local stream
- Handles rendering of a frame
- Updates the frame dimensions and reports changes
- Logs the rendering statistics
- Get audio stream info
- Get camera info for specified camera
- On remove stream
- Get the react tag for a given media stream
- Sets the stream URL for the given view
- Stop tracking for a media stream
- Releases a media stream
- Set the layout size
- Remove a single stream from the peer connection
- Adds a stream to the peer connection
- Called when a connection is received
- Called when the surface is destroyed
- From interface DataChannel
- Received data channel
- Set the description of a peer connection
- Releases a media stream from a media stream
- Handles creation of a peer connection request
- Sets the local description for a peer connection
- Render a frame
- Add a connection to the peer connection
react-native-webrtc Key Features
react-native-webrtc Examples and Code Snippets
Community Discussions
Trending Discussions on react-native-webrtc
QUESTION
I am building an app like Messenger, everything works normally like sending messages, receiving messages, video calling. the technologies i use are react-native, reactJS, socket.io, nodeJS, react-native-webrtc
I wonder how can when I close an app like the messenger I can still receive incoming call notifications from other people. I'm studying firebase notification and react-native-background-timer but it doesn't seem to work the way I want it to
Has anyone had a problem like this and have an answer, please let me know Have a nice day guys <3
...ANSWER
Answered 2022-Mar-29 at 05:23In react native firebase there are two types of notifications "background"
and "foreground"
.
Foreground Notifications:
A foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a Notification. Foreground services continue running even when the user isn't interacting with the app.
When you use a foreground service, you must display a notification so that users are actively aware that the service is running. This notification cannot be dismissed unless the service is either stopped or removed from the foreground.
Background Notification:
A background service performs an operation that isn't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service.
You want to follow there Documentation to apply push notifications in react native.
QUESTION
I was learning a bit about using 'useRef' hooks in React Native functions. While examining some code I found on the Internet...I saw usage including question marks ("?"), like this (as noted in the code):
...ANSWER
Answered 2022-Mar-12 at 08:26it's look you don't need ?.
on your example, it's optional chaining, and one more, please add you cunstruction to the ref
QUESTION
Unfortunately, from time to time when making a one-on-one video call using react-native-webrtc
one of the two video streams freezes or becomes black. Is there a way to detect when that happens programmatically? Thx in advance!
ANSWER
Answered 2021-Oct-13 at 21:51It looks like each video track has a listener that fires as soon as the stream freezes.
In react native it's the onmute
listener:
QUESTION
i have converted my class based component as below and i have converted to function based in the below but i am not sure about if my variables are are defined correctly and my function based component is running as a infinite loop can someone guide me right direction?
...ANSWER
Answered 2021-Sep-01 at 11:02import React, { useEffect } from "react";
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
TouchableOpacity,
Dimensions,
} from "react-native";
import {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
registerGlobals,
} from "react-native-webrtc";
import io from "socket.io-client";
const dimensions = Dimensions.get("window");
const pc_config = {
iceServers: [
// {
// urls: 'stun:[STUN_IP]:[PORT]',
// 'credentials': '[YOR CREDENTIALS]',
// 'username': '[USERNAME]'
// },
{
urls: "stun:stun.l.google.com:19302",
},
],
};
function App(props) {
const [localStream, SetlocalStream] = useState(null);
const [remoteStream, SetremoteStream] = useState(null);
const socket = useRef(
io.connect("https://daae-171-61-.ngrok.io/webrtcPeer", {
path: "/io/webrtc",
query: {},
})
);
const sdp = useRef(null);
const pc = useRef(new RTCPeerConnection(pc_config));
const candidates = useRef([]);
useEffect(() => {
socket.current.on("connection-success", (success) => {
console.log(success);
});
socket.current.on("offerOrAnswer", (sdp) => {
sdp.current = JSON.stringify(sdp);
// set sdp as remote description
pc.current.setRemoteDescription(new RTCSessionDescription(sdp));
});
socket.current.on("candidate", (candidate) => {
// console.log('From Peer... ', JSON.stringify(candidate))
// candidates.current = [...candidates.current, candidate]
pc.current.addIceCandidate(new RTCIceCandidate(candidate));
});
pc.current = new RTCPeerConnection(pc_config);
pc.current.onicecandidate = (e) => {
// send the candidates to the remote peer
// see addCandidate below to be triggered on the remote peer
if (e.candidate) {
// console.log(JSON.stringify(e.candidate))
sendToPeer("candidate", e.candidate);
}
};
// triggered when there is a change in connection state
pc.current.oniceconnectionstatechange = (e) => {
console.log(e);
};
pc.current.onaddstream = (e) => {
debugger;
// this.remoteVideoref.current.srcObject = e.streams[0]
SetremoteStream(e.stream);
};
const success = (stream) => {
console.log(stream.toURL());
SetlocalStream(stream);
pc.current.addStream(stream);
};
const failure = (e) => {
console.log("getUserMedia Error: ", e);
};
let isFront = true;
mediaDevices.enumerateDevices().then((sourceInfos) => {
console.log(sourceInfos);
let videoSourceId;
for (let i = 0; i < sourceInfos.length; i++) {
const sourceInfo = sourceInfos[i];
if (
sourceInfo.kind == "videoinput" &&
sourceInfo.facing == (isFront ? "front" : "environment")
) {
videoSourceId = sourceInfo.deviceId;
}
}
const constraints = {
audio: true,
video: {
mandatory: {
minWidth: 500, // Provide your own width, height and frame rate here
minHeight: 300,
minFrameRate: 30,
},
facingMode: isFront ? "user" : "environment",
optional: videoSourceId ? [{ sourceId: videoSourceId }] : [],
},
};
mediaDevices.getUserMedia(constraints).then(success).catch(failure);
});
}, []);
const sendToPeer = (messageType, payload) => {
socket.current.emit(messageType, {
socketID: socket.current.id,
payload,
});
};
const createOffer = () => {
console.log("Offer");
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer
// initiates the creation of SDP
pc.current.createOffer({ offerToReceiveVideo: 1 }).then((sdp) => {
// console.log(JSON.stringify(sdp))
// set offer sdp as local description
pc.current.setLocalDescription(sdp);
sendToPeer("offerOrAnswer", sdp);
});
};
const createAnswer = () => {
console.log("Answer");
pc.current.createAnswer({ offerToReceiveVideo: 1 }).then((sdp) => {
// console.log(JSON.stringify(sdp))
// set answer sdp as local description
pc.current.setLocalDescription(sdp);
sendToPeer("offerOrAnswer", sdp);
});
};
const setRemoteDescription = () => {
// retrieve and parse the SDP copied from the remote peer
const desc = JSON.parse(sdp.current);
// set sdp as remote description
pc.current.setRemoteDescription(new RTCSessionDescription(desc));
};
const addCandidate = () => {
// retrieve and parse the Candidate copied from the remote peer
// const candidate = JSON.parse(this.textref.value)
// console.log('Adding candidate:', candidate)
// add the candidate to the peer connection
// pc.current.addIceCandidate(new RTCIceCandidate(candidate))
candidates.current.forEach((candidate) => {
console.log(JSON.stringify(candidate));
pc.current.addIceCandidate(new RTCIceCandidate(candidate));
});
};
const remoteVideo = remoteStream ? (
) : (
Waiting for Peer connection ...
);
return (
Call
Answer
localStream._tracks[1]._switchCamera()}
>
{remoteVideo}
);
}
export default App;
const styles = StyleSheet.create({
buttonsContainer: {
flexDirection: "row",
},
button: {
margin: 5,
paddingVertical: 10,
backgroundColor: "lightgrey",
borderRadius: 5,
},
textContent: {
fontFamily: "Avenir",
fontSize: 20,
textAlign: "center",
},
videosContainer: {
flex: 1,
flexDirection: "row",
justifyContent: "center",
},
rtcView: {
width: 100, //dimensions.width,
height: 200, //dimensions.height / 2,
backgroundColor: "black",
},
scrollView: {
flex: 1,
// flexDirection: 'row',
backgroundColor: "teal",
padding: 15,
},
rtcViewRemote: {
width: dimensions.width - 30,
height: 200, //dimensions.height / 2,
backgroundColor: "black",
},
});
QUESTION
ANSWER
Answered 2021-Aug-17 at 06:56Your comment is getting deleted for some reason. Please check if you have placed the google-service.json in the correct place. The naming of that is file important. Make sure there is no number added at the end. It should be as you downloaded.
QUESTION
I am trying to make a peer to peer video call app. I am using expo for the front end and I want to know how to get the media stream from the mobile camera to pass it to the peer.currently this can be achieved using react-native-webrtc but expo does not support this package. So is there any alternatives to get media stream from camera ?
...ANSWER
Answered 2021-Jun-23 at 14:10QUESTION
i'm seeing this error in my react-native app on android before launch. I haven't tested on iOS
this is a copy of my metro
...ANSWER
Answered 2021-May-09 at 21:04Realized it only occurs on 1.89.1
downgrading to 1.84.1 worked for me
QUESTION
I'm facing a complex error when import react-native-peerjs module to any file in React native project. I just tried everything, but nothing works. Can you help me? That is the error.
Error: Unknown named module "react-native-webrtc"
This is the step-by-step if someone wanna test.
npx react-native init teste . yarn add react-native-webrtc . cd ios && pod install . cd .. . yarn add react-native-peerjs . npx react-native run-ios . import Peer from 'react-native-peerjs' in App.js
...ANSWER
Answered 2021-Apr-29 at 11:26On metro.config.js
located at the root folder of the app, changing the inlineRequires
to false
should do the job.
QUESTION
I'm using react native for webrtc and I keep getting mediaDevices.enumerateDevices() is object of null.
this is part of the code where its falling:
...ANSWER
Answered 2021-Mar-31 at 07:55You have to first ask for permission of the access input & output devices then run enumerateDevices()
QUESTION
I have this in my React Native Code:
...ANSWER
Answered 2021-Mar-25 at 14:03change permissions to PERMISSIONS in permissionCheck function
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-native-webrtc
You can use react-native-webrtc like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the react-native-webrtc component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page