ExtensionInstallDialogView: fix scrolling behavior on Views (Win,Linux)
[chromium-blink-merge.git] / components / audio_modem / public / whispernet_client.h
blob48d1efa9b2be30683573f52ae524369eb481a0d0
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_AUDIO_MODEM_PUBLIC_WHISPERNET_CLIENT_H_
6 #define COMPONENTS_AUDIO_MODEM_PUBLIC_WHISPERNET_CLIENT_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "components/audio_modem/public/audio_modem_types.h"
12 #include "media/base/audio_bus.h"
14 namespace audio_modem {
16 // Generic callback to indicate a boolean success or failure.
17 using SuccessCallback = base::Callback<void(bool)>;
19 // Callback to receive encoded samples from Whispernet.
20 // AudioType type: Type of audio encoding - AUDIBLE or INAUDIBLE.
21 // const std::string& token: The token that we encoded.
22 // const scoped_refptr<media::AudioBusRefCounted>& samples - Encoded samples.
23 using SamplesCallback =
24 base::Callback<void(AudioType,
25 const std::string&,
26 const scoped_refptr<media::AudioBusRefCounted>&)>;
28 // A client for the Whispernet audio library,
29 // responsible for the actual encoding and decoding of tokens.
30 class WhispernetClient {
31 public:
32 // Initialize the whispernet client and call the callback when done. The
33 // parameter indicates whether we succeeded or failed.
34 virtual void Initialize(const SuccessCallback& init_callback) = 0;
36 // Fires an event to request a token encode.
37 virtual void EncodeToken(const std::string& token,
38 AudioType type,
39 const TokenParameters token_params[2]) = 0;
40 // Fires an event to request a decode for the given samples.
41 virtual void DecodeSamples(AudioType type,
42 const std::string& samples,
43 const TokenParameters token_params[2]) = 0;
45 // Callback registration methods. The modem will set these to receive data.
46 virtual void RegisterTokensCallback(
47 const TokensCallback& tokens_callback) = 0;
48 virtual void RegisterSamplesCallback(
49 const SamplesCallback& samples_callback) = 0;
51 // Don't cache these callbacks, as they may become invalid at any time.
52 // Always invoke callbacks directly through these accessors.
53 virtual TokensCallback GetTokensCallback() = 0;
54 virtual SamplesCallback GetSamplesCallback() = 0;
55 virtual SuccessCallback GetInitializedCallback() = 0;
57 virtual ~WhispernetClient() {}
60 } // namespace audio_modem
62 #endif // COMPONENTS_AUDIO_MODEM_PUBLIC_WHISPERNET_CLIENT_H_