3.0.11 • Published 3 years ago

@lapix/olwebrtc v3.0.11

Weekly downloads
6
License
ISC
Repository
github
Last release
3 years ago

Otra Librería WebRTC (olwebrtc)

npm npm

Yet another WebRTC Library.

Usage

import {WebRTCCall} from '@lapix/olwebrtc/dist/webrtc-call';
import {GraphqlSignaling} from '@lapix/olwebrtc/dist/graphql-signaling';
import {FetchCheckNetworkStatus} from '@lapix/olwebrtc/dist/fetch-check-network-status';
import newCallClient from "@lapix/olwebrtc/dist/graphql-client"

// Split the mutations and subscriptions based on the
// current graphql implementation.
const apolloClient = newCallClient({uri: "wss://my-signaling-server.io/query"}, currentApolloClient)

const call = new WebRTCCall({
  // Zero Log everything, Five silence.
  logLevel: 5,
  // Will sanitize the sdp, browsers will not support that.
  allowSDPTransform: true,
  // If could not find a valid ice, then will try to make
  // the call again.
  allowIceStalledChecking: true,
  // If the ICE connection state is disconnected it will
  // check the bitrate in the next 5s and if it get worst 
  // the will restart the ICE candidates.
  allowBitrateChecking: true,
  // Max bandwidth.
  bandwidth: 300,
  // Will check the network connection to if the peer connection
  // is closed before the call has been finished.
  network: new FetchCheckNetworkStatus(),
  signaling: new GraphqlSignaling(apolloClient),
  rtcConfiguration: {
    iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
  },
});

call.start({
  roomId: "vip-room",
  mediaStreamConstrains: {
    camera: {
      video: {
        width: { min: 720 },
        height: { min: 480 },
        frameRate: { max: 30 },
      },
      audio: {
        noiseSuppression: true,
      },
    },
    // By default it will share the camera stream, if you want to
    // share your screen just call the `shareScreen` method, by now
    // it does not renegotiate, it just close the connection and start
    // a new one, then if you what to share the camera again just call
    // the `shareVideo` method.
    screen: {
      video: true,
    }, 
  },
});

call.on("change", () => console.log(call))
call.on("error", err => console.error(err))
call.on("finish", err => console.warn("Has been finished"))

call.on("local-track-change", () => {
    this.localStream = call.localStream;
})
call.on("track-change", () => {
    this.peerStream = call.peerStream;
})

// are Video or audio enabled?
this.video = call.video; 
this.audio = call.audio; 

// Update local controls.
this.toggleAudio();
this.toggleVideo();

// Peer controls.
const {video, audio} = call.externalControls;

// Share screen or camera.
call.shareScreen();
call.shareVideo();

// Has the call been finished.
this.finished = call.finished;
this.finish();

GraphQL

Signaling server must implement the following graphql schema.

ReactNative

It works with ReactNative, you only need to replace the FetchCheckNetworkStatus for RNCheckNetworkStatus.

TODO

  • (*) Test
  • Docs
  • Disconnection Strategy in ReactNative.
  • Fix the max bandwidth.
  • Make it flexible.

Thanks to

License

ISC

3.0.10

3 years ago

3.0.11

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago