Re-implement audio capturing based on the AudioService API (fixes issue #2755)

This commit is contained in:
Mike Wiedenbauer 2020-05-01 18:18:18 +00:00 committed by Marshall Greenblatt
parent d65483ae16
commit 8d01442d75
24 changed files with 2210 additions and 6 deletions

View File

@ -377,6 +377,8 @@ if (is_win) {
static_library("libcef_static") {
sources = includes_common +
gypi_paths.autogen_cpp_includes + [
"libcef/browser/audio_capturer.cc",
"libcef/browser/audio_capturer.h",
"libcef/browser/browser_context.cc",
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc",

View File

@ -8,7 +8,7 @@
# by hand. See the translator.README.txt file in the tools directory for
# more information.
#
# $hash=578c0aef11c3c7840679e480069fc9031c628e25$
# $hash=21f0ab1e9902e4a47bf2893a4a383d33bd8161e2$
#
{
@ -16,6 +16,7 @@
'autogen_cpp_includes': [
'include/cef_accessibility_handler.h',
'include/cef_app.h',
'include/cef_audio_handler.h',
'include/cef_auth_callback.h',
'include/cef_browser.h',
'include/cef_browser_process_handler.h',
@ -111,6 +112,7 @@
'autogen_capi_includes': [
'include/capi/cef_accessibility_handler_capi.h',
'include/capi/cef_app_capi.h',
'include/capi/cef_audio_handler_capi.h',
'include/capi/cef_auth_callback_capi.h',
'include/capi/cef_browser_capi.h',
'include/capi/cef_browser_process_handler_capi.h',
@ -208,6 +210,8 @@
'libcef_dll/ctocpp/accessibility_handler_ctocpp.h',
'libcef_dll/ctocpp/app_ctocpp.cc',
'libcef_dll/ctocpp/app_ctocpp.h',
'libcef_dll/ctocpp/audio_handler_ctocpp.cc',
'libcef_dll/ctocpp/audio_handler_ctocpp.h',
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
'libcef_dll/cpptoc/auth_callback_cpptoc.h',
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
@ -512,6 +516,8 @@
'libcef_dll/cpptoc/accessibility_handler_cpptoc.h',
'libcef_dll/cpptoc/app_cpptoc.cc',
'libcef_dll/cpptoc/app_cpptoc.h',
'libcef_dll/cpptoc/audio_handler_cpptoc.cc',
'libcef_dll/cpptoc/audio_handler_cpptoc.h',
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
'libcef_dll/ctocpp/auth_callback_ctocpp.h',
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',

View File

@ -466,6 +466,7 @@
'tests/cefsimple/simple_handler_linux.cc',
],
'ceftests_sources_common': [
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/browser_info_map_unittest.cc',
'tests/ceftests/command_line_unittest.cc',
'tests/ceftests/cookie_unittest.cc',
@ -565,6 +566,7 @@
'tests/shared/browser/resource_util.h',
'tests/shared/browser/resource_util_mac.mm',
'tests/shared/browser/resource_util_posix.cc',
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/client_app_delegates.cc',
'tests/ceftests/cookie_unittest.cc',
'tests/ceftests/dom_unittest.cc',

View File

@ -0,0 +1,121 @@
// Copyright (c) 2020 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=430877d950508a545d0baa18c8c8c0d2d183fec4$
//
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_browser_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Implement this structure to handle audio events.
///
typedef struct _cef_audio_handler_t {
///
// Base structure.
///
cef_base_ref_counted_t base;
///
// Called on the UI thread to allow configuration of audio stream parameters.
// Return true (1) to proceed with audio stream capture, or false (0) to
// cancel it. All members of |params| can optionally be configured here, but
// they are also pre-filled with some sensible defaults.
///
int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
cef_audio_parameters_t* params);
///
// Called on a browser audio capture thread when the browser starts streaming
// audio. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both functions may be called multiple times for the
// same browser. |params| contains the audio parameters like sample rate and
// channel layout. |channels| is the number of channels.
///
void(CEF_CALLBACK* on_audio_stream_started)(
struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_audio_parameters_t* params,
int channels);
///
// Called on the audio stream thread when a PCM packet is received for the
// stream. |data| is an array representing the raw PCM data as a floating
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
// Unix Epoch) and represents the time at which the decompressed packet should
// be presented to the user. Based on |frames| and the |channel_layout| value
// passed to OnAudioStreamStarted you can calculate the size of the |data|
// array in bytes.
///
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const float** data,
int frames,
int64 pts);
///
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
// will always be called after OnAudioStreamStarted; both functions may be
// called multiple times for the same stream.
///
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser);
///
// Called on the UI or audio stream thread when an error occurred. During the
// stream creation phase this callback will be called on the UI thread while
// in the capturing phase it will be called on the audio stream thread. The
// stream will be stopped immediately.
///
void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* message);
} cef_audio_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_

View File

@ -33,13 +33,14 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=6a0312765614a697d56e87c8503afba8404bb08b$
// $hash=8d4cb3e0bbf230804c93898daa4a8b2866a2c1ce$
//
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
#pragma once
#include "include/capi/cef_audio_handler_capi.h"
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_context_menu_handler_capi.h"
#include "include/capi/cef_dialog_handler_capi.h"
@ -69,6 +70,12 @@ typedef struct _cef_client_t {
///
cef_base_ref_counted_t base;
///
// Return the handler for audio rendering events.
///
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
struct _cef_client_t* self);
///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.

111
include/cef_audio_handler.h Normal file
View File

@ -0,0 +1,111 @@
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_AUDIO_HANDLER_H_
#define CEF_INCLUDE_CEF_AUDIO_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
///
// Implement this interface to handle audio events.
///
/*--cef(source=client)--*/
class CefAudioHandler : public virtual CefBaseRefCounted {
public:
typedef cef_channel_layout_t ChannelLayout;
///
// Called on the UI thread to allow configuration of audio stream parameters.
// Return true to proceed with audio stream capture, or false to cancel it.
// All members of |params| can optionally be configured here, but they are
// also pre-filled with some sensible defaults.
///
/*--cef()--*/
virtual bool GetAudioParameters(CefRefPtr<CefBrowser> browser,
CefAudioParameters& params) {
return true;
}
///
// Called on a browser audio capture thread when the browser starts
// streaming audio. OnAudioSteamStopped will always be called after
// OnAudioStreamStarted; both methods may be called multiple times
// for the same browser. |params| contains the audio parameters like
// sample rate and channel layout. |channels| is the number of channels.
///
/*--cef()--*/
virtual void OnAudioStreamStarted(CefRefPtr<CefBrowser> browser,
const CefAudioParameters& params,
int channels) = 0;
///
// Called on the audio stream thread when a PCM packet is received for the
// stream. |data| is an array representing the raw PCM data as a floating
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
// Unix Epoch) and represents the time at which the decompressed packet should
// be presented to the user. Based on |frames| and the |channel_layout| value
// passed to OnAudioStreamStarted you can calculate the size of the |data|
// array in bytes.
///
/*--cef()--*/
virtual void OnAudioStreamPacket(CefRefPtr<CefBrowser> browser,
const float** data,
int frames,
int64 pts) = 0;
///
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
// will always be called after OnAudioStreamStarted; both methods may be
// called multiple times for the same stream.
///
/*--cef()--*/
virtual void OnAudioStreamStopped(CefRefPtr<CefBrowser> browser) = 0;
///
// Called on the UI or audio stream thread when an error occurred. During the
// stream creation phase this callback will be called on the UI thread while
// in the capturing phase it will be called on the audio stream thread. The
// stream will be stopped immediately.
///
/*--cef()--*/
virtual void OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) = 0;
};
#endif // CEF_INCLUDE_CEF_AUDIO_HANDLER_H_

View File

@ -38,6 +38,7 @@
#define CEF_INCLUDE_CEF_CLIENT_H_
#pragma once
#include "include/cef_audio_handler.h"
#include "include/cef_base.h"
#include "include/cef_context_menu_handler.h"
#include "include/cef_dialog_handler.h"
@ -60,6 +61,12 @@
/*--cef(source=client,no_debugct_check)--*/
class CefClient : public virtual CefBaseRefCounted {
public:
///
// Return the handler for audio rendering events.
///
/*--cef()--*/
virtual CefRefPtr<CefAudioHandler> GetAudioHandler() { return nullptr; }
///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.

View File

@ -3003,6 +3003,137 @@ typedef struct _cef_composition_underline_t {
cef_composition_underline_style_t style;
} cef_composition_underline_t;
///
// Enumerates the various representations of the ordering of audio channels.
// Must be kept synchronized with media::ChannelLayout from Chromium.
// See media\base\channel_layout.h
///
typedef enum {
CEF_CHANNEL_LAYOUT_NONE = 0,
CEF_CHANNEL_LAYOUT_UNSUPPORTED = 1,
// Front C
CEF_CHANNEL_LAYOUT_MONO = 2,
// Front L, Front R
CEF_CHANNEL_LAYOUT_STEREO = 3,
// Front L, Front R, Back C
CEF_CHANNEL_LAYOUT_2_1 = 4,
// Front L, Front R, Front C
CEF_CHANNEL_LAYOUT_SURROUND = 5,
// Front L, Front R, Front C, Back C
CEF_CHANNEL_LAYOUT_4_0 = 6,
// Front L, Front R, Side L, Side R
CEF_CHANNEL_LAYOUT_2_2 = 7,
// Front L, Front R, Back L, Back R
CEF_CHANNEL_LAYOUT_QUAD = 8,
// Front L, Front R, Front C, Side L, Side R
CEF_CHANNEL_LAYOUT_5_0 = 9,
// Front L, Front R, Front C, LFE, Side L, Side R
CEF_CHANNEL_LAYOUT_5_1 = 10,
// Front L, Front R, Front C, Back L, Back R
CEF_CHANNEL_LAYOUT_5_0_BACK = 11,
// Front L, Front R, Front C, LFE, Back L, Back R
CEF_CHANNEL_LAYOUT_5_1_BACK = 12,
// Front L, Front R, Front C, Side L, Side R, Back L, Back R
CEF_CHANNEL_LAYOUT_7_0 = 13,
// Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
CEF_CHANNEL_LAYOUT_7_1 = 14,
// Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE = 15,
// Stereo L, Stereo R
CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
// Stereo L, Stereo R, LFE
CEF_CHANNEL_LAYOUT_2POINT1 = 17,
// Stereo L, Stereo R, Front C, LFE
CEF_CHANNEL_LAYOUT_3_1 = 18,
// Stereo L, Stereo R, Front C, Rear C, LFE
CEF_CHANNEL_LAYOUT_4_1 = 19,
// Stereo L, Stereo R, Front C, Side L, Side R, Back C
CEF_CHANNEL_LAYOUT_6_0 = 20,
// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_6_0_FRONT = 21,
// Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
CEF_CHANNEL_LAYOUT_HEXAGONAL = 22,
// Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
CEF_CHANNEL_LAYOUT_6_1 = 23,
// Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
CEF_CHANNEL_LAYOUT_6_1_BACK = 24,
// Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
CEF_CHANNEL_LAYOUT_6_1_FRONT = 25,
// Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_0_FRONT = 26,
// Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
// Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
CEF_CHANNEL_LAYOUT_OCTAGONAL = 28,
// Channels are not explicitly mapped to speakers.
CEF_CHANNEL_LAYOUT_DISCRETE = 29,
// Front L, Front R, Front C. Front C contains the keyboard mic audio. This
// layout is only intended for input for WebRTC. The Front C channel
// is stripped away in the WebRTC audio input pipeline and never seen outside
// of that.
CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
// Front L, Front R, Side L, Side R, LFE
CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
// Actual channel layout is specified in the bitstream and the actual channel
// count is unknown at Chromium media pipeline level (useful for audio
// pass-through mode).
CEF_CHANNEL_LAYOUT_BITSTREAM = 32,
// Max value, must always equal the largest entry ever logged.
CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_BITSTREAM
} cef_channel_layout_t;
///
// Structure representing the audio parameters for setting up the audio handler.
///
typedef struct _cef_audio_parameters_t {
///
// Layout of the audio channels
///
cef_channel_layout_t channel_layout;
///
// Sample rate
//
int sample_rate;
///
// Number of frames per buffer
///
int frames_per_buffer;
} cef_audio_parameters_t;
///
// Result codes for CefMediaRouter::CreateRoute. Should be kept in sync with
// Chromium's media_router::RouteRequestResult::ResultCode type.

View File

@ -960,4 +960,23 @@ struct CefCompositionUnderlineTraits {
///
typedef CefStructBase<CefCompositionUnderlineTraits> CefCompositionUnderline;
struct CefAudioParametersTraits {
typedef cef_audio_parameters_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src,
struct_type* target,
bool copy) {
*target = *src;
}
};
///
// Class representing CefAudioParameters settings
///
typedef CefStructBase<CefAudioParametersTraits> CefAudioParameters;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@ -0,0 +1,125 @@
// 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.
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/browser_host_impl.h"
#include "components/mirroring/service/captured_audio_input.h"
#include "content/public/browser/audio_loopback_stream_creator.h"
#include "media/audio/audio_input_device.h"
namespace {
media::ChannelLayout TranslateChannelLayout(
cef_channel_layout_t channel_layout) {
// Verify that our enum matches Chromium's values. The enum values match
// between those enums and existing values don't ever change, so it's enough
// to check that there are no new ones added.
static_assert(
static_cast<int>(CEF_CHANNEL_LAYOUT_MAX) ==
static_cast<int>(media::CHANNEL_LAYOUT_MAX),
"cef_channel_layout_t must match the ChannelLayout enum in Chromium");
return static_cast<media::ChannelLayout>(channel_layout);
}
void StreamCreatorHelper(
content::WebContents* source_web_contents,
content::AudioLoopbackStreamCreator* audio_stream_creator,
mojo::PendingRemote<mirroring::mojom::AudioStreamCreatorClient> client,
const media::AudioParameters& params,
uint32_t total_segments) {
audio_stream_creator->CreateLoopbackStream(
source_web_contents, params, total_segments,
base::BindRepeating(
[](mojo::PendingRemote<mirroring::mojom::AudioStreamCreatorClient>
client,
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe) {
mojo::Remote<mirroring::mojom::AudioStreamCreatorClient>
audio_client(std::move(client));
audio_client->StreamCreated(
std::move(stream), std::move(client_receiver),
std::move(data_pipe), false /* initially_muted */);
},
base::Passed(&client)));
}
} // namespace
CefAudioCapturer::CefAudioCapturer(const CefAudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> audio_handler)
: params_(params),
browser_(browser),
audio_handler_(audio_handler),
audio_stream_creator_(content::AudioLoopbackStreamCreator::
CreateInProcessAudioLoopbackStreamCreator()) {
media::AudioParameters audio_params(
media::AudioParameters::AUDIO_PCM_LINEAR,
TranslateChannelLayout(params.channel_layout), params.sample_rate,
params.frames_per_buffer);
if (!audio_params.IsValid()) {
LOG(ERROR) << "Invalid audio parameters";
return;
}
DCHECK(browser_);
DCHECK(audio_handler_);
DCHECK(browser_->web_contents());
channels_ = audio_params.channels();
audio_input_device_ = new media::AudioInputDevice(
std::make_unique<mirroring::CapturedAudioInput>(base::BindRepeating(
&StreamCreatorHelper, base::Unretained(browser_->web_contents()),
base::Unretained(audio_stream_creator_.get()))),
media::AudioInputDevice::kLoopback);
audio_input_device_->Initialize(audio_params, this);
audio_input_device_->Start();
}
CefAudioCapturer::~CefAudioCapturer() {
StopStream();
}
void CefAudioCapturer::OnCaptureStarted() {
audio_handler_->OnAudioStreamStarted(browser_, params_, channels_);
DCHECK(!capturing_);
capturing_ = true;
}
void CefAudioCapturer::Capture(const media::AudioBus* source,
base::TimeTicks audio_capture_time,
double /*volume*/,
bool /*key_pressed*/) {
const int channels = source->channels();
std::array<const float*, media::CHANNELS_MAX> data;
DCHECK(channels == channels_);
DCHECK(channels <= static_cast<int>(data.size()));
for (int c = 0; c < channels; ++c) {
data[c] = source->channel(c);
}
base::TimeDelta pts = audio_capture_time - base::TimeTicks::UnixEpoch();
audio_handler_->OnAudioStreamPacket(browser_, data.data(), source->frames(),
pts.InMilliseconds());
}
void CefAudioCapturer::OnCaptureError(const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
}
void CefAudioCapturer::StopStream() {
if (audio_input_device_)
audio_input_device_->Stop();
if (capturing_)
audio_handler_->OnAudioStreamStopped(browser_);
audio_input_device_ = nullptr;
capturing_ = false;
}

View File

@ -0,0 +1,53 @@
// 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
#include "include/internal/cef_ptr.h"
#include "include/internal/cef_types_wrappers.h"
#include "media/base/audio_capturer_source.h"
namespace content {
class AudioLoopbackStreamCreator;
} // namespace content
namespace media {
class AudioInputDevice;
} // namespace media
class CefAudioHandler;
class CefBrowserHostImpl;
class CefAudioCapturer : public media::AudioCapturerSource::CaptureCallback {
public:
CefAudioCapturer(const CefAudioParameters& params,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefAudioHandler> audio_handler);
~CefAudioCapturer() override;
private:
void OnCaptureStarted() override;
void Capture(const media::AudioBus* audio_source,
base::TimeTicks audio_capture_time,
double volume,
bool key_pressed) override;
void OnCaptureError(const std::string& message) override;
void OnCaptureMuted(bool is_muted) override {}
void StopStream();
CefAudioParameters params_;
CefRefPtr<CefBrowserHostImpl> browser_;
CefRefPtr<CefAudioHandler> audio_handler_;
std::unique_ptr<content::AudioLoopbackStreamCreator> audio_stream_creator_;
scoped_refptr<media::AudioInputDevice> audio_input_device_;
bool capturing_ = false;
int channels_ = 0;
};
#endif // CEF_LIBCEF_BROWSER_AUDIO_CAPTURER_H_

View File

@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "libcef/browser/audio_capturer.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/browser_info_manager.h"
@ -194,6 +195,9 @@ void OnDownloadImage(uint32 max_image_size,
image_impl.get());
}
static constexpr base::TimeDelta kRecentlyAudibleTimeout =
base::TimeDelta::FromSeconds(2);
} // namespace
// CefBrowserHost static methods.
@ -1559,6 +1563,10 @@ void CefBrowserHostImpl::DestroyBrowser() {
javascript_dialog_manager_.reset(nullptr);
menu_manager_.reset(nullptr);
// Delete the audio capturer
recently_audible_timer_.Stop();
audio_capturer_.reset(nullptr);
// Delete the platform delegate.
platform_delegate_.reset(nullptr);
@ -2697,6 +2705,25 @@ void CefBrowserHostImpl::DidUpdateFaviconURL(
}
}
void CefBrowserHostImpl::OnAudioStateChanged(bool audible) {
if (audible) {
recently_audible_timer_.Stop();
StartAudioCapturer();
} else if (audio_capturer_) {
// If you have a media playing that has a short quiet moment, web_contents
// will immediately switch to non-audible state. We don't want to stop
// audio stream so quickly, let's give the stream some time to resume
// playing.
recently_audible_timer_.Start(
FROM_HERE, kRecentlyAudibleTimeout,
base::BindOnce(&CefBrowserHostImpl::OnRecentlyAudibleTimerFired, this));
}
}
void CefBrowserHostImpl::OnRecentlyAudibleTimerFired() {
audio_capturer_.reset();
}
bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
// Handle the cursor message here if mouse cursor change is disabled instead
// of propegating the message to the normal handler.
@ -2792,6 +2819,25 @@ bool CefBrowserHostImpl::HasObserver(Observer* observer) const {
return observers_.HasObserver(observer);
}
void CefBrowserHostImpl::StartAudioCapturer() {
if (!client_.get() || audio_capturer_)
return;
CefRefPtr<CefAudioHandler> audio_handler = client_->GetAudioHandler();
if (!audio_handler.get())
return;
CefAudioParameters params;
params.channel_layout = CEF_CHANNEL_LAYOUT_STEREO;
params.sample_rate = media::AudioParameters::kAudioCDSampleRate;
params.frames_per_buffer = 1024;
if (!audio_handler->GetAudioParameters(this, params))
return;
audio_capturer_.reset(new CefAudioCapturer(params, this, audio_handler));
}
CefBrowserHostImpl::NavigationLock::NavigationLock(
CefRefPtr<CefBrowserHostImpl> browser)
: browser_(browser) {

View File

@ -48,6 +48,7 @@ class Widget;
}
#endif // defined(USE_AURA)
class CefAudioCapturer;
class CefBrowserInfo;
class CefBrowserPlatformDelegate;
class CefDevToolsFrontend;
@ -486,6 +487,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
base::ProcessId plugin_pid) override;
void DidUpdateFaviconURL(
const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
void OnAudioStateChanged(bool audible) override;
bool OnMessageReceived(const IPC::Message& message) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
@ -505,6 +507,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const;
class NavigationLock final {
private:
friend class CefBrowserHostImpl;
@ -585,6 +588,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
void ConfigureAutoResize();
void StartAudioCapturer();
void OnRecentlyAudibleTimerFired();
CefBrowserSettings settings_;
CefRefPtr<CefClient> client_;
scoped_refptr<CefBrowserInfo> browser_info_;
@ -667,6 +674,14 @@ class CefBrowserHostImpl : public CefBrowserHost,
CefRefPtr<CefExtension> extension_;
bool is_background_host_ = false;
// Used for capturing audio for CefAudioHandler.
std::unique_ptr<CefAudioCapturer> audio_capturer_;
// Timer for determining when "recently audible" transitions to false. This
// starts running when a tab stops being audible, and is canceled if it starts
// being audible again before it fires.
base::OneShotTimer recently_audible_timer_;
// Used with auto-resize.
bool auto_resize_enabled_ = false;
gfx::Size auto_resize_min_;

View File

@ -0,0 +1,191 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=4568fbb1f264fe9a900784aa3040c406a919ad37$
//
#include "libcef_dll/cpptoc/audio_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/shutdown_checker.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK
audio_handler_get_audio_parameters(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
cef_audio_parameters_t* params) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: params; type: simple_byref
DCHECK(params);
if (!params)
return 0;
// Translate param: params; type: simple_byref
CefAudioParameters paramsVal = params ? *params : CefAudioParameters();
// Execute
bool _retval = CefAudioHandlerCppToC::Get(self)->GetAudioParameters(
CefBrowserCToCpp::Wrap(browser), paramsVal);
// Restore param: params; type: simple_byref
if (params)
*params = paramsVal;
// Return type: bool
return _retval;
}
void CEF_CALLBACK
audio_handler_on_audio_stream_started(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_audio_parameters_t* params,
int channels) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: params; type: simple_byref_const
DCHECK(params);
if (!params)
return;
// Translate param: params; type: simple_byref_const
CefAudioParameters paramsVal = params ? *params : CefAudioParameters();
// Execute
CefAudioHandlerCppToC::Get(self)->OnAudioStreamStarted(
CefBrowserCToCpp::Wrap(browser), paramsVal, channels);
}
void CEF_CALLBACK
audio_handler_on_audio_stream_packet(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const float** data,
int frames,
int64 pts) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: data; type: simple_byaddr
DCHECK(data);
if (!data)
return;
// Execute
CefAudioHandlerCppToC::Get(self)->OnAudioStreamPacket(
CefBrowserCToCpp::Wrap(browser), data, frames, pts);
}
void CEF_CALLBACK
audio_handler_on_audio_stream_stopped(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Execute
CefAudioHandlerCppToC::Get(self)->OnAudioStreamStopped(
CefBrowserCToCpp::Wrap(browser));
}
void CEF_CALLBACK
audio_handler_on_audio_stream_error(struct _cef_audio_handler_t* self,
struct _cef_browser_t* browser,
const cef_string_t* message) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: message; type: string_byref_const
DCHECK(message);
if (!message)
return;
// Execute
CefAudioHandlerCppToC::Get(self)->OnAudioStreamError(
CefBrowserCToCpp::Wrap(browser), CefString(message));
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefAudioHandlerCppToC::CefAudioHandlerCppToC() {
GetStruct()->get_audio_parameters = audio_handler_get_audio_parameters;
GetStruct()->on_audio_stream_started = audio_handler_on_audio_stream_started;
GetStruct()->on_audio_stream_packet = audio_handler_on_audio_stream_packet;
GetStruct()->on_audio_stream_stopped = audio_handler_on_audio_stream_stopped;
GetStruct()->on_audio_stream_error = audio_handler_on_audio_stream_error;
}
// DESTRUCTOR - Do not edit by hand.
CefAudioHandlerCppToC::~CefAudioHandlerCppToC() {
shutdown_checker::AssertNotShutdown();
}
template <>
CefRefPtr<CefAudioHandler> CefCppToCRefCounted<
CefAudioHandlerCppToC,
CefAudioHandler,
cef_audio_handler_t>::UnwrapDerived(CefWrapperType type,
cef_audio_handler_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCRefCounted<CefAudioHandlerCppToC,
CefAudioHandler,
cef_audio_handler_t>::kWrapperType =
WT_AUDIO_HANDLER;

View File

@ -0,0 +1,37 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=27689a3c353f267fb650ec5b7dc095e0a6be8b13$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_AUDIO_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_AUDIO_HANDLER_CPPTOC_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_audio_handler_capi.h"
#include "include/cef_audio_handler.h"
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefAudioHandlerCppToC : public CefCppToCRefCounted<CefAudioHandlerCppToC,
CefAudioHandler,
cef_audio_handler_t> {
public:
CefAudioHandlerCppToC();
virtual ~CefAudioHandlerCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_AUDIO_HANDLER_CPPTOC_H_

View File

@ -9,10 +9,11 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=154a21a2f4ac985eeed2d28ad9479f322c4aad07$
// $hash=04cee2c6a1910d7084c556f1bde99ba971b354d2$
//
#include "libcef_dll/cpptoc/client_cpptoc.h"
#include "libcef_dll/cpptoc/audio_handler_cpptoc.h"
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
#include "libcef_dll/cpptoc/dialog_handler_cpptoc.h"
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
@ -34,6 +35,22 @@ namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_audio_handler_t* CEF_CALLBACK
client_get_audio_handler(struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefAudioHandler> _retval =
CefClientCppToC::Get(self)->GetAudioHandler();
// Return type: refptr_same
return CefAudioHandlerCppToC::Wrap(_retval);
}
struct _cef_context_menu_handler_t* CEF_CALLBACK
client_get_context_menu_handler(struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -280,6 +297,7 @@ client_on_process_message_received(struct _cef_client_t* self,
// CONSTRUCTOR - Do not edit by hand.
CefClientCppToC::CefClientCppToC() {
GetStruct()->get_audio_handler = client_get_audio_handler;
GetStruct()->get_context_menu_handler = client_get_context_menu_handler;
GetStruct()->get_dialog_handler = client_get_dialog_handler;
GetStruct()->get_display_handler = client_get_display_handler;

View File

@ -0,0 +1,164 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=d7f2fb8ad6fe2bd0ab928b09ab596b12e9049ddf$
//
#include "libcef_dll/ctocpp/audio_handler_ctocpp.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/shutdown_checker.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
bool CefAudioHandlerCToCpp::GetAudioParameters(CefRefPtr<CefBrowser> browser,
CefAudioParameters& params) {
shutdown_checker::AssertNotShutdown();
cef_audio_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_audio_parameters))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Execute
int _retval = _struct->get_audio_parameters(
_struct, CefBrowserCppToC::Wrap(browser), &params);
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
void CefAudioHandlerCToCpp::OnAudioStreamStarted(
CefRefPtr<CefBrowser> browser,
const CefAudioParameters& params,
int channels) {
shutdown_checker::AssertNotShutdown();
cef_audio_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_audio_stream_started))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Execute
_struct->on_audio_stream_started(_struct, CefBrowserCppToC::Wrap(browser),
&params, channels);
}
NO_SANITIZE("cfi-icall")
void CefAudioHandlerCToCpp::OnAudioStreamPacket(CefRefPtr<CefBrowser> browser,
const float** data,
int frames,
int64 pts) {
shutdown_checker::AssertNotShutdown();
cef_audio_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_audio_stream_packet))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: data; type: simple_byaddr
DCHECK(data);
if (!data)
return;
// Execute
_struct->on_audio_stream_packet(_struct, CefBrowserCppToC::Wrap(browser),
data, frames, pts);
}
NO_SANITIZE("cfi-icall")
void CefAudioHandlerCToCpp::OnAudioStreamStopped(
CefRefPtr<CefBrowser> browser) {
shutdown_checker::AssertNotShutdown();
cef_audio_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_audio_stream_stopped))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Execute
_struct->on_audio_stream_stopped(_struct, CefBrowserCppToC::Wrap(browser));
}
NO_SANITIZE("cfi-icall")
void CefAudioHandlerCToCpp::OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) {
shutdown_checker::AssertNotShutdown();
cef_audio_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_audio_stream_error))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Verify param: message; type: string_byref_const
DCHECK(!message.empty());
if (message.empty())
return;
// Execute
_struct->on_audio_stream_error(_struct, CefBrowserCppToC::Wrap(browser),
message.GetStruct());
}
// CONSTRUCTOR - Do not edit by hand.
CefAudioHandlerCToCpp::CefAudioHandlerCToCpp() {}
// DESTRUCTOR - Do not edit by hand.
CefAudioHandlerCToCpp::~CefAudioHandlerCToCpp() {
shutdown_checker::AssertNotShutdown();
}
template <>
cef_audio_handler_t*
CefCToCppRefCounted<CefAudioHandlerCToCpp,
CefAudioHandler,
cef_audio_handler_t>::UnwrapDerived(CefWrapperType type,
CefAudioHandler* c) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCToCppRefCounted<CefAudioHandlerCToCpp,
CefAudioHandler,
cef_audio_handler_t>::kWrapperType =
WT_AUDIO_HANDLER;

