base_pipwire_capturer: Stop stream upon destruction

Shared screencast stream is tied to desktop capturer options,
which may outlive capturer itself. This leads to a case where
one may attempt to restart the stream in the capturer. This
causes the previous pipewire objects to leak (as observed
in `pw-top` output) and seems to appear as frozen screen for
clients. This CL ensures that the shared screen cast stream,
which is started in this capturer, is also stopped when the
capturer is destroyed.

Bug: chromium:1291247
Change-Id: I5f2b22e54e916549a5280ec457cd76360e42e48a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276640
Commit-Queue: Salman Malik <salmanmalik@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#38187}
diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
index 8bf0662..2a63fc7 100644
--- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
+++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
@@ -44,7 +44,9 @@
   source_id_ = RestoreTokenManager::GetInstance().GetUnusedId();
 }
 
-BaseCapturerPipeWire::~BaseCapturerPipeWire() {}
+BaseCapturerPipeWire::~BaseCapturerPipeWire() {
+  options_.screencast_stream()->StopScreenCastStream();
+}
 
 void BaseCapturerPipeWire::OnScreenCastRequestResult(RequestResponse result,
                                                      uint32_t stream_node_id,