PP.Video

WebRTC signaling for low-latency peer-to-peer voice and video calls. PP handles the signaling channel over its binary transport; media streams flow directly between peers.

Signaling

Use the existing PP connection as the signaling channel. Exchange SDP offers/answers and ICE candidates through the server without extra infrastructure.

import { PPClient } from '@painda/core';
import '@painda/video';

// Initiate a call (client A)
client.video.call(userBId).then(pc => {
  pc.on('track', (e) => {
    remoteVideo.srcObject = e.streams[0];
  });
});

// Answer (client B)
client.video.on('incoming', (from, accept) => {
  accept().then(pc => {
    // P2P established
  });
});

P2P Setup

PP.Video uses WebRTC under the hood. Once the handshake completes, audio/video streams go peer-to-peer. The server only relays signaling messages via PP binary frames.

// TURN/STUN for NAT traversal
client.video.setIceServers({
  iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
});

For file/image transfer, see PP.Media.