| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_ | 5 #ifndef COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_ |
| 6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_ | 6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_ |
| 7 | 7 |
| 8 #include <google/protobuf/repeated_field.h> | 8 #include <google/protobuf/repeated_field.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "components/copresence/tokens.h" | 15 #include "components/copresence/tokens.h" |
| 16 #include "media/base/channel_layout.h" | 16 #include "media/base/channel_layout.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 class AudioBusRefCounted; | 19 class AudioBusRefCounted; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace copresence { | 22 namespace copresence { |
| 23 | 23 |
| 24 class Directive; | 24 class Directive; |
| 25 class SubscribedMessage; | 25 class SubscribedMessage; |
| 26 | 26 |
| 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; | |
| 31 | |
| 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; | |
| 36 | |
| 37 // 18500 for ultrasound, needs to be consistent between platforms. | |
| 38 extern const float kDefaultCarrierFrequency; | |
| 39 | |
| 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; | |
| 44 | |
| 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. | |
| 48 | |
| 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. | |
| 53 | |
| 54 namespace config { | |
| 55 | |
| 56 struct AudioDsssParams { | |
| 57 int64_t include_parity_symbol; | |
| 58 int64_t use_single_sideband; | |
| 59 double desired_carrier_frequency; | |
| 60 int64_t use_crc_16; | |
| 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; | |
| 67 }; | |
| 68 | |
| 69 struct AdsrParams { | |
| 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; | |
| 75 }; | |
| 76 | |
| 77 struct AudioDtmfParams { | |
| 78 int64_t include_parity_symbol; | |
| 79 int64_t use_crc_16; | |
| 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; | |
| 86 }; | |
| 87 | |
| 88 struct LoggerParam { | |
| 89 int64_t clear_cached_request_duration_millis; | |
| 90 int64_t request_buffer_limit; | |
| 91 }; | |
| 92 | |
| 93 struct AudioParamData { | |
| 94 LoggerParam logger; | |
| 95 AudioDsssParams audio_dsss; | |
| 96 AudioDtmfParams audio_dtmf; | |
| 97 int64_t recording_channels; | |
| 98 }; | |
| 99 | |
| 100 } // namespace config | |
| 101 | |
| 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]. | |
| 106 enum AudioType { | |
| 107 AUDIBLE = 0, | |
| 108 INAUDIBLE = 1, | |
| 109 BOTH = 2, | |
| 110 AUDIO_TYPE_UNKNOWN = 3, | |
| 111 }; | |
| 112 | |
| 113 | |
| 114 // These callbacks are used from various places in Copresence. | |
| 115 | |
| 116 // Generic callback to indicate a boolean success or failure. | |
| 117 using SuccessCallback = base::Callback<void(bool)>; | |
| 118 | |
| 119 // Callback to pass around found tokens. | |
| 120 using TokensCallback = base::Callback<void(const std::vector<AudioToken>&)>; | |
| 121 | |
| 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, | |
| 128 const std::string&, | |
| 129 const scoped_refptr<media::AudioBusRefCounted>&)>; | |
| 130 | |
| 131 // Callback to pass a list of directives back to CopresenceState. | 27 // Callback to pass a list of directives back to CopresenceState. |
| 132 using DirectivesCallback = base::Callback<void(const std::vector<Directive>&)>; | 28 using DirectivesCallback = base::Callback<void(const std::vector<Directive>&)>; |
| 133 | 29 |
| 134 // Callback to pass around a list of SubscribedMessages. | 30 // Callback to pass around a list of SubscribedMessages. |
| 135 using MessagesCallback = base::Callback<void( | 31 using MessagesCallback = base::Callback<void( |
| 136 const google::protobuf::RepeatedPtrField<SubscribedMessage>&)>; | 32 const google::protobuf::RepeatedPtrField<SubscribedMessage>&)>; |
| 137 | 33 |
| 138 } // namespace copresence | 34 } // namespace copresence |
| 139 | 35 |
| 140 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_ | 36 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_ |
| OLD | NEW |