| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/speech/speech_recognition_manager_impl.h" | 5 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/browser/browser_main_loop.h" | 14 #include "content/browser/browser_main_loop.h" |
| 15 #include "content/browser/renderer_host/media/media_stream_manager.h" | 15 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" | 16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" |
| 17 #include "content/browser/speech/speech_recognition_engine.h" | 17 #include "content/browser/speech/speech_recognition_engine.h" |
| 18 #include "content/browser/speech/speech_recognizer_impl.h" | 18 #include "content/browser/speech/speech_recognizer_impl.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/resource_context.h" | 21 #include "content/public/browser/resource_context.h" |
| 22 #include "content/public/browser/speech_recognition_event_listener.h" | 22 #include "content/public/browser/speech_recognition_event_listener.h" |
| 23 #include "content/public/browser/speech_recognition_manager_delegate.h" | 23 #include "content/public/browser/speech_recognition_manager_delegate.h" |
| 24 #include "content/public/browser/speech_recognition_session_config.h" | 24 #include "content/public/browser/speech_recognition_session_config.h" |
| 25 #include "content/public/browser/speech_recognition_session_context.h" | 25 #include "content/public/browser/speech_recognition_session_context.h" |
| 26 #include "content/public/common/speech_recognition_error.h" | 26 #include "content/public/common/speech_recognition_error.h" |
| 27 #include "content/public/common/speech_recognition_result.h" | 27 #include "content/public/common/speech_recognition_result.h" |
| 28 #include "media/audio/audio_device_description.h" |
| 28 #include "media/audio/audio_manager.h" | 29 #include "media/audio/audio_manager.h" |
| 29 #include "media/audio/audio_manager_base.h" | |
| 30 | 30 |
| 31 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
| 32 #include "content/browser/speech/speech_recognizer_impl_android.h" | 32 #include "content/browser/speech/speech_recognizer_impl_android.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 using base::Callback; | 35 using base::Callback; |
| 36 | 36 |
| 37 namespace content { | 37 namespace content { |
| 38 | 38 |
| 39 SpeechRecognitionManager* SpeechRecognitionManager::manager_for_tests_; | 39 SpeechRecognitionManager* SpeechRecognitionManager::manager_for_tests_; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // - Are guaranteed to be not reentrant (themselves and each other); | 555 // - Are guaranteed to be not reentrant (themselves and each other); |
| 556 | 556 |
| 557 void SpeechRecognitionManagerImpl::SessionStart(const Session& session) { | 557 void SpeechRecognitionManagerImpl::SessionStart(const Session& session) { |
| 558 DCHECK_EQ(primary_session_id_, session.id); | 558 DCHECK_EQ(primary_session_id_, session.id); |
| 559 const MediaStreamDevices& devices = session.context.devices; | 559 const MediaStreamDevices& devices = session.context.devices; |
| 560 std::string device_id; | 560 std::string device_id; |
| 561 if (devices.empty()) { | 561 if (devices.empty()) { |
| 562 // From the ask_user=false path, use the default device. | 562 // From the ask_user=false path, use the default device. |
| 563 // TODO(xians): Abort the session after we do not need to support this path | 563 // TODO(xians): Abort the session after we do not need to support this path |
| 564 // anymore. | 564 // anymore. |
| 565 device_id = media::AudioManagerBase::kDefaultDeviceId; | 565 device_id = media::AudioDeviceDescription::kDefaultDeviceId; |
| 566 } else { | 566 } else { |
| 567 // From the ask_user=true path, use the selected device. | 567 // From the ask_user=true path, use the selected device. |
| 568 DCHECK_EQ(1u, devices.size()); | 568 DCHECK_EQ(1u, devices.size()); |
| 569 DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, devices.front().type); | 569 DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, devices.front().type); |
| 570 device_id = devices.front().id; | 570 device_id = devices.front().id; |
| 571 } | 571 } |
| 572 | 572 |
| 573 session.recognizer->StartRecognition(device_id); | 573 session.recognizer->StartRecognition(device_id); |
| 574 } | 574 } |
| 575 | 575 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 SpeechRecognitionManagerImpl::Session::Session() | 666 SpeechRecognitionManagerImpl::Session::Session() |
| 667 : id(kSessionIDInvalid), | 667 : id(kSessionIDInvalid), |
| 668 abort_requested(false), | 668 abort_requested(false), |
| 669 listener_is_active(true) { | 669 listener_is_active(true) { |
| 670 } | 670 } |
| 671 | 671 |
| 672 SpeechRecognitionManagerImpl::Session::~Session() { | 672 SpeechRecognitionManagerImpl::Session::~Session() { |
| 673 } | 673 } |
| 674 | 674 |
| 675 } // namespace content | 675 } // namespace content |
| OLD | NEW |