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

Unified Diff: components/copresence/test/audio_test_support.cc

Issue 419073002: Add the copresence DirectiveHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gn fix Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/test/audio_test_support.cc
diff --git a/components/copresence/test/audio_test_support.cc b/components/copresence/test/audio_test_support.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5a05d30045b62e6c8962ae05b473f2ef1d218347
--- /dev/null
+++ b/components/copresence/test/audio_test_support.cc
@@ -0,0 +1,41 @@
+// Copyright 2014 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.
+
+#include "components/copresence/test/audio_test_support.h"
+
+#include <cstdlib>
+
+#include "media/base/audio_bus.h"
+
+namespace {
+
+const int kFixedRandomSeed = 0x1337;
+
+} // namespace
+
+namespace copresence {
+
+void PopulateSamples(int random_seed, size_t size, float* samples) {
+ srand(random_seed);
+ for (size_t i = 0; i < size; ++i)
+ samples[i] = (2.0 * rand() / RAND_MAX) - 1;
+}
+
+scoped_ptr<media::AudioBus> CreateRandomAudio(int channels, int samples) {
+ scoped_ptr<media::AudioBus> bus = media::AudioBus::Create(channels, samples);
+ for (int ch = 0; ch < channels; ++ch)
+ PopulateSamples(kFixedRandomSeed, samples, bus->channel(ch));
+ return bus.Pass();
+}
+
+scoped_refptr<media::AudioBusRefCounted> CreateRandomAudioRefCounted(
+ int channels, int samples) {
+ scoped_refptr<media::AudioBusRefCounted> bus =
+ media::AudioBusRefCounted::Create(channels, samples);
+ for (int ch = 0; ch < channels; ++ch)
+ PopulateSamples(kFixedRandomSeed, samples, bus->channel(ch));
+ return bus;
+}
+
+} // namespace copresence

Powered by Google App Engine
This is Rietveld 408576698