Created
April 23, 2015 13:53
-
-
Save ryaninvents/6760a3daa7189e5b6ce1 to your computer and use it in GitHub Desktop.
Creating an offer with RTCPeerConnection
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<h1>Creating an offer using <a href="https://github.com/otalk/RTCPeerConnection">RTCPeerConnection</a></h1> | |
<pre></pre> | |
<script src="https://rawgit.com/otalk/RTCPeerConnection/master/rtcpeerconnection.bundle.js"></script> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
function main(){ | |
var config = { | |
debug: false, | |
// makes the entire PC config overridable | |
peerConnectionConfig: { | |
iceServers: [{"url": "stun:stun.l.google.com:19302"}] | |
}, | |
peerConnectionConstraints: { | |
optional: [ | |
{DtlsSrtpKeyAgreement: true} | |
] | |
}, | |
receiveMedia: { | |
mandatory: { | |
OfferToReceiveAudio: true, | |
OfferToReceiveVideo: true | |
} | |
}, | |
enableDataChannels: true | |
}; | |
var pc = new PeerConnection(config); | |
// create an offer | |
pc.offer(function (err, offer) { | |
if (!err) $('pre').html( | |
JSON.stringify(offer, null, 2) | |
.replace(/\n/g,'<br>') | |
.replace(/\\r\\n/g, '<br> ') | |
.replace(/ /g, ' ') | |
); | |
}); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment