// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_TRACK_AUDIO_RENDERER_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_TRACK_AUDIO_RENDERER_H_ #include <stdint.h> #include <memory> #include "base/functional/callback.h" #include "base/memory/scoped_refptr.h" #include "base/synchronization/lock.h" #include "base/task/single_thread_task_runner.h" #include "base/time/time.h" #include "base/unguessable_token.h" #include "media/base/audio_renderer_sink.h" #include "third_party/blink/public/platform/modules/mediastream/web_media_stream_audio_sink.h" #include "third_party/blink/renderer/modules/mediastream/media_stream_audio_renderer.h" #include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/platform/mediastream/media_stream_component.h" #include "third_party/blink/renderer/platform/wtf/deque.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" namespace media { class AudioBus; class AudioShifter; class AudioParameters; } // namespace media namespace blink { class LocalFrame; // TrackAudioRenderer is a MediaStreamAudioRenderer for plumbing audio // data generated from either local or remote (but not // PeerConnection/WebRTC-sourced) MediaStreamAudioTracks to an audio output // device, reconciling differences in the rates of production and consumption of // the audio data. Note that remote PeerConnection-sourced tracks are NOT // rendered by this implementation (see MediaStreamRendererFactory). // // This class uses AudioDeviceFactory to create media::AudioRendererSink and // owns/manages their lifecycles. Output devices are automatically re-created // in response to audio format changes, or use of the SwitchOutputDevice() API // by client code. // // Audio data is feed-in from the source via calls to OnData(). The // internally-owned media::AudioOutputDevice calls Render() to pull-out that // audio data. However, because of clock differences and other environmental // factors, the audio will inevitably feed-in at a rate different from the rate // it is being rendered-out. media::AudioShifter is used to buffer, stretch // and skip audio to maintain time synchronization between the producer and // consumer. class MODULES_EXPORT TrackAudioRenderer : public MediaStreamAudioRenderer, public WebMediaStreamAudioSink, public media::AudioRendererSink::RenderCallback { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_TRACK_AUDIO_RENDERER_H_