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