OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/audio_track_recorder.h" | 5 #include "content/renderer/media/audio_track_recorder.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/renderer/media/media_stream_audio_source.h" | 13 #include "content/renderer/media/media_stream_audio_source.h" |
14 #include "content/renderer/media/mock_media_constraint_factory.h" | |
15 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
16 #include "content/renderer/media/webrtc_local_audio_track.h" | 15 #include "content/renderer/media/webrtc_local_audio_track.h" |
17 #include "media/audio/simple_sources.h" | 16 #include "media/audio/simple_sources.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "third_party/WebKit/public/web/WebHeap.h" | 19 #include "third_party/WebKit/public/web/WebHeap.h" |
21 #include "third_party/opus/src/include/opus.h" | 20 #include "third_party/opus/src/include/opus.h" |
22 | 21 |
23 using ::testing::_; | 22 using ::testing::_; |
24 using ::testing::DoAll; | 23 using ::testing::DoAll; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 201 |
203 // Decoder for verifying data was properly encoded. | 202 // Decoder for verifying data was properly encoded. |
204 OpusDecoder* opus_decoder_; | 203 OpusDecoder* opus_decoder_; |
205 scoped_ptr<float[]> buffer_; | 204 scoped_ptr<float[]> buffer_; |
206 | 205 |
207 private: | 206 private: |
208 // Prepares a blink track of a given MediaStreamType and attaches the native | 207 // Prepares a blink track of a given MediaStreamType and attaches the native |
209 // track, which can be used to capture audio data and pass it to the producer. | 208 // track, which can be used to capture audio data and pass it to the producer. |
210 // Adapted from media::WebRTCLocalAudioSourceProviderTest. | 209 // Adapted from media::WebRTCLocalAudioSourceProviderTest. |
211 void PrepareBlinkTrack() { | 210 void PrepareBlinkTrack() { |
212 MockMediaConstraintFactory constraint_factory; | |
213 scoped_refptr<WebRtcAudioCapturer> capturer( | |
214 WebRtcAudioCapturer::CreateCapturer( | |
215 -1, StreamDeviceInfo(), | |
216 constraint_factory.CreateWebMediaConstraints(), NULL, NULL)); | |
217 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( | 211 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( |
218 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); | 212 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); |
219 scoped_ptr<WebRtcLocalAudioTrack> native_track( | 213 scoped_ptr<WebRtcLocalAudioTrack> native_track( |
220 new WebRtcLocalAudioTrack(adapter.get(), capturer, NULL)); | 214 new WebRtcLocalAudioTrack(adapter.get())); |
221 blink::WebMediaStreamSource audio_source; | 215 blink::WebMediaStreamSource audio_source; |
222 audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"), | 216 audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"), |
223 blink::WebMediaStreamSource::TypeAudio, | 217 blink::WebMediaStreamSource::TypeAudio, |
224 base::UTF8ToUTF16("dummy_source_name"), | 218 base::UTF8ToUTF16("dummy_source_name"), |
225 false /* remote */, true /* readonly */); | 219 false /* remote */, true /* readonly */); |
226 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), | 220 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), |
227 audio_source); | 221 audio_source); |
228 blink_track_.setExtraData(native_track.release()); | 222 blink_track_.setExtraData(native_track.release()); |
229 } | 223 } |
230 | 224 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 base::TimeTicks::Now()); | 276 base::TimeTicks::Now()); |
283 } | 277 } |
284 | 278 |
285 run_loop.Run(); | 279 run_loop.Run(); |
286 Mock::VerifyAndClearExpectations(this); | 280 Mock::VerifyAndClearExpectations(this); |
287 } | 281 } |
288 | 282 |
289 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); | 283 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); |
290 | 284 |
291 } // namespace content | 285 } // namespace content |
OLD | NEW |