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 "content/renderer/media/speech_recognition_audio_sink.h" | 5 #include "content/renderer/media/speech_recognition_audio_sink.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <utility> | 10 #include <utility> |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 NULL)); | 285 NULL)); |
286 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( | 286 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( |
287 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); | 287 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); |
288 scoped_ptr<WebRtcLocalAudioTrack> native_track( | 288 scoped_ptr<WebRtcLocalAudioTrack> native_track( |
289 new WebRtcLocalAudioTrack(adapter.get(), capturer, NULL)); | 289 new WebRtcLocalAudioTrack(adapter.get(), capturer, NULL)); |
290 blink::WebMediaStreamSource blink_audio_source; | 290 blink::WebMediaStreamSource blink_audio_source; |
291 blink_audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"), | 291 blink_audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"), |
292 blink::WebMediaStreamSource::TypeAudio, | 292 blink::WebMediaStreamSource::TypeAudio, |
293 base::UTF8ToUTF16("dummy_source_name"), | 293 base::UTF8ToUTF16("dummy_source_name"), |
294 false /* remote */, true /* readonly */); | 294 false /* remote */, true /* readonly */); |
295 MediaStreamSource::SourceStoppedCallback cb; | 295 MediaStreamSource* const audio_source = new MediaStreamAudioSource(); |
296 blink_audio_source.setExtraData( | 296 audio_source->SetDeviceInfo(device_info); |
297 new MediaStreamAudioSource(-1, device_info, cb, NULL)); | 297 blink_audio_source.setExtraData(audio_source); // Takes ownership. |
298 blink_track->initialize(blink::WebString::fromUTF8("dummy_track"), | 298 blink_track->initialize(blink::WebString::fromUTF8("dummy_track"), |
299 blink_audio_source); | 299 blink_audio_source); |
300 blink_track->setExtraData(native_track.release()); | 300 blink_track->setExtraData(native_track.release()); |
301 } | 301 } |
302 | 302 |
303 // Emulates an audio capture device capturing data from the source. | 303 // Emulates an audio capture device capturing data from the source. |
304 inline void CaptureAudio(const uint32_t buffers) { | 304 inline void CaptureAudio(const uint32_t buffers) { |
305 for (uint32_t i = 0; i < buffers; ++i) { | 305 for (uint32_t i = 0; i < buffers; ++i) { |
306 const base::TimeTicks estimated_capture_time = first_frame_capture_time_ + | 306 const base::TimeTicks estimated_capture_time = first_frame_capture_time_ + |
307 (sample_frames_captured_ * base::TimeDelta::FromSeconds(1) / | 307 (sample_frames_captured_ * base::TimeDelta::FromSeconds(1) / |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600); | 528 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600); |
529 AssertConsumedBuffers(0U); | 529 AssertConsumedBuffers(0U); |
530 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 530 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
531 EXPECT_CALL(*this, StoppedCallback()).Times(1); | 531 EXPECT_CALL(*this, StoppedCallback()).Times(1); |
532 | 532 |
533 native_track()->Stop(); | 533 native_track()->Stop(); |
534 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 534 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
535 } | 535 } |
536 | 536 |
537 } // namespace content | 537 } // namespace content |
OLD | NEW |