stephenlb / webrtc-sdk

WebRTC Simple Calling API + Mobile SDK - A simplified approach to RTCPeerConnection for mobile and web video calling apps.

Home Page:https://stephenlb.github.io/webrtc-sdk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

session.snap sometimes takes my own camera photo instead of the caller

crookedbard opened this issue · comments

As far as I understood phone.snap is used to take a snapshot of local video cam
and session.snap is used to take a snapshot of other callers video, but sometimes session.snap takes my local video pic.

It seems that snap() functions always takes the local video cam pic.

So I wrote another method for such feature:

let canvas = document.createElement('canvas');
let context = canvas.getContext("2d");
let snap = { width: 640, height: 480 };

        let video = $("div." + number).find("div.video-out").find("video")[0];

        canvas.width = snap.width;
        canvas.height = snap.height;

        context.drawImage(video, 0, 0, snap.width, snap.height);

        let img = document.createElement('img');
        img.src = canvas.toDataURL('image/jpeg', 0.50);

        pic.append(img);

Nice!