| 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_LOCAL_AUDIO_RENDERER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/renderer/media_stream_audio_sink.h" | 16 #include "content/public/renderer/media_stream_audio_sink.h" |
| 17 #include "content/renderer/media/media_stream_audio_renderer.h" | 17 #include "content/renderer/media/media_stream_audio_renderer.h" |
| 18 #include "content/renderer/media/webrtc_audio_device_impl.h" | 18 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 19 #include "content/renderer/media/webrtc_local_audio_track.h" | 19 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 20 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 20 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 21 | 21 |
| 22 namespace media { | 22 namespace media { |
| 23 class AudioBus; | 23 class AudioBus; |
| 24 class AudioFifo; | 24 class AudioShifter; |
| 25 class AudioOutputDevice; | 25 class AudioOutputDevice; |
| 26 class AudioParameters; | 26 class AudioParameters; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 class WebRtcAudioCapturer; | 31 class WebRtcAudioCapturer; |
| 32 | 32 |
| 33 // WebRtcLocalAudioRenderer is a MediaStreamAudioRenderer designed for rendering | 33 // WebRtcLocalAudioRenderer is a MediaStreamAudioRenderer designed for rendering |
| 34 // local audio media stream tracks, | 34 // local audio media stream tracks, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const int source_render_frame_id_; | 113 const int source_render_frame_id_; |
| 114 const int session_id_; | 114 const int session_id_; |
| 115 | 115 |
| 116 // MessageLoop associated with the single thread that performs all control | 116 // MessageLoop associated with the single thread that performs all control |
| 117 // tasks. Set to the MessageLoop that invoked the ctor. | 117 // tasks. Set to the MessageLoop that invoked the ctor. |
| 118 const scoped_refptr<base::MessageLoopProxy> message_loop_; | 118 const scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 119 | 119 |
| 120 // The sink (destination) for rendered audio. | 120 // The sink (destination) for rendered audio. |
| 121 scoped_refptr<media::AudioOutputDevice> sink_; | 121 scoped_refptr<media::AudioOutputDevice> sink_; |
| 122 | 122 |
| 123 // Contains copies of captured audio frames. | 123 // This does all the synchronization/resampling/smoothing. |
| 124 scoped_ptr<media::AudioFifo> loopback_fifo_; | 124 scoped_ptr<media::AudioShifter> audio_shifter_; |
| 125 | 125 |
| 126 // Stores last time a render callback was received. The time difference | 126 // Stores last time a render callback was received. The time difference |
| 127 // between a new time stamp and this value can be used to derive the | 127 // between a new time stamp and this value can be used to derive the |
| 128 // total render time. | 128 // total render time. |
| 129 base::TimeTicks last_render_time_; | 129 base::TimeTicks last_render_time_; |
| 130 | 130 |
| 131 // Keeps track of total time audio has been rendered. | 131 // Keeps track of total time audio has been rendered. |
| 132 base::TimeDelta total_render_time_; | 132 base::TimeDelta total_render_time_; |
| 133 | 133 |
| 134 // The audio parameters of the capture source. | 134 // The audio parameters of the capture source. |
| 135 // Must only be touched on the main thread. | 135 // Must only be touched on the main thread. |
| 136 media::AudioParameters source_params_; | 136 media::AudioParameters source_params_; |
| 137 | 137 |
| 138 // The audio parameters used by the sink. | 138 // The audio parameters used by the sink. |
| 139 // Must only be touched on the main thread. | 139 // Must only be touched on the main thread. |
| 140 media::AudioParameters sink_params_; | 140 media::AudioParameters sink_params_; |
| 141 | 141 |
| 142 // Set when playing, cleared when paused. | 142 // Set when playing, cleared when paused. |
| 143 bool playing_; | 143 bool playing_; |
| 144 | 144 |
| 145 // Protects |loopback_fifo_|, |playing_| and |sink_|. | 145 // Protects |audio_shifter_|, |playing_| and |sink_|. |
| 146 mutable base::Lock thread_lock_; | 146 mutable base::Lock thread_lock_; |
| 147 | 147 |
| 148 // The preferred buffer size provided via the ctor. | 148 // The preferred buffer size provided via the ctor. |
| 149 const int frames_per_buffer_; | 149 const int frames_per_buffer_; |
| 150 | 150 |
| 151 // The preferred device id of the output device or empty for the default | 151 // The preferred device id of the output device or empty for the default |
| 152 // output device. | 152 // output device. |
| 153 const std::string output_device_id_; | 153 const std::string output_device_id_; |
| 154 | 154 |
| 155 // Cache value for the volume. | 155 // Cache value for the volume. |
| 156 float volume_; | 156 float volume_; |
| 157 | 157 |
| 158 // Flag to indicate whether |sink_| has been started yet. | 158 // Flag to indicate whether |sink_| has been started yet. |
| 159 bool sink_started_; | 159 bool sink_started_; |
| 160 | 160 |
| 161 // Used to DCHECK that some methods are called on the capture audio thread. | 161 // Used to DCHECK that some methods are called on the capture audio thread. |
| 162 base::ThreadChecker capture_thread_checker_; | 162 base::ThreadChecker capture_thread_checker_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioRenderer); | 164 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioRenderer); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 } // namespace content | 167 } // namespace content |
| 168 | 168 |
| 169 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ | 169 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ |
| OLD | NEW |