Make castv2 performance test work.
[chromium-blink-merge.git] / chrome / browser / copresence / chrome_whispernet_client.h
blob5548104aaf35a86a19e9e9a3544fd2a982b2e64c
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 CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_
6 #define CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h"
13 #include "chrome/browser/copresence/chrome_whispernet_config.h"
14 #include "components/audio_modem/public/whispernet_client.h"
16 namespace content {
17 class BrowserContext;
20 namespace extensions {
22 struct Event;
23 class EventRouter;
25 namespace api {
26 namespace copresence_private {
27 struct AudioParameters;
31 } // namespace extensions
33 namespace media {
34 class AudioBusRefCounted;
37 // This class is responsible for communication with our whispernet_proxy
38 // extension that talks to the whispernet audio library.
39 class ChromeWhispernetClient final : public audio_modem::WhispernetClient {
40 public:
41 // The browser context needs to outlive this class.
42 explicit ChromeWhispernetClient(content::BrowserContext* browser_context);
43 ~ChromeWhispernetClient() override;
45 // WhispernetClient overrides:
46 void Initialize(const audio_modem::SuccessCallback& init_callback) override;
47 void EncodeToken(const std::string& token_str,
48 audio_modem::AudioType type,
49 const audio_modem::TokenParameters token_params[2]) override;
50 void DecodeSamples(
51 audio_modem::AudioType type,
52 const std::string& samples,
53 const audio_modem::TokenParameters token_params[2]) override;
54 void RegisterTokensCallback(
55 const audio_modem::TokensCallback& tokens_callback) override;
56 void RegisterSamplesCallback(
57 const audio_modem::SamplesCallback& samples_callback) override;
59 audio_modem::TokensCallback GetTokensCallback() override;
60 audio_modem::SamplesCallback GetSamplesCallback() override;
61 audio_modem::SuccessCallback GetInitializedCallback() override;
63 static const char kWhispernetProxyExtensionId[];
65 private:
66 // Fire an event to configure whispernet with the given audio parameters.
67 void AudioConfiguration(const AudioParamData& params);
69 void SendEventIfLoaded(scoped_ptr<extensions::Event> event);
71 // This gets called when the proxy extension loads.
72 void OnExtensionLoaded(bool success);
74 content::BrowserContext* const browser_context_;
75 extensions::EventRouter* const event_router_;
76 std::string client_id_;
78 audio_modem::SuccessCallback extension_loaded_callback_;
79 audio_modem::SuccessCallback init_callback_;
81 audio_modem::TokensCallback tokens_callback_;
82 audio_modem::SamplesCallback samples_callback_;
84 ScopedVector<extensions::Event> queued_events_;
85 bool extension_loaded_;
87 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClient);
90 #endif // CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_