| 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_TRACK_AUDIO_RENDERER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_TRACK_AUDIO_RENDERER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_TRACK_AUDIO_RENDERER_H_ | 6 #define CONTENT_RENDERER_MEDIA_TRACK_AUDIO_RENDERER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 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/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/public/renderer/media_stream_audio_renderer.h" | 20 #include "content/public/renderer/media_stream_audio_renderer.h" |
| 21 #include "content/public/renderer/media_stream_audio_sink.h" | 21 #include "content/public/renderer/media_stream_audio_sink.h" |
| 22 #include "media/base/audio_renderer_sink.h" | 22 #include "media/base/audio_renderer_sink.h" |
| 23 #include "media/base/output_device.h" | |
| 24 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 23 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 25 | 24 |
| 26 namespace media { | 25 namespace media { |
| 27 class AudioBus; | 26 class AudioBus; |
| 28 class AudioShifter; | 27 class AudioShifter; |
| 29 class AudioParameters; | 28 class AudioParameters; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace content { | 31 namespace content { |
| 33 | 32 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 // Audio data is feed-in from the source via calls to OnData(). The | 45 // Audio data is feed-in from the source via calls to OnData(). The |
| 47 // internally-owned media::AudioOutputDevice calls Render() to pull-out that | 46 // internally-owned media::AudioOutputDevice calls Render() to pull-out that |
| 48 // audio data. However, because of clock differences and other environmental | 47 // audio data. However, because of clock differences and other environmental |
| 49 // factors, the audio will inevitably feed-in at a rate different from the rate | 48 // factors, the audio will inevitably feed-in at a rate different from the rate |
| 50 // it is being rendered-out. media::AudioShifter is used to buffer, stretch | 49 // it is being rendered-out. media::AudioShifter is used to buffer, stretch |
| 51 // and skip audio to maintain time synchronization between the producer and | 50 // and skip audio to maintain time synchronization between the producer and |
| 52 // consumer. | 51 // consumer. |
| 53 class CONTENT_EXPORT TrackAudioRenderer | 52 class CONTENT_EXPORT TrackAudioRenderer |
| 54 : NON_EXPORTED_BASE(public MediaStreamAudioRenderer), | 53 : NON_EXPORTED_BASE(public MediaStreamAudioRenderer), |
| 55 NON_EXPORTED_BASE(public MediaStreamAudioSink), | 54 NON_EXPORTED_BASE(public MediaStreamAudioSink), |
| 56 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), | 55 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback) { |
| 57 NON_EXPORTED_BASE(public media::OutputDevice) { | |
| 58 public: | 56 public: |
| 59 // Creates a renderer for the given |audio_track|. |playout_render_frame_id| | 57 // Creates a renderer for the given |audio_track|. |playout_render_frame_id| |
| 60 // refers to the RenderFrame that owns this instance (e.g., it contains the | 58 // refers to the RenderFrame that owns this instance (e.g., it contains the |
| 61 // DOM widget representing the player). |session_id| and |device_id| are | 59 // DOM widget representing the player). |session_id| and |device_id| are |
| 62 // optional, and are used to direct audio output to a pre-selected device; | 60 // optional, and are used to direct audio output to a pre-selected device; |
| 63 // otherwise, audio is output to the default device for the system. | 61 // otherwise, audio is output to the default device for the system. |
| 64 // | 62 // |
| 65 // Called on the main thread. | 63 // Called on the main thread. |
| 66 TrackAudioRenderer(const blink::WebMediaStreamTrack& audio_track, | 64 TrackAudioRenderer(const blink::WebMediaStreamTrack& audio_track, |
| 67 int playout_render_frame_id, | 65 int playout_render_frame_id, |
| 68 int session_id, | 66 int session_id, |
| 69 const std::string& device_id, | 67 const std::string& device_id, |
| 70 const url::Origin& security_origin); | 68 const url::Origin& security_origin); |
| 71 | 69 |
| 72 // MediaStreamAudioRenderer implementation. | 70 // MediaStreamAudioRenderer implementation. |
| 73 // Called on the main thread. | 71 // Called on the main thread. |
| 74 void Start() override; | 72 void Start() override; |
| 75 void Stop() override; | 73 void Stop() override; |
| 76 void Play() override; | 74 void Play() override; |
| 77 void Pause() override; | 75 void Pause() override; |
| 78 void SetVolume(float volume) override; | 76 void SetVolume(float volume) override; |
| 79 media::OutputDevice* GetOutputDevice() override; | 77 media::OutputDeviceInfo GetOutputDeviceInfo() override; |
| 80 base::TimeDelta GetCurrentRenderTime() const override; | 78 base::TimeDelta GetCurrentRenderTime() const override; |
| 81 bool IsLocalRenderer() const override; | 79 bool IsLocalRenderer() const override; |
| 82 | |
| 83 // media::OutputDevice implementation | |
| 84 void SwitchOutputDevice(const std::string& device_id, | 80 void SwitchOutputDevice(const std::string& device_id, |
| 85 const url::Origin& security_origin, | 81 const url::Origin& security_origin, |
| 86 const media::SwitchOutputDeviceCB& callback) override; | 82 const media::OutputDeviceStatusCB& callback) override; |
| 87 media::AudioParameters GetOutputParameters() override; | |
| 88 media::OutputDeviceStatus GetDeviceStatus() override; | |
| 89 | 83 |
| 90 protected: | 84 protected: |
| 91 ~TrackAudioRenderer() override; | 85 ~TrackAudioRenderer() override; |
| 92 | 86 |
| 93 private: | 87 private: |
| 94 // MediaStreamAudioSink implementation. | 88 // MediaStreamAudioSink implementation. |
| 95 | 89 |
| 96 // Called on the AudioInputDevice worker thread. | 90 // Called on the AudioInputDevice worker thread. |
| 97 void OnData(const media::AudioBus& audio_bus, | 91 void OnData(const media::AudioBus& audio_bus, |
| 98 base::TimeTicks reference_time) override; | 92 base::TimeTicks reference_time) override; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 173 |
| 180 // Used to DCHECK that some methods are called on the audio thread. | 174 // Used to DCHECK that some methods are called on the audio thread. |
| 181 base::ThreadChecker audio_thread_checker_; | 175 base::ThreadChecker audio_thread_checker_; |
| 182 | 176 |
| 183 DISALLOW_COPY_AND_ASSIGN(TrackAudioRenderer); | 177 DISALLOW_COPY_AND_ASSIGN(TrackAudioRenderer); |
| 184 }; | 178 }; |
| 185 | 179 |
| 186 } // namespace content | 180 } // namespace content |
| 187 | 181 |
| 188 #endif // CONTENT_RENDERER_MEDIA_TRACK_AUDIO_RENDERER_H_ | 182 #endif // CONTENT_RENDERER_MEDIA_TRACK_AUDIO_RENDERER_H_ |
| OLD | NEW |