| 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 #include "components/copresence/public/copresence_constants.h" | 14 #include "components/copresence/public/copresence_constants.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 class AudioBusRefCounted; | 17 class AudioBusRefCounted; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace copresence { | 20 namespace copresence { |
| 21 | 21 |
| 22 struct AudioToken { | |
| 23 AudioToken(const std::string& token, bool audible) | |
| 24 : token(token), audible(audible) {} | |
| 25 std::string token; | |
| 26 bool audible; | |
| 27 }; | |
| 28 | |
| 29 // The interface that the whispernet client needs to implement. These methods | 22 // The interface that the whispernet client needs to implement. These methods |
| 30 // provide us the ability to use the audio medium in copresence. Currently since | 23 // provide us the ability to use the audio medium in copresence. Currently since |
| 31 // the only medium that copresence uses is audio, the implementation of this | 24 // the only medium that copresence uses is audio, the implementation of this |
| 32 // interface is required. | 25 // interface is required. |
| 33 class WhispernetClient { | 26 class WhispernetClient { |
| 34 public: | 27 public: |
| 35 // Generic callback to indicate a boolean success or failure. | |
| 36 typedef base::Callback<void(bool)> SuccessCallback; | |
| 37 // Callback that returns detected tokens. | |
| 38 typedef base::Callback<void(const std::vector<AudioToken>&)> TokensCallback; | |
| 39 // Callback that returns encoded samples for a given token. | |
| 40 typedef base::Callback<void(const std::string&, | |
| 41 AudioType, | |
| 42 const scoped_refptr<media::AudioBusRefCounted>&)> | |
| 43 SamplesCallback; | |
| 44 | |
| 45 // Initialize the whispernet client and call the callback when done. The | 28 // Initialize the whispernet client and call the callback when done. The |
| 46 // parameter indicates whether we succeeded or failed. | 29 // parameter indicates whether we succeeded or failed. |
| 47 virtual void Initialize(const SuccessCallback& init_callback) = 0; | 30 virtual void Initialize(const SuccessCallback& init_callback) = 0; |
| 48 // Copresence will call this before making any calls to its destructors. | 31 // Copresence will call this before making any calls to its destructors. |
| 49 virtual void Shutdown() = 0; | 32 virtual void Shutdown() = 0; |
| 50 | 33 |
| 51 // Fires an event to request a token encode. | 34 // Fires an event to request a token encode. |
| 52 virtual void EncodeToken(const std::string& token, AudioType type) = 0; | 35 virtual void EncodeToken(const std::string& token, AudioType type) = 0; |
| 53 // Fires an event to request a decode for the given samples. | 36 // Fires an event to request a decode for the given samples. |
| 54 virtual void DecodeSamples(AudioType type, const std::string& samples) = 0; | 37 virtual void DecodeSamples(AudioType type, const std::string& samples) = 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 70 virtual SamplesCallback GetSamplesCallback() = 0; | 53 virtual SamplesCallback GetSamplesCallback() = 0; |
| 71 virtual SuccessCallback GetDetectBroadcastCallback() = 0; | 54 virtual SuccessCallback GetDetectBroadcastCallback() = 0; |
| 72 virtual SuccessCallback GetInitializedCallback() = 0; | 55 virtual SuccessCallback GetInitializedCallback() = 0; |
| 73 | 56 |
| 74 virtual ~WhispernetClient() {} | 57 virtual ~WhispernetClient() {} |
| 75 }; | 58 }; |
| 76 | 59 |
| 77 } // namespace copresence | 60 } // namespace copresence |
| 78 | 61 |
| 79 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ | 62 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ |
| OLD | NEW |