OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 // Globals holding our encoder and decoder. We will never have more than one | 7 // Globals holding our encoder and decoder. We will never have more than one |
8 // Global variable that will be used to access this Nacl bridge. | 8 // Global variable that will be used to access this Nacl bridge. |
9 var whispernetNacl = null; | 9 var whispernetNacl = null; |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 console.log('Configuring encoder!'); | 26 console.log('Configuring encoder!'); |
27 whisperEncoder = new WhisperEncoder(audioParams.paramData, whispernetNacl); | 27 whisperEncoder = new WhisperEncoder(audioParams.paramData, whispernetNacl); |
28 whisperEncoder.setAudioDataCallback(chrome.copresencePrivate.sendSamples); | 28 whisperEncoder.setAudioDataCallback(chrome.copresencePrivate.sendSamples); |
29 | 29 |
30 console.log('Configuring decoder!'); | 30 console.log('Configuring decoder!'); |
31 whisperDecoder = new WhisperDecoder(audioParams.paramData, whispernetNacl); | 31 whisperDecoder = new WhisperDecoder(audioParams.paramData, whispernetNacl); |
32 whisperDecoder.setReceiveCallback(chrome.copresencePrivate.sendFound); | 32 whisperDecoder.setReceiveCallback(chrome.copresencePrivate.sendFound); |
33 whisperDecoder.onDetectBroadcast(chrome.copresencePrivate.sendDetect); | 33 whisperDecoder.onDetectBroadcast(chrome.copresencePrivate.sendDetect); |
34 | |
35 chrome.copresencePrivate.sendInitialized(true); | |
36 } | 34 } |
37 | 35 |
38 /** | 36 /** |
39 * Sends a request to whispernet to encode a token. | 37 * Sends a request to whispernet to encode a token. |
40 * @param {Object} params Encode token parameters object. | 38 * @param {Object} params Encode token parameters object. |
41 */ | 39 */ |
42 function encodeTokenRequest(params) { | 40 function encodeTokenRequest(params) { |
43 if (whisperEncoder) { | 41 if (whisperEncoder) { |
44 whisperEncoder.encode(params); | 42 whisperEncoder.encode(params); |
45 } else { | 43 } else { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 */ | 93 */ |
96 function initWhispernet() { | 94 function initWhispernet() { |
97 console.log('init: Starting Nacl bridge.'); | 95 console.log('init: Starting Nacl bridge.'); |
98 // TODO(rkc): Figure out how to embed the .nmf and the .pexe into component | 96 // TODO(rkc): Figure out how to embed the .nmf and the .pexe into component |
99 // resources without having to rename them to .js. | 97 // resources without having to rename them to .js. |
100 whispernetNacl = new NaclBridge('whispernet_proxy.nmf.png', | 98 whispernetNacl = new NaclBridge('whispernet_proxy.nmf.png', |
101 onWhispernetLoaded); | 99 onWhispernetLoaded); |
102 } | 100 } |
103 | 101 |
104 window.addEventListener('DOMContentLoaded', initWhispernet); | 102 window.addEventListener('DOMContentLoaded', initWhispernet); |
OLD | NEW |