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_
8 #include <google/protobuf/repeated_field.h>
13 #include "base/callback_forward.h"
14 #include "base/memory/ref_counted.h"
15 #include "components/copresence/tokens.h"
16 #include "media/base/channel_layout.h"
19 class AudioBusRefCounted
;
22 namespace copresence
{
25 class SubscribedMessage
;
27 // Audio constants. Currently used from the AudioPlayer/AudioRecorder.
28 // TODO(rkc): Make these values configurable then remove them from here.
29 // Number of repetitions of the audio token in one sequence of samples.
30 extern const int kDefaultRepetitions
;
32 // The default sample rate. We need to ensure that both the recorder and the
33 // player on _all platforms use the same rate.
34 extern const float kDefaultSampleRate
;
35 extern const int kDefaultBitsPerSample
;
37 // 18500 for ultrasound, needs to be consistent between platforms.
38 extern const float kDefaultCarrierFrequency
;
40 // The next two really need to be configurable since they don't need to be
41 // consistent across platforms, or even playing/recording.
42 extern const int kDefaultChannels
;
43 extern const media::ChannelLayout kDefaultChannelLayout
;
45 // Shared structs with whispernet. TODO(rkc): These will be removed once we can
46 // get protobufs working with Nacl. At that point, we'll just pass in
47 // config_data.proto to the whispernet nacl wrapper directly.
49 // We will be using fixed types in all these structures since they will be
50 // stuffed into a string and then read on the other side via a completely
51 // different toolchain. The struct is in its own namespace to disambiguate it
52 // from the protobuf structures.
56 struct AudioDsssParams
{
57 int64_t include_parity_symbol
;
58 int64_t use_single_sideband
;
59 double desired_carrier_frequency
;
61 double coder_sample_rate
;
62 int64_t bits_per_symbol
;
63 int64_t min_cycles_per_frame
;
64 int64_t baseband_decimation_factor
;
65 int64_t upsampling_factor
;
66 int64_t num_repetitions_to_play
;
70 int64_t attack_time_millis
;
71 int64_t decay_time_millis
;
72 int64_t sustain_time_millis
;
73 int64_t release_time_millis
;
74 double sustain_amplitude
;
77 struct AudioDtmfParams
{
78 int64_t include_parity_symbol
;
80 double coder_sample_rate
;
81 int64_t baseband_decimation_factor
;
82 int64_t frequencies_per_symbol
;
83 int64_t window_duration_millis
;
84 AdsrParams adsr_params
;
85 int64_t num_repetitions_to_play
;
89 int64_t clear_cached_request_duration_millis
;
90 int64_t request_buffer_limit
;
93 struct AudioParamData
{
95 AudioDsssParams audio_dsss
;
96 AudioDtmfParams audio_dtmf
;
97 int64_t recording_channels
;
100 } // namespace config
102 // These constants are used from everywhere.
103 // Particularly, these are used to index the directive lists in the
104 // audio manager, so do not change these enums without changing
105 // audio_directive_list.[h|cc].
110 AUDIO_TYPE_UNKNOWN
= 3,
114 // These callbacks are used from various places in Copresence.
116 // Generic callback to indicate a boolean success or failure.
117 using SuccessCallback
= base::Callback
<void(bool)>;
119 // Callback to pass around found tokens.
120 using TokensCallback
= base::Callback
<void(const std::vector
<AudioToken
>&)>;
122 // Callback to receive encoded samples from Whispernet.
123 // AudioType type: Type of audio encoding - AUDIBLE or INAUDIBLE.
124 // const std::string& token: The token that we encoded.
125 // const scoped_refptr<media::AudioBusRefCounted>& samples - Encoded samples.
126 using SamplesCallback
=
127 base::Callback
<void(AudioType
,
129 const scoped_refptr
<media::AudioBusRefCounted
>&)>;
131 // Callback to pass a list of directives back to CopresenceState.
132 using DirectivesCallback
= base::Callback
<void(const std::vector
<Directive
>&)>;
134 // Callback to pass around a list of SubscribedMessages.
135 using MessagesCallback
= base::Callback
<void(
136 const google::protobuf::RepeatedPtrField
<SubscribedMessage
>&)>;
138 } // namespace copresence
140 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_