Created
March 21, 2013 12:05
-
-
Save samiy-xx/5212544 to your computer and use it in GitHub Desktop.
WebRTC Fail
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
import 'dart:html'; | |
void main() { | |
RtcPeerConnection pc1 = new RtcPeerConnection(null); | |
RtcPeerConnection pc2 = new RtcPeerConnection(null); | |
pc1.onAddStream.listen((MediaStreamEvent e) { | |
print("pc1 got stream"); | |
}); | |
pc2.onAddStream.listen((MediaStreamEvent e) { | |
print("pc2 got stream"); | |
}); | |
pc1.onIceCandidate.listen((RtcIceCandidateEvent e) { | |
if (e.candidate != null) | |
pc2.addIceCandidate(e.candidate); | |
}); | |
pc2.onIceCandidate.listen((RtcIceCandidateEvent e) { | |
if (e.candidate != null) | |
pc1.addIceCandidate(e.candidate); | |
}); | |
pc1.onNegotiationNeeded.listen((Event e) { | |
pc1.createOffer({}).then((RtcSessionDescription sdp) { | |
pc1.setLocalDescription(sdp); | |
pc2.setRemoteDescription(sdp); | |
pc2.createAnswer({}).then((RtcSessionDescription sdp2) { | |
pc2.setLocalDescription(sdp2); | |
pc1.setRemoteDescription(sdp2); | |
}); | |
}); | |
}); | |
if (MediaStream.supported) { | |
window.navigator.getUserMedia(audio: true, video: true).then((LocalMediaStream stream) { | |
pc1.addStream(stream); | |
pc2.addStream(stream); | |
}); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment