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 { |
| 22 FullToken(const std::string& token, bool audible) |
| 23 : token(token), audible(audible) {} |
| 24 std::string token; |
| 25 bool audible; |
| 26 }; |
| 27 |
21 // The interface that the whispernet client needs to implement. These methods | 28 // The interface that the whispernet client needs to implement. These methods |
22 // 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 |
23 // 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 |
24 // interface is required. | 31 // interface is required. |
25 class WhispernetClient { | 32 class WhispernetClient { |
26 public: | 33 public: |
27 // Generic callback to indicate a boolean success or failure. | 34 // Generic callback to indicate a boolean success or failure. |
28 typedef base::Callback<void(bool)> SuccessCallback; | 35 typedef base::Callback<void(bool)> SuccessCallback; |
29 // Callback that returns detected tokens. | 36 // Callback that returns detected tokens. |
30 typedef base::Callback<void(const std::vector<std::string>&)> TokensCallback; | 37 typedef base::Callback<void(const std::vector<FullToken>&)> TokensCallback; |
31 // Callback that returns encoded samples for a given token. | 38 // Callback that returns encoded samples for a given token. |
32 typedef base::Callback< | 39 typedef base::Callback<void(const std::string&, |
33 void(const std::string&, const scoped_refptr<media::AudioBusRefCounted>&)> | 40 bool, |
| 41 const scoped_refptr<media::AudioBusRefCounted>&)> |
34 SamplesCallback; | 42 SamplesCallback; |
35 | 43 |
36 // Initialize the whispernet client and call the callback when done. The | 44 // Initialize the whispernet client and call the callback when done. The |
37 // parameter indicates whether we succeeded or failed. | 45 // parameter indicates whether we succeeded or failed. |
38 virtual void Initialize(const SuccessCallback& init_callback) = 0; | 46 virtual void Initialize(const SuccessCallback& init_callback) = 0; |
39 // Copresence will call this before making any calls to its destructors. | 47 // Copresence will call this before making any calls to its destructors. |
40 virtual void Shutdown() = 0; | 48 virtual void Shutdown() = 0; |
41 | 49 |
42 // Fires an event to request a token encode. | 50 // Fires an event to request a token encode. |
43 virtual void EncodeToken(const std::string& token, bool audible) = 0; | 51 virtual void EncodeToken(const std::string& token, bool audible) = 0; |
(...skipping 17 matching lines...) Expand all Loading... |
61 virtual SamplesCallback GetSamplesCallback() = 0; | 69 virtual SamplesCallback GetSamplesCallback() = 0; |
62 virtual SuccessCallback GetDetectBroadcastCallback() = 0; | 70 virtual SuccessCallback GetDetectBroadcastCallback() = 0; |
63 virtual SuccessCallback GetInitializedCallback() = 0; | 71 virtual SuccessCallback GetInitializedCallback() = 0; |
64 | 72 |
65 virtual ~WhispernetClient() {}; | 73 virtual ~WhispernetClient() {}; |
66 }; | 74 }; |
67 | 75 |
68 } // namespace copresence | 76 } // namespace copresence |
69 | 77 |
70 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ | 78 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ |
OLD | NEW |