Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / copresence / public / copresence_constants.h
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.
4
5 #ifndef COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_
6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13 #include "media/base/channel_layout.h"
14
15 namespace media {
16 class AudioBusRefCounted;
17 }
18
19 namespace copresence {
20
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;
25
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;
30
31 // 18500 for ultrasound, needs to be consistent between platforms.
32 extern const float kDefaultCarrierFrequency;
33
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;
38
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].
43 enum AudioType {
44   AUDIBLE = 0,
45   INAUDIBLE = 1,
46   BOTH = 2,
47   AUDIO_TYPE_UNKNOWN = 3,
48 };
49
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
57 // These callbacks are used from various places in Copresence.
58
59 // Generic callback to indicate a boolean success or failure.
60 using SuccessCallback = base::Callback<void(bool)>;
61
62 // 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>&)>;
66
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,
73                         const std::string&,
74                         const scoped_refptr<media::AudioBusRefCounted>&)>;
75 }  // namespace copresence
76
77 #endif  // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CONSTANTS_H_