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> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Audio data is feed-in from the source via calls to OnData(). The | 46 // Audio data is feed-in from the source via calls to OnData(). The |
47 // internally-owned media::AudioOutputDevice calls Render() to pull-out that | 47 // internally-owned media::AudioOutputDevice calls Render() to pull-out that |
48 // audio data. However, because of clock differences and other environmental | 48 // 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 | 49 // 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 | 50 // it is being rendered-out. media::AudioShifter is used to buffer, stretch |
51 // and skip audio to maintain time synchronization between the producer and | 51 // and skip audio to maintain time synchronization between the producer and |
52 // consumer. | 52 // consumer. |
53 class CONTENT_EXPORT TrackAudioRenderer | 53 class CONTENT_EXPORT TrackAudioRenderer |
54 : NON_EXPORTED_BASE(public MediaStreamAudioRenderer), | 54 : NON_EXPORTED_BASE(public MediaStreamAudioRenderer), |
55 NON_EXPORTED_BASE(public MediaStreamAudioSink), | 55 NON_EXPORTED_BASE(public MediaStreamAudioSink), |
56 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback), | 56 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback) { |
57 NON_EXPORTED_BASE(public media::OutputDevice) { | |
58 public: | 57 public: |
59 // Creates a renderer for the given |audio_track|. |playout_render_frame_id| | 58 // 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 | 59 // 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 | 60 // 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; | 61 // 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. | 62 // otherwise, audio is output to the default device for the system. |
64 // | 63 // |
65 // Called on the main thread. | 64 // Called on the main thread. |
66 TrackAudioRenderer(const blink::WebMediaStreamTrack& audio_track, | 65 TrackAudioRenderer(const blink::WebMediaStreamTrack& audio_track, |
67 int playout_render_frame_id, | 66 int playout_render_frame_id, |
68 int session_id, | 67 int session_id, |
69 const std::string& device_id, | 68 const std::string& device_id, |
70 const url::Origin& security_origin); | 69 const url::Origin& security_origin); |
71 | 70 |
72 // MediaStreamAudioRenderer implementation. | 71 // MediaStreamAudioRenderer implementation. |
73 // Called on the main thread. | 72 // Called on the main thread. |
74 void Start() override; | 73 void Start() override; |
75 void Stop() override; | 74 void Stop() override; |
76 void Play() override; | 75 void Play() override; |
77 void Pause() override; | 76 void Pause() override; |
78 void SetVolume(float volume) override; | 77 void SetVolume(float volume) override; |
79 media::OutputDevice* GetOutputDevice() override; | 78 media::OutputDevice* GetOutputDevice() override; |
80 base::TimeDelta GetCurrentRenderTime() const override; | 79 base::TimeDelta GetCurrentRenderTime() const override; |
81 bool IsLocalRenderer() const override; | 80 bool IsLocalRenderer() const override; |
82 | |
83 // media::OutputDevice implementation | |
84 void SwitchOutputDevice(const std::string& device_id, | 81 void SwitchOutputDevice(const std::string& device_id, |
85 const url::Origin& security_origin, | 82 const url::Origin& security_origin, |
86 const media::SwitchOutputDeviceCB& callback) override; | 83 const media::SwitchOutputDeviceCB& callback) override; |
87 media::AudioParameters GetOutputParameters() override; | |
88 media::OutputDeviceStatus GetDeviceStatus() override; | |
89 | |
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; |
99 | 93 |
(...skipping 79 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 |