Index: media/base/audio_hash.cc |
diff --git a/media/base/audio_hash.cc b/media/base/audio_hash.cc |
index d879e5453629ff1f4e08a4b37c1ed71e1d6b9324..7f133dd78ba086bcf0d0109ff89b35610c6b0561 100644 |
--- a/media/base/audio_hash.cc |
+++ b/media/base/audio_hash.cc |
@@ -5,6 +5,7 @@ |
// MSVC++ requires this to be set before any other includes to get M_PI. |
#define _USE_MATH_DEFINES |
#include <cmath> |
+#include <sstream> |
#include "media/base/audio_hash.h" |
@@ -52,4 +53,17 @@ std::string AudioHash::ToString() const { |
return result; |
} |
+bool AudioHash::IsEquivalent(const std::string& other, double tolerance) const { |
+ float other_hash; |
+ char comma; |
+ |
+ std::stringstream is(other); |
+ for (size_t i = 0; i < arraysize(audio_hash_); ++i) { |
+ is >> other_hash >> comma; |
+ if (fabs(audio_hash_[i] - other_hash) > tolerance) |
+ return false; |
+ } |
+ return true; |
+} |
+ |
} // namespace media |