can not get audio data by CefAudioHandler #453
WuCheng0912
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
//
// CefViewBrowserClient.h
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
#ifndef CefViewBrowserHandler_h
#define CefViewBrowserHandler_h
#pragma once
#pragma region stl_headers
#include
#include <unordered_map>
#pragma endregion
#include <CefViewCoreGlobal.h>
#include <CefViewBrowserApp.h>
#include <CefViewBrowserClientDelegate.h>
#if CEF_VERSION_MAJOR < 122
#define CEFVIEW_MAIN_FRAME (0)
#define CEFVIEW_ALL_FRAMES (-1)
#else
#define CEFVIEW_MAIN_FRAME ("0")
#define CEFVIEW_ALL_FRAMES ("-1")
#endif
///
/// Forward declaration
///
class CefViewQueryHandler;
///
///
///
class CefViewBrowserClient
: public CefClient
, public CefContextMenuHandler
, public CefDialogHandler
, public CefDisplayHandler
, public CefDownloadHandler
, public CefDragHandler
, public CefFindHandler
, public CefFocusHandler
, public CefJSDialogHandler
, public CefKeyboardHandler
, public CefLifeSpanHandler
, public CefLoadHandler
, public CefRequestHandler
, public CefResourceRequestHandler
, public CefRenderHandler
, public CefAudioHandler
{
IMPLEMENT_REFCOUNTING(CefViewBrowserClient);
private:
///
///
///
CefRefPtr app_;
///
///
///
CefViewBrowserClientDelegateInterface::WeakPtr client_delegate_;
// flags
bool is_closing_;
bool close_by_native_;
bool initial_navigation_;
// message router
CefMessageRouterConfig message_router_config_;
CefRefPtr message_router_;
CefRefPtr message_router_handler_;
// resource manager
CefRefPtr resource_manager_;
// browser map
std::unordered_map<int, CefRefPtr> browser_map_;
public:
///
///
///
///
///
CefViewBrowserClient(CefRefPtr app, CefViewBrowserClientDelegateInterface::RefPtr delegate);
///
///
///
~CefViewBrowserClient();
///
///
///
///
int GetBrowserCount() { return static_cast(browser_map_.size()); }
///
///
///
void CloseAllBrowsers();
///
///
///
///
///
///
void AddLocalDirectoryResourceProvider(const std::string& dir_path, const std::string& url, int priority = 0);
///
///
///
///
///
///
///
void AddArchiveResourceProvider(const std::string& archive_path,
const std::string& url,
const std::string& password,
int priority = 0);
bool TriggerEvent(CefRefPtr browser, const CefFrameId& frame_id, const CefRefPtr msg);
///
///
///
///
///
///
///
///
bool ResponseQuery(const int64_t query, bool success, const CefString& response, int error);
///
///
///
///
///
///
///
///
///
int64_t AsyncExecuteJSCode(CefRefPtr browser,
CefRefPtr frame,
const CefString& code,
const CefString& url,
const CefString& context);
protected:
bool DispatchRenderMessage(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr message);
bool OnRenderFocusedNodeChangedMessage(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr message);
bool OnRenderInvokeMethodMessage(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr message);
bool OnRenderReportJSResultMessage(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr message);
// CefClient methods:
#pragma region CefContextMenuHandler
virtual bool OnProcessMessageReceived(CefRefPtr browser,
CefRefPtr frame,
CefProcessId source_process,
CefRefPtr message) override;
#pragma endregion
// CefContextMenuHandler methods
#pragma region CefContextMenuHandler
virtual CefRefPtr GetContextMenuHandler() override;
virtual void OnBeforeContextMenu(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr params,
CefRefPtr model) override;
virtual bool RunContextMenu(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr params,
CefRefPtr model,
CefRefPtr callback) override;
virtual bool OnContextMenuCommand(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr params,
int command_id,
EventFlags event_flags) override;
virtual void OnContextMenuDismissed(CefRefPtr browser, CefRefPtr frame) override;
#pragma endregion
// CefDialogHandler
#pragma region CefDialogHandler
virtual CefRefPtr GetDialogHandler() override;
#if CEF_VERSION_MAJOR < 102
virtual bool OnFileDialog(CefRefPtr browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector& accept_filters,
int selected_accept_filter,
CefRefPtr callback) override;
#elif CEF_VERSION_MAJOR < 126
virtual bool OnFileDialog(CefRefPtr browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector& accept_filters,
CefRefPtr callback) override;
#else
virtual bool OnFileDialog(CefRefPtr browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector& accept_filters,
const std::vector& accept_extensions,
const std::vector& accept_descriptions,
CefRefPtr callback) override;
#endif
#pragma endregion
// CefDisplayHandler methods
#pragma region CefDisplayHandler
virtual CefRefPtr GetDisplayHandler() override;
virtual void OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) override;
virtual void OnTitleChange(CefRefPtr browser, const CefString& title) override;
virtual void OnFaviconURLChange(CefRefPtr browser, const std::vector& icon_urls) override;
virtual void OnFullscreenModeChange(CefRefPtr browser, bool fullscreen) override;
virtual bool OnTooltip(CefRefPtr browser, CefString& text) override;
virtual void OnStatusMessage(CefRefPtr browser, const CefString& value) override;
virtual bool OnConsoleMessage(CefRefPtr browser,
cef_log_severity_t level,
const CefString& message,
const CefString& source,
int line) override;
virtual bool OnAutoResize(CefRefPtr browser, const CefSize& new_size) override;
virtual void OnLoadingProgressChange(CefRefPtr browser, double progress) override;
virtual bool OnCursorChange(CefRefPtr browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) override;
#pragma endregion
// CefDownloadHandler
#pragma region CefDownloadHandler
virtual CefRefPtr GetDownloadHandler() override;
#if CEF_VERSION_MAJOR < 125
virtual void OnBeforeDownload(CefRefPtr browser,
CefRefPtr download_item,
const CefString& suggested_name,
CefRefPtr callback) override;
#else
virtual bool OnBeforeDownload(CefRefPtr browser,
CefRefPtr download_item,
const CefString& suggested_name,
CefRefPtr callback) override;
#endif
void OnDownloadUpdated(CefRefPtr browser,
CefRefPtr download_item,
CefRefPtr callback) override;
#pragma endregion
// CefDragHandler methods
#pragma region CefDragHandler
virtual CefRefPtr GetDragHandler() override;
virtual bool OnDragEnter(CefRefPtr browser,
CefRefPtr dragData,
CefDragHandler::DragOperationsMask mask) override;
virtual void OnDraggableRegionsChanged(CefRefPtr browser,
CefRefPtr frame,
const std::vector& regions) override;
#pragma endregion
// CefFindHandler methods
#pragma region CefDragHandler
virtual CefRefPtr GetFindHandler() override;
virtual void OnFindResult(CefRefPtr browser,
int identifier,
int count,
const CefRect& selectionRect,
int activeMatchOrdinal,
bool finalUpdate) override;
#pragma endregion
// CefFocusHandler methods
#pragma region CefFocusHandler
virtual CefRefPtr GetFocusHandler() override;
void OnTakeFocus(CefRefPtr browser, bool next) override;
bool OnSetFocus(CefRefPtr browser, FocusSource source) override;
void OnGotFocus(CefRefPtr browser) override;
#pragma endregion
// CefJSDialogHandler methods
#pragma region CefJSDialogHandler
virtual CefRefPtr GetJSDialogHandler() override;
virtual bool OnJSDialog(CefRefPtr browser,
const CefString& origin_url,
JSDialogType dialog_type,
const CefString& message_text,
const CefString& default_prompt_text,
CefRefPtr callback,
bool& suppress_message) override;
virtual bool OnBeforeUnloadDialog(CefRefPtr browser,
const CefString& message_text,
bool is_reload,
CefRefPtr callback) override;
virtual void OnResetDialogState(CefRefPtr browser) override;
#pragma endregion
// CefKeyboardHandler methods
#pragma region CefKeyboardHandler
virtual CefRefPtr GetKeyboardHandler() override;
virtual bool OnPreKeyEvent(CefRefPtr browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) override;
virtual bool OnKeyEvent(CefRefPtr browser, const CefKeyEvent& event, CefEventHandle os_event) override;
#pragma endregion
// CefLifeSpanHandler methods:
#pragma region CefLifeSpanHandler
virtual CefRefPtr GetLifeSpanHandler() override;
virtual bool OnBeforePopup(CefRefPtr browser,
CefRefPtr frame,
const CefString& target_url,
const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr& client,
CefBrowserSettings& settings,
CefRefPtr& extra_info,
bool* no_javascript_access) override;
virtual void OnAfterCreated(CefRefPtr browser) override;
virtual bool DoClose(CefRefPtr browser) override;
virtual void OnBeforeClose(CefRefPtr browser) override;
#pragma endregion
// CefLoadHandler methods
#pragma region CefLoadHandler
virtual CefRefPtr GetLoadHandler() override;
virtual void OnLoadingStateChange(CefRefPtr browser,
bool isLoading,
bool canGoBack,
bool canGoForward) override;
virtual void OnLoadStart(CefRefPtr browser,
CefRefPtr frame,
TransitionType transition_type) override;
virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) override;
virtual void OnLoadError(CefRefPtr browser,
CefRefPtr frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) override;
#pragma endregion
// CefRenderHandler
#pragma region CefRenderHandler
virtual CefRefPtr GetRenderHandler() override;
virtual CefRefPtr GetAccessibilityHandler() override;
virtual bool GetRootScreenRect(CefRefPtr browser, CefRect& rect) override;
virtual void GetViewRect(CefRefPtr browser, CefRect& rect) override;
virtual bool GetScreenPoint(CefRefPtr browser, int viewX, int viewY, int& screenX, int& screenY) override;
virtual bool GetScreenInfo(CefRefPtr browser, CefScreenInfo& screen_info) override;
virtual void OnPopupShow(CefRefPtr browser, bool show) override;
virtual void OnPopupSize(CefRefPtr browser, const CefRect& rect) override;
virtual void OnPaint(CefRefPtr browser,
PaintElementType type,
const RectList& dirtyRects,
const void* buffer,
int width,
int height) override;
#if CEF_VERSION_MAJOR < 124
virtual void OnAcceleratedPaint(CefRefPtr browser,
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) override;
#else
virtual void OnAcceleratedPaint(CefRefPtr browser,
PaintElementType type,
const RectList& dirtyRects,
const CefAcceleratedPaintInfo& info) override;
#endif
virtual bool StartDragging(CefRefPtr browser,
CefRefPtr drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
int x,
int y) override;
virtual void UpdateDragCursor(CefRefPtr browser, DragOperation operation) override;
virtual void OnScrollOffsetChanged(CefRefPtr browser, double x, double y) override;
virtual void OnImeCompositionRangeChanged(CefRefPtr browser,
const CefRange& selected_range,
const RectList& character_bounds) override;
virtual void OnTextSelectionChanged(CefRefPtr browser,
const CefString& selected_text,
const CefRange& selected_range) override;
virtual void OnVirtualKeyboardRequested(CefRefPtr browser, TextInputMode input_mode) override;
#pragma endregion
// CefRequestHandler methods
#pragma region CefRequestHandler
virtual CefRefPtr GetRequestHandler() override;
virtual bool OnBeforeBrowse(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr request,
bool user_gesture,
bool is_redirect) override;
virtual bool OnOpenURLFromTab(CefRefPtr browser,
CefRefPtr frame,
const CefString& target_url,
CefRequestHandler::WindowOpenDisposition target_disposition,
bool user_gesture) override;
#if CEF_VERSION_MAJOR > 91 && CEF_VERSION_MAJOR < 109
virtual bool OnQuotaRequest(CefRefPtr browser,
const CefString& origin_url,
int64 new_size,
CefRefPtr callback) override;
#endif
#if CEF_VERSION_MAJOR < 124
virtual void OnRenderProcessTerminated(CefRefPtr browser, TerminationStatus status) override;
#else
virtual void OnRenderProcessTerminated(CefRefPtr browser,
TerminationStatus status,
int error_code,
const CefString& error_string) override;
#endif
#pragma endregion
// CefResourceRequestHandler
#pragma region CefResourceRequestHandler
virtual CefRefPtr GetResourceRequestHandler(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr request,
bool is_navigation,
bool is_download,
const CefString& request_initiator,
bool& disable_default_handling) override;
virtual ReturnValue OnBeforeResourceLoad(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr request,
#if CEF_VERSION_MAJOR > 91
CefRefPtr callback
#else
CefRefPtr callback
#endif
) override;
virtual CefRefPtr GetResourceHandler(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr request) override;
virtual void OnProtocolExecution(CefRefPtr browser,
CefRefPtr frame,
CefRefPtr request,
bool& allow_os_execution) override;
#pragma endregion
//CefAudioHandler
#pragma region CefAudioHandler
virtual bool GetAudioParameters(CefRefPtr browser, CefAudioParameters& params) override;
virtual void OnAudioStreamStarted(CefRefPtr browser, const CefAudioParameters& params, int channels) override;
virtual void OnAudioStreamPacket(CefRefPtr browser, const float** data, int frames, int64_t pos) override;
virtual void OnAudioStreamStopped(CefRefPtr browser) override;
virtual void OnAudioStreamError(CefRefPtr browser, const CefString& message) override;
#pragma endregion
};
#endif
Beta Was this translation helpful? Give feedback.
All reactions