1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. 2 // Portions copyright (c) 2011 The Chromium Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 6 #ifndef CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_ 7 #define CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_ 8 #pragma once 9 10 #include "include/internal/cef_ptr.h" 11 #include "include/internal/cef_types_wrappers.h" 12 13 #include "media/base/audio_capturer_source.h" 14 15 namespace media { 16 class AudioInputDevice; 17 } // namespace media 18 19 class CefAudioHandler; 20 class CefAudioLoopbackStreamCreator; 21 class AlloyBrowserHostImpl; 22 23 class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback { 24 public: 25 CefAudioCapturer(const CefAudioParameters& params, 26 CefRefPtr<AlloyBrowserHostImpl> browser, 27 CefRefPtr<CefAudioHandler> audio_handler); 28 ~CefAudioCapturer() override; 29 30 private: 31 void OnCaptureStarted() override; 32 void Capture(const media::AudioBus* audio_source, 33 base::TimeTicks audio_capture_time, 34 double volume, 35 bool key_pressed) override; 36 void OnCaptureError(media::AudioCapturerSource::ErrorCode code, 37 const std::string& message) override; OnCaptureMuted(bool is_muted)38 void OnCaptureMuted(bool is_muted) override {} 39 40 void StopStream(); 41 42 CefAudioParameters params_; 43 CefRefPtr<AlloyBrowserHostImpl> browser_; 44 CefRefPtr<CefAudioHandler> audio_handler_; 45 std::unique_ptr<CefAudioLoopbackStreamCreator> audio_stream_creator_; 46 scoped_refptr<media::AudioInputDevice> audio_input_device_; 47 bool capturing_ = false; 48 int channels_ = 0; 49 }; 50 51 #endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_