Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
angular-react-vue
Browse files Browse the repository at this point in the history
Upgraded to Chromium/CefGlue v83.
  • Loading branch information
mattkol committed Jul 22, 2020
1 parent 99aa50f commit 0f6a83e
Show file tree
Hide file tree
Showing 43 changed files with 1,659 additions and 356 deletions.
15 changes: 1 addition & 14 deletions src/Chromely.CefGlue/Browser/CefGlueBrowser.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CefGlueBrowser.cs" company="Chromely Projects">
// Copyright (c) 2017-2019 Chromely Projects
// </copyright>
// <license>
// See the LICENSE.md file in the project root for more information.
// </license>
// ----------------------------------------------------------------------------------------------------------------------

using System;
using System;
using System.Reflection;
using Chromely.CefGlue.Browser.EventParams;
using Chromely.Core;
using Chromely.Core.Configuration;
using Chromely.Core.Network;
using Xilium.CefGlue;
using Xilium.CefGlue.Wrapper;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
// ReSharper disable UnusedMember.Global

namespace Chromely.CefGlue.Browser
{
Expand Down
99 changes: 64 additions & 35 deletions src/Chromely.CefGlue/CefGlue/Classes.Handlers/CefAudioHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
//
// Feature removed since CEF 77.
//
/*
namespace Xilium.CefGlue
namespace Xilium.CefGlue
{
using System;
using System.Collections.Generic;
Expand All @@ -16,64 +12,97 @@ namespace Xilium.CefGlue
/// </summary>
public abstract unsafe partial class CefAudioHandler
{
private void on_audio_stream_started(cef_audio_handler_t* self, cef_browser_t* browser, int audio_stream_id, int channels, CefChannelLayout channel_layout, int sample_rate, int frames_per_buffer)
private int get_audio_parameters(cef_audio_handler_t* self, cef_browser_t* browser, cef_audio_parameters_t* @params)
{
CheckSelf(self);

var mBrowser = CefBrowser.FromNative(browser);
OnAudioStreamStarted(mBrowser, audio_stream_id, channels, channel_layout, sample_rate, frames_per_buffer);

var mResult = GetAudioParameters(mBrowser, new CefAudioParameters(@params));
return mResult ? 1 : 0;
}

/// <summary>
/// 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.
/// </summary>
protected abstract bool GetAudioParameters(CefBrowser browser, CefAudioParameters parameters);


private void on_audio_stream_started(cef_audio_handler_t* self, cef_browser_t* browser, cef_audio_parameters_t* @params, int channels)
{
CheckSelf(self);

var mBrowser = CefBrowser.FromNative(browser);
OnAudioStreamStarted(mBrowser, new CefAudioParameters(@params), channels);
}

/// <summary>
/// Called when the stream identified by |audio_stream_id| has started.
/// |audio_stream_id| will uniquely identify the stream across all future
/// CefAudioHandler callbacks. OnAudioSteamStopped will always be called after
/// OnAudioStreamStarted; both methods may be called multiple times for the
/// same stream. |channels| is the number of channels, |channel_layout| is the
/// layout of the channels and |sample_rate| is the stream sample rate.
/// |frames_per_buffer| is the maximum number of frames that will occur in the
/// PCM packet passed to OnAudioStreamPacket.
/// 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.
/// </summary>
protected abstract void OnAudioStreamStarted(CefBrowser browser, int audioStreamId, int channels, CefChannelLayout channelLayout, int sampleRate, int framesPerBuffer);
protected abstract void OnAudioStreamStarted(CefBrowser browser, in CefAudioParameters parameters, int channels);


private void on_audio_stream_packet(cef_audio_handler_t* self, cef_browser_t* browser, int audio_stream_id, float** data, int frames, long pts)
private void on_audio_stream_packet(cef_audio_handler_t* self, cef_browser_t* browser, float** data, int frames, long pts)
{
CheckSelf(self);

var mBrowser = CefBrowser.FromNative(browser);
OnAudioStreamPacket(mBrowser, audio_stream_id, (IntPtr)data, frames, pts);
OnAudioStreamPacket(mBrowser, (IntPtr)data, frames, pts);
}

/// <summary>
/// Called when a PCM packet is received for the stream identified by
/// |audio_stream_id|. |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.
/// 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.
///
/// |data| type is |float**|
/// |data| is |float**|, readonly!
/// </summary>
protected abstract void OnAudioStreamPacket(CefBrowser browser, IntPtr data, int frames, long pts);


private void on_audio_stream_stopped(cef_audio_handler_t* self, cef_browser_t* browser)
{
CheckSelf(self);

var mBrowser = CefBrowser.FromNative(browser);
OnAudioStreamStopped(mBrowser);
}

/// <summary>
/// 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.
/// </summary>
protected abstract void OnAudioStreamPacket(CefBrowser browser, int audioStreamId, IntPtr data, int frames, long pts);
protected abstract void OnAudioStreamStopped(CefBrowser browser);


private void on_audio_stream_stopped(cef_audio_handler_t* self, cef_browser_t* browser, int audio_stream_id)
private void on_audio_stream_error(cef_audio_handler_t* self, cef_browser_t* browser, cef_string_t* message)
{
CheckSelf(self);

var mBrowser = CefBrowser.FromNative(browser);
OnAudioStreamStopped(mBrowser, audio_stream_id);
var mMessage = cef_string_t.ToString(message);
OnAudioStreamError(mBrowser, mMessage);
}

/// <summary>
/// Called when the stream identified by |audio_stream_id| has stopped.
/// OnAudioSteamStopped will always be called after OnAudioStreamStarted; both
/// methods may be called multiple times for the same stream.
/// 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.
/// </summary>
protected abstract void OnAudioStreamStopped(CefBrowser browser, int audioStreamId);
protected abstract void OnAudioStreamError(CefBrowser browser, string message);
}
}
*/
31 changes: 14 additions & 17 deletions src/Chromely.CefGlue/CefGlue/Classes.Handlers/CefClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@

public abstract unsafe partial class CefClient
{
//
// Feature removed since CEF 77.
//
//private cef_audio_handler_t* get_audio_handler(cef_client_t* self)
//{
// CheckSelf(self);
// var result = GetAudioHandler();
// return result != null ? result.ToNative() : null;
//}
//
///// <summary>
///// Return the handler for audio rendering events.
///// </summary>
//protected virtual CefAudioHandler GetAudioHandler()
//{
// return null;
//}
private cef_audio_handler_t* get_audio_handler(cef_client_t* self)
{
CheckSelf(self);
var result = GetAudioHandler();
return result != null ? result.ToNative() : null;
}

/// <summary>
/// Return the handler for audio rendering events.
/// </summary>
protected virtual CefAudioHandler GetAudioHandler()
{
return null;
}


private cef_context_menu_handler_t* get_context_menu_handler(cef_client_t* self)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
namespace Xilium.CefGlue
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Xilium.CefGlue.Interop;

/// <summary>
/// Callback interface for CefBrowserHost::AddDevToolsMessageObserver. The
/// methods of this class will be called on the browser process UI thread.
/// </summary>
public abstract unsafe partial class CefDevToolsMessageObserver
{
private int on_dev_tools_message(cef_dev_tools_message_observer_t* self, cef_browser_t* browser, void* message, UIntPtr message_size)
{
CheckSelf(self);

var m_browser = CefBrowser.FromNative(browser);

var m_result = OnDevToolsMessage(m_browser, (IntPtr)message, checked((int)message_size));

return m_result ? 1 : 0;
}

/// <summary>
/// Method that will be called on receipt of a DevTools protocol message.
/// |browser| is the originating browser instance. |message| is a UTF8-encoded
/// JSON dictionary representing either a method result or an event. |message|
/// is only valid for the scope of this callback and should be copied if
/// necessary. Return true if the message was handled or false if the message
/// should be further processed and passed to the OnDevToolsMethodResult or
/// OnDevToolsEvent methods as appropriate.
/// Method result dictionaries include an "id" (int) value that identifies the
/// orginating method call sent from CefBrowserHost::SendDevToolsMessage, and
/// optionally either a "result" (dictionary) or "error" (dictionary) value.
/// The "error" dictionary will contain "code" (int) and "message" (string)
/// values. Event dictionaries include a "method" (string) value and optionally
/// a "params" (dictionary) value. See the DevTools protocol documentation at
/// https://chromedevtools.github.io/devtools-protocol/ for details of
/// supported method calls and the expected "result" or "params" dictionary
/// contents. JSON dictionaries can be parsed using the CefParseJSON function
/// if desired, however be aware of performance considerations when parsing
/// large messages (some of which may exceed 1MB in size).
/// </summary>
protected abstract bool OnDevToolsMessage(CefBrowser browser, IntPtr message, int messageSize);


private void on_dev_tools_method_result(cef_dev_tools_message_observer_t* self, cef_browser_t* browser, int message_id, int success, void* result, UIntPtr result_size)
{
CheckSelf(self);

var m_browser = CefBrowser.FromNative(browser);

OnDevToolsMethodResult(m_browser, message_id, success != 0, (IntPtr)result, checked((int)result_size));
}

/// <summary>
/// Method that will be called after attempted execution of a DevTools protocol
/// method. |browser| is the originating browser instance. |message_id| is the
/// "id" value that identifies the originating method call message. If the
/// method succeeded |success| will be true and |result| will be the
/// UTF8-encoded JSON "result" dictionary value (which may be empty). If the
/// method failed |success| will be false and |result| will be the UTF8-encoded
/// JSON "error" dictionary value. |result| is only valid for the scope of this
/// callback and should be copied if necessary. See the OnDevToolsMessage
/// documentation for additional details on |result| contents.
/// </summary>
protected abstract void OnDevToolsMethodResult(CefBrowser browser, int messageId, bool success, IntPtr result, int resultSize);


private void on_dev_tools_event(cef_dev_tools_message_observer_t* self, cef_browser_t* browser, cef_string_t* method, void* @params, UIntPtr params_size)
{
CheckSelf(self);

var m_browser = CefBrowser.FromNative(browser);
var m_method = cef_string_t.ToString(method);

OnDevToolsEvent(m_browser, m_method, (IntPtr)@params, checked((int)params_size));
}

/// <summary>
/// Method that will be called on receipt of a DevTools protocol event.
/// |browser| is the originating browser instance. |method| is the "method"
/// value. |params| is the UTF8-encoded JSON "params" dictionary value (which
/// may be empty). |params| is only valid for the scope of this callback and
/// should be copied if necessary. See the OnDevToolsMessage documentation for
/// additional details on |params| contents.
/// </summary>
protected abstract void OnDevToolsEvent(CefBrowser browser, string method, IntPtr parameters, int parametersSize);


private void on_dev_tools_agent_attached(cef_dev_tools_message_observer_t* self, cef_browser_t* browser)
{
CheckSelf(self);

var m_browser = CefBrowser.FromNative(browser);

OnDevToolsAgentAttached(m_browser);
}

/// <summary>
/// Method that will be called when the DevTools agent has attached. |browser|
/// is the originating browser instance. This will generally occur in response
/// to the first message sent while the agent is detached.
/// </summary>
protected abstract void OnDevToolsAgentAttached(CefBrowser browser);


private void on_dev_tools_agent_detached(cef_dev_tools_message_observer_t* self, cef_browser_t* browser)
{
CheckSelf(self);

var m_browser = CefBrowser.FromNative(browser);

OnDevToolsAgentDetached(m_browser);
}

/// <summary>
/// Method that will be called when the DevTools agent has detached. |browser|
/// is the originating browser instance. Any method results that were pending
/// before the agent became detached will not be delivered, and any active
/// event subscriptions will be canceled.
/// </summary>
protected abstract void OnDevToolsAgentDetached(CefBrowser browser);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Xilium.CefGlue
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Xilium.CefGlue.Interop;

/// <summary>
/// Callback interface for CefMediaSink::GetDeviceInfo. The methods of this
/// class will be called on the browser process UI thread.
/// </summary>
public abstract unsafe partial class CefMediaSinkDeviceInfoCallback
{
private void on_media_sink_device_info(cef_media_sink_device_info_callback_t* self, cef_media_sink_device_info_t* device_info)
{
CheckSelf(self);

var mIPAddress = cef_string_t.ToString(&device_info->ip_address);
var mModelName = cef_string_t.ToString(&device_info->model_name);

var mDeviceInfo = new CefMediaSinkDeviceInfo(
ipAddress: mIPAddress,
port: device_info->port,
modelName: mModelName);

OnMediaSinkDeviceInfo(in mDeviceInfo);
}

/// <summary>
/// Method that will be executed asyncronously once device information has been
/// retrieved.
/// </summary>
protected abstract void OnMediaSinkDeviceInfo(in CefMediaSinkDeviceInfo deviceInfo);
}
}
18 changes: 18 additions & 0 deletions src/Chromely.CefGlue/CefGlue/Classes.Handlers/CefRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,23 @@ private void on_render_process_terminated(cef_request_handler_t* self, cef_brows
protected virtual void OnRenderProcessTerminated(CefBrowser browser, CefTerminationStatus status)
{
}


private void on_document_available_in_main_frame(cef_request_handler_t* self, cef_browser_t* browser)
{
CheckSelf(self);

var m_browser = CefBrowser.FromNative(browser);

OnDocumentAvailableInMainFrame(m_browser);
}

/// <summary>
/// Called on the browser process UI thread when the window.document object of
/// the main frame has been created.
/// </summary>
protected virtual void OnDocumentAvailableInMainFrame(CefBrowser browser)
{
}
}
}
Loading

0 comments on commit 0f6a83e

Please sign in to comment.