OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEBRTC_AUDIO_RENDERER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 const blink::WebMediaStream& media_stream); | 102 const blink::WebMediaStream& media_stream); |
103 | 103 |
104 // Used to DCHECK on the expected state. | 104 // Used to DCHECK on the expected state. |
105 bool IsStarted() const; | 105 bool IsStarted() const; |
106 | 106 |
107 // Accessors to the sink audio parameters. | 107 // Accessors to the sink audio parameters. |
108 int channels() const { return sink_params_.channels(); } | 108 int channels() const { return sink_params_.channels(); } |
109 int sample_rate() const { return sink_params_.sample_rate(); } | 109 int sample_rate() const { return sink_params_.sample_rate(); } |
110 int frames_per_buffer() const { return sink_params_.frames_per_buffer(); } | 110 int frames_per_buffer() const { return sink_params_.frames_per_buffer(); } |
111 | 111 |
| 112 // Returns true if called on rendering thread, otherwise false. |
| 113 bool CurrentThreadIsRenderingThread(); |
| 114 |
112 private: | 115 private: |
113 // MediaStreamAudioRenderer implementation. This is private since we want | 116 // MediaStreamAudioRenderer implementation. This is private since we want |
114 // callers to use proxy objects. | 117 // callers to use proxy objects. |
115 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? | 118 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? |
116 void Start() override; | 119 void Start() override; |
117 void Play() override; | 120 void Play() override; |
118 void Pause() override; | 121 void Pause() override; |
119 void Stop() override; | 122 void Stop() override; |
120 void SetVolume(float volume) override; | 123 void SetVolume(float volume) override; |
121 media::OutputDeviceInfo GetOutputDeviceInfo() override; | 124 media::OutputDeviceInfo GetOutputDeviceInfo() override; |
(...skipping 26 matching lines...) Expand all Loading... |
148 // Holds raw pointers to PlaingState objects. Ownership is managed outside | 151 // Holds raw pointers to PlaingState objects. Ownership is managed outside |
149 // of this type. | 152 // of this type. |
150 typedef std::vector<PlayingState*> PlayingStates; | 153 typedef std::vector<PlayingState*> PlayingStates; |
151 // Maps an audio source to a list of playing states that collectively hold | 154 // Maps an audio source to a list of playing states that collectively hold |
152 // volume information for that source. | 155 // volume information for that source. |
153 typedef std::map<webrtc::AudioSourceInterface*, PlayingStates> | 156 typedef std::map<webrtc::AudioSourceInterface*, PlayingStates> |
154 SourcePlayingStates; | 157 SourcePlayingStates; |
155 | 158 |
156 // Used to DCHECK that we are called on the correct thread. | 159 // Used to DCHECK that we are called on the correct thread. |
157 base::ThreadChecker thread_checker_; | 160 base::ThreadChecker thread_checker_; |
158 base::ThreadChecker audio_renderer_thread_checker_; | |
159 | 161 |
160 // Flag to keep track the state of the renderer. | 162 // Flag to keep track the state of the renderer. |
161 State state_; | 163 State state_; |
162 | 164 |
163 // media::AudioRendererSink::RenderCallback implementation. | 165 // media::AudioRendererSink::RenderCallback implementation. |
164 // These two methods are called on the AudioOutputDevice worker thread. | 166 // These two methods are called on the AudioOutputDevice worker thread. |
165 int Render(media::AudioBus* audio_bus, | 167 int Render(media::AudioBus* audio_bus, |
166 uint32_t frames_delayed, | 168 uint32_t frames_delayed, |
167 uint32_t frames_skipped) override; | 169 uint32_t frames_skipped) override; |
168 void OnRenderError() override; | 170 void OnRenderError() override; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Used for triggering new UMA histogram. Counts number of render | 257 // Used for triggering new UMA histogram. Counts number of render |
256 // callbacks modulo |kNumCallbacksBetweenRenderTimeHistograms|. | 258 // callbacks modulo |kNumCallbacksBetweenRenderTimeHistograms|. |
257 int render_callback_count_; | 259 int render_callback_count_; |
258 | 260 |
259 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); | 261 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); |
260 }; | 262 }; |
261 | 263 |
262 } // namespace content | 264 } // namespace content |
263 | 265 |
264 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 266 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
OLD | NEW |