Last active
August 11, 2018 06:36
-
-
Save voluntas/e13a6cb38d382e4f4090c0e6e0422099 to your computer and use it in GitHub Desktop.
WebRTC Chrome M70 でいろいろ確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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