OLD | NEW |
---|---|
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 15 matching lines...) Expand all Loading... | |
26 #include "config.h" | 26 #include "config.h" |
27 #include "web/SpeechRecognitionClientProxy.h" | 27 #include "web/SpeechRecognitionClientProxy.h" |
28 | 28 |
29 #include "core/dom/ExecutionContext.h" | 29 #include "core/dom/ExecutionContext.h" |
30 #include "modules/speech/SpeechGrammarList.h" | 30 #include "modules/speech/SpeechGrammarList.h" |
31 #include "modules/speech/SpeechRecognition.h" | 31 #include "modules/speech/SpeechRecognition.h" |
32 #include "modules/speech/SpeechRecognitionError.h" | 32 #include "modules/speech/SpeechRecognitionError.h" |
33 #include "modules/speech/SpeechRecognitionResult.h" | 33 #include "modules/speech/SpeechRecognitionResult.h" |
34 #include "modules/speech/SpeechRecognitionResultList.h" | 34 #include "modules/speech/SpeechRecognitionResultList.h" |
35 #include "platform/weborigin/SecurityOrigin.h" | 35 #include "platform/weborigin/SecurityOrigin.h" |
36 #include "public/platform/WebMediaStreamTrack.h" | |
36 #include "public/web/WebSecurityOrigin.h" | 37 #include "public/web/WebSecurityOrigin.h" |
37 #include "public/web/WebSpeechGrammar.h" | 38 #include "public/web/WebSpeechGrammar.h" |
38 #include "public/web/WebSpeechRecognitionHandle.h" | 39 #include "public/web/WebSpeechRecognitionHandle.h" |
39 #include "public/web/WebSpeechRecognitionParams.h" | 40 #include "public/web/WebSpeechRecognitionParams.h" |
40 #include "public/web/WebSpeechRecognitionResult.h" | 41 #include "public/web/WebSpeechRecognitionResult.h" |
41 #include "public/web/WebSpeechRecognizer.h" | 42 #include "public/web/WebSpeechRecognizer.h" |
42 #include "wtf/PassRefPtr.h" | 43 #include "wtf/PassRefPtr.h" |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 | 46 |
46 SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() | 47 SpeechRecognitionClientProxy::~SpeechRecognitionClientProxy() |
47 { | 48 { |
48 } | 49 } |
49 | 50 |
50 PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We bSpeechRecognizer* recognizer) | 51 PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We bSpeechRecognizer* recognizer) |
51 { | 52 { |
52 return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); | 53 return adoptPtr(new SpeechRecognitionClientProxy(recognizer)); |
53 } | 54 } |
54 | 55 |
55 void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S peechGrammarList* grammarList, const String& lang, bool continuous, bool interim Results, unsigned long maxAlternatives) | 56 void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const S peechGrammarList* grammarList, const String& lang, bool continuous, bool interim Results, unsigned long maxAlternatives, MediaStreamTrack* audioTrack) |
56 { | 57 { |
57 WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarLis t->length())); | 58 WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarLis t->length())); |
58 for (unsigned long i = 0; i < grammarList->length(); ++i) | 59 for (unsigned long i = 0; i < grammarList->length(); ++i) |
59 webSpeechGrammars[i] = grammarList->item(i); | 60 webSpeechGrammars[i] = grammarList->item(i); |
60 | 61 |
61 WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, inter imResults, maxAlternatives, WebSecurityOrigin(recognition->executionContext()->s ecurityOrigin())); | 62 WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, inter imResults, maxAlternatives, WebSecurityOrigin(recognition->executionContext()->s ecurityOrigin())); |
62 m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, this); | 63 if (audioTrack) |
64 m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, aud ioTrack->component(), this); | |
Mike West
2014/09/17 10:20:27
Could the new MediaStreamComponent argument instea
burnik
2014/09/17 11:17:20
Good point as well. Although that would require mo
Mike West
2014/09/17 11:30:46
Sure. But I think it reduces the complexity of the
| |
65 else | |
66 m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, thi s); | |
63 } | 67 } |
64 | 68 |
65 void SpeechRecognitionClientProxy::stop(SpeechRecognition* recognition) | 69 void SpeechRecognitionClientProxy::stop(SpeechRecognition* recognition) |
66 { | 70 { |
67 m_recognizer->stop(WebSpeechRecognitionHandle(recognition), this); | 71 m_recognizer->stop(WebSpeechRecognitionHandle(recognition), this); |
68 } | 72 } |
69 | 73 |
70 void SpeechRecognitionClientProxy::abort(SpeechRecognition* recognition) | 74 void SpeechRecognitionClientProxy::abort(SpeechRecognition* recognition) |
71 { | 75 { |
72 m_recognizer->abort(WebSpeechRecognitionHandle(recognition), this); | 76 m_recognizer->abort(WebSpeechRecognitionHandle(recognition), this); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 SpeechRecognition* recognition(handle); | 141 SpeechRecognition* recognition(handle); |
138 recognition->didEnd(); | 142 recognition->didEnd(); |
139 } | 143 } |
140 | 144 |
141 SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer* recognizer) | 145 SpeechRecognitionClientProxy::SpeechRecognitionClientProxy(WebSpeechRecognizer* recognizer) |
142 : m_recognizer(recognizer) | 146 : m_recognizer(recognizer) |
143 { | 147 { |
144 } | 148 } |
145 | 149 |
146 } // namespace blink | 150 } // namespace blink |
OLD | NEW |