View File

@ -0,0 +1,51 @@
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=e5517ccac966337ef7dc576a24eedfe1154b2813$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_AUDIO_HANDLER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_AUDIO_HANDLER_CTOCPP_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_audio_handler_capi.h"
#include "include/cef_audio_handler.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefAudioHandlerCToCpp : public CefCToCppRefCounted<CefAudioHandlerCToCpp,
CefAudioHandler,
cef_audio_handler_t> {
public:
CefAudioHandlerCToCpp();
virtual ~CefAudioHandlerCToCpp();
// CefAudioHandler methods.
bool GetAudioParameters(CefRefPtr<CefBrowser> browser,
CefAudioParameters& params) override;
void OnAudioStreamStarted(CefRefPtr<CefBrowser> browser,
const CefAudioParameters& params,
int channels) override;
void OnAudioStreamPacket(CefRefPtr<CefBrowser> browser,
const float** data,
int frames,
int64 pts) override;
void OnAudioStreamStopped(CefRefPtr<CefBrowser> browser) override;
void OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_AUDIO_HANDLER_CTOCPP_H_

View File

@ -9,13 +9,14 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=cb91642733be3dfd60a0d848c41c71bbe06a835c$
// $hash=0e4556cf21b4d75aefbfa90963c6b5c9aba33bad$
//
#include "libcef_dll/ctocpp/client_ctocpp.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
#include "libcef_dll/ctocpp/audio_handler_ctocpp.h"
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
#include "libcef_dll/ctocpp/dialog_handler_ctocpp.h"
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
@ -32,6 +33,21 @@
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
CefRefPtr<CefAudioHandler> CefClientCToCpp::GetAudioHandler() {
cef_client_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_audio_handler))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_audio_handler_t* _retval = _struct->get_audio_handler(_struct);
// Return type: refptr_same
return CefAudioHandlerCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefContextMenuHandler> CefClientCToCpp::GetContextMenuHandler() {
cef_client_t* _struct = GetStruct();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=94a6eac6479bc8404b73ff49b581338ef198a0cc$
// $hash=f751ee624cc3b8570cba8caa051c51bb7aeccaa7$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_
@ -33,6 +33,7 @@ class CefClientCToCpp
virtual ~CefClientCToCpp();
// CefClient methods.
CefRefPtr<CefAudioHandler> GetAudioHandler() override;
CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() override;
CefRefPtr<CefDialogHandler> GetDialogHandler() override;
CefRefPtr<CefDisplayHandler> GetDisplayHandler() override;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=089392d929a9f7a3ca4fe7f53d63b98536505261$
// $hash=9bfe176dfac4770800e95e2bbc0fafffbf0aeeaf$
//
#ifndef CEF_LIBCEF_DLL_WRAPPER_TYPES_H_
@ -21,6 +21,7 @@ enum CefWrapperType {
WT_BASE_SCOPED,
WT_ACCESSIBILITY_HANDLER,
WT_APP,
WT_AUDIO_HANDLER,
WT_AUTH_CALLBACK,
WT_BEFORE_DOWNLOAD_CALLBACK,
WT_BINARY_VALUE,

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,10 @@ using client::ClientAppBrowser;
using client::ClientAppRenderer;
void CreateBrowserDelegates(ClientAppBrowser::DelegateSet& delegates) {
// Bring in audio output tests.
extern void CreateAudioOutputTests(ClientAppBrowser::DelegateSet & delegates);
CreateAudioOutputTests(delegates);
// Bring in the Navigation tests.
extern void CreateNavigationBrowserTests(ClientAppBrowser::DelegateSet &
delegates);

View File

@ -381,6 +381,7 @@ _simpletypes = {
'uint64': ['uint64', '0'],
'double': ['double', '0'],
'float': ['float', '0'],
'float*': ['float*', 'NULL'],
'long': ['long', '0'],
'unsigned long': ['unsigned long', '0'],
'long long': ['long long', '0'],
@ -404,6 +405,7 @@ _simpletypes = {
'CefDraggableRegion': ['cef_draggable_region_t', 'CefDraggableRegion()'],
'CefThreadId': ['cef_thread_id_t', 'TID_UI'],
'CefTime': ['cef_time_t', 'CefTime()'],
'CefAudioParameters': ['cef_audio_parameters_t', 'CefAudioParameters()']
}