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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 audio_converter_->RemoveInput(this); | 54 audio_converter_->RemoveInput(this); |
55 | 55 |
56 // Notify the track before this sink goes away. | 56 // Notify the track before this sink goes away. |
57 if (!track_stopped_) | 57 if (!track_stopped_) |
58 MediaStreamAudioSink::RemoveFromAudioTrack(this, track_); | 58 MediaStreamAudioSink::RemoveFromAudioTrack(this, track_); |
59 } | 59 } |
60 | 60 |
61 // static | 61 // static |
62 bool SpeechRecognitionAudioSink::IsSupportedTrack( | 62 bool SpeechRecognitionAudioSink::IsSupportedTrack( |
63 const blink::WebMediaStreamTrack& track) { | 63 const blink::WebMediaStreamTrack& track) { |
64 if (track.source().type() != blink::WebMediaStreamSource::TypeAudio) | |
65 return false; | |
66 | |
67 MediaStreamAudioSource* native_source = | 64 MediaStreamAudioSource* native_source = |
68 static_cast<MediaStreamAudioSource*>(track.source().extraData()); | 65 MediaStreamAudioSource::From(track.source()); |
69 if (!native_source) | 66 if (!native_source) |
70 return false; | 67 return false; |
71 | 68 |
72 const StreamDeviceInfo& device_info = native_source->device_info(); | 69 const StreamDeviceInfo& device_info = native_source->device_info(); |
73 // Purposely only support tracks from an audio device. Dissallow WebAudio. | 70 // Purposely only support tracks from an audio device. Dissallow WebAudio. |
74 return (device_info.device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE); | 71 return (device_info.device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE); |
75 } | 72 } |
76 | 73 |
77 void SpeechRecognitionAudioSink::OnSetFormat( | 74 void SpeechRecognitionAudioSink::OnSetFormat( |
78 const media::AudioParameters& input_params) { | 75 const media::AudioParameters& input_params) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 174 } |
178 | 175 |
179 media::AudioInputBuffer* | 176 media::AudioInputBuffer* |
180 SpeechRecognitionAudioSink::GetAudioInputBuffer() const { | 177 SpeechRecognitionAudioSink::GetAudioInputBuffer() const { |
181 DCHECK(capture_thread_checker_.CalledOnValidThread()); | 178 DCHECK(capture_thread_checker_.CalledOnValidThread()); |
182 DCHECK(shared_memory_.memory()); | 179 DCHECK(shared_memory_.memory()); |
183 return static_cast<media::AudioInputBuffer*>(shared_memory_.memory()); | 180 return static_cast<media::AudioInputBuffer*>(shared_memory_.memory()); |
184 } | 181 } |
185 | 182 |
186 } // namespace content | 183 } // namespace content |
OLD | NEW |