fix: make window capturer work, still issue with first refresh

This commit is contained in:
Keeley Hammond 2024-08-26 11:33:47 -07:00
Родитель af809d0419
Коммит a417b455bf
Не найден ключ, соответствующий данной подписи
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -331,6 +331,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
window_capturer_ = std::make_unique<NativeDesktopMediaList>(
DesktopMediaList::Type::kWindow, std::move(capturer));
window_capturer_->SetThumbnailSize(thumbnail_size);
window_capturer_->ShowDelegatedList();
#if BUILDFLAG(IS_MAC)
window_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow) ? 2
@ -344,9 +345,10 @@ void DesktopCapturer::StartHandling(bool capture_window,
// Needed to force a refresh for the native MacOS Picker
OnceCallback wrapped_update_callback = base::BindOnce(
&DesktopCapturer::RequestUpdate, weak_ptr_factory_.GetWeakPtr(),
screen_capturer_.get(), std::move(update_callback));
window_capturer_.get(), std::move(update_callback));
if (window_capturer_->IsSourceListDelegated()) {
LOG(INFO) << "IsSourceListDelegated";
OnceCallback failure_callback = base::BindOnce(
&DesktopCapturer::HandleFailure, weak_ptr_factory_.GetWeakPtr());
window_listener_ = std::make_unique<DesktopListListener>(
@ -354,6 +356,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
thumbnail_size.IsEmpty());
window_capturer_->StartUpdating(window_listener_.get());
} else {
LOG(INFO) << "Inside the else block";
window_capturer_->Update(std::move(update_callback),
/* refresh_thumbnails = */ true);
}
@ -400,6 +403,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
void DesktopCapturer::RequestUpdate(DesktopMediaList* list,
OnceCallback update_callback) {
LOG(ERROR) << "Inside RequestUpdate";
list->Update(std::move(update_callback));
}
@ -407,6 +411,8 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
if (capture_window_ &&
list->GetMediaListType() == DesktopMediaList::Type::kWindow) {
capture_window_ = false;
base::debug::StackTrace().Print();
LOG(ERROR) << "GetSourceCount (windows): " << list->GetSourceCount();
std::vector<DesktopCapturer::Source> window_sources;
window_sources.reserve(list->GetSourceCount());
for (int i = 0; i < list->GetSourceCount(); i++) {
@ -420,7 +426,8 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
if (capture_screen_ &&
list->GetMediaListType() == DesktopMediaList::Type::kScreen) {
capture_screen_ = false;
LOG(ERROR) << "GetSourceCount" << list->GetSourceCount();
base::debug::StackTrace().Print();
LOG(ERROR) << "GetSourceCount (screens): " << list->GetSourceCount();
std::vector<DesktopCapturer::Source> screen_sources;
screen_sources.reserve(list->GetSourceCount());
for (int i = 0; i < list->GetSourceCount(); i++) {