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 "content/renderer/media/webrtc_audio_device_impl.h" | 10 #include "content/renderer/media/webrtc_audio_device_impl.h" |
11 #include "media/base/audio_decoder.h" | 11 #include "media/base/audio_decoder.h" |
12 #include "media/base/audio_renderer_sink.h" | 12 #include "media/base/audio_renderer_sink.h" |
13 #include "webkit/media/media_stream_audio_renderer.h" | 13 #include "webkit/media/media_stream_audio_renderer.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class RendererAudioOutputDevice; | |
17 class WebRtcAudioRendererSource; | 18 class WebRtcAudioRendererSource; |
18 | 19 |
19 // This renderer handles calls from the pipeline and WebRtc ADM. It is used | 20 // This renderer handles calls from the pipeline and WebRtc ADM. It is used |
20 // for connecting WebRtc MediaStream with pipeline. | 21 // for connecting WebRtc MediaStream with pipeline. |
21 class CONTENT_EXPORT WebRtcAudioRenderer | 22 class CONTENT_EXPORT WebRtcAudioRenderer |
22 : NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), | 23 : NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), |
23 NON_EXPORTED_BASE(public webkit_media::MediaStreamAudioRenderer) { | 24 NON_EXPORTED_BASE(public webkit_media::MediaStreamAudioRenderer) { |
24 public: | 25 public: |
25 WebRtcAudioRenderer(); | 26 explicit WebRtcAudioRenderer(int source_render_view_id); |
26 | 27 |
27 // Initialize function called by clients like WebRtcAudioDeviceImpl. Note, | 28 // Initialize function called by clients like WebRtcAudioDeviceImpl. Note, |
28 // Stop() has to be called before |source| is deleted. | 29 // Stop() has to be called before |source| is deleted. |
29 // Returns false if Initialize() fails. | 30 // Returns false if Initialize() fails. |
30 bool Initialize(WebRtcAudioRendererSource* source); | 31 bool Initialize(WebRtcAudioRendererSource* source); |
31 | 32 |
32 // Methods called by WebMediaPlayerMS and WebRtcAudioDeviceImpl. | 33 // Methods called by WebMediaPlayerMS and WebRtcAudioDeviceImpl. |
33 // MediaStreamAudioRenderer implementation. | 34 // MediaStreamAudioRenderer implementation. |
34 virtual void Play() OVERRIDE; | 35 virtual void Play() OVERRIDE; |
35 virtual void Pause() OVERRIDE; | 36 virtual void Pause() OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... | |
46 PAUSED, | 47 PAUSED, |
47 }; | 48 }; |
48 // Flag to keep track the state of the renderer. | 49 // Flag to keep track the state of the renderer. |
49 State state_; | 50 State state_; |
50 | 51 |
51 // media::AudioRendererSink::RenderCallback implementation. | 52 // media::AudioRendererSink::RenderCallback implementation. |
52 virtual int Render(media::AudioBus* audio_bus, | 53 virtual int Render(media::AudioBus* audio_bus, |
53 int audio_delay_milliseconds) OVERRIDE; | 54 int audio_delay_milliseconds) OVERRIDE; |
54 virtual void OnRenderError() OVERRIDE; | 55 virtual void OnRenderError() OVERRIDE; |
55 | 56 |
57 // The render view in which the audio is rendered into |sink_|. | |
58 const int source_render_view_id_; | |
59 | |
56 // The sink (destination) for rendered audio. | 60 // The sink (destination) for rendered audio. |
57 scoped_refptr<media::AudioRendererSink> sink_; | 61 scoped_refptr<RendererAudioOutputDevice> sink_; |
58 | 62 |
59 // Audio data source from the browser process. | 63 // Audio data source from the browser process. |
60 WebRtcAudioRendererSource* source_; | 64 WebRtcAudioRendererSource* source_; |
61 | 65 |
62 // Cached values of utilized audio parameters. Platform dependent. | 66 // Cached values of utilized audio parameters. Platform dependent. |
63 media::AudioParameters params_; | 67 media::AudioParameters params_; |
64 | 68 |
65 // Buffers used for temporary storage during render callbacks. | 69 // Buffers used for temporary storage during render callbacks. |
66 // Allocated during initialization. | 70 // Allocated during initialization. |
67 scoped_array<int16> buffer_; | 71 scoped_array<int16> buffer_; |
68 | 72 |
69 // Protect access to |state_|. | 73 // Protect access to |state_|. |
70 base::Lock lock_; | 74 base::Lock lock_; |
71 | 75 |
72 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioRenderer); | 76 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioRenderer); |
scherkus (not reviewing)
2012/11/30 22:09:43
ditto
miu
2012/12/01 00:40:17
Done.
| |
73 }; | 77 }; |
74 | 78 |
75 } // namespace content | 79 } // namespace content |
76 | 80 |
77 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 81 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
OLD | NEW |