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 #ifndef CONTENT_RENDERER_MEDIA_SPEECH_RECOGNITION_AUDIO_SINK_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_SPEECH_RECOGNITION_AUDIO_SINK_H_ |
6 #define CONTENT_RENDERER_MEDIA_SPEECH_RECOGNITION_AUDIO_SINK_H_ | 6 #define CONTENT_RENDERER_MEDIA_SPEECH_RECOGNITION_AUDIO_SINK_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 public: | 35 public: |
36 typedef base::Callback<void()> OnStoppedCB; | 36 typedef base::Callback<void()> OnStoppedCB; |
37 | 37 |
38 // Socket ownership is transferred to the class via constructor. | 38 // Socket ownership is transferred to the class via constructor. |
39 SpeechRecognitionAudioSink(const blink::WebMediaStreamTrack& track, | 39 SpeechRecognitionAudioSink(const blink::WebMediaStreamTrack& track, |
40 const media::AudioParameters& params, | 40 const media::AudioParameters& params, |
41 const base::SharedMemoryHandle memory, | 41 const base::SharedMemoryHandle memory, |
42 scoped_ptr<base::SyncSocket> socket, | 42 scoped_ptr<base::SyncSocket> socket, |
43 const OnStoppedCB& on_stopped_cb); | 43 const OnStoppedCB& on_stopped_cb); |
44 | 44 |
45 virtual ~SpeechRecognitionAudioSink(); | 45 ~SpeechRecognitionAudioSink() override; |
46 | 46 |
47 // Returns whether the provided track is supported. | 47 // Returns whether the provided track is supported. |
48 static bool IsSupportedTrack(const blink::WebMediaStreamTrack& track); | 48 static bool IsSupportedTrack(const blink::WebMediaStreamTrack& track); |
49 | 49 |
50 private: | 50 private: |
51 // content::MediaStreamAudioSink implementation. | 51 // content::MediaStreamAudioSink implementation. |
52 virtual void OnReadyStateChanged( | 52 void OnReadyStateChanged( |
53 blink::WebMediaStreamSource::ReadyState state) override; | 53 blink::WebMediaStreamSource::ReadyState state) override; |
54 | 54 |
55 virtual void OnData(const int16* audio_data, int sample_rate, | 55 void OnData(const int16* audio_data, |
56 int number_of_channels, int number_of_frames) override; | 56 int sample_rate, |
57 virtual void OnSetFormat(const media::AudioParameters& params) override; | 57 int number_of_channels, |
| 58 int number_of_frames) override; |
| 59 void OnSetFormat(const media::AudioParameters& params) override; |
58 | 60 |
59 // media::AudioConverter::Inputcallback implementation. | 61 // media::AudioConverter::Inputcallback implementation. |
60 virtual double ProvideInput(media::AudioBus* audio_bus, | 62 double ProvideInput(media::AudioBus* audio_bus, |
61 base::TimeDelta buffer_delay) override; | 63 base::TimeDelta buffer_delay) override; |
62 | 64 |
63 // Returns the pointer to the audio input buffer mapped in the shared memory. | 65 // Returns the pointer to the audio input buffer mapped in the shared memory. |
64 media::AudioInputBuffer* GetAudioInputBuffer() const; | 66 media::AudioInputBuffer* GetAudioInputBuffer() const; |
65 | 67 |
66 // Number of frames per buffer in FIFO. When the buffer is full we convert and | 68 // Number of frames per buffer in FIFO. When the buffer is full we convert and |
67 // consume it on the |output_bus_|. Size of the buffer depends on the | 69 // consume it on the |output_bus_|. Size of the buffer depends on the |
68 // resampler. Example: for 44.1 to 16.0 conversion, it should be 4100 frames. | 70 // resampler. Example: for 44.1 to 16.0 conversion, it should be 4100 frames. |
69 int fifo_buffer_size_; | 71 int fifo_buffer_size_; |
70 | 72 |
71 // Used to DCHECK that some methods are called on the main render thread. | 73 // Used to DCHECK that some methods are called on the main render thread. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 112 |
111 // Callback for the renderer client. Called when the audio track was stopped. | 113 // Callback for the renderer client. Called when the audio track was stopped. |
112 const OnStoppedCB on_stopped_cb_; | 114 const OnStoppedCB on_stopped_cb_; |
113 | 115 |
114 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionAudioSink); | 116 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionAudioSink); |
115 }; | 117 }; |
116 | 118 |
117 } // namespace content | 119 } // namespace content |
118 | 120 |
119 #endif // CONTENT_RENDERER_MEDIA_SPEECH_RECOGNITION_AUDIO_SINK_H_ | 121 #endif // CONTENT_RENDERER_MEDIA_SPEECH_RECOGNITION_AUDIO_SINK_H_ |
OLD | NEW |