OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "content/public/renderer/media_stream_audio_sink.h" | 8 #include "content/public/renderer/media_stream_audio_sink.h" |
9 #include "content/renderer/media/html_audio_element_capturer_source.h" | 9 #include "content/renderer/media/html_audio_element_capturer_source.h" |
10 #include "content/renderer/media/media_stream_audio_track.h" | 10 #include "content/renderer/media/media_stream_audio_track.h" |
11 #include "media/audio/null_audio_sink.h" | 11 #include "media/audio/null_audio_sink.h" |
12 #include "media/base/audio_parameters.h" | 12 #include "media/base/audio_parameters.h" |
13 #include "media/base/fake_audio_render_callback.h" | 13 #include "media/base/fake_audio_render_callback.h" |
| 14 #include "media/base/media_log.h" |
14 #include "media/blink/webaudiosourceprovider_impl.h" | 15 #include "media/blink/webaudiosourceprovider_impl.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
18 #include "third_party/WebKit/public/web/WebHeap.h" | 19 #include "third_party/WebKit/public/web/WebHeap.h" |
19 | 20 |
20 using ::testing::_; | 21 using ::testing::_; |
21 using ::testing::AllOf; | 22 using ::testing::AllOf; |
22 using ::testing::InSequence; | 23 using ::testing::InSequence; |
23 using ::testing::Mock; | 24 using ::testing::Mock; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // test, and a WebMediaStreamAudioTrack, that the class under test needs to | 60 // test, and a WebMediaStreamAudioTrack, that the class under test needs to |
60 // connect to in order to operate correctly. This class has an inner content | 61 // connect to in order to operate correctly. This class has an inner content |
61 // MediaStreamAudioTrack. | 62 // MediaStreamAudioTrack. |
62 // - finally, a MockMediaStreamAudioSink to observe captured audio frames, and | 63 // - finally, a MockMediaStreamAudioSink to observe captured audio frames, and |
63 // that plugs into the former MediaStreamAudioTrack. | 64 // that plugs into the former MediaStreamAudioTrack. |
64 class HTMLAudioElementCapturerSourceTest : public testing::Test { | 65 class HTMLAudioElementCapturerSourceTest : public testing::Test { |
65 public: | 66 public: |
66 HTMLAudioElementCapturerSourceTest() | 67 HTMLAudioElementCapturerSourceTest() |
67 : fake_callback_(0.1), | 68 : fake_callback_(0.1), |
68 audio_source_(new media::WebAudioSourceProviderImpl( | 69 audio_source_(new media::WebAudioSourceProviderImpl( |
69 new media::NullAudioSink(base::ThreadTaskRunnerHandle::Get()))) {} | 70 new media::NullAudioSink(base::ThreadTaskRunnerHandle::Get()), |
| 71 new media::MediaLog())) {} |
70 | 72 |
71 void SetUp() final { | 73 void SetUp() final { |
72 const media::AudioParameters params( | 74 const media::AudioParameters params( |
73 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 75 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
74 media::GuessChannelLayout(kNumChannelsForTest), | 76 media::GuessChannelLayout(kNumChannelsForTest), |
75 kAudioTrackSampleRate /* sample_rate */, 16 /* bits_per_sample */, | 77 kAudioTrackSampleRate /* sample_rate */, 16 /* bits_per_sample */, |
76 kAudioTrackSamplesPerBuffer /* frames_per_buffer */); | 78 kAudioTrackSamplesPerBuffer /* frames_per_buffer */); |
77 audio_source_->Initialize(params, &fake_callback_); | 79 audio_source_->Initialize(params, &fake_callback_); |
78 | 80 |
79 blink_audio_source_.initialize(blink::WebString::fromUTF8("audio_id"), | 81 blink_audio_source_.initialize(blink::WebString::fromUTF8("audio_id"), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 std::unique_ptr<media::AudioBus> bus = media::AudioBus::Create( | 147 std::unique_ptr<media::AudioBus> bus = media::AudioBus::Create( |
146 kNumChannelsForTest, kAudioTrackSamplesPerBuffer); | 148 kNumChannelsForTest, kAudioTrackSamplesPerBuffer); |
147 InjectAudio(bus.get()); | 149 InjectAudio(bus.get()); |
148 run_loop.Run(); | 150 run_loop.Run(); |
149 | 151 |
150 track()->Stop(); | 152 track()->Stop(); |
151 track()->RemoveSink(&sink); | 153 track()->RemoveSink(&sink); |
152 } | 154 } |
153 | 155 |
154 } // namespace content | 156 } // namespace content |
OLD | NEW |