Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: content/browser/speech/speech_recognition_dispatcher_host.cc

Issue 549373003: Binding media stream audio track to speech recognition [browser] Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wait with no timeout Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_dispatcher_host.h" 5 #include "content/browser/speech/speech_recognition_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/sync_socket.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest.h" 11 #include "content/browser/browser_plugin/browser_plugin_guest.h"
11 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/speech/speech_recognition_manager_impl.h" 14 #include "content/browser/speech/speech_recognition_manager_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 15 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/common/speech_recognition_messages.h" 16 #include "content/common/speech_recognition_messages.h"
16 #include "content/public/browser/speech_recognition_manager_delegate.h" 17 #include "content/public/browser/speech_recognition_manager_delegate.h"
17 #include "content/public/browser/speech_recognition_session_config.h" 18 #include "content/public/browser/speech_recognition_session_config.h"
18 #include "content/public/browser/speech_recognition_session_context.h" 19 #include "content/public/browser/speech_recognition_session_context.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "media/audio/audio_parameters.h"
20 22
21 namespace content { 23 namespace content {
22 24
23 SpeechRecognitionDispatcherHost::SpeechRecognitionDispatcherHost( 25 SpeechRecognitionDispatcherHost::SpeechRecognitionDispatcherHost(
24 int render_process_id, 26 int render_process_id,
25 net::URLRequestContextGetter* context_getter) 27 net::URLRequestContextGetter* context_getter)
26 : BrowserMessageFilter(SpeechRecognitionMsgStart), 28 : BrowserMessageFilter(SpeechRecognitionMsgStart),
27 render_process_id_(render_process_id), 29 render_process_id_(render_process_id),
28 context_getter_(context_getter), 30 context_getter_(context_getter),
29 weak_factory_(this) { 31 weak_factory_(this) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 config.language = params.language; 162 config.language = params.language;
161 config.grammars = params.grammars; 163 config.grammars = params.grammars;
162 config.max_hypotheses = params.max_hypotheses; 164 config.max_hypotheses = params.max_hypotheses;
163 config.origin_url = params.origin_url; 165 config.origin_url = params.origin_url;
164 config.initial_context = context; 166 config.initial_context = context;
165 config.url_request_context_getter = context_getter_.get(); 167 config.url_request_context_getter = context_getter_.get();
166 config.filter_profanities = filter_profanities; 168 config.filter_profanities = filter_profanities;
167 config.continuous = params.continuous; 169 config.continuous = params.continuous;
168 config.interim_results = params.interim_results; 170 config.interim_results = params.interim_results;
169 config.event_listener = AsWeakPtr(); 171 config.event_listener = AsWeakPtr();
172 config.using_audio_track = params.using_audio_track;
173 // TODO(burnik): This needs to be tested on Windows.
174 config.peer_process_handle = PeerHandle();
170 175
171 int session_id = SpeechRecognitionManager::GetInstance()->CreateSession( 176 int session_id = SpeechRecognitionManager::GetInstance()->CreateSession(
172 config); 177 config);
173 DCHECK_NE(session_id, SpeechRecognitionManager::kSessionIDInvalid); 178 DCHECK_NE(session_id, SpeechRecognitionManager::kSessionIDInvalid);
174 SpeechRecognitionManager::GetInstance()->StartSession(session_id); 179 SpeechRecognitionManager::GetInstance()->StartSession(session_id);
175 } 180 }
176 181
177 void SpeechRecognitionDispatcherHost::OnAbortRequest(int render_view_id, 182 void SpeechRecognitionDispatcherHost::OnAbortRequest(int render_view_id,
178 int request_id) { 183 int request_id) {
179 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( 184 int session_id = SpeechRecognitionManager::GetInstance()->GetSession(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // The events below are currently not used by speech JS APIs implementation. 275 // The events below are currently not used by speech JS APIs implementation.
271 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id, 276 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id,
272 float volume, 277 float volume,
273 float noise_volume) { 278 float noise_volume) {
274 } 279 }
275 280
276 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete( 281 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete(
277 int session_id) { 282 int session_id) {
278 } 283 }
279 284
285 void SpeechRecognitionDispatcherHost::OnAudioReceiverReady(
286 int session_id,
287 const media::AudioParameters& params,
288 const base::SharedMemoryHandle memory,
289 const base::SyncSocket::TransitDescriptor socket) {
290 const SpeechRecognitionSessionContext& context =
291 SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id);
292 Send(new SpeechRecognitionMsg_AudioReceiverReady(context.render_view_id,
293 context.request_id,
294 params,
295 memory,
296 socket));
297 }
298
280 } // namespace content 299 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognition_dispatcher_host.h ('k') | content/browser/speech/speech_recognition_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698