| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
void RunCapturerTask(R (webrtc::DesktopCapturer::*method)(Args...),Can you add a comment on this method to indicate why it is useful, essentially that it allows callers to set capture params before the underlying capturer has been created.
bool capturer_set_ = false;Can you continue to check whether `capturer_` is null rather than introduce the `capturer_set_` member? I don't think it's valid to to set capturer_ to null via the setter and it looks like capturer_ is not released before desctruction.
(capturer_.get()->*method)(std::forward<Args>(args)...);Is `capturer_->*method` valid here? Or is .get() required due to templating?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
void RunCapturerTask(R (webrtc::DesktopCapturer::*method)(Args...),Can you add a comment on this method to indicate why it is useful, essentially that it allows callers to set capture params before the underlying capturer has been created.
Done
Can you continue to check whether `capturer_` is null rather than introduce the `capturer_set_` member? I don't think it's valid to to set capturer_ to null via the setter and it looks like capturer_ is not released before desctruction.
Done. The code in [LegacyInteractionStrategy](https://source.chromium.org/chromium/chromium/src/+/main:remoting/host/legacy_interaction_strategy.cc;l=121;drc=cd4d28a2c2add65c76bb3252dc28370982577e33) suggests that the capturer could potentially be null, but there is no way it can work with a null capturer, so I just changed it to log at DFATAL level.
(capturer_.get()->*method)(std::forward<Args>(args)...);Is `capturer_->*method` valid here? Or is .get() required due to templating?
`->*` is actually a single operator, and the current C++ spec doesn't support overloading it.
FWIW this template isn't going to work once I replace `webrtc::DesktopCapturer` with `remoting::DesktopCapturer` in this file, so I'm replacing it with `std::invocable` and `std::invoke` in this CL. The latter does not require getting the raw pointer.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
5 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: remoting/host/desktop_capturer_proxy.cc
Insertions: 21, Deletions: 19.
@@ -65,14 +65,17 @@
void OnCaptureResult(webrtc::DesktopCapturer::Result result,
std::unique_ptr<webrtc::DesktopFrame> frame) override;
- template <typename R, typename... Args>
- void RunCapturerTask(R (webrtc::DesktopCapturer::*method)(Args...),
- typename std::decay<Args>::type&&... args);
+ // Either runs the capturer task right away if it is set, or queue it so that
+ // it can be run after the underlying capturer is created. This is to allow
+ // callers to set capture params before the underlying capturer has been
+ // created.
+ template <typename F, typename... Args>
+ requires std::invocable<F, webrtc::DesktopCapturer*, Args...>
+ void RunCapturerTask(F&& method, Args&&... args);
base::WeakPtr<DesktopCapturerProxy> proxy_;
scoped_refptr<base::SequencedTaskRunner> caller_task_runner_;
std::unique_ptr<webrtc::DesktopCapturer> capturer_;
- bool capturer_set_ = false;
// Tasks to be run after `capturer_` is set.
base::queue<base::OnceCallback<void(webrtc::DesktopCapturer*)>>
@@ -95,11 +98,13 @@
void DesktopCapturerProxy::Core::SetCapturer(
std::unique_ptr<webrtc::DesktopCapturer> capturer) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- DCHECK(!capturer_set_);
DCHECK(!capturer_);
capturer_ = std::move(capturer);
- capturer_set_ = true;
+ if (!capturer_) {
+ LOG(DFATAL) << "Trying to set the underlying capturer to null.";
+ return;
+ }
while (!pending_tasks_.empty()) {
if (capturer_) {
std::move(pending_tasks_.front()).Run(capturer_.get());
@@ -177,25 +182,22 @@
result, std::move(frame)));
}
-template <typename R, typename... Args>
-void DesktopCapturerProxy::Core::RunCapturerTask(
- R (webrtc::DesktopCapturer::*method)(Args...),
- typename std::decay<Args>::type&&... args) {
+template <typename F, typename... Args>
+ requires std::invocable<F, webrtc::DesktopCapturer*, Args...>
+void DesktopCapturerProxy::Core::RunCapturerTask(F&& method, Args&&... args) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- if (capturer_set_) {
- if (capturer_) {
- (capturer_.get()->*method)(std::forward<Args>(args)...);
- }
+ if (capturer_) {
+ std::invoke(std::forward<F>(method), capturer_,
+ std::forward<Args>(args)...);
return;
}
pending_tasks_.push(base::BindOnce(
- [](R (webrtc::DesktopCapturer::*method)(Args...),
- typename std::decay<Args>::type&&... args,
- webrtc::DesktopCapturer* capturer) {
- (capturer->*method)(std::forward<Args>(args)...);
+ [](F&& method, Args&&... args, webrtc::DesktopCapturer* capturer) {
+ std::invoke(std::forward<F>(method), capturer,
+ std::forward<Args>(args)...);
},
- method, std::forward<Args>(args)...));
+ std::forward<F>(method), std::forward<Args>(args)...));
}
DesktopCapturerProxy::DesktopCapturerProxy(
```
[crd host][linux] Fix issues with DesktopCapturerProxy
GnomeInteractionStrategy uses DesktopCapturerProxy to allow a
DesktopCapturer to be created and returned to the caller before the
underlying PipeWire capturer is create, but the logic appears to be
problematic. `set_capturer` is not allowed after `Start` is called, and
the DesktopCapturer will be transferred to WebRtcVideoStream, which runs
tasks in a dedicated thread, so it is not safe to access its WeakPtr
from the thread of GnomeInteractionStrategy, which is the network
thread. The current logic doesn't seem to have issues with the
single-process Wayland host, but it fails a DCHECK with the
multi-process Wayland host.
This CL fixes this by making DesktopCaptureProxy::Core store pending
tasks and execute them after the underlying capturer is set, and
introducing a GetSetCapturerCallback() method which binds to the WeakPtr
of the Core and allows setting the capturer from any threads.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |