| 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().getType() != blink::WebMediaStreamSource::TypeAudio) |
| 65 return false; |
| 66 |
| 64 MediaStreamAudioSource* native_source = | 67 MediaStreamAudioSource* native_source = |
| 65 MediaStreamAudioSource::From(track.source()); | 68 static_cast<MediaStreamAudioSource*>(track.source().getExtraData()); |
| 66 if (!native_source) | 69 if (!native_source) |
| 67 return false; | 70 return false; |
| 68 | 71 |
| 69 const StreamDeviceInfo& device_info = native_source->device_info(); | 72 const StreamDeviceInfo& device_info = native_source->device_info(); |
| 70 // Purposely only support tracks from an audio device. Dissallow WebAudio. | 73 // Purposely only support tracks from an audio device. Dissallow WebAudio. |
| 71 return (device_info.device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE); | 74 return (device_info.device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| 72 } | 75 } |
| 73 | 76 |
| 74 void SpeechRecognitionAudioSink::OnSetFormat( | 77 void SpeechRecognitionAudioSink::OnSetFormat( |
| 75 const media::AudioParameters& input_params) { | 78 const media::AudioParameters& input_params) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 177 } |
| 175 | 178 |
| 176 media::AudioInputBuffer* | 179 media::AudioInputBuffer* |
| 177 SpeechRecognitionAudioSink::GetAudioInputBuffer() const { | 180 SpeechRecognitionAudioSink::GetAudioInputBuffer() const { |
| 178 DCHECK(capture_thread_checker_.CalledOnValidThread()); | 181 DCHECK(capture_thread_checker_.CalledOnValidThread()); |
| 179 DCHECK(shared_memory_.memory()); | 182 DCHECK(shared_memory_.memory()); |
| 180 return static_cast<media::AudioInputBuffer*>(shared_memory_.memory()); | 183 return static_cast<media::AudioInputBuffer*>(shared_memory_.memory()); |
| 181 } | 184 } |
| 182 | 185 |
| 183 } // namespace content | 186 } // namespace content |
| OLD | NEW |