| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <cmath> | 6 #include <cmath> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Assume the audio signal is a single sine wave (it can have some | 169 // Assume the audio signal is a single sine wave (it can have some |
| 170 // low-amplitude noise). Count zero crossings, and extrapolate the | 170 // low-amplitude noise). Count zero crossings, and extrapolate the |
| 171 // frequency of the sine wave in |audio_frame|. | 171 // frequency of the sine wave in |audio_frame|. |
| 172 int crossings = 0; | 172 int crossings = 0; |
| 173 for (int ch = 0; ch < audio_frame->channels(); ++ch) { | 173 for (int ch = 0; ch < audio_frame->channels(); ++ch) { |
| 174 crossings += media::cast::CountZeroCrossings(audio_frame->channel(ch), | 174 crossings += media::cast::CountZeroCrossings(audio_frame->channel(ch), |
| 175 audio_frame->frames()); | 175 audio_frame->frames()); |
| 176 } | 176 } |
| 177 crossings /= audio_frame->channels(); // Take the average. | 177 crossings /= audio_frame->channels(); // Take the average. |
| 178 const float seconds_per_frame = | 178 const float seconds_per_frame = |
| 179 audio_frame->frames() / static_cast<float>(audio_config().frequency); | 179 audio_frame->frames() / static_cast<float>(audio_config().rtp_timebase); |
| 180 const float frequency = crossings / seconds_per_frame / 2.0f; | 180 const float frequency = crossings / seconds_per_frame / 2.0f; |
| 181 VLOG(1) << "Current audio tone frequency: " << frequency; | 181 VLOG(1) << "Current audio tone frequency: " << frequency; |
| 182 | 182 |
| 183 const int kTargetWindowHz = 20; | 183 const int kTargetWindowHz = 20; |
| 184 for (std::vector<int>::iterator it = expected_tones_.begin(); | 184 for (std::vector<int>::iterator it = expected_tones_.begin(); |
| 185 it != expected_tones_.end(); ++it) { | 185 it != expected_tones_.end(); ++it) { |
| 186 if (abs(static_cast<int>(frequency) - *it) < kTargetWindowHz) { | 186 if (abs(static_cast<int>(frequency) - *it) < kTargetWindowHz) { |
| 187 LOG(INFO) << "Heard tone at frequency " << *it << " Hz."; | 187 LOG(INFO) << "Heard tone at frequency " << *it << " Hz."; |
| 188 expected_tones_.erase(it); | 188 expected_tones_.erase(it); |
| 189 MaybeRunDoneCallback(); | 189 MaybeRunDoneCallback(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 delete receiver; | 386 delete receiver; |
| 387 cast_environment->Shutdown(); | 387 cast_environment->Shutdown(); |
| 388 } | 388 } |
| 389 | 389 |
| 390 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { | 390 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { |
| 391 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); | 391 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); |
| 392 } | 392 } |
| 393 | 393 |
| 394 } // namespace extensions | 394 } // namespace extensions |
| OLD | NEW |