--- a/static/js/main.js Mon Mar 11 23:44:44 2013 +0900
+++ b/static/js/main.js Tue Mar 12 02:23:34 2013 +0900
- document.getElementById('btn-call').className += ' btn-active';
+ $('#btn-call').addClass('btn-active');
- document.getElementById('btn-receive').className += ' btn-active';
+ $('#btn-receive').addClass('btn-active');
function init(initiator) {
- audio: document.getElementById('audio').checked,
- video: document.getElementById('video').checked
+ audio: $('#audio').prop('checked'),
+ video: $('#video').prop('checked')
getUserMedia(constraints, function(stream) {
pc = new RTCPeerConnection(null);
- attachMediaStream(document.getElementById('local'), stream);
+ $('#local').prop('src', URL.createObjectURL(stream));
pc.onaddstream = function(event) {
- attachMediaStream(document.getElementById('remote'), event.stream);
+ $('#remote').prop('src', URL.createObjectURL(event.stream));
pc.onicecandidate = function(event) {
+ log('waiting for offer...');
- console.log('creating offer');
+ log('creating offer...');
pc.createOffer(function(offer) {
- console.log('created offer');
+ log('created offer...');
pc.setLocalDescription(offer, function() {
- console.log('setLocalDescription done, sending to remote');
+ log('sending to remote...');
ws.send(JSON.stringify(offer));
function receiveOffer(offer) {
- console.log('received offer');
+ log('received offer...');
pc.setRemoteDescription(new RTCSessionDescription(offer), function() {
- console.log('creating answer');
+ log('creating answer...');
pc.createAnswer(function(answer) {
- console.log('created answer');
+ log('created answer...');
pc.setLocalDescription(answer, function() {
- console.log('setLocalDescription done, sending to remote');
ws.send(JSON.stringify(answer));
function receiveAnswer(answer) {
- console.log('received answer');
+ log('received answer');
pc.setRemoteDescription(new RTCSessionDescription(answer));
+ $('#status').text(Array.prototype.join.call(arguments, ' '));
+ console.log.apply(console, arguments);
+function logStreaming(streaming) {
+ $('#streaming').text(streaming ? '[streaming]' : '[..]');
+ $('#status').text(Array.prototype.join.call(arguments, ' '));
+ console.error.apply(console, arguments);
--- a/templates/index.html Mon Mar 11 23:44:44 2013 +0900
+++ b/templates/index.html Tue Mar 12 02:23:34 2013 +0900
<title>Tornado WebRTC</title>
<link rel="stylesheet" type="text/css" href="{{ static_url('css/kube.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ static_url('css/main.css') }}">
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="{{ static_url('js/webrtc-adapter.js') }}"></script>
<script src="{{ static_url('js/main.js') }}"></script>
+ <span id="streaming" class="small"></span>
+ <span id="status" class="small"></span>