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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "content/public/renderer/media_stream_audio_renderer.h" | 19 #include "content/public/renderer/media_stream_audio_renderer.h" |
20 #include "content/renderer/media/webrtc_audio_device_impl.h" | 20 #include "content/renderer/media/webrtc_audio_device_impl.h" |
21 #include "media/base/audio_decoder.h" | 21 #include "media/base/audio_decoder.h" |
22 #include "media/base/audio_pull_fifo.h" | 22 #include "media/base/audio_pull_fifo.h" |
23 #include "media/base/audio_renderer_sink.h" | 23 #include "media/base/audio_renderer_sink.h" |
24 #include "media/base/channel_layout.h" | 24 #include "media/base/channel_layout.h" |
25 #include "media/base/output_device.h" | |
26 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 25 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
27 | 26 |
28 namespace webrtc { | 27 namespace webrtc { |
29 class AudioSourceInterface; | 28 class AudioSourceInterface; |
30 } // namespace webrtc | 29 } // namespace webrtc |
31 | 30 |
32 namespace content { | 31 namespace content { |
33 | 32 |
34 class WebRtcAudioRendererSource; | 33 class WebRtcAudioRendererSource; |
35 | 34 |
36 // This renderer handles calls from the pipeline and WebRtc ADM. It is used | 35 // This renderer handles calls from the pipeline and WebRtc ADM. It is used |
37 // for connecting WebRtc MediaStream with the audio pipeline. | 36 // for connecting WebRtc MediaStream with the audio pipeline. |
38 class CONTENT_EXPORT WebRtcAudioRenderer | 37 class CONTENT_EXPORT WebRtcAudioRenderer |
39 : NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), | 38 : NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), |
40 NON_EXPORTED_BASE(public MediaStreamAudioRenderer), | 39 NON_EXPORTED_BASE(public MediaStreamAudioRenderer) { |
41 NON_EXPORTED_BASE(public media::OutputDevice) { | |
42 public: | 40 public: |
43 // This is a little utility class that holds the configured state of an audio | 41 // This is a little utility class that holds the configured state of an audio |
44 // stream. | 42 // stream. |
45 // It is used by both WebRtcAudioRenderer and SharedAudioRenderer (see cc | 43 // It is used by both WebRtcAudioRenderer and SharedAudioRenderer (see cc |
46 // file) so a part of why it exists is to avoid code duplication and track | 44 // file) so a part of why it exists is to avoid code duplication and track |
47 // the state in the same way in WebRtcAudioRenderer and SharedAudioRenderer. | 45 // the state in the same way in WebRtcAudioRenderer and SharedAudioRenderer. |
48 class PlayingState : public base::NonThreadSafe { | 46 class PlayingState : public base::NonThreadSafe { |
49 public: | 47 public: |
50 PlayingState() : playing_(false), volume_(1.0f) {} | 48 PlayingState() : playing_(false), volume_(1.0f) {} |
51 | 49 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 110 |
113 private: | 111 private: |
114 // MediaStreamAudioRenderer implementation. This is private since we want | 112 // MediaStreamAudioRenderer implementation. This is private since we want |
115 // callers to use proxy objects. | 113 // callers to use proxy objects. |
116 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? | 114 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? |
117 void Start() override; | 115 void Start() override; |
118 void Play() override; | 116 void Play() override; |
119 void Pause() override; | 117 void Pause() override; |
120 void Stop() override; | 118 void Stop() override; |
121 void SetVolume(float volume) override; | 119 void SetVolume(float volume) override; |
122 media::OutputDevice* GetOutputDevice() override; | 120 media::OutputDeviceInfo GetOutputDeviceInfo() override; |
123 base::TimeDelta GetCurrentRenderTime() const override; | 121 base::TimeDelta GetCurrentRenderTime() const override; |
124 bool IsLocalRenderer() const override; | 122 bool IsLocalRenderer() const override; |
125 | |
126 // media::OutputDevice implementation | |
127 void SwitchOutputDevice(const std::string& device_id, | 123 void SwitchOutputDevice(const std::string& device_id, |
128 const url::Origin& security_origin, | 124 const url::Origin& security_origin, |
129 const media::SwitchOutputDeviceCB& callback) override; | 125 const media::OutputDeviceStatusCB& callback) override; |
130 media::AudioParameters GetOutputParameters() override; | |
131 media::OutputDeviceStatus GetDeviceStatus() override; | |
132 | 126 |
133 // Called when an audio renderer, either the main or a proxy, starts playing. | 127 // Called when an audio renderer, either the main or a proxy, starts playing. |
134 // Here we maintain a reference count of how many renderers are currently | 128 // Here we maintain a reference count of how many renderers are currently |
135 // playing so that the shared play state of all the streams can be reflected | 129 // playing so that the shared play state of all the streams can be reflected |
136 // correctly. | 130 // correctly. |
137 void EnterPlayState(); | 131 void EnterPlayState(); |
138 | 132 |
139 // Called when an audio renderer, either the main or a proxy, is paused. | 133 // Called when an audio renderer, either the main or a proxy, is paused. |
140 // See EnterPlayState for more details. | 134 // See EnterPlayState for more details. |
141 void EnterPauseState(); | 135 void EnterPauseState(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // Used for triggering new UMA histogram. Counts number of render | 254 // Used for triggering new UMA histogram. Counts number of render |
261 // callbacks modulo |kNumCallbacksBetweenRenderTimeHistograms|. | 255 // callbacks modulo |kNumCallbacksBetweenRenderTimeHistograms|. |
262 int render_callback_count_; | 256 int render_callback_count_; |
263 | 257 |
264 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); | 258 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); |
265 }; | 259 }; |
266 | 260 |
267 } // namespace content | 261 } // namespace content |
268 | 262 |
269 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 263 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
OLD | NEW |