OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_PUBLIC_WHISPERNET_CLIENT_H_ | 5 #ifndef COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ |
6 #define COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ | 6 #define COMPONENTS_COPRESENCE_PUBLIC_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 | 14 |
15 namespace media { | 15 namespace media { |
16 class AudioBusRefCounted; | 16 class AudioBusRefCounted; |
17 } | 17 } |
18 | 18 |
19 namespace copresence { | 19 namespace copresence { |
20 | 20 |
21 struct FullToken { | 21 struct AudioToken { |
22 FullToken(const std::string& token, bool audible) | 22 AudioToken(const std::string& token, bool audible) |
23 : token(token), audible(audible) {} | 23 : token(token), audible(audible) {} |
24 std::string token; | 24 std::string token; |
25 bool audible; | 25 bool audible; |
26 }; | 26 }; |
27 | 27 |
28 // The interface that the whispernet client needs to implement. These methods | 28 // The interface that the whispernet client needs to implement. These methods |
29 // provide us the ability to use the audio medium in copresence. Currently since | 29 // provide us the ability to use the audio medium in copresence. Currently since |
30 // the only medium that copresence uses is audio, the implementation of this | 30 // the only medium that copresence uses is audio, the implementation of this |
31 // interface is required. | 31 // interface is required. |
32 class WhispernetClient { | 32 class WhispernetClient { |
33 public: | 33 public: |
34 // Generic callback to indicate a boolean success or failure. | 34 // Generic callback to indicate a boolean success or failure. |
35 typedef base::Callback<void(bool)> SuccessCallback; | 35 typedef base::Callback<void(bool)> SuccessCallback; |
36 // Callback that returns detected tokens. | 36 // Callback that returns detected tokens. |
37 typedef base::Callback<void(const std::vector<FullToken>&)> TokensCallback; | 37 typedef base::Callback<void(const std::vector<AudioToken>&)> TokensCallback; |
38 // Callback that returns encoded samples for a given token. | 38 // Callback that returns encoded samples for a given token. |
39 typedef base::Callback<void(const std::string&, | 39 typedef base::Callback<void(const std::string&, |
40 bool, | 40 bool, |
41 const scoped_refptr<media::AudioBusRefCounted>&)> | 41 const scoped_refptr<media::AudioBusRefCounted>&)> |
42 SamplesCallback; | 42 SamplesCallback; |
43 | 43 |
44 // Initialize the whispernet client and call the callback when done. The | 44 // Initialize the whispernet client and call the callback when done. The |
45 // parameter indicates whether we succeeded or failed. | 45 // parameter indicates whether we succeeded or failed. |
46 virtual void Initialize(const SuccessCallback& init_callback) = 0; | 46 virtual void Initialize(const SuccessCallback& init_callback) = 0; |
47 // Copresence will call this before making any calls to its destructors. | 47 // Copresence will call this before making any calls to its destructors. |
(...skipping 15 matching lines...) Expand all Loading... |
63 virtual void RegisterDetectBroadcastCallback( | 63 virtual void RegisterDetectBroadcastCallback( |
64 const SuccessCallback& db_callback) = 0; | 64 const SuccessCallback& db_callback) = 0; |
65 | 65 |
66 // Don't cache these callbacks, as they may become invalid at any time. | 66 // Don't cache these callbacks, as they may become invalid at any time. |
67 // Always invoke callbacks directly through these accessors. | 67 // Always invoke callbacks directly through these accessors. |
68 virtual TokensCallback GetTokensCallback() = 0; | 68 virtual TokensCallback GetTokensCallback() = 0; |
69 virtual SamplesCallback GetSamplesCallback() = 0; | 69 virtual SamplesCallback GetSamplesCallback() = 0; |
70 virtual SuccessCallback GetDetectBroadcastCallback() = 0; | 70 virtual SuccessCallback GetDetectBroadcastCallback() = 0; |
71 virtual SuccessCallback GetInitializedCallback() = 0; | 71 virtual SuccessCallback GetInitializedCallback() = 0; |
72 | 72 |
73 virtual ~WhispernetClient() {}; | 73 virtual ~WhispernetClient() {} |
74 }; | 74 }; |
75 | 75 |
76 } // namespace copresence | 76 } // namespace copresence |
77 | 77 |
78 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ | 78 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ |
OLD | NEW |