2020-05-01 20:18:18 +02:00
|
|
|
// Copyright (c) 2019 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
|
|
|
|
#pragma once
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/internal/cef_ptr.h"
|
|
|
|
#include "cef/include/internal/cef_types_wrappers.h"
|
2020-05-01 20:18:18 +02:00
|
|
|
#include "media/base/audio_capturer_source.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
class AudioInputDevice;
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
class CefAudioHandler;
|
2020-12-02 23:31:49 +01:00
|
|
|
class CefAudioLoopbackStreamCreator;
|
2020-09-22 21:54:02 +02:00
|
|
|
class AlloyBrowserHostImpl;
|
2020-05-01 20:18:18 +02:00
|
|
|
|
|
|
|
class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
|
|
|
|
public:
|
|
|
|
CefAudioCapturer(const CefAudioParameters& params,
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser,
|
2020-05-01 20:18:18 +02:00
|
|
|
CefRefPtr<CefAudioHandler> audio_handler);
|
|
|
|
~CefAudioCapturer() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void OnCaptureStarted() override;
|
|
|
|
void Capture(const media::AudioBus* audio_source,
|
|
|
|
base::TimeTicks audio_capture_time,
|
2024-03-19 22:11:42 +01:00
|
|
|
const media::AudioGlitchInfo& glitch_info,
|
2020-05-01 20:18:18 +02:00
|
|
|
double volume,
|
|
|
|
bool key_pressed) override;
|
2021-07-23 18:40:13 +02:00
|
|
|
void OnCaptureError(media::AudioCapturerSource::ErrorCode code,
|
|
|
|
const std::string& message) override;
|
2020-05-01 20:18:18 +02:00
|
|
|
void OnCaptureMuted(bool is_muted) override {}
|
|
|
|
|
|
|
|
void StopStream();
|
|
|
|
|
|
|
|
CefAudioParameters params_;
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser_;
|
2020-05-01 20:18:18 +02:00
|
|
|
CefRefPtr<CefAudioHandler> audio_handler_;
|
2020-12-02 23:31:49 +01:00
|
|
|
std::unique_ptr<CefAudioLoopbackStreamCreator> audio_stream_creator_;
|
2020-05-01 20:18:18 +02:00
|
|
|
scoped_refptr<media::AudioInputDevice> audio_input_device_;
|
|
|
|
bool capturing_ = false;
|
|
|
|
int channels_ = 0;
|
|
|
|
};
|
|
|
|
|
2024-03-19 22:11:42 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_
|