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 <memory> |
| 6 #include <string> |
| 7 |
5 #include "base/logging.h" | 8 #include "base/logging.h" |
6 #include "build/build_config.h" | 9 #include "build/build_config.h" |
7 #include "content/public/renderer/media_stream_audio_sink.h" | 10 #include "content/public/renderer/media_stream_audio_sink.h" |
8 #include "content/renderer/media/media_stream_audio_track.h" | 11 #include "content/renderer/media/media_stream_audio_track.h" |
9 #include "content/renderer/media/mock_audio_device_factory.h" | 12 #include "content/renderer/media/mock_audio_device_factory.h" |
10 #include "content/renderer/media/mock_constraint_factory.h" | 13 #include "content/renderer/media/mock_constraint_factory.h" |
11 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" | 14 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" |
12 #include "content/renderer/media/webrtc/processed_local_audio_source.h" | 15 #include "content/renderer/media/webrtc/processed_local_audio_source.h" |
13 #include "media/base/audio_bus.h" | 16 #include "media/base/audio_bus.h" |
14 #include "media/base/audio_parameters.h" | 17 #include "media/base/audio_parameters.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 89 } |
87 | 90 |
88 void TearDown() override { | 91 void TearDown() override { |
89 blink_audio_track_.reset(); | 92 blink_audio_track_.reset(); |
90 blink_audio_source_.reset(); | 93 blink_audio_source_.reset(); |
91 blink::WebHeap::collectAllGarbageForTesting(); | 94 blink::WebHeap::collectAllGarbageForTesting(); |
92 } | 95 } |
93 | 96 |
94 void CreateProcessedLocalAudioSource( | 97 void CreateProcessedLocalAudioSource( |
95 const blink::WebMediaConstraints& constraints) { | 98 const blink::WebMediaConstraints& constraints) { |
96 ProcessedLocalAudioSource* const source = | 99 ProcessedLocalAudioSource* const source = new ProcessedLocalAudioSource( |
97 new ProcessedLocalAudioSource( | 100 -1 /* consumer_render_frame_id is N/A for non-browser tests */, |
98 -1 /* consumer_render_frame_id is N/A for non-browser tests */, | 101 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock audio device", |
99 StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock audio device", | 102 "mock_audio_device_id", "mock_group_id", kSampleRate, |
100 "mock_audio_device_id", kSampleRate, | 103 kChannelLayout, kRequestedBufferSize), |
101 kChannelLayout, kRequestedBufferSize), | 104 &mock_dependency_factory_); |
102 &mock_dependency_factory_); | |
103 source->SetAllowInvalidRenderFrameIdForTesting(true); | 105 source->SetAllowInvalidRenderFrameIdForTesting(true); |
104 source->SetSourceConstraints(constraints); | 106 source->SetSourceConstraints(constraints); |
105 blink_audio_source_.setExtraData(source); // Takes ownership. | 107 blink_audio_source_.setExtraData(source); // Takes ownership. |
106 } | 108 } |
107 | 109 |
108 void CheckSourceFormatMatches(const media::AudioParameters& params) { | 110 void CheckSourceFormatMatches(const media::AudioParameters& params) { |
109 EXPECT_EQ(kSampleRate, params.sample_rate()); | 111 EXPECT_EQ(kSampleRate, params.sample_rate()); |
110 EXPECT_EQ(kChannelLayout, params.channel_layout()); | 112 EXPECT_EQ(kChannelLayout, params.channel_layout()); |
111 EXPECT_EQ(kExpectedSourceBufferSize, params.frames_per_buffer()); | 113 EXPECT_EQ(kExpectedSourceBufferSize, params.frames_per_buffer()); |
112 } | 114 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // Even though ConnectToTrack() failed, there should still have been a new | 220 // Even though ConnectToTrack() failed, there should still have been a new |
219 // MediaStreamAudioTrack instance created, owned by the | 221 // MediaStreamAudioTrack instance created, owned by the |
220 // blink::WebMediaStreamTrack. | 222 // blink::WebMediaStreamTrack. |
221 EXPECT_TRUE(MediaStreamAudioTrack::From(blink_audio_track())); | 223 EXPECT_TRUE(MediaStreamAudioTrack::From(blink_audio_track())); |
222 } | 224 } |
223 | 225 |
224 // TODO(miu): There's a lot of logic in ProcessedLocalAudioSource around | 226 // TODO(miu): There's a lot of logic in ProcessedLocalAudioSource around |
225 // constraints processing and validation that should have unit testing. | 227 // constraints processing and validation that should have unit testing. |
226 | 228 |
227 } // namespace content | 229 } // namespace content |
OLD | NEW |