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 "content/renderer/media_capture_from_element/html_audio_element_capture
r_source.h" | 5 #include "content/renderer/media_capture_from_element/html_audio_element_capture
r_source.h" |
6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/test/scoped_task_environment.h" | 8 #include "base/test/scoped_task_environment.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "content/public/renderer/media_stream_audio_sink.h" | 10 #include "content/public/renderer/media_stream_audio_sink.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // connect to in order to operate correctly. This class has an inner content | 62 // connect to in order to operate correctly. This class has an inner content |
63 // MediaStreamAudioTrack. | 63 // MediaStreamAudioTrack. |
64 // - finally, a MockMediaStreamAudioSink to observe captured audio frames, and | 64 // - finally, a MockMediaStreamAudioSink to observe captured audio frames, and |
65 // that plugs into the former MediaStreamAudioTrack. | 65 // that plugs into the former MediaStreamAudioTrack. |
66 class HTMLAudioElementCapturerSourceTest : public testing::Test { | 66 class HTMLAudioElementCapturerSourceTest : public testing::Test { |
67 public: | 67 public: |
68 HTMLAudioElementCapturerSourceTest() | 68 HTMLAudioElementCapturerSourceTest() |
69 : fake_callback_(0.1, kAudioTrackSampleRate), | 69 : fake_callback_(0.1, kAudioTrackSampleRate), |
70 audio_source_(new media::WebAudioSourceProviderImpl( | 70 audio_source_(new media::WebAudioSourceProviderImpl( |
71 new media::NullAudioSink(base::ThreadTaskRunnerHandle::Get()), | 71 new media::NullAudioSink(base::ThreadTaskRunnerHandle::Get()), |
72 new media::MediaLog())) {} | 72 &media_log_)) {} |
73 | 73 |
74 void SetUp() final { | 74 void SetUp() final { |
75 const media::AudioParameters params( | 75 const media::AudioParameters params( |
76 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 76 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
77 media::GuessChannelLayout(kNumChannelsForTest), | 77 media::GuessChannelLayout(kNumChannelsForTest), |
78 kAudioTrackSampleRate /* sample_rate */, 16 /* bits_per_sample */, | 78 kAudioTrackSampleRate /* sample_rate */, 16 /* bits_per_sample */, |
79 kAudioTrackSamplesPerBuffer /* frames_per_buffer */); | 79 kAudioTrackSamplesPerBuffer /* frames_per_buffer */); |
80 audio_source_->Initialize(params, &fake_callback_); | 80 audio_source_->Initialize(params, &fake_callback_); |
81 | 81 |
82 blink_audio_source_.Initialize(blink::WebString::FromUTF8("audio_id"), | 82 blink_audio_source_.Initialize(blink::WebString::FromUTF8("audio_id"), |
(...skipping 27 matching lines...) Expand all Loading... |
110 int InjectAudio(media::AudioBus* audio_bus) { | 110 int InjectAudio(media::AudioBus* audio_bus) { |
111 return audio_source_->RenderForTesting(audio_bus); | 111 return audio_source_->RenderForTesting(audio_bus); |
112 } | 112 } |
113 | 113 |
114 protected: | 114 protected: |
115 const base::test::ScopedTaskEnvironment scoped_task_environment_; | 115 const base::test::ScopedTaskEnvironment scoped_task_environment_; |
116 | 116 |
117 blink::WebMediaStreamSource blink_audio_source_; | 117 blink::WebMediaStreamSource blink_audio_source_; |
118 blink::WebMediaStreamTrack blink_audio_track_; | 118 blink::WebMediaStreamTrack blink_audio_track_; |
119 | 119 |
| 120 media::MediaLog media_log_; |
120 media::FakeAudioRenderCallback fake_callback_; | 121 media::FakeAudioRenderCallback fake_callback_; |
121 scoped_refptr<media::WebAudioSourceProviderImpl> audio_source_; | 122 scoped_refptr<media::WebAudioSourceProviderImpl> audio_source_; |
122 }; | 123 }; |
123 | 124 |
124 // Constructs and destructs all objects. This is a non trivial sequence. | 125 // Constructs and destructs all objects. This is a non trivial sequence. |
125 TEST_F(HTMLAudioElementCapturerSourceTest, ConstructAndDestruct) { | 126 TEST_F(HTMLAudioElementCapturerSourceTest, ConstructAndDestruct) { |
126 } | 127 } |
127 | 128 |
128 // This test verifies that Audio can be properly captured when injected in the | 129 // This test verifies that Audio can be properly captured when injected in the |
129 // WebAudioSourceProviderImpl. | 130 // WebAudioSourceProviderImpl. |
(...skipping 18 matching lines...) Expand all Loading... |
148 std::unique_ptr<media::AudioBus> bus = media::AudioBus::Create( | 149 std::unique_ptr<media::AudioBus> bus = media::AudioBus::Create( |
149 kNumChannelsForTest, kAudioTrackSamplesPerBuffer); | 150 kNumChannelsForTest, kAudioTrackSamplesPerBuffer); |
150 InjectAudio(bus.get()); | 151 InjectAudio(bus.get()); |
151 run_loop.Run(); | 152 run_loop.Run(); |
152 | 153 |
153 track()->Stop(); | 154 track()->Stop(); |
154 track()->RemoveSink(&sink); | 155 track()->RemoveSink(&sink); |
155 } | 156 } |
156 | 157 |
157 } // namespace content | 158 } // namespace content |
OLD | NEW |