Commit 53669684 authored by ckehoe's avatar ckehoe Committed by Commit bot

Adding CRC and multi-client support in the Whispernet NaCl wrapper. NaCl changes in cl/86735537.

BUG=455823

Review URL: https://codereview.chromium.org/943053002

Cr-Commit-Position: refs/heads/master@{#317472}
parent 5ec8522f
......@@ -144,8 +144,8 @@ Status AudioModemAPI::StartTransmit(const std::string& app_id,
base::Base64Encode(token, &encoded_token);
base::RemoveChars(encoded_token, "=", &encoded_token);
modem_->SetToken(audio_type, encoded_token);
modem_->SetTokenParams(audio_type, TokenParamsForEncoding(params.encoding));
modem_->SetToken(audio_type, encoded_token);
modem_->StartPlaying(audio_type);
transmit_timers_[audio_type].Start(
......
......@@ -23,7 +23,7 @@ function audioConfig(clientId, audioParams) {
return;
}
console.log('Configuring encoder and decoder!');
console.log('Configuring encoder and decoder for client ' + clientId);
whisperEncoders[clientId] =
new WhisperEncoder(audioParams.paramData, whispernetNacl, clientId);
whisperDecoders[clientId] =
......@@ -39,7 +39,8 @@ function encodeTokenRequest(clientId, params) {
if (whisperEncoders[clientId]) {
whisperEncoders[clientId].encode(params);
} else {
console.error('encodeTokenRequest: Whisper not initialized!');
console.error('encodeTokenRequest: Whisper not initialized for client ' +
clientId);
}
}
......@@ -52,7 +53,8 @@ function decodeSamplesRequest(clientId, params) {
if (whisperDecoders[clientId]) {
whisperDecoders[clientId].processSamples(params);
} else {
console.error('decodeSamplesRequest: Whisper not initialized!');
console.error('decodeSamplesRequest: Whisper not initialized for client ' +
clientId);
}
}
......
......@@ -44,6 +44,7 @@ function WhisperEncoder(params, whisperNacl, clientId) {
var msg = {
type: 'initialize_encoder',
client_id: clientId,
params: params
};
......@@ -84,7 +85,7 @@ WhisperEncoder.prototype.encode = function(params) {
*/
WhisperEncoder.prototype.onNaclMessage_ = function(e) {
var msg = e.data;
if (msg.type == 'encode_token_response') {
if (msg.type == 'encode_token_response' && msg.client_id == this.clientId_) {
chrome.copresencePrivate.sendSamples(this.clientId_,
{ token: bytesToBase64(msg.token), audible: msg.audible }, msg.samples);
}
......@@ -105,21 +106,12 @@ function WhisperDecoder(params, whisperNacl, clientId) {
var msg = {
type: 'initialize_decoder',
client_id: clientId,
params: params
};
this.whisperNacl_.send(msg);
}
/**
* Method to request the decoder to wipe its internal buffer.
*/
WhisperDecoder.prototype.wipeDecoder = function() {
var msg = {
type: 'wipe_decode_buffer'
};
this.whisperNacl_.send(msg);
};
/**
* Method to request the decoder to process samples.
* @param {Object} params Process samples parameters object.
......@@ -151,7 +143,7 @@ WhisperDecoder.prototype.processSamples = function(params) {
*/
WhisperDecoder.prototype.onNaclMessage_ = function(e) {
var msg = e.data;
if (msg.type == 'decode_tokens_response') {
if (msg.type == 'decode_tokens_response' && msg.client_id == this.clientId_) {
this.handleCandidates_(msg.tokens, msg.audible);
}
};
......
{
"program": {
"portable": {
"pnacl-translate": { "url": "whispernet_proxy_pnacl.pexe.png?v00005" }
"pnacl-translate": { "url": "whispernet_proxy_pnacl.pexe.png?v00006" }
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment