From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 18 Oct 2018 17:07:01 -0700 Subject: desktop_media_list.patch * Expose the capturer source list for the desktopCapturer API * Free the one-time use capturer after thumbnails are fetched diff --git a/chrome/browser/media/webrtc/desktop_media_list.h b/chrome/browser/media/webrtc/desktop_media_list.h index a489bf6ea2179059f53e53563e993db9c7cd123b..8d3df446290e2111e4952899539cbc16d37546e5 100644 --- a/chrome/browser/media/webrtc/desktop_media_list.h +++ b/chrome/browser/media/webrtc/desktop_media_list.h @@ -69,6 +69,7 @@ class DesktopMediaList { virtual int GetSourceCount() const = 0; virtual const Source& GetSource(int index) const = 0; + virtual const std::vector& GetSources() const = 0; virtual content::DesktopMediaID::Type GetMediaListType() const = 0; }; diff --git a/chrome/browser/media/webrtc/desktop_media_list_base.cc b/chrome/browser/media/webrtc/desktop_media_list_base.cc index 9d9b7435044c4b84f971bd94765eb875fbac1624..eb7e10f7d9e937ebd6f776e4b4ec495d02fb884b 100644 --- a/chrome/browser/media/webrtc/desktop_media_list_base.cc +++ b/chrome/browser/media/webrtc/desktop_media_list_base.cc @@ -56,7 +56,7 @@ void DesktopMediaListBase::Update(UpdateCallback callback) { DCHECK(sources_.empty()); DCHECK(!refresh_callback_); refresh_callback_ = std::move(callback); - Refresh(false); + Refresh(true); } int DesktopMediaListBase::GetSourceCount() const { @@ -70,6 +70,11 @@ const DesktopMediaList::Source& DesktopMediaListBase::GetSource( return sources_[index]; } +const std::vector& DesktopMediaListBase::GetSources() + const { + return sources_; +} + DesktopMediaID::Type DesktopMediaListBase::GetMediaListType() const { return type_; } diff --git a/chrome/browser/media/webrtc/desktop_media_list_base.h b/chrome/browser/media/webrtc/desktop_media_list_base.h index 3c09ec3111d54cb4f0b74f16a81292b779009eae..26acc18acaef21ced3604fe7ede079d8577f53f4 100644 --- a/chrome/browser/media/webrtc/desktop_media_list_base.h +++ b/chrome/browser/media/webrtc/desktop_media_list_base.h @@ -34,6 +34,7 @@ class DesktopMediaListBase : public DesktopMediaList { void Update(UpdateCallback callback) override; int GetSourceCount() const override; const Source& GetSource(int index) const override; + const std::vector& GetSources() const override; content::DesktopMediaID::Type GetMediaListType() const override; static uint32_t GetImageHash(const gfx::Image& image); diff --git a/chrome/browser/media/webrtc/native_desktop_media_list.cc b/chrome/browser/media/webrtc/native_desktop_media_list.cc index 2b109bd1dea2aed647ec01c0660b2d4c963312f2..8567b4c84b55f1f7774ef3755dca63e94ddd7a29 100644 --- a/chrome/browser/media/webrtc/native_desktop_media_list.cc +++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc @@ -10,14 +10,15 @@ #include "base/hash/hash.h" #include "base/message_loop/message_pump_type.h" #include "base/single_thread_task_runner.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/task/post_task.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" #include "chrome/browser/media/webrtc/desktop_media_list.h" -#include "chrome/grit/generated_resources.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" +#include "electron/grit/electron_resources.h" #include "media/base/video_util.h" #include "third_party/libyuv/include/libyuv/scale_argb.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -220,6 +221,8 @@ void NativeDesktopMediaList::Worker::RefreshThumbnails( FROM_HERE, {BrowserThread::UI}, base::BindOnce(&NativeDesktopMediaList::UpdateNativeThumbnailsFinished, media_list_)); + + capturer_.reset(); } void NativeDesktopMediaList::Worker::OnCaptureResult(