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

Side by Side Diff: chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc

Issue 845993002: Adding "rtp_timebase" variable in lieu of "frequency" for FrameReceiverConfig structure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | media/cast/cast_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | media/cast/cast_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698