// Copyright 2014 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_PLATFORM_MEDIASTREAM_MEDIA_STREAM_AUDIO_SOURCE_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_MEDIASTREAM_MEDIA_STREAM_AUDIO_SOURCE_H_ #include <limits> #include <memory> #include <string> #include "base/memory/weak_ptr.h" #include "media/base/audio_capturer_source.h" #include "media/base/limits.h" #include "third_party/blink/public/platform/modules/mediastream/web_platform_media_stream_source.h" #include "third_party/blink/renderer/platform/mediastream/media_stream_audio_deliverer.h" #include "third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h" #include "third_party/blink/renderer/platform/platform_export.h" namespace base { class SingleThreadTaskRunner; } namespace media { struct AudioGlitchInfo; } namespace blink { PLATFORM_EXPORT extern const int kFallbackAudioLatencyMs; class MediaStreamAudioTrack; class MediaStreamComponent; // Represents a source of audio, and manages the delivery of audio data between // the source implementation and one or more MediaStreamAudioTracks. This is a // base class providing all the necessary functionality to connect tracks and // have audio data delivered to them. Subclasses provide the actual audio source // implementation (e.g., media::AudioCapturerSource), and should implement the // EnsureSourceIsStarted() and EnsureSourceIsStopped() methods, and call // SetFormat() and DeliverDataToTracks(). // // This base class can be instantiated, to be used as a place-holder or a "null" // source of audio. This can be useful for unit testing, wherever a mock is // needed, and/or calls to DeliverDataToTracks() must be made at very specific // times. // // An instance of this class is owned by MediaStreamSource. // // Usage example: // // class MyAudioSource : public MediaStreamAudioSource { ... }; // // MediaStreamSource* media_stream_source = // MakeGarbageCollected<MediaStreamSource>( // ..., std::make_unique<MyAudioSource>()); // MediaStreamComponent* media_stream_track = ...; // if (MediaStreamAudioSource::From(media_stream_source) // ->ConnectToInitializedTrack(media_stream_track)) { // LOG(INFO) << "Success!"; // } else { // LOG(ERROR) << "Failed!"; // } class PLATFORM_EXPORT MediaStreamAudioSource : public WebPlatformMediaStreamSource { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_MEDIASTREAM_MEDIA_STREAM_AUDIO_SOURCE_H_