OLD | NEW |
| (Empty) |
1 /** | |
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 | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 // Public interface towards the other javascript files, such as | |
8 // message_handling.js. The contract for these functions is described in | |
9 // message_handling.js. | |
10 | |
11 function handleMessage(peerConnection, message) { | |
12 peerConnection.processSignalingMessage(message); | |
13 } | |
14 | |
15 function createPeerConnection(stun_server) { | |
16 peerConnection = new webkitDeprecatedPeerConnection( | |
17 stun_server, signalingMessageCallback); | |
18 peerConnection.onaddstream = addStreamCallback; | |
19 peerConnection.onremovestream = removeStreamCallback; | |
20 | |
21 return peerConnection; | |
22 } | |
23 | |
24 function setupCall(peerConnection) { | |
25 peerConnection.addStream(gLocalStream); | |
26 } | |
27 | |
28 function answerCall(peerConnection, message) { | |
29 peerConnection.addStream(gLocalStream); | |
30 handleMessage(peerConnection, message); | |
31 } | |
32 | |
33 // Internals. | |
34 function signalingMessageCallback(message) { | |
35 sendToPeer(gRemotePeerId, message); | |
36 } | |
37 | |
38 function addStreamCallback(event) { | |
39 debug('Receiving remote stream...'); | |
40 var streamUrl = webkitURL.createObjectURL(event.stream); | |
41 document.getElementById('remote_view').src = streamUrl; | |
42 | |
43 // This means the call has been set up. | |
44 returnToPyAuto('ok-call-established'); | |
45 } | |
46 | |
47 function removeStreamCallback(event) { | |
48 debug('Call ended.'); | |
49 document.getElementById("remote_view").src = ''; | |
50 } | |
51 | |
52 | |
OLD | NEW |