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