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_COPRESENCE_CONSTANTS_H_
6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13 #include "media/base/channel_layout.h"
16 class AudioBusRefCounted;
19 namespace copresence {
21 // Audio constants. Currently used from the AudioPlayer/AudioRecorder.
22 // TODO(rkc): Make these values configurable then remove them from here.
23 // Number of repetitions of the audio token in one sequence of samples.
24 extern const int kDefaultRepetitions;
26 // The default sample rate. We need to ensure that both the recorder and the
27 // player on _all platforms use the same rate.
28 extern const float kDefaultSampleRate;
29 extern const int kDefaultBitsPerSample;
31 // 18500 for ultrasound, needs to be consistent between platforms.
32 extern const float kDefaultCarrierFrequency;
34 // The next two really need to be configurable since they don't need to be
35 // consistent across platforms, or even playing/recording.
36 extern const int kDefaultChannels;
37 extern const media::ChannelLayout kDefaultChannelLayout;
39 // These constants are used from everywhere.
40 // Particularly, these are used to index the directive lists in the
41 // audio manager, so do not change these enums without changing
42 // audio_directive_list.[h|cc].
47 AUDIO_TYPE_UNKNOWN = 3,
51 AudioToken(const std::string& token, bool audible)
52 : token(token), audible(audible) {}
57 // These callbacks are used from various places in Copresence.
59 // Generic callback to indicate a boolean success or failure.
60 using SuccessCallback = base::Callback<void(bool)>;
62 // Callback to pass around found tokens.
64 // const std::vector<AudioToken>& tokens - List of found tokens.
65 using TokensCallback = base::Callback<void(const std::vector<AudioToken>&)>;
67 // Callback to receive encoded samples from Whispernet.
68 // AudioType type: Type of audio encoding - AUDIBLE or INAUDIBLE.
69 // const std::string& token: The token that we encoded.
70 // const scoped_refptr<media::AudioBusRefCounted>& samples - Encoded samples.
71 using SamplesCallback =
72 base::Callback<void(AudioType,
74 const scoped_refptr<media::AudioBusRefCounted>&)>;
75 } // namespace copresence
77 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_