Skip to content

Instantly share code, notes, and snippets.

@voluntas
Last active August 11, 2018 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voluntas/e13a6cb38d382e4f4090c0e6e0422099 to your computer and use it in GitHub Desktop.
Save voluntas/e13a6cb38d382e4f4090c0e6e0422099 to your computer and use it in GitHub Desktop.
WebRTC Chrome M70 でいろいろ確認
// Unified Plan の最低限のサンプル
const pc1 = new RTCPeerConnection({sdpSemantics: "unified-plan"});
const pc2 = new RTCPeerConnection({sdpSemantics: "unified-plan"});
const stream = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
// pc1.addTrack(stream.getAudioTracks()[0], stream);
pc1.addTrack(stream.getVideoTracks()[0], stream);
// pc2.addTrack(stream.getAudioTracks()[0], stream);
pc2.addTrack(stream.getVideoTracks()[0], stream);
const offer = await pc1.createOffer();
await pc1.setLocalDescription(offer);
await pc2.setRemoteDescription(offer);
const answer = await pc2.createAnswer();
await pc2.setLocalDescription(answer);
await pc1.setRemoteDescription(answer);
pc1.getSenders()[0].getParameters();
pc2.getSenders()[0].getParameters();
// 以下で対応しているかどうかが取れる
RTCRtpSender.getCapabilities('video');
RTCRtpSender.getCapabilities('audio');
RTCRtpReceiver.getCapabilities('video');
RTCRtpReceiver.getCapabilities('audio');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment