All Projects → react-native-webrtc → React Native Webrtc

react-native-webrtc / React Native Webrtc

Licence: mit
The WebRTC module for React Native

Programming Languages

java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to React Native Webrtc

Wilearning
Multiparty meeting&e-learning using mediasoup, webrtc ,angular and ionic with powerful whiteboard support
Stars: ✭ 280 (-92.48%)
Mutual labels:  webrtc
Meething
dWebRTC Video Meetings MESH/SFU hybrid using GunDB, MediaSoup and Beyond!
Stars: ✭ 303 (-91.86%)
Mutual labels:  webrtc
Gb28181.solution
Linux/Win/Docker/kubernetes/Chart/Kustomize/GB28181/SIP/RTP/SDP/WebRTC/作为上下级域/平台级联互联
Stars: ✭ 323 (-91.33%)
Mutual labels:  webrtc
Vosk Server
WebSocket, gRPC and WebRTC speech recognition server based on Vosk and Kaldi libraries
Stars: ✭ 277 (-92.56%)
Mutual labels:  webrtc
Peerjs Server
Server for PeerJS
Stars: ✭ 3,313 (-11.04%)
Mutual labels:  webrtc
Monibuca
🧩 Monibuca is a Modularized, Extensible framework for building Streaming Server
Stars: ✭ 307 (-91.76%)
Mutual labels:  webrtc
Ion
Real-Distributed RTC System by pure Go and Flutter
Stars: ✭ 3,279 (-11.95%)
Mutual labels:  webrtc
Webrtc Pc
WebRTC 1.0 API
Stars: ✭ 323 (-91.33%)
Mutual labels:  webrtc
Jeelizar
JavaScript object detection lightweight library for augmented reality (WebXR demos included). It uses convolutional neural networks running on the GPU with WebGL.
Stars: ✭ 296 (-92.05%)
Mutual labels:  webrtc
Mediasoup
Cutting Edge WebRTC Video Conferencing
Stars: ✭ 4,054 (+8.86%)
Mutual labels:  webrtc
Starrtc Web Demo
一对一voip视频聊天,直播连麦,多人视频会议,在线会议web演示:
Stars: ✭ 281 (-92.45%)
Mutual labels:  webrtc
Awesome Live Stream
Webrtc && Nginx && DASH && Quic 学习资料收集,持续更新中
Stars: ✭ 290 (-92.21%)
Mutual labels:  webrtc
Server
screen sharing for developers https://screego.net/
Stars: ✭ 3,931 (+5.56%)
Mutual labels:  webrtc
Glipchat
video chatroom using meteor + webrtc + react + redux
Stars: ✭ 280 (-92.48%)
Mutual labels:  webrtc
Mediasoup Client
mediasoup client side JavaScript library
Stars: ✭ 320 (-91.41%)
Mutual labels:  webrtc
Awesome Pion
A curated list of awesome things related to Pion
Stars: ✭ 272 (-92.7%)
Mutual labels:  webrtc
Webrtc Tutorial
📚 WebRTC 中文教程
Stars: ✭ 305 (-91.81%)
Mutual labels:  webrtc
Smoke
Turns a Web Browser into a Web Server with WebRTC
Stars: ✭ 326 (-91.25%)
Mutual labels:  webrtc
Rawrtc
WebRTC and ORTC with a little bit of RAWR!
Stars: ✭ 323 (-91.33%)
Mutual labels:  webrtc
Decentralized Video Chat
🚀 Zipcall- Acquired @ 250k users 🚀 Peer to peer browser video calling platform with unmatched video quality and latency.
Stars: ✭ 3,284 (-11.82%)
Mutual labels:  webrtc

react-native-webrtc

npm version npm downloads

A WebRTC module for React Native.

  • Support iOS / macOS / Android.
  • Support Video / Audio / Data Channels.

NOTE for Expo users: this plugin doesn't work unless you eject.

Community

Everyone is welcome to our Discourse community to discuss any React Native and WebRTC related topics.

WebRTC Revision

  • Currently used revision: M94
  • Supported architectures
    • Android: armeabi-v7a, arm64-v8a, x86, x86_64
    • iOS: arm64, x86_64 (for bitcode support, run this script)
    • macOS: x86_64

Installation

Usage

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.

import {
  RTCPeerConnection,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView,
  MediaStream,
  MediaStreamTrack,
  mediaDevices,
  registerGlobals
} from 'react-native-webrtc';

Anything about using RTCPeerConnection, RTCSessionDescription and RTCIceCandidate is like browser. Support most WebRTC APIs, please see the Document.

const configuration = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]};
const pc = new RTCPeerConnection(configuration);

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;
    }
  }
  mediaDevices.getUserMedia({
    audio: true,
    video: {
      width: 640,
      height: 480,
      frameRate: 30,
      facingMode: (isFront ? "user" : "environment"),
      deviceId: videoSourceId
    }
  })
  .then(stream => {
    // Got stream!
  })
  .catch(error => {
    // Log error
  });
});

pc.createOffer().then(desc => {
  pc.setLocalDescription(desc).then(() => {
    // Send pc.localDescription to peer
  });
});

pc.onicecandidate = function (event) {
  // send event.candidate to peer
};

// also support setRemoteDescription, createAnswer, addIceCandidate, onnegotiationneeded, oniceconnectionstatechange, onsignalingstatechange, onaddstream

RTCView

However, render video stream should be used by React way.

Rendering RTCView.

<RTCView streamURL={this.state.stream.toURL()}/>
Name Type Default Description
mirror boolean false Indicates whether the video specified by "streamURL" should be mirrored during rendering. Commonly, applications choose to mirror theuser-facing camera.
objectFit string 'contain' Can be contain or cover
streamURL string '' This is mandatory
zOrder number 0 Similarly to zIndex

Custom APIs

registerGlobals()

By calling this method the JavaScript global namespace gets "polluted" with the following additions:

  • navigator.mediaDevices.getUserMedia()
  • navigator.mediaDevices.getDisplayMedia()
  • navigator.mediaDevices.enumerateDevices()
  • window.RTCPeerConnection
  • window.RTCIceCandidate
  • window.RTCSessionDescription
  • window.MediaStream
  • window.MediaStreamTrack

This is useful to make existing WebRTC JavaScript libraries (that expect those globals to exist) work with react-native-webrtc.

MediaStreamTrack.prototype._switchCamera()

This function allows to switch the front / back cameras in a video track on the fly, without the need for adding / removing tracks or renegotiating.

VideoTrack.enabled

Starting with version 1.67, when setting a local video track's enabled state to false, the camera will be closed, but the track will remain alive. Setting it back to true will re-enable the camera.

Related projects

The react-native-webrtc organization provides a number of packages which are useful when developing Real Time Communications applications.

The react-native-webrtc-web-shim project provides a shim for react-native-web support, allowing you to use (almost) the same code in react-native-web as in react-native.

Acknowledgements

Thanks to all contributors for helping with the project!

Special thanks to Wan Huang Yang for creating the first version of this package.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].