Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: media/audio/audio_parameters.h

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More constructors. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_PARAMETERS_H_
6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // effects should be enabled. 50 // effects should be enabled.
51 enum PlatformEffectsMask { 51 enum PlatformEffectsMask {
52 NO_EFFECTS = 0x0, 52 NO_EFFECTS = 0x0,
53 ECHO_CANCELLER = 0x1, 53 ECHO_CANCELLER = 0x1,
54 DUCKING = 0x2, // Enables ducking if the OS supports it. 54 DUCKING = 0x2, // Enables ducking if the OS supports it.
55 KEYBOARD_MIC = 0x4, 55 KEYBOARD_MIC = 0x4,
56 HOTWORD = 0x8, 56 HOTWORD = 0x8,
57 }; 57 };
58 58
59 AudioParameters(); 59 AudioParameters();
60 AudioParameters(Format format, ChannelLayout channel_layout, 60 AudioParameters(Format format,
61 int sample_rate, int bits_per_sample, 61 ChannelLayout channel_layout,
62 int frames_per_buffer); 62 int sample_rate,
63 AudioParameters(Format format, ChannelLayout channel_layout, 63 int bits_per_sample,
64 int sample_rate, int bits_per_sample, 64 int frames_per_buffer,
65 int frames_per_buffer, int effects); 65 const std::string& mic_positions = "",
66 AudioParameters(Format format, ChannelLayout channel_layout, 66 int effects = NO_EFFECTS);
67 int channels, int sample_rate, int bits_per_sample, 67 AudioParameters(Format format,
68 int frames_per_buffer, int effects); 68 int channels,
69 ChannelLayout channel_layout,
70 int sample_rate,
71 int bits_per_sample,
72 int frames_per_buffer,
73 const std::string& mic_positions = "",
74 int effects = NO_EFFECTS);
69 75
70 void Reset(Format format, ChannelLayout channel_layout, 76 void Reset(Format format, ChannelLayout channel_layout,
71 int channels, int sample_rate, int bits_per_sample, 77 int channels, int sample_rate, int bits_per_sample,
72 int frames_per_buffer); 78 int frames_per_buffer);
73 79
74 // Checks that all values are in the expected range. All limits are specified 80 // Checks that all values are in the expected range. All limits are specified
75 // in media::Limits. 81 // in media::Limits.
76 bool IsValid() const; 82 bool IsValid() const;
77 83
78 // Returns a human-readable string describing |*this|. For debugging & test 84 // Returns a human-readable string describing |*this|. For debugging & test
(...skipping 16 matching lines...) Expand all
95 // Comparison with other AudioParams. 101 // Comparison with other AudioParams.
96 bool Equals(const AudioParameters& other) const; 102 bool Equals(const AudioParameters& other) const;
97 103
98 Format format() const { return format_; } 104 Format format() const { return format_; }
99 ChannelLayout channel_layout() const { return channel_layout_; } 105 ChannelLayout channel_layout() const { return channel_layout_; }
100 int sample_rate() const { return sample_rate_; } 106 int sample_rate() const { return sample_rate_; }
101 int bits_per_sample() const { return bits_per_sample_; } 107 int bits_per_sample() const { return bits_per_sample_; }
102 int frames_per_buffer() const { return frames_per_buffer_; } 108 int frames_per_buffer() const { return frames_per_buffer_; }
103 int channels() const { return channels_; } 109 int channels() const { return channels_; }
104 int effects() const { return effects_; } 110 int effects() const { return effects_; }
111 const std::string& mic_positions() const { return mic_positions_; }
105 112
106 private: 113 private:
107 // These members are mutable to support entire struct assignment. They should 114 // These members are mutable to support entire struct assignment. They should
108 // not be mutated individually. 115 // not be mutated individually.
109 Format format_; // Format of the stream. 116 Format format_; // Format of the stream.
110 ChannelLayout channel_layout_; // Order of surround sound channels. 117 ChannelLayout channel_layout_; // Order of surround sound channels.
111 int sample_rate_; // Sampling frequency/rate. 118 int sample_rate_; // Sampling frequency/rate.
112 int bits_per_sample_; // Number of bits per sample. 119 int bits_per_sample_; // Number of bits per sample.
113 int frames_per_buffer_; // Number of frames in a buffer. 120 int frames_per_buffer_; // Number of frames in a buffer.
114 121
115 int channels_; // Number of channels. Value set based on 122 int channels_; // Number of channels. Value set based on
116 // |channel_layout|. 123 // |channel_layout|.
124
125 // Whitespace-separated microphone positions using Cartesian coordinates in
126 // meters with ordering x, y, z.
127 // x: the horizontal dimension, with positive to the right from the camera's
128 // perspective.
129 // y: the depth dimension, with positive forward from the camera's
130 // perspective.
131 // z: the vertical dimension, with positive upwards.
132 //
133 // Usually, the center of the microphone array will be treated as the origin
134 // (often the position of the camera). The string is formatted as:
135 // "x1 y1 z1 ... zn yn zn" for an n-microphone array.
136 // For example, a two-mic device with 4 cm of horizontal spacing would use:
137 // "-0.02 0 0 0.02 0 0"
138 //
139 // The empty string indicates unknown positions.
140 std::string mic_positions_;
Henrik Grunell 2015/08/27 08:38:18 I think we should have some other type for this. I
ajm 2015/08/28 07:36:13 The reasons I want to use a string are: 1. It will
Henrik Grunell 2015/08/28 15:04:34 I really hope there's only one in Chrome. :) Are t
aluebs-chromium 2015/08/28 19:14:30 I agree with Henrik, this also allows you to only
141
117 int effects_; // Bitmask using PlatformEffectsMask. 142 int effects_; // Bitmask using PlatformEffectsMask.
118 }; 143 };
119 144
120 // Comparison is useful when AudioParameters is used with std structures. 145 // Comparison is useful when AudioParameters is used with std structures.
121 inline bool operator<(const AudioParameters& a, const AudioParameters& b) { 146 inline bool operator<(const AudioParameters& a, const AudioParameters& b) {
122 if (a.format() != b.format()) 147 if (a.format() != b.format())
123 return a.format() < b.format(); 148 return a.format() < b.format();
124 if (a.channels() != b.channels()) 149 if (a.channels() != b.channels())
125 return a.channels() < b.channels(); 150 return a.channels() < b.channels();
126 if (a.sample_rate() != b.sample_rate()) 151 if (a.sample_rate() != b.sample_rate())
127 return a.sample_rate() < b.sample_rate(); 152 return a.sample_rate() < b.sample_rate();
128 if (a.bits_per_sample() != b.bits_per_sample()) 153 if (a.bits_per_sample() != b.bits_per_sample())
129 return a.bits_per_sample() < b.bits_per_sample(); 154 return a.bits_per_sample() < b.bits_per_sample();
130 return a.frames_per_buffer() < b.frames_per_buffer(); 155 return a.frames_per_buffer() < b.frames_per_buffer();
131 } 156 }
132 157
133 } // namespace media 158 } // namespace media
134 159
135 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 160 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698