| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/renderer/media/media_stream_audio_renderer.h" |
| 13 #include "content/renderer/media/webrtc_audio_device_impl.h" | 14 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 14 #include "content/renderer/media/webrtc_local_audio_track.h" | 15 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 15 #include "webkit/renderer/media/media_stream_audio_renderer.h" | |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 class AudioBus; | 18 class AudioBus; |
| 19 class AudioFifo; | 19 class AudioFifo; |
| 20 class AudioOutputDevice; | 20 class AudioOutputDevice; |
| 21 class AudioParameters; | 21 class AudioParameters; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class WebRtcAudioCapturer; | 26 class WebRtcAudioCapturer; |
| 27 | 27 |
| 28 // WebRtcLocalAudioRenderer is a webkit_media::MediaStreamAudioRenderer | 28 // WebRtcLocalAudioRenderer is a MediaStreamAudioRenderer designed for rendering |
| 29 // designed for rendering local audio media stream tracks, | 29 // local audio media stream tracks, |
| 30 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamtrack | 30 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamtrack |
| 31 // It also implements media::AudioRendererSink::RenderCallback to render audio | 31 // It also implements media::AudioRendererSink::RenderCallback to render audio |
| 32 // data provided from a WebRtcLocalAudioTrack source. | 32 // data provided from a WebRtcLocalAudioTrack source. |
| 33 // When the audio layer in the browser process asks for data to render, this | 33 // When the audio layer in the browser process asks for data to render, this |
| 34 // class provides the data by implementing the WebRtcAudioCapturerSink | 34 // class provides the data by implementing the WebRtcAudioCapturerSink |
| 35 // interface, i.e., we are a sink seen from the WebRtcAudioCapturer perspective. | 35 // interface, i.e., we are a sink seen from the WebRtcAudioCapturer perspective. |
| 36 // TODO(henrika): improve by using similar principles as in RTCVideoRenderer | 36 // TODO(henrika): improve by using similar principles as in RTCVideoRenderer |
| 37 // which register itself to the video track when the provider is started and | 37 // which register itself to the video track when the provider is started and |
| 38 // deregisters itself when it is stopped. | 38 // deregisters itself when it is stopped. |
| 39 // Tracking this at http://crbug.com/164813. | 39 // Tracking this at http://crbug.com/164813. |
| 40 class CONTENT_EXPORT WebRtcLocalAudioRenderer | 40 class CONTENT_EXPORT WebRtcLocalAudioRenderer |
| 41 : NON_EXPORTED_BASE(public webkit_media::MediaStreamAudioRenderer), | 41 : NON_EXPORTED_BASE(public MediaStreamAudioRenderer), |
| 42 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), | 42 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), |
| 43 NON_EXPORTED_BASE(public WebRtcAudioCapturerSink) { | 43 NON_EXPORTED_BASE(public WebRtcAudioCapturerSink) { |
| 44 public: | 44 public: |
| 45 // Creates a local renderer and registers a capturing |source| object. | 45 // Creates a local renderer and registers a capturing |source| object. |
| 46 // The |source| is owned by the WebRtcAudioDeviceImpl. | 46 // The |source| is owned by the WebRtcAudioDeviceImpl. |
| 47 // Called on the main thread. | 47 // Called on the main thread. |
| 48 WebRtcLocalAudioRenderer(WebRtcLocalAudioTrack* audio_track, | 48 WebRtcLocalAudioRenderer(WebRtcLocalAudioTrack* audio_track, |
| 49 int source_render_view_id); | 49 int source_render_view_id); |
| 50 | 50 |
| 51 // webkit_media::MediaStreamAudioRenderer implementation. | 51 // MediaStreamAudioRenderer implementation. |
| 52 // Called on the main thread. | 52 // Called on the main thread. |
| 53 virtual void Start() OVERRIDE; | 53 virtual void Start() OVERRIDE; |
| 54 virtual void Stop() OVERRIDE; | 54 virtual void Stop() OVERRIDE; |
| 55 virtual void Play() OVERRIDE; | 55 virtual void Play() OVERRIDE; |
| 56 virtual void Pause() OVERRIDE; | 56 virtual void Pause() OVERRIDE; |
| 57 virtual void SetVolume(float volume) OVERRIDE; | 57 virtual void SetVolume(float volume) OVERRIDE; |
| 58 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; | 58 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; |
| 59 virtual bool IsLocalRenderer() const OVERRIDE; | 59 virtual bool IsLocalRenderer() const OVERRIDE; |
| 60 | 60 |
| 61 const base::TimeDelta& total_render_time() const { | 61 const base::TimeDelta& total_render_time() const { |
| 62 return total_render_time_; | 62 return total_render_time_; |
| 63 } | 63 } |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 virtual ~WebRtcLocalAudioRenderer(); | 66 virtual ~WebRtcLocalAudioRenderer(); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 // content::WebRtcAudioCapturerSink implementation. | 69 // WebRtcAudioCapturerSink implementation. |
| 70 | 70 |
| 71 // Called on the AudioInputDevice worker thread. | 71 // Called on the AudioInputDevice worker thread. |
| 72 virtual void CaptureData(const int16* audio_data, | 72 virtual void CaptureData(const int16* audio_data, |
| 73 int number_of_channels, | 73 int number_of_channels, |
| 74 int number_of_frames, | 74 int number_of_frames, |
| 75 int audio_delay_milliseconds, | 75 int audio_delay_milliseconds, |
| 76 double volume) OVERRIDE; | 76 double volume) OVERRIDE; |
| 77 | 77 |
| 78 // Can be called on different user thread. | 78 // Can be called on different user thread. |
| 79 virtual void SetCaptureFormat(const media::AudioParameters& params) OVERRIDE; | 79 virtual void SetCaptureFormat(const media::AudioParameters& params) OVERRIDE; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 // Protects |loopback_fifo_|, |playing_| and |sink_|. | 122 // Protects |loopback_fifo_|, |playing_| and |sink_|. |
| 123 mutable base::Lock thread_lock_; | 123 mutable base::Lock thread_lock_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioRenderer); | 125 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioRenderer); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace content | 128 } // namespace content |
| 129 | 129 |
| 130 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ | 130 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_RENDERER_H_ |
| OLD | NEW |