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_PUBLIC_WHISPERNET_CLIENT_H_ | |
6 #define COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "components/copresence/public/copresence_constants.h" | |
11 | |
12 namespace media { | |
13 class AudioBusRefCounted; | |
14 } | |
15 | |
16 namespace copresence { | |
17 | |
18 // The interface that the whispernet client needs to implement. These methods | |
19 // provide us the ability to use the audio medium in copresence. Currently since | |
20 // the only medium that copresence uses is audio, the implementation of this | |
21 // interface is required. | |
22 class WhispernetClient { | |
23 public: | |
24 // Initialize the whispernet client and call the callback when done. The | |
25 // parameter indicates whether we succeeded or failed. | |
26 virtual void Initialize(const SuccessCallback& init_callback) = 0; | |
27 // Copresence will call this before making any calls to its destructors. | |
28 virtual void Shutdown() = 0; | |
29 | |
30 // Fires an event to request a token encode. | |
31 virtual void EncodeToken(const std::string& token, AudioType type) = 0; | |
32 // Fires an event to request a decode for the given samples. | |
33 virtual void DecodeSamples(AudioType type, | |
34 const std::string& samples, | |
35 const size_t token_length[2]) = 0; | |
36 // Fires an event to request detection of a whispernet broadcast. | |
37 virtual void DetectBroadcast() = 0; | |
38 | |
39 // Callback registreation methods. These are the callbacks that will be | |
40 // registered by Copresence to receive data. | |
41 virtual void RegisterTokensCallback( | |
42 const TokensCallback& tokens_callback) = 0; | |
43 virtual void RegisterSamplesCallback( | |
44 const SamplesCallback& samples_callback) = 0; | |
45 virtual void RegisterDetectBroadcastCallback( | |
46 const SuccessCallback& db_callback) = 0; | |
47 | |
48 // Don't cache these callbacks, as they may become invalid at any time. | |
49 // Always invoke callbacks directly through these accessors. | |
50 virtual TokensCallback GetTokensCallback() = 0; | |
51 virtual SamplesCallback GetSamplesCallback() = 0; | |
52 virtual SuccessCallback GetDetectBroadcastCallback() = 0; | |
53 virtual SuccessCallback GetInitializedCallback() = 0; | |
54 | |
55 virtual ~WhispernetClient() {} | |
56 }; | |
57 | |
58 } // namespace copresence | |
59 | |
60 #endif // COMPONENTS_COPRESENCE_PUBLIC_WHISPERNET_CLIENT_H_ | |
OLD | NEW |