Skip to content

Instantly share code, notes, and snippets.

@samiy-xx
Created February 13, 2013 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samiy-xx/4945442 to your computer and use it in GitHub Desktop.
Save samiy-xx/4945442 to your computer and use it in GitHub Desktop.
Test 8361
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((RtcSessionDescription sdp) {
pc1.setLocalDescription(sdp, _onLocalDescriptionSuccess, _onRTCError);
pc2.setRemoteDescription(sdp, _onRemoteDescriptionSuccess, _onRTCError);
pc2.createAnswer((RtcSessionDescription sdp2) {
pc2.setLocalDescription(sdp2, _onLocalDescriptionSuccess, _onRTCError);
pc1.setRemoteDescription(sdp2, _onRemoteDescriptionSuccess, _onRTCError);
},(String s) {
}, null);
},(String s) {
}, null);
});
if (MediaStream.supported) {
window.navigator.getUserMedia(audio: true, video: true).then((LocalMediaStream stream) {
pc1.addStream(stream);
pc2.addStream(stream);
});
}
}
void _onLocalDescriptionSuccess() {
print("local desc success");
}
void _onRemoteDescriptionSuccess() {
print("remote desc success");
}
void _onRTCError(String error) {
print("error $error");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment