| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_ | 5 #ifndef COMPONENTS_AUDIO_MODEM_TEST_STUB_WHISPERNET_CLIENT_H_ |
| 6 #define COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_ | 6 #define COMPONENTS_AUDIO_MODEM_TEST_STUB_WHISPERNET_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "components/copresence/public/whispernet_client.h" | 14 #include "components/audio_modem/public/whispernet_client.h" |
| 15 #include "components/copresence/tokens.h" | |
| 16 #include "media/base/audio_bus.h" | 15 #include "media/base/audio_bus.h" |
| 17 | 16 |
| 18 namespace copresence { | 17 namespace audio_modem { |
| 19 | 18 |
| 20 // A simple WhispernetClient for testing. | 19 // A simple WhispernetClient for testing. |
| 21 class StubWhispernetClient final : public WhispernetClient { | 20 class StubWhispernetClient final : public WhispernetClient { |
| 22 public: | 21 public: |
| 23 // Constructor. |samples| and |tokens|, if specified, | 22 // Constructor. |samples| and |tokens|, if specified, |
| 24 // will be returned for any encoding and decoding requests. | 23 // will be returned for any encoding and decoding requests. |
| 25 StubWhispernetClient( | 24 StubWhispernetClient( |
| 26 scoped_refptr<media::AudioBusRefCounted> samples = | 25 scoped_refptr<media::AudioBusRefCounted> samples = |
| 27 scoped_refptr<media::AudioBusRefCounted>(), | 26 scoped_refptr<media::AudioBusRefCounted>(), |
| 28 const std::vector<AudioToken>& tokens = std::vector<AudioToken>()); | 27 const std::vector<AudioToken>& tokens = std::vector<AudioToken>()); |
| 29 | 28 |
| 30 ~StubWhispernetClient() override; | 29 ~StubWhispernetClient() override; |
| 31 | 30 |
| 32 void Initialize(const SuccessCallback& init_callback) override; | 31 void Initialize(const SuccessCallback& init_callback) override; |
| 33 void Shutdown() override {} | |
| 34 | 32 |
| 35 void EncodeToken(const std::string& token, AudioType type) override; | 33 void EncodeToken(const std::string& token, AudioType type) override; |
| 36 void DecodeSamples(AudioType type, | 34 void DecodeSamples(AudioType type, |
| 37 const std::string& samples, | 35 const std::string& samples, |
| 38 const size_t token_length[2]) override; | 36 const size_t token_length[2]) override; |
| 39 void DetectBroadcast() override {} | 37 void DetectBroadcast() override {} |
| 40 | 38 |
| 41 void RegisterTokensCallback(const TokensCallback& tokens_cb) override; | 39 void RegisterTokensCallback(const TokensCallback& tokens_cb) override; |
| 42 void RegisterSamplesCallback(const SamplesCallback& samples_cb) override; | 40 void RegisterSamplesCallback(const SamplesCallback& samples_cb) override; |
| 43 void RegisterDetectBroadcastCallback( | 41 void RegisterDetectBroadcastCallback( |
| 44 const SuccessCallback& /* db_cb */) override {} | 42 const SuccessCallback& /* db_cb */) override {} |
| 45 | 43 |
| 46 TokensCallback GetTokensCallback() override; | 44 TokensCallback GetTokensCallback() override; |
| 47 SamplesCallback GetSamplesCallback() override; | 45 SamplesCallback GetSamplesCallback() override; |
| 48 SuccessCallback GetDetectBroadcastCallback() override; | 46 SuccessCallback GetDetectBroadcastCallback() override; |
| 49 SuccessCallback GetInitializedCallback() override; | 47 SuccessCallback GetInitializedCallback() override; |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 TokensCallback tokens_cb_; | 50 TokensCallback tokens_cb_; |
| 53 SamplesCallback samples_cb_; | 51 SamplesCallback samples_cb_; |
| 54 scoped_refptr<media::AudioBusRefCounted> samples_; | 52 scoped_refptr<media::AudioBusRefCounted> samples_; |
| 55 std::vector<AudioToken> tokens_; | 53 std::vector<AudioToken> tokens_; |
| 56 | 54 |
| 57 DISALLOW_COPY_AND_ASSIGN(StubWhispernetClient); | 55 DISALLOW_COPY_AND_ASSIGN(StubWhispernetClient); |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 } // namespace copresence | 58 } // namespace audio_modem |
| 61 | 59 |
| 62 #endif // COMPONENTS_COPRESENCE_TEST_STUB_WHISPERNET_CLIENT_H_ | 60 #endif // COMPONENTS_AUDIO_MODEM_TEST_STUB_WHISPERNET_CLIENT_H_ |
| OLD | NEW |