Index: media/audio/point.h |
diff --git a/media/audio/point.h b/media/audio/point.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1fbe752c3417b15b79da869f8838f930c173966a |
--- /dev/null |
+++ b/media/audio/point.h |
@@ -0,0 +1,57 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_AUDIO_MIC_POSITIONS_H_ |
DaleCurtis
2015/09/03 01:58:37
Header tag is not correct. Is it worth reusing ui/
ajm
2015/09/03 04:19:29
It appears to do everything we need except for the
Henrik Grunell
2015/09/03 07:14:20
If we can't use an existing point class, maybe a b
ajm
2015/09/09 01:01:29
gfx::Point3F works fine. I added a typedef below,
|
+#define MEDIA_AUDIO_MIC_POSITIONS_H_ |
+ |
+#include <cmath> |
+#include <string> |
+#include <vector> |
+ |
+#include "media/base/media_export.h" |
+ |
+namespace media { |
+ |
+// Represents a 3D point using Cartesian coordinates in meters. |
+class MEDIA_EXPORT Point final { |
+ public: |
+ Point(); |
+ Point(float x, float y, float z); |
+ |
+ float x() const { return x_; } |
+ float y() const { return y_; } |
+ float z() const { return z_; } |
+ |
+ // Checks that all coordinates are finite (not infinite or NaN). |
+ bool IsValid() const; |
+ |
+ // Returns a human-readable string of the coordinates. |
+ std::string ToString() const; |
+ |
+ Point(const Point&) = default; |
+ Point& operator=(const Point&) = default; |
+ |
+ bool operator==(const Point& rhs) const { |
+ return x_ == rhs.x_ && y_ == rhs.y_ && z_ == rhs.z_; |
+ } |
+ |
+ bool operator!=(const Point& rhs) const { return !(*this == rhs); } |
+ |
+ private: |
+ float x_; |
+ float y_; |
+ float z_; |
+}; |
+ |
+// Returns a vector of points parsed from a whitespace-separated string |
+// formatted |
+// as: "x1 y1 z1 ... zn yn zn" for n points. |
+// |
+// Returns an empty vector if |points_string| is empty or isn't parseable. |
+MEDIA_EXPORT std::vector<Point> ParsePointsFromString( |
+ const std::string& points_string); |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_AUDIO_MIC_POSITIONS_H_ |