summaryrefslogtreecommitdiffstats
path: root/components/copresence
diff options
context:
space:
mode:
authorCharlie Kehoe <ckehoe@chromium.org>2015-02-19 16:44:34 -0800
committerCharlie Kehoe <ckehoe@chromium.org>2015-02-20 00:45:46 +0000
commitd5f5d1157d418bb545df5621848a8f91e0b5c9f3 (patch)
tree9d2d834d83ea03b049d4c6bfa4dba42f55a53310 /components/copresence
parentda3105a6d3301c557b20fbbee9c5b00ac48840f0 (diff)
downloadchromium_src-d5f5d1157d418bb545df5621848a8f91e0b5c9f3.zip
chromium_src-d5f5d1157d418bb545df5621848a8f91e0b5c9f3.tar.gz
chromium_src-d5f5d1157d418bb545df5621848a8f91e0b5c9f3.tar.bz2
Adding the Audio Modem API. See design doc at go/chrome-modem.
BUG=455823 R=isherman@chromium.org, rkc@chromium.org, rockot@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/917523004 Cr-Commit-Position: refs/heads/master@{#317196}
Diffstat (limited to 'components/copresence')
-rw-r--r--components/copresence/handlers/audio/audio_directive_handler_impl.cc11
-rw-r--r--components/copresence/handlers/audio/audio_directive_handler_unittest.cc30
2 files changed, 9 insertions, 32 deletions
diff --git a/components/copresence/handlers/audio/audio_directive_handler_impl.cc b/components/copresence/handlers/audio/audio_directive_handler_impl.cc
index 16b0269..d91b4d8 100644
--- a/components/copresence/handlers/audio/audio_directive_handler_impl.cc
+++ b/components/copresence/handlers/audio/audio_directive_handler_impl.cc
@@ -22,6 +22,7 @@
using audio_modem::AUDIBLE;
using audio_modem::INAUDIBLE;
+using audio_modem::TokenParameters;
namespace copresence {
@@ -102,12 +103,13 @@ void AudioDirectiveHandlerImpl::AddInstruction(
DCHECK_GT(token_length, 0u);
switch (instruction.medium()) {
case AUDIO_ULTRASOUND_PASSBAND:
- audio_modem_->SetTokenLength(INAUDIBLE, token_length);
+ audio_modem_->SetTokenParams(INAUDIBLE,
+ TokenParameters(token_length));
transmits_lists_[INAUDIBLE]->AddDirective(op_id, directive);
audio_modem_->SetToken(INAUDIBLE, instruction.token_id());
break;
case AUDIO_AUDIBLE_DTMF:
- audio_modem_->SetTokenLength(AUDIBLE, token_length);
+ audio_modem_->SetTokenParams(AUDIBLE, TokenParameters(token_length));
transmits_lists_[AUDIBLE]->AddDirective(op_id, directive);
audio_modem_->SetToken(AUDIBLE, instruction.token_id());
break;
@@ -123,11 +125,12 @@ void AudioDirectiveHandlerImpl::AddInstruction(
DCHECK_GT(token_length, 0u);
switch (instruction.medium()) {
case AUDIO_ULTRASOUND_PASSBAND:
- audio_modem_->SetTokenLength(INAUDIBLE, token_length);
+ audio_modem_->SetTokenParams(INAUDIBLE,
+ TokenParameters(token_length));
receives_lists_[INAUDIBLE]->AddDirective(op_id, directive);
break;
case AUDIO_AUDIBLE_DTMF:
- audio_modem_->SetTokenLength(AUDIBLE, token_length);
+ audio_modem_->SetTokenParams(AUDIBLE, TokenParameters(token_length));
receives_lists_[AUDIBLE]->AddDirective(op_id, directive);
break;
default:
diff --git a/components/copresence/handlers/audio/audio_directive_handler_unittest.cc b/components/copresence/handlers/audio/audio_directive_handler_unittest.cc
index d414dd2..24da3ca 100644
--- a/components/copresence/handlers/audio/audio_directive_handler_unittest.cc
+++ b/components/copresence/handlers/audio/audio_directive_handler_unittest.cc
@@ -12,6 +12,7 @@
#include "base/timer/mock_timer.h"
#include "components/audio_modem/public/modem.h"
#include "components/audio_modem/test/random_samples.h"
+#include "components/audio_modem/test/stub_modem.h"
#include "components/copresence/handlers/audio/audio_directive_handler_impl.h"
#include "components/copresence/handlers/audio/tick_clock_ref_counted.h"
#include "components/copresence/proto/data.pb.h"
@@ -20,6 +21,7 @@
using audio_modem::AUDIBLE;
using audio_modem::AudioType;
using audio_modem::INAUDIBLE;
+using audio_modem::StubModem;
namespace copresence {
@@ -39,34 +41,6 @@ const Directive CreateDirective(TokenInstructionType type,
} // namespace
-class StubModem final : public audio_modem::Modem {
- public:
- StubModem() {}
- ~StubModem() override {}
-
- // AudioManager overrides:
- void Initialize(audio_modem::WhispernetClient* whispernet_client,
- const audio_modem::TokensCallback& tokens_cb) override {}
- void StartPlaying(AudioType type) override { playing_[type] = true; }
- void StopPlaying(AudioType type) override { playing_[type] = false; }
- void StartRecording(AudioType type) override { recording_[type] = true; }
- void StopRecording(AudioType type) override { recording_[type] = false; }
- void SetToken(AudioType type, const std::string& url_unsafe_token) override {}
- const std::string GetToken(AudioType type) override { return std::string(); }
- bool IsPlayingTokenHeard(AudioType type) override { return false; }
- void SetTokenLength(AudioType type, size_t token_length) override {}
-
- bool IsRecording(AudioType type) { return recording_[type]; }
- bool IsPlaying(AudioType type) { return playing_[type]; }
-
- private:
- // Indexed using enum AudioType.
- bool playing_[2];
- bool recording_[2];
-
- DISALLOW_COPY_AND_ASSIGN(StubModem);
-};
-
class AudioDirectiveHandlerTest : public testing::Test {
public:
AudioDirectiveHandlerTest() {