OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/copresence/test/audio_test_support.h" | 5 #include "components/copresence/test/audio_test_support.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "media/base/audio_bus.h" | 9 #include "media/base/audio_bus.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 scoped_refptr<media::AudioBusRefCounted> | 28 scoped_refptr<media::AudioBusRefCounted> |
29 CreateRandomAudioRefCounted(int random_seed, int channels, int samples) { | 29 CreateRandomAudioRefCounted(int random_seed, int channels, int samples) { |
30 scoped_refptr<media::AudioBusRefCounted> bus = | 30 scoped_refptr<media::AudioBusRefCounted> bus = |
31 media::AudioBusRefCounted::Create(channels, samples); | 31 media::AudioBusRefCounted::Create(channels, samples); |
32 for (int ch = 0; ch < channels; ++ch) | 32 for (int ch = 0; ch < channels; ++ch) |
33 PopulateSamples(random_seed, samples, bus->channel(ch)); | 33 PopulateSamples(random_seed, samples, bus->channel(ch)); |
34 return bus; | 34 return bus; |
35 } | 35 } |
36 | 36 |
| 37 // TestAudioPlayer implementation. |
| 38 TestAudioPlayer::TestAudioPlayer() : is_playing_(false) { |
| 39 } |
| 40 TestAudioPlayer::~TestAudioPlayer() { |
| 41 } |
| 42 void TestAudioPlayer::Initialize() { |
| 43 } |
| 44 void TestAudioPlayer::Play( |
| 45 const scoped_refptr<media::AudioBusRefCounted>& /* samples */) { |
| 46 is_playing_ = true; |
| 47 } |
| 48 void TestAudioPlayer::Stop() { |
| 49 is_playing_ = false; |
| 50 } |
| 51 void TestAudioPlayer::Finalize() { |
| 52 delete this; |
| 53 } |
| 54 bool TestAudioPlayer::IsPlaying() { |
| 55 return is_playing_; |
| 56 } |
| 57 |
| 58 // TestAudioRecorder implementation. |
| 59 TestAudioRecorder::TestAudioRecorder() |
| 60 : AudioRecorderImpl(), is_recording_(false) { |
| 61 } |
| 62 TestAudioRecorder::~TestAudioRecorder() { |
| 63 } |
| 64 void TestAudioRecorder::Initialize(const RecordedSamplesCallback& cb) { |
| 65 cb_ = cb; |
| 66 } |
| 67 void TestAudioRecorder::Record() { |
| 68 is_recording_ = true; |
| 69 } |
| 70 void TestAudioRecorder::Stop() { |
| 71 is_recording_ = false; |
| 72 } |
| 73 void TestAudioRecorder::Finalize() { |
| 74 delete this; |
| 75 } |
| 76 bool TestAudioRecorder::IsRecording() { |
| 77 return is_recording_; |
| 78 } |
| 79 void TestAudioRecorder::TriggerDecodeRequest() { |
| 80 if (!cb_.is_null()) |
| 81 cb_.Run(std::string(7, 0x1337)); |
| 82 } |
| 83 |
37 } // namespace copresence | 84 } // namespace copresence |
OLD | NEW |