Chromium Code Reviews| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 // is "playing", Pause() won't be called when the state already is "paused" | 46 // is "playing", Pause() won't be called when the state already is "paused" |
| 47 // etc and similarly maintains the same state for Stop(). | 47 // etc and similarly maintains the same state for Stop(). |
| 48 // When Stop() is called or when the proxy goes out of scope, the proxy | 48 // When Stop() is called or when the proxy goes out of scope, the proxy |
| 49 // will ensure that Pause() is called followed by a call to Stop(), which | 49 // will ensure that Pause() is called followed by a call to Stop(), which |
| 50 // is the usage pattern that WebRtcAudioRenderer requires. | 50 // is the usage pattern that WebRtcAudioRenderer requires. |
| 51 scoped_refptr<MediaStreamAudioRenderer> CreateSharedAudioRendererProxy(); | 51 scoped_refptr<MediaStreamAudioRenderer> CreateSharedAudioRendererProxy(); |
| 52 | 52 |
| 53 // Used to DCHECK on the expected state. | 53 // Used to DCHECK on the expected state. |
| 54 bool IsStarted() const; | 54 bool IsStarted() const; |
| 55 | 55 |
| 56 // Accessors to the sink audio parameters. | |
| 57 int channels() const { return number_of_channels_; } | |
| 58 int sample_rate() const { return sample_rate_; } | |
| 59 | |
| 56 private: | 60 private: |
| 57 // MediaStreamAudioRenderer implementation. This is private since we want | 61 // MediaStreamAudioRenderer implementation. This is private since we want |
| 58 // callers to use proxy objects. | 62 // callers to use proxy objects. |
| 59 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? | 63 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? |
| 60 virtual void Start() OVERRIDE; | 64 virtual void Start() OVERRIDE; |
| 61 virtual void Play() OVERRIDE; | 65 virtual void Play() OVERRIDE; |
| 62 virtual void Pause() OVERRIDE; | 66 virtual void Pause() OVERRIDE; |
| 63 virtual void Stop() OVERRIDE; | 67 virtual void Stop() OVERRIDE; |
| 64 virtual void SetVolume(float volume) OVERRIDE; | 68 virtual void SetVolume(float volume) OVERRIDE; |
| 65 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; | 69 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 95 const int source_render_view_id_; | 99 const int source_render_view_id_; |
| 96 const int source_render_frame_id_; | 100 const int source_render_frame_id_; |
| 97 const int session_id_; | 101 const int session_id_; |
| 98 | 102 |
| 99 // The sink (destination) for rendered audio. | 103 // The sink (destination) for rendered audio. |
| 100 scoped_refptr<media::AudioOutputDevice> sink_; | 104 scoped_refptr<media::AudioOutputDevice> sink_; |
| 101 | 105 |
| 102 // Audio data source from the browser process. | 106 // Audio data source from the browser process. |
| 103 WebRtcAudioRendererSource* source_; | 107 WebRtcAudioRendererSource* source_; |
| 104 | 108 |
| 105 // Buffers used for temporary storage during render callbacks. | |
| 106 // Allocated during initialization. | |
| 107 scoped_ptr<int16[]> buffer_; | |
| 108 | |
| 109 // Protects access to |state_|, |source_| and |sink_|. | 109 // Protects access to |state_|, |source_| and |sink_|. |
| 110 base::Lock lock_; | 110 base::Lock lock_; |
| 111 | 111 |
| 112 // Ref count for the MediaPlayers which are playing audio. | 112 // Ref count for the MediaPlayers which are playing audio. |
| 113 int play_ref_count_; | 113 int play_ref_count_; |
| 114 | 114 |
| 115 // Ref count for the MediaPlayers which have called Start() but not Stop(). | 115 // Ref count for the MediaPlayers which have called Start() but not Stop(). |
| 116 int start_ref_count_; | 116 int start_ref_count_; |
| 117 | 117 |
| 118 // Used to buffer data between the client and the output device in cases where | 118 // Used to buffer data between the client and the output device in cases where |
| 119 // the client buffer size is not the same as the output device buffer size. | 119 // the client buffer size is not the same as the output device buffer size. |
| 120 scoped_ptr<media::AudioPullFifo> audio_fifo_; | 120 scoped_ptr<media::AudioPullFifo> audio_fifo_; |
| 121 | 121 |
| 122 // Contains the accumulated delay estimate which is provided to the WebRTC | 122 // Contains the accumulated delay estimate which is provided to the WebRTC |
| 123 // AEC. | 123 // AEC. |
| 124 int audio_delay_milliseconds_; | 124 int audio_delay_milliseconds_; |
| 125 | 125 |
| 126 // Delay due to the FIFO in milliseconds. | 126 // Delay due to the FIFO in milliseconds. |
| 127 int fifo_delay_milliseconds_; | 127 int fifo_delay_milliseconds_; |
| 128 | 128 |
| 129 // The preferred sample rate and buffer sizes provided via the ctor. | 129 // The sample rate, number of channels and buffer sizes used by the sink of |
| 130 const int sample_rate_; | 130 // the renderer. |
|
tommi (sloooow) - chröme
2014/01/31 13:58:32
now that these are no longer const, can you docume
no longer working on chromium
2014/02/02 16:50:16
Added a comment to explain they are modified only
| |
| 131 const int frames_per_buffer_; | 131 int sample_rate_; |
| 132 int number_of_channels_; | |
| 133 int frames_per_buffer_; | |
| 132 | 134 |
| 133 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); | 135 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 } // namespace content | 138 } // namespace content |
| 137 | 139 |
| 138 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 140 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
| OLD | NEW |