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

Side by Side Diff: Source/modules/speech/SpeechRecognition.cpp

Issue 448163003: Support for providing media stream audio track to speech recognition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename methods and remove clearAudioTrack from inner layers Created 6 years, 4 months 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
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | Source/modules/speech/SpeechRecognition.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void SpeechRecognition::start(ExceptionState& exceptionState) 47 void SpeechRecognition::start(ExceptionState& exceptionState)
48 { 48 {
49 ASSERT(m_controller); 49 ASSERT(m_controller);
50 if (m_started) { 50 if (m_started) {
51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started."); 51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started.");
52 return; 52 return;
53 } 53 }
54 54
55 m_finalResults.clear(); 55 m_finalResults.clear();
56 m_controller->attach(this, m_audioTrack);
56 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR esults, m_maxAlternatives); 57 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR esults, m_maxAlternatives);
no longer working on chromium 2014/08/15 10:22:56 I am wondering if we should just pass the m_audioT
burnik 2014/08/15 11:29:41 I've gone through that approach as well, and in or
57 m_started = true; 58 m_started = true;
58 } 59 }
59 60
60 void SpeechRecognition::stopFunction() 61 void SpeechRecognition::stopFunction()
61 { 62 {
62 ASSERT(m_controller); 63 ASSERT(m_controller);
63 if (m_started && !m_stopping) { 64 if (m_started && !m_stopping) {
64 m_stopping = true; 65 m_stopping = true;
65 m_controller->stop(this); 66 m_controller->stop(this);
66 } 67 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 162 }
162 163
163 bool SpeechRecognition::hasPendingActivity() const 164 bool SpeechRecognition::hasPendingActivity() const
164 { 165 {
165 return m_started; 166 return m_started;
166 } 167 }
167 168
168 SpeechRecognition::SpeechRecognition(ExecutionContext* context) 169 SpeechRecognition::SpeechRecognition(ExecutionContext* context)
169 : ActiveDOMObject(context) 170 : ActiveDOMObject(context)
170 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute. 171 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute.
172 , m_audioTrack(nullptr)
171 , m_continuous(false) 173 , m_continuous(false)
172 , m_interimResults(false) 174 , m_interimResults(false)
173 , m_maxAlternatives(1) 175 , m_maxAlternatives(1)
174 , m_controller(nullptr) 176 , m_controller(nullptr)
175 , m_stoppedByActiveDOMObject(false) 177 , m_stoppedByActiveDOMObject(false)
176 , m_started(false) 178 , m_started(false)
177 , m_stopping(false) 179 , m_stopping(false)
178 { 180 {
179 ScriptWrappable::init(this); 181 ScriptWrappable::init(this);
180 Document* document = toDocument(executionContext()); 182 Document* document = toDocument(executionContext());
181 183
182 Page* page = document->page(); 184 Page* page = document->page();
183 ASSERT(page); 185 ASSERT(page);
184 186
185 m_controller = SpeechRecognitionController::from(page); 187 m_controller = SpeechRecognitionController::from(page);
186 ASSERT(m_controller); 188 ASSERT(m_controller);
187 189
188 // FIXME: Need to hook up with Page to get notified when the visibility chan ges. 190 // FIXME: Need to hook up with Page to get notified when the visibility chan ges.
189 } 191 }
190 192
191 SpeechRecognition::~SpeechRecognition() 193 SpeechRecognition::~SpeechRecognition()
192 { 194 {
193 } 195 }
194 196
195 void SpeechRecognition::trace(Visitor* visitor) 197 void SpeechRecognition::trace(Visitor* visitor)
196 { 198 {
197 visitor->trace(m_grammars); 199 visitor->trace(m_grammars);
200 visitor->trace(m_audioTrack);
198 #if ENABLE(OILPAN) 201 #if ENABLE(OILPAN)
199 visitor->trace(m_controller); 202 visitor->trace(m_controller);
200 #endif 203 #endif
201 visitor->trace(m_finalResults); 204 visitor->trace(m_finalResults);
202 EventTargetWithInlineData::trace(visitor); 205 EventTargetWithInlineData::trace(visitor);
203 } 206 }
204 207
205 } // namespace blink 208 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | Source/modules/speech/SpeechRecognition.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698