OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/audio_modem/test/stub_modem.h" | |
6 | |
7 #include "base/base64.h" | |
8 #include "base/logging.h" | |
9 | |
10 namespace audio_modem { | |
11 | |
12 StubModem::StubModem() { | |
13 playing_[AUDIBLE] = false; | |
14 playing_[INAUDIBLE] = false; | |
15 recording_[AUDIBLE] = false; | |
16 recording_[INAUDIBLE] = false; | |
17 } | |
18 | |
19 StubModem::~StubModem() {} | |
20 | |
21 void StubModem::Initialize(WhispernetClient* whispernet_client, | |
22 const TokensCallback& tokens_cb) { | |
23 tokens_callback_ = tokens_cb; | |
24 } | |
25 | |
26 void StubModem::StartPlaying(AudioType type) { | |
27 playing_[type] = true; | |
28 } | |
29 | |
30 void StubModem::StopPlaying(AudioType type) { | |
31 playing_[type] = false; | |
32 } | |
33 | |
34 void StubModem::StartRecording(AudioType type) { | |
35 recording_[type] = true; | |
36 } | |
37 | |
38 void StubModem::StopRecording(AudioType type) { | |
39 recording_[type] = false; | |
40 } | |
41 | |
42 const std::string StubModem::GetToken(AudioType type) const { | |
43 return std::string(); | |
44 } | |
45 | |
46 bool StubModem::IsPlayingTokenHeard(AudioType type) const { | |
47 return false; | |
48 } | |
49 | |
50 bool StubModem::IsRecording(AudioType type) const { | |
51 return recording_[type]; | |
52 } | |
53 | |
54 bool StubModem::IsPlaying(AudioType type) const { | |
55 return playing_[type]; | |
56 } | |
57 | |
58 void StubModem::DeliverTokens(const std::vector<AudioToken>& tokens) { | |
59 std::vector<AudioToken> encoded_tokens; | |
60 for (const AudioToken& token : tokens) { | |
61 std::string encoded_token; | |
62 base::Base64Encode(token.token, & encoded_token); | |
63 encoded_tokens.push_back(AudioToken(encoded_token, token.audible)); | |
64 } | |
65 DCHECK_EQ(tokens.size(), encoded_tokens.size()); | |
66 tokens_callback_.Run(encoded_tokens); | |
67 } | |
68 | |
69 } // namespace audio_modem | |
OLD | NEW |