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