| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 source_bus_->Zero(); | 236 source_bus_->Zero(); |
| 237 first_frame_capture_time_ = base::TimeTicks::Now(); | 237 first_frame_capture_time_ = base::TimeTicks::Now(); |
| 238 sample_frames_captured_ = 0; | 238 sample_frames_captured_ = 0; |
| 239 | 239 |
| 240 // Prepare the track and audio source. | 240 // Prepare the track and audio source. |
| 241 blink::WebMediaStreamTrack blink_track; | 241 blink::WebMediaStreamTrack blink_track; |
| 242 PrepareBlinkTrackOfType(MEDIA_DEVICE_AUDIO_CAPTURE, &blink_track); | 242 PrepareBlinkTrackOfType(MEDIA_DEVICE_AUDIO_CAPTURE, &blink_track); |
| 243 | 243 |
| 244 // Get the native track from the blink track and initialize. | 244 // Get the native track from the blink track and initialize. |
| 245 native_track_ = | 245 native_track_ = |
| 246 static_cast<WebRtcLocalAudioTrack*>(blink_track.extraData()); | 246 static_cast<WebRtcLocalAudioTrack*>(blink_track.getExtraData()); |
| 247 native_track_->OnSetFormat(source_params_); | 247 native_track_->OnSetFormat(source_params_); |
| 248 | 248 |
| 249 // Create and initialize the consumer. | 249 // Create and initialize the consumer. |
| 250 recognizer_.reset(new FakeSpeechRecognizer()); | 250 recognizer_.reset(new FakeSpeechRecognizer()); |
| 251 base::SharedMemoryHandle foreign_memory_handle; | 251 base::SharedMemoryHandle foreign_memory_handle; |
| 252 recognizer_->Initialize(blink_track, sink_params_, &foreign_memory_handle); | 252 recognizer_->Initialize(blink_track, sink_params_, &foreign_memory_handle); |
| 253 | 253 |
| 254 // Create the producer. | 254 // Create the producer. |
| 255 scoped_ptr<base::SyncSocket> sending_socket(recognizer_->sending_socket()); | 255 scoped_ptr<base::SyncSocket> sending_socket(recognizer_->sending_socket()); |
| 256 speech_audio_sink_.reset(new SpeechRecognitionAudioSink( | 256 speech_audio_sink_.reset(new SpeechRecognitionAudioSink( |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600); | 520 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600); |
| 521 AssertConsumedBuffers(0U); | 521 AssertConsumedBuffers(0U); |
| 522 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 522 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
| 523 EXPECT_CALL(*this, StoppedCallback()).Times(1); | 523 EXPECT_CALL(*this, StoppedCallback()).Times(1); |
| 524 | 524 |
| 525 native_track()->Stop(); | 525 native_track()->Stop(); |
| 526 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); | 526 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace content | 529 } // namespace content |
| OLD | NEW |