// 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. // Low-latency audio capturing class utilizing audio input stream provided // by a server process by use of an IPC interface. // // Relationship of classes: // // AudioInputController AudioInputDevice // ^ ^ // | | // v IPC v // MojoAudioInputStream <-----------> AudioInputIPC // ^ (MojoAudioInputIPC) // | // v // AudioInputDeviceManager // // Transportation of audio samples from the browser to the render process // is done by using shared memory in combination with a SyncSocket. // The AudioInputDevice user registers an AudioInputDevice::CaptureCallback by // calling Initialize(). The callback will be called with recorded audio from // the underlying audio layers. // The session ID is used by the RenderFrameAudioInputStreamFactory to start // the device referenced by this ID. // // State sequences: // // Start -> CreateStream -> // <- OnStreamCreated <- // -> RecordStream -> // // AudioInputDevice::Capture => low latency audio transport on audio thread => // // Stop -> CloseStream -> Close // // This class depends on the audio transport thread. That thread is responsible // for calling the CaptureCallback and feeding it audio samples from the server // side audio layer using a socket and shared memory. // // Implementation notes: // - The user must call Stop() before deleting the class instance. #ifndef MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ #define MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ #include <memory> #include <optional> #include <string> #include "base/compiler_specific.h" #include "base/memory/raw_ptr.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/sequence_checker.h" #include "base/threading/platform_thread.h" #include "media/audio/alive_checker.h" #include "media/audio/audio_device_thread.h" #include "media/audio/audio_input_ipc.h" #include "media/base/audio_capturer_source.h" #include "media/base/audio_parameters.h" #include "media/base/media_export.h" namespace media { class MEDIA_EXPORT AudioInputDevice : public AudioCapturerSource, public AudioInputIPCDelegate { … }; } // namespace media #endif // MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_