From ae64f36e77c61551ebfa61be99b21959ccc88e61 Mon Sep 17 00:00:00 2001 From: tengfan Date: Tue, 24 Dec 2024 10:42:02 +0800 Subject: [PATCH] optimize stop screen capture Signed-off-by: tengfan --- include/capi/cef_browser_capi.h | 1 + include/cef_browser.h | 2 +- libcef/browser/browser_host_base.cc | 4 +-- libcef/browser/browser_host_base.h | 2 +- libcef_dll/cpptoc/browser_host_cpptoc.cc | 3 ++- .../cpptoc/screen_capture_callback_cpptoc.cc | 27 ++++++++++--------- .../cpptoc/screen_capture_callback_cpptoc.h | 27 ++++++++++--------- libcef_dll/ctocpp/browser_host_ctocpp.cc | 4 +-- libcef_dll/ctocpp/browser_host_ctocpp.h | 2 +- .../ctocpp/screen_capture_callback_ctocpp.cc | 27 ++++++++++--------- .../ctocpp/screen_capture_callback_ctocpp.h | 27 ++++++++++--------- 11 files changed, 66 insertions(+), 60 deletions(-) diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index e6c4bfdbc..1a4bc62ef 100644 --- a/include/capi/cef_browser_capi.h +++ b/include/capi/cef_browser_capi.h @@ -2175,6 +2175,7 @@ typedef struct _cef_browser_host_t { /// Close current screen capture. /// void(CEF_CALLBACK* stop_screen_capture)(struct _cef_browser_host_t* self, + int32_t nweb_id, const cef_string_t* session_id); /// diff --git a/include/cef_browser.h b/include/cef_browser.h index 37441c11c..2b9704587 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -2175,7 +2175,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// Close current screen capture. /// /*--cef()--*/ - virtual void StopScreenCapture(const CefString& session_id) = 0; + virtual void StopScreenCapture(int32_t nweb_id, const CefString& session_id) = 0; /// /// Register screen capture listener. diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index dcbec5610..6db45dd44 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -706,7 +706,7 @@ void CefBrowserHostBase::CreateToPDF(const CefPdfPrintSettings& settings, } -void CefBrowserHostBase::StopScreenCapture(const CefString& session_id) { +void CefBrowserHostBase::StopScreenCapture(int32_t nweb_id, const CefString& session_id) { #if defined(OHOS_EX_SCREEN_CAPTURE) auto web_contents = GetWebContents(); if (!web_contents) { @@ -714,7 +714,7 @@ void CefBrowserHostBase::StopScreenCapture(const CefString& session_id) { return; } std::string session_id_str = session_id; - web_contents->StopScreenCapture(session_id_str); + web_contents->StopScreenCapture(nweb_id, session_id_str); #endif // defined(OHOS_EX_SCREEN_CAPTURE) } diff --git a/libcef/browser/browser_host_base.h b/libcef/browser/browser_host_base.h index 2a69f1ea4..8fdfcd80b 100644 --- a/libcef/browser/browser_host_base.h +++ b/libcef/browser/browser_host_base.h @@ -353,7 +353,7 @@ class CefBrowserHostBase : public CefBrowserHost, void StartCamera() override; void StopCamera() override; void CloseCamera() override; - void StopScreenCapture(const CefString& session_id) override; + void StopScreenCapture(int32_t nweb_id, const CefString& session_id) override; void RegisterScreenCaptureDelegateListener( CefRefPtr listener) override; diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index 0cca028d0..ad9fb939e 100644 --- a/libcef_dll/cpptoc/browser_host_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_host_cpptoc.cc @@ -3997,6 +3997,7 @@ browser_host_execute_video_assistant_function(struct _cef_browser_host_t* self, void CEF_CALLBACK browser_host_stop_screen_capture(struct _cef_browser_host_t* self, + int32_t nweb_id, const cef_string_t* session_id) { shutdown_checker::AssertNotShutdown(); @@ -4013,7 +4014,7 @@ browser_host_stop_screen_capture(struct _cef_browser_host_t* self, } // Execute - CefBrowserHostCppToC::Get(self)->StopScreenCapture(CefString(session_id)); + CefBrowserHostCppToC::Get(self)->StopScreenCapture(nweb_id, CefString(session_id)); } void CEF_CALLBACK browser_host_register_screen_capture_delegate_listener( diff --git a/libcef_dll/cpptoc/screen_capture_callback_cpptoc.cc b/libcef_dll/cpptoc/screen_capture_callback_cpptoc.cc index e64049a01..ff748cde4 100644 --- a/libcef_dll/cpptoc/screen_capture_callback_cpptoc.cc +++ b/libcef_dll/cpptoc/screen_capture_callback_cpptoc.cc @@ -1,16 +1,17 @@ -// Copyright (c) 2024 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=8b0caf995ec0310a520beda6c86211ed6723ccef$ -// +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "libcef_dll/cpptoc/screen_capture_callback_cpptoc.h" #include "libcef_dll/shutdown_checker.h" diff --git a/libcef_dll/cpptoc/screen_capture_callback_cpptoc.h b/libcef_dll/cpptoc/screen_capture_callback_cpptoc.h index 099b19cfc..1f4ffb9b6 100644 --- a/libcef_dll/cpptoc/screen_capture_callback_cpptoc.h +++ b/libcef_dll/cpptoc/screen_capture_callback_cpptoc.h @@ -1,16 +1,17 @@ -// Copyright (c) 2024 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=991b8b66513d85cb57a7ccdc33f67502ab0d9be2$ -// +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CEF_LIBCEF_DLL_CPPTOC_SCREEN_CAPTURE_CALLBACK_CPPTOC_H_ #define CEF_LIBCEF_DLL_CPPTOC_SCREEN_CAPTURE_CALLBACK_CPPTOC_H_ diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index 50af46a9c..35cac99e9 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_host_ctocpp.cc @@ -3690,7 +3690,7 @@ void CefBrowserHostCToCpp::ExecuteVideoAssistantFunction( } NO_SANITIZE("cfi-icall") -void CefBrowserHostCToCpp::StopScreenCapture(const CefString& session_id) { +void CefBrowserHostCToCpp::StopScreenCapture(int32_t nweb_id, const CefString& session_id) { shutdown_checker::AssertNotShutdown(); cef_browser_host_t* _struct = GetStruct(); @@ -3707,7 +3707,7 @@ void CefBrowserHostCToCpp::StopScreenCapture(const CefString& session_id) { } // Execute - _struct->stop_screen_capture(_struct, session_id.GetStruct()); + _struct->stop_screen_capture(_struct, nweb_id, session_id.GetStruct()); } NO_SANITIZE("cfi-icall") diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.h b/libcef_dll/ctocpp/browser_host_ctocpp.h index b218480f3..ec14e58cb 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.h +++ b/libcef_dll/ctocpp/browser_host_ctocpp.h @@ -327,7 +327,7 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted listener) override; }; diff --git a/libcef_dll/ctocpp/screen_capture_callback_ctocpp.cc b/libcef_dll/ctocpp/screen_capture_callback_ctocpp.cc index 238e3fe91..caa1c96bf 100644 --- a/libcef_dll/ctocpp/screen_capture_callback_ctocpp.cc +++ b/libcef_dll/ctocpp/screen_capture_callback_ctocpp.cc @@ -1,16 +1,17 @@ -// Copyright (c) 2024 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=b516314ad82c4737d78dc8aaf6cf687881b4be35$ -// +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "libcef_dll/ctocpp/screen_capture_callback_ctocpp.h" #include "libcef_dll/shutdown_checker.h" diff --git a/libcef_dll/ctocpp/screen_capture_callback_ctocpp.h b/libcef_dll/ctocpp/screen_capture_callback_ctocpp.h index dd7161294..1eb2427af 100644 --- a/libcef_dll/ctocpp/screen_capture_callback_ctocpp.h +++ b/libcef_dll/ctocpp/screen_capture_callback_ctocpp.h @@ -1,16 +1,17 @@ -// Copyright (c) 2024 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=d57b8cc988e52957eac21d44e6e3a84a35a5cf31$ -// +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CEF_LIBCEF_DLL_CTOCPP_SCREEN_CAPTURE_CALLBACK_CTOCPP_H_ #define CEF_LIBCEF_DLL_CTOCPP_SCREEN_CAPTURE_CALLBACK_CTOCPP_H_ -- Gitee