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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 function encodeTokenRequest(token, audible) { | 43 function encodeTokenRequest(token, audible) { |
44 if (whisperEncoder) { | 44 if (whisperEncoder) { |
45 whisperEncoder.encode(atob(token), audible, true); | 45 whisperEncoder.encode(atob(token), audible, true); |
46 } else { | 46 } else { |
47 console.error('encodeTokenRequest: Whisper not initialized!'); | 47 console.error('encodeTokenRequest: Whisper not initialized!'); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 /** | 51 /** |
52 * Sends a request to whispernet to decode samples. | 52 * Sends a request to whispernet to decode samples. |
53 * @param {string} type Type of decoding to perform. | |
Daniel Erat
2014/10/17 22:25:59
document the acceptable values (or at least that t
rkc
2014/10/18 00:21:54
Code changed. This is now an object.
| |
53 * @param {ArrayBuffer} samples Array of samples to decode. | 54 * @param {ArrayBuffer} samples Array of samples to decode. |
54 */ | 55 */ |
55 function decodeSamplesRequest(samples) { | 56 function decodeSamplesRequest(type, samples) { |
56 if (whisperDecoder) { | 57 if (whisperDecoder) { |
57 whisperDecoder.processSamples(samples); | 58 whisperDecoder.processSamples(type, samples); |
58 } else { | 59 } else { |
59 console.error('decodeSamplesRequest: Whisper not initialized!'); | 60 console.error('decodeSamplesRequest: Whisper not initialized!'); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 /** | 64 /** |
64 * Sends a request to whispernet to detect broadcast. | 65 * Sends a request to whispernet to detect broadcast. |
65 */ | 66 */ |
66 function detectBroadcastRequest() { | 67 function detectBroadcastRequest() { |
67 if (whisperDecoder) { | 68 if (whisperDecoder) { |
(...skipping 28 matching lines...) Expand all Loading... | |
96 */ | 97 */ |
97 function initWhispernet() { | 98 function initWhispernet() { |
98 console.log('init: Starting Nacl bridge.'); | 99 console.log('init: Starting Nacl bridge.'); |
99 // TODO(rkc): Figure out how to embed the .nmf and the .pexe into component | 100 // TODO(rkc): Figure out how to embed the .nmf and the .pexe into component |
100 // resources without having to rename them to .js. | 101 // resources without having to rename them to .js. |
101 whispernetNacl = new NaclBridge('whispernet_proxy.nmf.png', | 102 whispernetNacl = new NaclBridge('whispernet_proxy.nmf.png', |
102 onWhispernetLoaded); | 103 onWhispernetLoaded); |
103 } | 104 } |
104 | 105 |
105 window.addEventListener('DOMContentLoaded', initWhispernet); | 106 window.addEventListener('DOMContentLoaded', initWhispernet); |
OLD | NEW |