OLD | NEW |
1 /** | 1 /** |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /** | 7 /** |
8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more | 8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more |
9 * information on getUserMedia. See | 9 * information on getUserMedia. See |
10 * http://dev.w3.org/2011/webrtc/editor/webrtc.html for more information on | 10 * http://dev.w3.org/2011/webrtc/editor/webrtc.html for more information on |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 peerConnection.addIceCandidate(candidate); | 447 peerConnection.addIceCandidate(candidate); |
448 return; | 448 return; |
449 } | 449 } |
450 error_('unknown message received'); | 450 error_('unknown message received'); |
451 } | 451 } |
452 | 452 |
453 function createPeerConnection(stun_server, useRtpDataChannels) { | 453 function createPeerConnection(stun_server, useRtpDataChannels) { |
454 servers = {iceServers: [{url: 'stun:' + stun_server}]}; | 454 servers = {iceServers: [{url: 'stun:' + stun_server}]}; |
455 try { | 455 try { |
456 var constraints = { optional: [{ RtpDataChannels: useRtpDataChannels }]}; | 456 var constraints = { optional: [{ RtpDataChannels: useRtpDataChannels }]}; |
457 peerConnection = new webkitRTCPeerConnection(servers, constraints); | 457 peerConnection = new RTCPeerConnection(servers, constraints); |
458 } catch (exception) { | 458 } catch (exception) { |
459 error_('Failed to create peer connection: ' + exception); | 459 error_('Failed to create peer connection: ' + exception); |
460 } | 460 } |
461 peerConnection.onaddstream = addStreamCallback_; | 461 peerConnection.onaddstream = addStreamCallback_; |
462 peerConnection.onremovestream = removeStreamCallback_; | 462 peerConnection.onremovestream = removeStreamCallback_; |
463 peerConnection.onicecandidate = iceCallback_; | 463 peerConnection.onicecandidate = iceCallback_; |
464 peerConnection.ondatachannel = onCreateDataChannelCallback_; | 464 peerConnection.ondatachannel = onCreateDataChannelCallback_; |
465 return peerConnection; | 465 return peerConnection; |
466 } | 466 } |
467 | 467 |
(...skipping 26 matching lines...) Expand all Loading... |
494 error_('Closing DataChannel, but none exists.'); | 494 error_('Closing DataChannel, but none exists.'); |
495 print_('DataChannel with label ' + global.dataChannel.label + | 495 print_('DataChannel with label ' + global.dataChannel.label + |
496 ' is beeing closed.'); | 496 ' is beeing closed.'); |
497 global.dataChannel.close(); | 497 global.dataChannel.close(); |
498 } | 498 } |
499 | 499 |
500 function createDtmfSender(peerConnection) { | 500 function createDtmfSender(peerConnection) { |
501 if (global.dtmfSender != null) | 501 if (global.dtmfSender != null) |
502 error_('Creating DTMF sender, but we already have one.'); | 502 error_('Creating DTMF sender, but we already have one.'); |
503 | 503 |
504 var localStream = global.localStream(); | 504 var localStream = global.localStream; |
505 if (localStream == null) | 505 if (localStream == null) |
506 error_('Creating DTMF sender but local stream is null.'); | 506 error_('Creating DTMF sender but local stream is null.'); |
507 local_audio_track = localStream.getAudioTracks()[0]; | 507 local_audio_track = localStream.getAudioTracks()[0]; |
508 global.dtmfSender = peerConnection.createDTMFSender(local_audio_track); | 508 global.dtmfSender = peerConnection.createDTMFSender(local_audio_track); |
509 global.dtmfSender.ontonechange = global.dtmfOnToneChange; | 509 global.dtmfSender.ontonechange = global.dtmfOnToneChange; |
510 } | 510 } |
511 | 511 |
512 /** | 512 /** |
513 * Connects to the provided peerconnection_server. | 513 * Connects to the provided peerconnection_server. |
514 * | 514 * |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 | 1359 |
1360 /** @private */ | 1360 /** @private */ |
1361 function readResponseHeader_(request, key) { | 1361 function readResponseHeader_(request, key) { |
1362 var value = request.getResponseHeader(key); | 1362 var value = request.getResponseHeader(key); |
1363 if (value == null || value.length == 0) { | 1363 if (value == null || value.length == 0) { |
1364 error_('Received empty value ' + value + | 1364 error_('Received empty value ' + value + |
1365 ' for response header key ' + key + '.'); | 1365 ' for response header key ' + key + '.'); |
1366 } | 1366 } |
1367 return parseInt(value); | 1367 return parseInt(value); |
1368 } | 1368 } |
OLD | NEW |