[WIP] Application audio capture prototype for Windows [chromium/src : main]

0 views
Skip to first unread message

Sunggook Chue (Gerrit)

unread,
Feb 26, 2025, 6:54:43 PMFeb 26
to Gabriel Brito, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito

Sunggook Chue added 23 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 255, Patchset 5 (Latest):std::optional<std::string> GetApplicationId(intptr_t window_id) {
Sunggook Chue . unresolved

we need to return value if not windows?

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 12, Patchset 5 (Latest):std::string GetAppMainProcessId(intptr_t window_id);
Sunggook Chue . unresolved

Can we have API descritpion?

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 54, Patchset 5 (Latest): GetWindowThreadProcessId(main_uwp_app_core_window, &main_process_id);
Sunggook Chue . unresolved

we need to validate the return value from the OS API, for all this file?

Line 82, Patchset 5 (Latest): HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
Sunggook Chue . unresolved

process_handle?

Line 82, Patchset 5 (Latest): HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
Sunggook Chue . unresolved

we need to validate if it is valid?

Line 96, Patchset 5 (Latest): OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, parent_id));
Sunggook Chue . unresolved

add /*bInheritHandle=*/?

File media/audio/BUILD.gn
Line 241, Patchset 5 (Latest): "mmdevapi.lib",
Sunggook Chue . unresolved

if getDisplayMedia for echo isn't major scenario, then we can make this as delay load?

File media/audio/audio_device_description.h
Line 95, Patchset 5 (Latest): static std::string GetApplicationId(std::string_view device_id);
Sunggook Chue . unresolved

I wonder who creates application device id? I assume that this file has that API to reduce any chance of error and improve readiability?

File media/audio/audio_features.h
Line 37, Patchset 5 (Latest):MEDIA_EXPORT bool IsApplicationLoopbackCaptureSupported();
Sunggook Chue . unresolved

same here because application loopback feature is already supported for other OSs and this CL is only for Windows?

File media/audio/audio_features.cc
Line 27, Patchset 5 (Latest): "ApplicationAudioCapture",
Sunggook Chue . unresolved

I wonder if we need to specify the Windows somehow and with if BUILDFLAG(IS_WIN)?

File media/audio/audio_input_device.cc
Line 490, Patchset 5 (Latest): // DCHECK_GE(now_time, capture_time);
Sunggook Chue . unresolved

?

File media/audio/audio_system_helper.cc
Line 120, Patchset 5 (Latest): AudioParameters params = audio_manager_->GetInputStreamParameters(device_id);
Sunggook Chue . unresolved

I wonder if GetInputStreamParameters can handel application device id as I don't see the AudioManager change in this CL?

File media/audio/win/audio_low_latency_input_win.cc
Line 596, Patchset 5 (Latest):class CompletionHandler
Sunggook Chue . unresolved

Can you add comment for the class?

Line 597, Patchset 5 (Latest): : public Microsoft::WRL::RuntimeClass<
Sunggook Chue . unresolved

probably, you don't want to remove this one like ComPtr by "using Microsoft::WRL::Runtimeclass", same for other Com classes.

Line 616, Patchset 5 (Latest): activate_operation->GetActivateResult(&hr_activate, &audio_client_);
Sunggook Chue . unresolved

please null check in case of the API does wrong behavior. we have to harden against third party (OS) APIs as they keep changing and introduced bug from time to time.

Line 647, Patchset 5 (Latest): if (AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Sunggook Chue . unresolved

It isn't clear what this API means by just reading a name itself? code wise, device_id_ is audio output device id, if it has something else, then we have to explain it here or its declaration on the header.

Line 649, Patchset 5 (Latest): .ActivationType = AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK,
Sunggook Chue . unresolved

It might be help to reader if it has a link to the MSDN for these values use

Line 677, Patchset 5 (Latest): hr = completion_handler->WaitAndGetAudioClient(audio_client_);
Sunggook Chue . unresolved

can we make this as &audio_client that will be more consistent with the below Activate all, clearer to out param.

Line 691, Patchset 5 (Latest): // Doesn't support these
Sunggook Chue . unresolved

Is this complete comment?

Line 1763, Patchset 5 (Latest): if (!AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Sunggook Chue . unresolved

can we have comment why we can't use simple_audio_volume_ for the application device id?

File media/audio/win/core_audio_util_win.cc
Line 380, Patchset 5 (Latest):
DCHECK(!(AudioDeviceDescription::IsApplicationDevice(device_id) &&
data_flow != eCapture));
Sunggook Chue . unresolved

it looks like it follows the above pattern, but it is difficult to read though.
how about CHECK(!AudioDeviceDescription::IsApplicationDevice(device_id) || (data_flow == eCapture)), but it is up to you though as it could be easier for somoneone.

Line 1037, Patchset 5 (Latest): // Loopback audio streams must be input streams.
Sunggook Chue . unresolved

update the comment?

Line 1038, Patchset 5 (Latest): DCHECK(!(AudioDeviceDescription::IsLoopbackDevice(device_id) &&
is_output_device) &&
!(AudioDeviceDescription::IsApplicationDevice(device_id) &&
is_output_device));
Sunggook Chue . unresolved

it can be updated to have sinlge is_output_device?

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 5
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Comment-Date: Wed, 26 Feb 2025 23:54:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Feb 28, 2025, 8:33:07 PMFeb 28
to Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Sunggook Chue

Gabriel Brito added 17 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 255, Patchset 5:std::optional<std::string> GetApplicationId(intptr_t window_id) {
Sunggook Chue . resolved

we need to return value if not windows?

Gabriel Brito

Done

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 12, Patchset 5:std::string GetAppMainProcessId(intptr_t window_id);
Sunggook Chue . resolved

Can we have API descritpion?

Gabriel Brito

Done

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 54, Patchset 5: GetWindowThreadProcessId(main_uwp_app_core_window, &main_process_id);
Sunggook Chue . resolved

we need to validate the return value from the OS API, for all this file?

Gabriel Brito

Done

Line 82, Patchset 5: HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
Sunggook Chue . resolved

process_handle?

Gabriel Brito

Done

Line 82, Patchset 5: HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
Sunggook Chue . resolved

we need to validate if it is valid?

Gabriel Brito

Done

Line 96, Patchset 5: OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, parent_id));
Sunggook Chue . resolved

add /*bInheritHandle=*/?

Gabriel Brito

Done

File media/audio/BUILD.gn
Line 241, Patchset 5: "mmdevapi.lib",
Sunggook Chue . resolved

if getDisplayMedia for echo isn't major scenario, then we can make this as delay load?

Gabriel Brito

Done

File media/audio/audio_device_description.h
Line 95, Patchset 5: static std::string GetApplicationId(std::string_view device_id);
Sunggook Chue . unresolved

I wonder who creates application device id? I assume that this file has that API to reduce any chance of error and improve readiability?

Gabriel Brito

chrome/browser/media/webrtc/desktop_capture_devices_util.cc creates it.

File media/audio/audio_features.cc
Line 27, Patchset 5: "ApplicationAudioCapture",
Sunggook Chue . unresolved

I wonder if we need to specify the Windows somehow and with if BUILDFLAG(IS_WIN)?

Gabriel Brito

I don't think it is necessary. If I do that, I will need to wrap all feature flag checks in ifdef's. Also, I think this feature will be implemented for other platforms in the future.

File media/audio/audio_input_device.cc
Line 490, Patchset 5: // DCHECK_GE(now_time, capture_time);
Sunggook Chue . resolved

?

Gabriel Brito

This DCHECK fails sometimes on my local debug build, making it crash. So I commented it temporarilly. I don't believe that this is related to my changes. I think that it is related to this issue: https://issues.chromium.org/issues/40061089

File media/audio/audio_system_helper.cc
Line 120, Patchset 5: AudioParameters params = audio_manager_->GetInputStreamParameters(device_id);
Sunggook Chue . unresolved

I wonder if GetInputStreamParameters can handel application device id as I don't see the AudioManager change in this CL?

Gabriel Brito

The parameters being used for the prototype are the same used by loopback device (system audio). Please check the changes in media/audio/win/core_audio_util_win.cc.

File media/audio/win/audio_low_latency_input_win.cc
Line 616, Patchset 5: activate_operation->GetActivateResult(&hr_activate, &audio_client_);
Sunggook Chue . resolved

please null check in case of the API does wrong behavior. we have to harden against third party (OS) APIs as they keep changing and introduced bug from time to time.

Gabriel Brito

Done

Line 647, Patchset 5: if (AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Sunggook Chue . unresolved

It isn't clear what this API means by just reading a name itself? code wise, device_id_ is audio output device id, if it has something else, then we have to explain it here or its declaration on the header.

Gabriel Brito

How is application loopback any different from system audio? Both are input streams, because they receive audio data from the OS audio rendering engine.

Line 691, Patchset 5: // Doesn't support these
Sunggook Chue . resolved

Is this complete comment?

Gabriel Brito

Added more information.

Line 1763, Patchset 5: if (!AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Sunggook Chue . resolved

can we have comment why we can't use simple_audio_volume_ for the application device id?

Gabriel Brito

Done

File media/audio/win/core_audio_util_win.cc
Line 1037, Patchset 5: // Loopback audio streams must be input streams.
Sunggook Chue . resolved

update the comment?

Gabriel Brito

Done

Line 1038, Patchset 5: DCHECK(!(AudioDeviceDescription::IsLoopbackDevice(device_id) &&

is_output_device) &&
!(AudioDeviceDescription::IsApplicationDevice(device_id) &&
is_output_device));
Sunggook Chue . resolved

it can be updated to have sinlge is_output_device?

Gabriel Brito

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 7
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Comment-Date: Sat, 01 Mar 2025 01:32:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Henrik Andreasson (Gerrit)

unread,
Mar 1, 2025, 9:42:30 AMMar 1
to Gabriel Brito, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito and Sunggook Chue

Henrik Andreasson added 1 comment

File media/audio/win/audio_low_latency_input_win.cc
Line 505, Patchset 8 (Latest): *audio_client = std::move(audio_client_);
Henrik Andreasson . unresolved
if (!audio_client_)
return E_FAIL;
}
Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 8
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Comment-Date: Sat, 01 Mar 2025 14:42:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Mar 3, 2025, 6:35:21 PMMar 3
to Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Henrik Andreasson and Sunggook Chue

Gabriel Brito voted and added 2 comments

Votes added by Gabriel Brito

Commit-Queue+1

2 comments

File media/audio/win/audio_low_latency_input_win.cc
Line 505, Patchset 8: *audio_client = std::move(audio_client_);
Henrik Andreasson . resolved
if (!audio_client_)
return E_FAIL;
}
Gabriel Brito

Done. Thanks!

Line 677, Patchset 5: hr = completion_handler->WaitAndGetAudioClient(audio_client_);
Sunggook Chue . resolved

can we make this as &audio_client that will be more consistent with the below Activate all, clearer to out param.

Gabriel Brito

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Henrik Andreasson
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 9
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Mon, 03 Mar 2025 23:35:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
Comment-In-Reply-To: Henrik Andreasson <hen...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fredrik Hernqvist (Gerrit)

unread,
Mar 4, 2025, 8:04:16 AMMar 4
to Gabriel Brito, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito, Henrik Andreasson and Sunggook Chue

Fredrik Hernqvist added 6 comments

Patchset-level comments
File-level comment, Patchset 9 (Latest):
Fredrik Hernqvist . resolved

Thank you very much for the prototype! I added some early comments, but I need to dig into the stack more before I can give more feedback.

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 7, Patchset 9 (Latest):#include <windows.h>
Fredrik Hernqvist . unresolved

Should this be included on all platforms? The CL builds on my mac so it seems like <windows.h> exists for me, but should it?

Line 309, Patchset 9 (Latest): std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . unresolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 84, Patchset 9 (Latest):std::string GetAppMainProcessId(intptr_t window_id) {
Fredrik Hernqvist . unresolved

Is this something we should be doing in the browser process? If this goes wrong and causes a crash, the whole browser will crash. If we instead do it in the AudioService, only the AudioService will crash.
Can we send the window ID to the AudioService instead, and get the process ID when we create the stream there?

File media/audio/audio_features.cc
Line 76, Patchset 9 (Latest): return true;
Fredrik Hernqvist . unresolved

You can remove the if-statement above, and replace this line with

`return base::FeatureList::IsEnabled(features::kApplicationAudioCapture);`

File media/audio/win/audio_low_latency_input_win.cc
Line 1010, Patchset 9 (Latest): bool is_first_audio_sample_ready_event = true;
Fredrik Hernqvist . unresolved

We can do this in a way where we don't have to call IsApplicationDevice on every callback. Simply set this variable to `AudioDeviceDescription::IsApplicationDevice(device_id_)`, and then remove that condition from the if-statement in the loop below. You might want to rename the variable to something that makes more sense, like `should_create_fifo_on_next_callback`.

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Henrik Andreasson
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 9
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Tue, 04 Mar 2025 13:04:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Mar 4, 2025, 11:35:04 PMMar 4
to Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Henrik Andreasson and Sunggook Chue

Gabriel Brito voted and added 6 comments

Votes added by Gabriel Brito

Commit-Queue+1

6 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 7, Patchset 9:#include <windows.h>
Fredrik Hernqvist . resolved

Should this be included on all platforms? The CL builds on my mac so it seems like <windows.h> exists for me, but should it?

Gabriel Brito

Thanks for pointing this out. This should have been removed when I created `desktop_capture_devices_util_win.h`. Removed it.

Line 309, Patchset 9: std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . unresolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

Gabriel Brito

Yes. It will expose the process id to the renderer process. I am sorry I forgot about this. I will check how to make use of the HMAC util functions and store this data in `MediaStreamManager::DeviceRequest` as suggested on the design doc.

FWIW, the device id data related to desktop capture is already exposed - e.g. Windows HWND handles. So I am not sure of how bad of a privacy issue this is.

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 84, Patchset 9:std::string GetAppMainProcessId(intptr_t window_id) {
Fredrik Hernqvist . resolved

Is this something we should be doing in the browser process? If this goes wrong and causes a crash, the whole browser will crash. If we instead do it in the AudioService, only the AudioService will crash.
Can we send the window ID to the AudioService instead, and get the process ID when we create the stream there?

Gabriel Brito

This was discussed during the design doc review. Actually this was my first idea too. But we want to keep the audio process doing only audio-related tasks and perform the process tree traversal in the Browser process. Here's a link to the discussion: https://docs.google.com/document/d/1eyO0pTChGUMN7J8tpEmb1UZ8OxMnxIUeoBkvOOiKA3k/edit?disco=AAABN8odm3w

IMO, If we handle the system calls correctly, this shouldn't crash. I am marking this as resolved, but feel free to reopen if you feel like it should.

File media/audio/audio_features.cc
Line 76, Patchset 9: return true;
Fredrik Hernqvist . resolved

You can remove the if-statement above, and replace this line with

`return base::FeatureList::IsEnabled(features::kApplicationAudioCapture);`

Gabriel Brito

Thanks!

File media/audio/win/audio_low_latency_input_win.cc
Line 596, Patchset 5:class CompletionHandler
Sunggook Chue . resolved

Can you add comment for the class?

Gabriel Brito

Done

Line 1010, Patchset 9: bool is_first_audio_sample_ready_event = true;
Fredrik Hernqvist . unresolved

We can do this in a way where we don't have to call IsApplicationDevice on every callback. Simply set this variable to `AudioDeviceDescription::IsApplicationDevice(device_id_)`, and then remove that condition from the if-statement in the loop below. You might want to rename the variable to something that makes more sense, like `should_create_fifo_on_next_callback`.

Gabriel Brito

I think that `AudioDeviceDescription::IsApplicationDevice` will be called just once on the first loop iteration and that's it. After the first iteration where the `audio_samples_ready_event_` has been set, `is_first_audio_sample_ready_event` will be set to `false`. Then, on the following iterations, `AudioDeviceDescription::IsApplicationDevice` will never be called again, because `is_first_audio_sample_ready_event` will be `false`, shortcircuiting the "and" statement and making it return early.

But I agree that this part could be made clearer. What if we just initialize the fifo queue when the first sample is ready for all types of capture? Then we can avoid the application capture checks altogether.

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Henrik Andreasson
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 10
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Mar 2025 04:34:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Fredrik Hernqvist <fhern...@google.com>
Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fredrik Hernqvist (Gerrit)

unread,
Mar 5, 2025, 4:01:38 AMMar 5
to Gabriel Brito, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito, Henrik Andreasson and Sunggook Chue

Fredrik Hernqvist added 1 comment

File media/audio/win/audio_low_latency_input_win.cc
Line 1010, Patchset 9: bool is_first_audio_sample_ready_event = true;
Fredrik Hernqvist . unresolved

We can do this in a way where we don't have to call IsApplicationDevice on every callback. Simply set this variable to `AudioDeviceDescription::IsApplicationDevice(device_id_)`, and then remove that condition from the if-statement in the loop below. You might want to rename the variable to something that makes more sense, like `should_create_fifo_on_next_callback`.

Gabriel Brito

I think that `AudioDeviceDescription::IsApplicationDevice` will be called just once on the first loop iteration and that's it. After the first iteration where the `audio_samples_ready_event_` has been set, `is_first_audio_sample_ready_event` will be set to `false`. Then, on the following iterations, `AudioDeviceDescription::IsApplicationDevice` will never be called again, because `is_first_audio_sample_ready_event` will be `false`, shortcircuiting the "and" statement and making it return early.

But I agree that this part could be made clearer. What if we just initialize the fifo queue when the first sample is ready for all types of capture? Then we can avoid the application capture checks altogether.

Fredrik Hernqvist

Ah right! I didn't think about the shortcircuiting and-statement. Yes then your way should be equally efficient. I think it would be clearer if we have a single bool as the source of truth for when we create the fifo, so that we use it both in the if-statement for if we should call CreateFifo() above, and below in the while-loop. So we create the bool above the first of the CreateFifo() if-statements, and use it in both of them.

I think it is probably better to create the fifo as early as possible (before the while-loop when possible), so that we do as little work as possible on the capture path.

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Henrik Andreasson
  • Sunggook Chue
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Mar 2025 09:01:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
Comment-In-Reply-To: Fredrik Hernqvist <fhern...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Henrik Andreasson (Gerrit)

unread,
Mar 5, 2025, 4:28:41 AMMar 5
to Gabriel Brito, Fredrik Hernqvist, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito and Sunggook Chue

Henrik Andreasson added 5 comments

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Henrik Andreasson . resolved

Not a complete review but adding some comments on the way.

File media/audio/audio_device_description.h
Line 44, Patchset 10 (Latest): // Input device id used to identify an application audio capture stream.
Henrik Andreasson . unresolved

I might be picky but "application audio capture stream" is a buit hard to read. Can it be made more clear? E.g. "Input device ID used to identify an application's audio input stream."

File media/audio/audio_device_description.cc
Line 76, Patchset 10 (Latest):bool AudioDeviceDescription::IsApplicationDevice(std::string_view device_id) {
Henrik Andreasson . unresolved
Line 146, Patchset 10 (Latest): std::string_view device_id) {
Henrik Andreasson . unresolved

base::StringPiece

Line 154, Patchset 10 (Latest): if (colon_pos == std::string::npos) {
Henrik Andreasson . unresolved

base::StringPiece::npos

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Sunggook Chue
Gerrit-Comment-Date: Wed, 05 Mar 2025 09:28:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Henrik Andreasson (Gerrit)

unread,
Mar 5, 2025, 6:58:00 AMMar 5
to Gabriel Brito, Fredrik Hernqvist, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito and Sunggook Chue

Henrik Andreasson added 4 comments

File media/audio/audio_input_device.cc
Line 490, Patchset 10 (Latest): // DCHECK_GE(now_time, capture_time);
Henrik Andreasson . unresolved

Why is this commented out?

File media/audio/win/audio_low_latency_input_win.h
Line 206, Patchset 10 (Latest): void CreateFifo();
Henrik Andreasson . unresolved

Add comment.

Line 171, Patchset 10 (Latest): // Activates the IAudioClient interface with the adequate parameters.
Henrik Andreasson . unresolved

Can you add some more comments here please.
Why isn't IMMDevice::Activate sufficient and why is an async activation needed. Does it have anything to do with that some applications that we capture audio from are UWP apps? Chrome itself is not an UWP app so is this really needed?

File media/audio/win/audio_low_latency_input_win.cc
Line 651, Patchset 10 (Latest): hr = ActivateAudioClientInterface();
Henrik Andreasson . unresolved

Add comment about two different main cases in this method since it is not clear from the method that there is a ig difference for the "application device".

Gerrit-Comment-Date: Wed, 05 Mar 2025 11:57:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Sharonova (Gerrit)

unread,
Mar 6, 2025, 10:33:03 AMMar 6
to Gabriel Brito, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito and Sunggook Chue

Olga Sharonova added 4 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 186, Patchset 10 (Latest): if (base::FeatureList::IsEnabled(features::kApplicationAudioCapture)) {
Olga Sharonova . unresolved

I think this should be taken into account earlier and reflected in capture_audio parameter - shouldn't it?

Line 309, Patchset 9: std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . unresolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

Gabriel Brito

Yes. It will expose the process id to the renderer process. I am sorry I forgot about this. I will check how to make use of the HMAC util functions and store this data in `MediaStreamManager::DeviceRequest` as suggested on the design doc.

FWIW, the device id data related to desktop capture is already exposed - e.g. Windows HWND handles. So I am not sure of how bad of a privacy issue this is.

Olga Sharonova

guidou@ - WDYT?

File media/audio/win/audio_low_latency_input_win.cc
Line 503, Patchset 10 (Latest): HRESULT WaitAndGetAudioClient(ComPtr<IAudioClient>* audio_client) {
Olga Sharonova . unresolved

I'm not sure we want to make synchronous calls like this. Can we avoid that? Can it result in a deadlock?

henrika@ - what's your take on it?

Line 1374, Patchset 10 (Latest):HRESULT WASAPIAudioInputStream::ActivateAudioClientInterface() {
Olga Sharonova . unresolved

Could you document it?

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 10
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Comment-Date: Thu, 06 Mar 2025 15:32:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Sharonova (Gerrit)

unread,
Mar 6, 2025, 10:35:50 AMMar 6
to Gabriel Brito, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito and Sunggook Chue

Olga Sharonova added 1 comment

Patchset-level comments
Olga Sharonova . resolved

Fogot to ssend this: that looks very interesting, thank you!

Gerrit-Comment-Date: Thu, 06 Mar 2025 15:35:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Henrik Andreasson (Gerrit)

unread,
Mar 6, 2025, 12:54:15 PMMar 6
to Gabriel Brito, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito and Sunggook Chue

Henrik Andreasson added 1 comment

File media/audio/win/audio_low_latency_input_win.cc
Line 503, Patchset 10 (Latest): HRESULT WaitAndGetAudioClient(ComPtr<IAudioClient>* audio_client) {
Olga Sharonova . unresolved

I'm not sure we want to make synchronous calls like this. Can we avoid that? Can it result in a deadlock?

henrika@ - what's your take on it?

Henrik Andreasson

I have asked similar questions in my review round. See e.g.https://chromium-review.googlesource.com/c/chromium/src/+/6210165/comment/14419678_19588014/. It is possible that it is required to be able to capture audio from UWP apps but I am not sure.

Gerrit-Comment-Date: Thu, 06 Mar 2025 17:54:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Mar 6, 2025, 10:26:13 PMMar 6
to Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Gabriel Brito added 12 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 186, Patchset 10: if (base::FeatureList::IsEnabled(features::kApplicationAudioCapture)) {
Olga Sharonova . resolved

I think this should be taken into account earlier and reflected in capture_audio parameter - shouldn't it?

Gabriel Brito

Correct. Removing the flag check. Thanks!

Line 309, Patchset 9: std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . unresolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

Gabriel Brito

Yes. It will expose the process id to the renderer process. I am sorry I forgot about this. I will check how to make use of the HMAC util functions and store this data in `MediaStreamManager::DeviceRequest` as suggested on the design doc.

FWIW, the device id data related to desktop capture is already exposed - e.g. Windows HWND handles. So I am not sure of how bad of a privacy issue this is.

Olga Sharonova

guidou@ - WDYT?

Gabriel Brito

In the latest patch, I removed the device type check from `MediaStreamManager::TranslateDeviceIdToSourceId`. I think that this should be enough to hash ids for both audio (PID) and video (HWND) devices used in window capture. WDYT? @gui...@chromium.org

File media/audio/audio_device_description.h
Line 44, Patchset 10: // Input device id used to identify an application audio capture stream.
Henrik Andreasson . resolved

I might be picky but "application audio capture stream" is a buit hard to read. Can it be made more clear? E.g. "Input device ID used to identify an application's audio input stream."

Gabriel Brito

No problem. Changed it!

File media/audio/audio_device_description.cc
Line 76, Patchset 10:bool AudioDeviceDescription::IsApplicationDevice(std::string_view device_id) {
Henrik Andreasson . unresolved

AFAIK, std::string_view is not fully approved in Chrome yet. See https://chromium.googlesource.com/chromium/src/+/1865f277bb4b77b6d12ccfa566d67a187d5d00e6/styleguide/c++/c++11.md#std_string_view-tbd

Gabriel Brito

I don't know why this is still TBD. Maybe we should ask someone to update this? I remember there was a recent effort to use `string_view` in the codebase: https://issues.chromium.org/issues/40506050. Also, it seems that base::StringPiece was even removed from chromium.src: https://chromium-review.googlesource.com/c/chromium/src/+/5729956

Can I keep `std::string_view` or should I use `std::string` anyways?

File media/audio/audio_input_device.cc
Line 490, Patchset 10: // DCHECK_GE(now_time, capture_time);
Henrik Andreasson . unresolved

Why is this commented out?

Gabriel Brito

This DCHECK fails sometimes on my local debug build, making it crash. So I commented it temporarilly. I don't believe that this is related to my changes. I think that it is related to this issue: https://issues.chromium.org/issues/40061089

File media/audio/win/audio_low_latency_input_win.h
Line 206, Patchset 10: void CreateFifo();
Henrik Andreasson . resolved

Add comment.

Gabriel Brito

Added. Thanks!

Line 171, Patchset 10: // Activates the IAudioClient interface with the adequate parameters.
Henrik Andreasson . resolved

Can you add some more comments here please.
Why isn't IMMDevice::Activate sufficient and why is an async activation needed. Does it have anything to do with that some applications that we capture audio from are UWP apps? Chrome itself is not an UWP app so is this really needed?

Gabriel Brito

I replied to this on this other comment: https://chromium-review.googlesource.com/c/chromium/src/+/6210165/comment/77d585e5_9846cc0f/

Also added a comment to the method's header. Please let me know if it needs improvements. Thanks!

File media/audio/win/audio_low_latency_input_win.cc
Line 503, Patchset 10: HRESULT WaitAndGetAudioClient(ComPtr<IAudioClient>* audio_client) {
Olga Sharonova . unresolved

I'm not sure we want to make synchronous calls like this. Can we avoid that? Can it result in a deadlock?

henrika@ - what's your take on it?

Henrik Andreasson

I have asked similar questions in my review round. See e.g.https://chromium-review.googlesource.com/c/chromium/src/+/6210165/comment/14419678_19588014/. It is possible that it is required to be able to capture audio from UWP apps but I am not sure.

Gabriel Brito

We an avoid a deadlock by specifying a timeout in millisecs in WaitForSingleObject: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject.

Henrik's comment for context:


>Why isn't IMMDevice::Activate sufficient and why is an async activation needed. Does it have anything to do with that some applications that we capture audio from are UWP apps? Chrome itself is not an UWP app so is this really needed?

Unfortunatelly, this is how the Windows API is implemented.

  • Why do we need to use `ActivateAudioInterfaceAsync`? Because it is the only way available to setup process audio capture.
  • Why can't we use `ActivateAudioInterfaceAsync` to also activate the `endpoint_`? Because only "interfaces" can be activated and endpoints are not audio interfaces.
  • Why isn't IMMDevice::Activate sufficient? Process loopback cannot be activated off an endpoint. The official documentation might make look like it is possible (https://learn.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate), but this is wrong. It will be corrected.
Line 649, Patchset 5: .ActivationType = AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK,
Sunggook Chue . unresolved

It might be help to reader if it has a link to the MSDN for these values use

Gabriel Brito

Done. Does it look good to you?

Line 651, Patchset 10: hr = ActivateAudioClientInterface();
Henrik Andreasson . resolved

Add comment about two different main cases in this method since it is not clear from the method that there is a ig difference for the "application device".

Gabriel Brito

Added the comment. Thanks!

Line 1010, Patchset 9: bool is_first_audio_sample_ready_event = true;
Fredrik Hernqvist . resolved

We can do this in a way where we don't have to call IsApplicationDevice on every callback. Simply set this variable to `AudioDeviceDescription::IsApplicationDevice(device_id_)`, and then remove that condition from the if-statement in the loop below. You might want to rename the variable to something that makes more sense, like `should_create_fifo_on_next_callback`.

Gabriel Brito

I think that `AudioDeviceDescription::IsApplicationDevice` will be called just once on the first loop iteration and that's it. After the first iteration where the `audio_samples_ready_event_` has been set, `is_first_audio_sample_ready_event` will be set to `false`. Then, on the following iterations, `AudioDeviceDescription::IsApplicationDevice` will never be called again, because `is_first_audio_sample_ready_event` will be `false`, shortcircuiting the "and" statement and making it return early.

But I agree that this part could be made clearer. What if we just initialize the fifo queue when the first sample is ready for all types of capture? Then we can avoid the application capture checks altogether.

Fredrik Hernqvist

Ah right! I didn't think about the shortcircuiting and-statement. Yes then your way should be equally efficient. I think it would be clearer if we have a single bool as the source of truth for when we create the fifo, so that we use it both in the if-statement for if we should call CreateFifo() above, and below in the while-loop. So we create the bool above the first of the CreateFifo() if-statements, and use it in both of them.

I think it is probably better to create the fifo as early as possible (before the while-loop when possible), so that we do as little work as possible on the capture path.

Gabriel Brito

Ok. I adopted your suggestion. Thanks!

Line 1374, Patchset 10:HRESULT WASAPIAudioInputStream::ActivateAudioClientInterface() {
Olga Sharonova . resolved

Could you document it?

Gabriel Brito

Added some comments. Please let me know if you think that I should add something else. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Henrik Andreasson
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 11
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Fri, 07 Mar 2025 03:26:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
Comment-In-Reply-To: Fredrik Hernqvist <fhern...@google.com>
Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Henrik Andreasson (Gerrit)

unread,
Mar 7, 2025, 3:18:25 AMMar 7
to Gabriel Brito, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Gabriel Brito, Olga Sharonova and Sunggook Chue

Henrik Andreasson added 2 comments

File media/audio/audio_device_description.cc
Line 76, Patchset 10:bool AudioDeviceDescription::IsApplicationDevice(std::string_view device_id) {
Henrik Andreasson . unresolved

AFAIK, std::string_view is not fully approved in Chrome yet. See https://chromium.googlesource.com/chromium/src/+/1865f277bb4b77b6d12ccfa566d67a187d5d00e6/styleguide/c++/c++11.md#std_string_view-tbd

Gabriel Brito

I don't know why this is still TBD. Maybe we should ask someone to update this? I remember there was a recent effort to use `string_view` in the codebase: https://issues.chromium.org/issues/40506050. Also, it seems that base::StringPiece was even removed from chromium.src: https://chromium-review.googlesource.com/c/chromium/src/+/5729956

Can I keep `std::string_view` or should I use `std::string` anyways?

Henrik Andreasson

All I can say at this stage is that there are other examples of usage of std::_string_view in media so I guess I don't have a string argument againts your usage.

I am not an owner of this particular area and don't want to block something based on the existing vague TBD statement.

Hence, don't change this now.

File media/audio/win/audio_low_latency_input_win.cc
Line 503, Patchset 10: HRESULT WaitAndGetAudioClient(ComPtr<IAudioClient>* audio_client) {
Olga Sharonova . unresolved

I'm not sure we want to make synchronous calls like this. Can we avoid that? Can it result in a deadlock?

henrika@ - what's your take on it?

Henrik Andreasson

I have asked similar questions in my review round. See e.g.https://chromium-review.googlesource.com/c/chromium/src/+/6210165/comment/14419678_19588014/. It is possible that it is required to be able to capture audio from UWP apps but I am not sure.

Gabriel Brito

We an avoid a deadlock by specifying a timeout in millisecs in WaitForSingleObject: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject.

Henrik's comment for context:
>Why isn't IMMDevice::Activate sufficient and why is an async activation needed. Does it have anything to do with that some applications that we capture audio from are UWP apps? Chrome itself is not an UWP app so is this really needed?

Unfortunatelly, this is how the Windows API is implemented.

  • Why do we need to use `ActivateAudioInterfaceAsync`? Because it is the only way available to setup process audio capture.
  • Why can't we use `ActivateAudioInterfaceAsync` to also activate the `endpoint_`? Because only "interfaces" can be activated and endpoints are not audio interfaces.
  • Why isn't IMMDevice::Activate sufficient? Process loopback cannot be activated off an endpoint. The official documentation might make look like it is possible (https://learn.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate), but this is wrong. It will be corrected.
Henrik Andreasson

But this pattern is not used today and we have support for loopback devices. Are you saying that the current implementation needs similar changed for looback as well?

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Gabriel Brito
  • Olga Sharonova
  • Sunggook Chue
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Comment-Date: Fri, 07 Mar 2025 08:18:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
Comment-In-Reply-To: Henrik Andreasson <hen...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fredrik Hernqvist (Gerrit)

unread,
Mar 7, 2025, 8:50:52 AMMar 7
to Gabriel Brito, Olga Sharonova, Guido Urdaneta, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

Fredrik Hernqvist added 1 comment

File media/audio/win/audio_low_latency_input_win.cc
Line 998, Patchset 11 (Latest): if (!AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Fredrik Hernqvist . unresolved

What I meant with my other comment is, we could define `is_first_audio_sample_ready_event` above this if-statement and change the if-statement to `if (!is_first_audio_sample_ready_event) {...}`

Then we will have the same variable in each place that concerns when to create the fifo, which I think will be clearer to the reader. Then the variable should probably also have a new name.

Open in Gerrit

Related details

Attention is currently required from:
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Comment-Date: Fri, 07 Mar 2025 13:50:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Guido Urdaneta (Gerrit)

unread,
Mar 7, 2025, 11:40:30 AMMar 7
to Gabriel Brito, Olga Sharonova, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

Guido Urdaneta added 1 comment

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 309, Patchset 9: std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . unresolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

Gabriel Brito

Yes. It will expose the process id to the renderer process. I am sorry I forgot about this. I will check how to make use of the HMAC util functions and store this data in `MediaStreamManager::DeviceRequest` as suggested on the design doc.

FWIW, the device id data related to desktop capture is already exposed - e.g. Windows HWND handles. So I am not sure of how bad of a privacy issue this is.

Olga Sharonova

guidou@ - WDYT?

Gabriel Brito

In the latest patch, I removed the device type check from `MediaStreamManager::TranslateDeviceIdToSourceId`. I think that this should be enough to hash ids for both audio (PID) and video (HWND) devices used in window capture. WDYT? @gui...@chromium.org

Guido Urdaneta

I propose creating a CL (or several if necessary) for hasing device IDs for screen capture (guarded by a feature flag), independent of this work. Then we have full freedom to add anything we want to the device IDs.

Gerrit-Comment-Date: Fri, 07 Mar 2025 16:40:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Mar 7, 2025, 10:53:42 PMMar 7
to Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Guido Urdaneta, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Gabriel Brito added 10 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 309, Patchset 9: std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . unresolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

Gabriel Brito

Yes. It will expose the process id to the renderer process. I am sorry I forgot about this. I will check how to make use of the HMAC util functions and store this data in `MediaStreamManager::DeviceRequest` as suggested on the design doc.

FWIW, the device id data related to desktop capture is already exposed - e.g. Windows HWND handles. So I am not sure of how bad of a privacy issue this is.

Olga Sharonova

guidou@ - WDYT?

Gabriel Brito

In the latest patch, I removed the device type check from `MediaStreamManager::TranslateDeviceIdToSourceId`. I think that this should be enough to hash ids for both audio (PID) and video (HWND) devices used in window capture. WDYT? @gui...@chromium.org

Guido Urdaneta

I propose creating a CL (or several if necessary) for hasing device IDs for screen capture (guarded by a feature flag), independent of this work. Then we have full freedom to add anything we want to the device IDs.

Gabriel Brito

Ok. I created this bug https://issues.chromium.org/issues/401522577. I set it up with limited visibility, because it is a privacy isse. Please feel free to modify the fields if you feel like it.

@ol...@chromium.org, it seems that hashing will be itself another project. Should we proceed with the window audio capture implementation and get back to hashing after we have window capture landed?

File media/audio/audio_device_description.h
Line 95, Patchset 5: static std::string GetApplicationId(std::string_view device_id);
Sunggook Chue . resolved

I wonder who creates application device id? I assume that this file has that API to reduce any chance of error and improve readiability?

Gabriel Brito

chrome/browser/media/webrtc/desktop_capture_devices_util.cc creates it.

Gabriel Brito

Done

File media/audio/audio_device_description.cc
Line 76, Patchset 10:bool AudioDeviceDescription::IsApplicationDevice(std::string_view device_id) {
Henrik Andreasson . resolved

AFAIK, std::string_view is not fully approved in Chrome yet. See https://chromium.googlesource.com/chromium/src/+/1865f277bb4b77b6d12ccfa566d67a187d5d00e6/styleguide/c++/c++11.md#std_string_view-tbd

Gabriel Brito

I don't know why this is still TBD. Maybe we should ask someone to update this? I remember there was a recent effort to use `string_view` in the codebase: https://issues.chromium.org/issues/40506050. Also, it seems that base::StringPiece was even removed from chromium.src: https://chromium-review.googlesource.com/c/chromium/src/+/5729956

Can I keep `std::string_view` or should I use `std::string` anyways?

Henrik Andreasson

All I can say at this stage is that there are other examples of usage of std::_string_view in media so I guess I don't have a string argument againts your usage.

I am not an owner of this particular area and don't want to block something based on the existing vague TBD statement.

Hence, don't change this now.

Gabriel Brito

Ok. I will resolve this comment then. Thanks!

Line 146, Patchset 10: std::string_view device_id) {
Henrik Andreasson . resolved

base::StringPiece

Gabriel Brito
Line 154, Patchset 10: if (colon_pos == std::string::npos) {
Henrik Andreasson . resolved

base::StringPiece::npos

Gabriel Brito
File media/audio/audio_features.cc
Line 27, Patchset 5: "ApplicationAudioCapture",
Sunggook Chue . resolved

I wonder if we need to specify the Windows somehow and with if BUILDFLAG(IS_WIN)?

Gabriel Brito

I don't think it is necessary. If I do that, I will need to wrap all feature flag checks in ifdef's. Also, I think this feature will be implemented for other platforms in the future.

Gabriel Brito

Done

File media/audio/audio_system_helper.cc
Line 120, Patchset 5: AudioParameters params = audio_manager_->GetInputStreamParameters(device_id);
Sunggook Chue . resolved

I wonder if GetInputStreamParameters can handel application device id as I don't see the AudioManager change in this CL?

Gabriel Brito

The parameters being used for the prototype are the same used by loopback device (system audio). Please check the changes in media/audio/win/core_audio_util_win.cc.

Gabriel Brito

Done

File media/audio/win/audio_low_latency_input_win.cc
Line 503, Patchset 10: HRESULT WaitAndGetAudioClient(ComPtr<IAudioClient>* audio_client) {
Olga Sharonova . unresolved

I'm not sure we want to make synchronous calls like this. Can we avoid that? Can it result in a deadlock?

henrika@ - what's your take on it?

Henrik Andreasson

I have asked similar questions in my review round. See e.g.https://chromium-review.googlesource.com/c/chromium/src/+/6210165/comment/14419678_19588014/. It is possible that it is required to be able to capture audio from UWP apps but I am not sure.

Gabriel Brito

We an avoid a deadlock by specifying a timeout in millisecs in WaitForSingleObject: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject.

Henrik's comment for context:
>Why isn't IMMDevice::Activate sufficient and why is an async activation needed. Does it have anything to do with that some applications that we capture audio from are UWP apps? Chrome itself is not an UWP app so is this really needed?

Unfortunatelly, this is how the Windows API is implemented.

  • Why do we need to use `ActivateAudioInterfaceAsync`? Because it is the only way available to setup process audio capture.
  • Why can't we use `ActivateAudioInterfaceAsync` to also activate the `endpoint_`? Because only "interfaces" can be activated and endpoints are not audio interfaces.
  • Why isn't IMMDevice::Activate sufficient? Process loopback cannot be activated off an endpoint. The official documentation might make look like it is possible (https://learn.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate), but this is wrong. It will be corrected.
Henrik Andreasson

But this pattern is not used today and we have support for loopback devices. Are you saying that the current implementation needs similar changed for looback as well?

Gabriel Brito

No need to change the system audio loopback implementation. The `IAudioClient` is only setup for loopback capture when we call `IAudioClient::Initialize` later in `InitializeAudioEngine`. This means that neither `IMMDevice::Activate` nor `ActivateAudioInterfaceAsync` have no information about whether we are creating a loopback capture stream or not.

We need these 2 patterns basically because the stream source is different for each scenario:

  • System audio loopback: we are capturing the loopback stream for a default endpoint device - e.g. the default speakers
  • Process loopback: the stream does not come from an endpoint but from a process.

I need to confirm, but I just noticed that it seems that we don't need to set `endpoint_device_` for application capture.

Line 649, Patchset 5: .ActivationType = AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK,
Sunggook Chue . resolved

It might be help to reader if it has a link to the MSDN for these values use

Gabriel Brito

Done. Does it look good to you?

Gabriel Brito

Done

Line 998, Patchset 11: if (!AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Fredrik Hernqvist . resolved

What I meant with my other comment is, we could define `is_first_audio_sample_ready_event` above this if-statement and change the if-statement to `if (!is_first_audio_sample_ready_event) {...}`

Then we will have the same variable in each place that concerns when to create the fifo, which I think will be clearer to the reader. Then the variable should probably also have a new name.

Gabriel Brito

Got it. I renamed the variable and moved the definition further up. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Guido Urdaneta
  • Henrik Andreasson
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 12
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Sat, 08 Mar 2025 03:53:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Guido Urdaneta <gui...@chromium.org>
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
Comment-In-Reply-To: Fredrik Hernqvist <fhern...@google.com>
Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Guido Urdaneta (Gerrit)

unread,
Mar 11, 2025, 10:23:09 AMMar 11
to Gabriel Brito, Elad Alon, Olga Sharonova, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Gabriel Brito, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Guido Urdaneta added 1 comment

Patchset-level comments
File-level comment, Patchset 12 (Latest):
Guido Urdaneta . resolved

cc eladalon@

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Gabriel Brito
  • Henrik Andreasson
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 12
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Elad Alon <elad...@chromium.org>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Tue, 11 Mar 2025 14:23:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Elad Alon (Gerrit)

unread,
Mar 11, 2025, 1:01:54 PMMar 11
to Gabriel Brito, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Gabriel Brito, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Elad Alon added 7 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 25, Patchset 12 (Latest):// Given a window's HWND pointer, returns a string containing the PID of the
// application's "main process" for audio capture purposes. let "window process"
Elad Alon . unresolved

Why a string? Did you mean `std::optional<DWORD>` perhaps?

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 27, Patchset 12 (Latest): int class_name_length = GetClassName(hwnd, class_name, MAX_PATH);
Elad Alon . unresolved

A method called GetClassName returns the name's **length**?

Line 28, Patchset 12 (Latest): // compare class_name with kUWPAppCoreWindowClassName
Elad Alon . unresolved

Remove this comment, it's too obvious.

Line 33, Patchset 12 (Latest): return false;
Elad Alon . unresolved

The method's documentation should explain when true/false is returned.

Line 39, Patchset 12 (Latest):bool IsUWPApplication(std::wstring_view app_base_name) {
return app_base_name == kApplicationFrameHostName;
}
Elad Alon . unresolved

Should this be inlined instead? A comment would likely suffice.

File chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.cc
Line 704, Patchset 12 (Latest): // Need to change the string?
Elad Alon . unresolved

Please remember to remove this comment.

File media/audio/audio_features.cc
Line 31, Patchset 12 (Latest):// When this feature is enabled, gDM will be able to capture audio from an
// application whose window is selected by the user through the picker UI.
Elad Alon . unresolved

It might be more accurate to say that when applications call `gDM({audio: true})`, Chromium will offer the user the option to also capture app-audio.

Gerrit-Comment-Date: Tue, 11 Mar 2025 17:01:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Mar 12, 2025, 2:22:53 PMMar 12
to Elad Alon, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Elad Alon, Fredrik Hernqvist, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Gabriel Brito added 7 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 25, Patchset 12:// Given a window's HWND pointer, returns a string containing the PID of the

// application's "main process" for audio capture purposes. let "window process"
Elad Alon . unresolved

Why a string? Did you mean `std::optional<DWORD>` perhaps?

Gabriel Brito

I am returning a `std::string` because I didn't want `chrome/browser/media/webrtc/desktop_capture_devices_util.cc` to need to include Windows headers. Is there a better way to ensure this or it is not important?

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 27, Patchset 12: int class_name_length = GetClassName(hwnd, class_name, MAX_PATH);
Elad Alon . unresolved

A method called GetClassName returns the name's **length**?

Gabriel Brito

It returns the number of copied chars to the `class_name` buffer. Is just `length` ok to you?

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassname

Line 28, Patchset 12: // compare class_name with kUWPAppCoreWindowClassName
Elad Alon . resolved

Remove this comment, it's too obvious.

Gabriel Brito

Done

Line 33, Patchset 12: return false;
Elad Alon . resolved

The method's documentation should explain when true/false is returned.

Gabriel Brito

Added the comment and a link to the Microsoft documentation. Thanks!

Line 39, Patchset 12:bool IsUWPApplication(std::wstring_view app_base_name) {
return app_base_name == kApplicationFrameHostName;
}
Elad Alon . unresolved

Should this be inlined instead? A comment would likely suffice.

Gabriel Brito

Personally, I prefer having a named function for clarity as I can read the code and understand without resorting to comments. But I understand your point since this check is only used in one place. Still, do you want me to get rid of the function?

File chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.cc
Line 704, Patchset 12: // Need to change the string?
Elad Alon . resolved

Please remember to remove this comment.

Gabriel Brito

Done. Thanks!

File media/audio/audio_features.cc
Line 31, Patchset 12:// When this feature is enabled, gDM will be able to capture audio from an

// application whose window is selected by the user through the picker UI.
Elad Alon . resolved

It might be more accurate to say that when applications call `gDM({audio: true})`, Chromium will offer the user the option to also capture app-audio.

Gabriel Brito

Ok. Made the change and just complemented with `for window screen captures` to be more specific. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Elad Alon
  • Fredrik Hernqvist
  • Henrik Andreasson
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 13
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Elad Alon <elad...@chromium.org>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Elad Alon <elad...@chromium.org>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 12 Mar 2025 18:22:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Elad Alon <elad...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Elad Alon (Gerrit)

unread,
Mar 12, 2025, 4:15:17 PMMar 12
to Gabriel Brito, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Gabriel Brito, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Elad Alon added 4 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 25, Patchset 12:// Given a window's HWND pointer, returns a string containing the PID of the
// application's "main process" for audio capture purposes. let "window process"
Elad Alon . unresolved

Why a string? Did you mean `std::optional<DWORD>` perhaps?

Gabriel Brito

I am returning a `std::string` because I didn't want `chrome/browser/media/webrtc/desktop_capture_devices_util.cc` to need to include Windows headers. Is there a better way to ensure this or it is not important?

Elad Alon

The conversion of what is essentially a number to a string consisting of a known prefix (`"application:"`) and a stringification of a number appears unusual, unexpected, and feels error-prone. Barring a strong reason, I'd avoid it. I have not yet heard a strong enough reason, imho; but I keep an open mind.

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 27, Patchset 12: int class_name_length = GetClassName(hwnd, class_name, MAX_PATH);
Elad Alon . unresolved

A method called GetClassName returns the name's **length**?

Gabriel Brito

It returns the number of copied chars to the `class_name` buffer. Is just `length` ok to you?

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassname

Elad Alon

Okay, so it

Line 27, Patchset 12: int class_name_length = GetClassName(hwnd, class_name, MAX_PATH);
Elad Alon . unresolved

A method called GetClassName returns the name's **length**?

Gabriel Brito

It returns the number of copied chars to the `class_name` buffer. Is just `length` ok to you?

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassname

Elad Alon

Ah, right...

Isn't it a problem that you're providing `MAX_PATH` as the maximum length there? Shouldn't that be `kUWPAppCoreWindowClassNameLength + 1`, at least with the code currently in PS13? Wouldn't that risk memory corruption?

Also, note that you likely want to allocate at least **two** character more than kUWPAppCoreWindowClassNameLength. That is, you want one more for the `\0`, and one more so that `Windows.UI.Core.CoreWindow_MORE_CHARS` would not get misidentified as equal to `Windows.UI.Core.CoreWindow` due to GetClassName truncating the result to [nMaxCount](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassname#parameters). Let me know if I'm wrong, though.

Line 39, Patchset 12:bool IsUWPApplication(std::wstring_view app_base_name) {
return app_base_name == kApplicationFrameHostName;
}
Elad Alon . unresolved

Should this be inlined instead? A comment would likely suffice.

Gabriel Brito

Personally, I prefer having a named function for clarity as I can read the code and understand without resorting to comments. But I understand your point since this check is only used in one place. Still, do you want me to get rid of the function?

Elad Alon

I understand the principle and sometimes I apply it myself. But I think the balance in this particular case leans towards getting rid of this helper.

If you think `name == kApplicationFrameHostName` would be insufficiently clear at the call site, you can try other mitigations, such as assigning it to a `const bool` that you name `is_uwp_app`, which will give you just as much clarity as the helper, but without the need to jump around the code to see how it's implemented.

But anyhow, that's a nit either way. I wouldn't block over something like this.

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Gabriel Brito
  • Henrik Andreasson
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 13
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Elad Alon <elad...@chromium.org>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 12 Mar 2025 20:15:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
Comment-In-Reply-To: Elad Alon <elad...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Sharonova (Gerrit)

unread,
Mar 13, 2025, 1:01:15 PMMar 13
to Gabriel Brito, Elad Alon, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Gabriel Brito, Henrik Andreasson and Sunggook Chue

Olga Sharonova added 2 comments

File media/audio/audio_device_description.h
Line 45, Patchset 13 (Latest): static const char kApplicationDeviceId[];
Olga Sharonova . unresolved

Where is it used to form the device id? I can't seem to find the place.

File media/audio/audio_device_description.cc
Line 145, Patchset 13 (Latest):std::string AudioDeviceDescription::GetApplicationId(
Olga Sharonova . unresolved

This method cannot be here it should not be possible to extract application id from AudioDeviceDescription without unhashing; and ADD does not have access to that logic.

Generally, AudioDeviceDescription is used for device enumerations, and application loopbacks are never enumerated. So I suggest we move all this logic out into some other helper.

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Gabriel Brito
  • Henrik Andreasson
  • Sunggook Chue
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Thu, 13 Mar 2025 17:01:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Gabriel Brito (Gerrit)

unread,
Apr 1, 2025, 11:05:46 PMApr 1
to Elad Alon, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Elad Alon, Fredrik Hernqvist, Guido Urdaneta, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Gabriel Brito added 10 comments

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 309, Patchset 9: std::optional<std::string> application_id = GetApplicationId(media_id.id);
Fredrik Hernqvist . resolved

I think we need to fully understand the implications of adding the application ID (which is currently the main process id) to the device ID.

Will this expose the process ID to the Renderer? It looks like blink::MediaStreamDevice has many usages there.
Is it a privacy issue to do so?

Gabriel Brito

Yes. It will expose the process id to the renderer process. I am sorry I forgot about this. I will check how to make use of the HMAC util functions and store this data in `MediaStreamManager::DeviceRequest` as suggested on the design doc.

FWIW, the device id data related to desktop capture is already exposed - e.g. Windows HWND handles. So I am not sure of how bad of a privacy issue this is.

Olga Sharonova

guidou@ - WDYT?

Gabriel Brito

In the latest patch, I removed the device type check from `MediaStreamManager::TranslateDeviceIdToSourceId`. I think that this should be enough to hash ids for both audio (PID) and video (HWND) devices used in window capture. WDYT? @gui...@chromium.org

Guido Urdaneta

I propose creating a CL (or several if necessary) for hasing device IDs for screen capture (guarded by a feature flag), independent of this work. Then we have full freedom to add anything we want to the device IDs.

Gabriel Brito

Ok. I created this bug https://issues.chromium.org/issues/401522577. I set it up with limited visibility, because it is a privacy isse. Please feel free to modify the fields if you feel like it.

@ol...@chromium.org, it seems that hashing will be itself another project. Should we proceed with the window audio capture implementation and get back to hashing after we have window capture landed?

Gabriel Brito
File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 25, Patchset 12:// Given a window's HWND pointer, returns a string containing the PID of the
// application's "main process" for audio capture purposes. let "window process"
Elad Alon . resolved

Why a string? Did you mean `std::optional<DWORD>` perhaps?

Gabriel Brito

I am returning a `std::string` because I didn't want `chrome/browser/media/webrtc/desktop_capture_devices_util.cc` to need to include Windows headers. Is there a better way to ensure this or it is not important?

Elad Alon

The conversion of what is essentially a number to a string consisting of a known prefix (`"application:"`) and a stringification of a number appears unusual, unexpected, and feels error-prone. Barring a strong reason, I'd avoid it. I have not yet heard a strong enough reason, imho; but I keep an open mind.

Gabriel Brito

Now returning a `base::ProcessId`, which is defined as a `DWORD` on Windows.

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 27, Patchset 12: int class_name_length = GetClassName(hwnd, class_name, MAX_PATH);
Elad Alon . resolved

A method called GetClassName returns the name's **length**?

Gabriel Brito

It returns the number of copied chars to the `class_name` buffer. Is just `length` ok to you?

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassname

Elad Alon

Ah, right...

Isn't it a problem that you're providing `MAX_PATH` as the maximum length there? Shouldn't that be `kUWPAppCoreWindowClassNameLength + 1`, at least with the code currently in PS13? Wouldn't that risk memory corruption?

Also, note that you likely want to allocate at least **two** character more than kUWPAppCoreWindowClassNameLength. That is, you want one more for the `\0`, and one more so that `Windows.UI.Core.CoreWindow_MORE_CHARS` would not get misidentified as equal to `Windows.UI.Core.CoreWindow` due to GetClassName truncating the result to [nMaxCount](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassname#parameters). Let me know if I'm wrong, though.

Gabriel Brito

This shouldn't be a problem anymore. Calling `base::win::GetWindowClass` now.

Line 39, Patchset 12:bool IsUWPApplication(std::wstring_view app_base_name) {
return app_base_name == kApplicationFrameHostName;
}
Elad Alon . resolved

Should this be inlined instead? A comment would likely suffice.

Gabriel Brito

Personally, I prefer having a named function for clarity as I can read the code and understand without resorting to comments. But I understand your point since this check is only used in one place. Still, do you want me to get rid of the function?

Elad Alon

I understand the principle and sometimes I apply it myself. But I think the balance in this particular case leans towards getting rid of this helper.

If you think `name == kApplicationFrameHostName` would be insufficiently clear at the call site, you can try other mitigations, such as assigning it to a `const bool` that you name `is_uwp_app`, which will give you just as much clarity as the helper, but without the need to jump around the code to see how it's implemented.

But anyhow, that's a nit either way. I wouldn't block over something like this.

Gabriel Brito

Done

File media/audio/audio_device_description.h
Line 45, Patchset 13: static const char kApplicationDeviceId[];
Olga Sharonova . resolved

Where is it used to form the device id? I can't seem to find the place.

Gabriel Brito
File media/audio/audio_device_description.cc
Line 145, Patchset 13:std::string AudioDeviceDescription::GetApplicationId(
Olga Sharonova . resolved

This method cannot be here it should not be possible to extract application id from AudioDeviceDescription without unhashing; and ADD does not have access to that logic.

Generally, AudioDeviceDescription is used for device enumerations, and application loopbacks are never enumerated. So I suggest we move all this logic out into some other helper.

Gabriel Brito
File media/audio/audio_features.h
Line 37, Patchset 5:MEDIA_EXPORT bool IsApplicationLoopbackCaptureSupported();
Sunggook Chue . resolved

same here because application loopback feature is already supported for other OSs and this CL is only for Windows?

Gabriel Brito

Yes.

File media/audio/win/audio_low_latency_input_win.cc
Line 597, Patchset 5: : public Microsoft::WRL::RuntimeClass<
Sunggook Chue . resolved

probably, you don't want to remove this one like ComPtr by "using Microsoft::WRL::Runtimeclass", same for other Com classes.

Gabriel Brito

I will keep it just because it is the pattern for the rest of the file.

Line 647, Patchset 5: if (AudioDeviceDescription::IsApplicationDevice(device_id_)) {
Sunggook Chue . resolved

It isn't clear what this API means by just reading a name itself? code wise, device_id_ is audio output device id, if it has something else, then we have to explain it here or its declaration on the header.

Gabriel Brito

How is application loopback any different from system audio? Both are input streams, because they receive audio data from the OS audio rendering engine.

File media/audio/win/core_audio_util_win.cc

DCHECK(!(AudioDeviceDescription::IsApplicationDevice(device_id) &&
data_flow != eCapture));
Sunggook Chue . resolved

it looks like it follows the above pattern, but it is difficult to read though.

how about CHECK(!AudioDeviceDescription::IsApplicationDevice(device_id) || (data_flow == eCapture)), but it is up to you though as it could be easier for somoneone.

Gabriel Brito

I will keep it like this for now. But take it into consideration when pushing the final CLs.

Open in Gerrit

Related details

Attention is currently required from:
  • Elad Alon
  • Fredrik Hernqvist
  • Guido Urdaneta
  • Henrik Andreasson
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1bf6a7cf46233524e1c0ff0b5213197f50327d48
Gerrit-Change-Number: 6210165
Gerrit-PatchSet: 15
Gerrit-Owner: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Elad Alon <elad...@chromium.org>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: Fredrik Hernqvist <fhern...@google.com>
Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
Gerrit-CC: Henrik Andreasson <hen...@chromium.org>
Gerrit-CC: Olga Sharonova <ol...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-CC: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
Gerrit-Attention: Elad Alon <elad...@chromium.org>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 02 Apr 2025 03:05:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
Comment-In-Reply-To: Guido Urdaneta <gui...@chromium.org>
Comment-In-Reply-To: Fredrik Hernqvist <fhern...@google.com>
Comment-In-Reply-To: Elad Alon <elad...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Elad Alon (Gerrit)

unread,
Apr 2, 2025, 5:10:22 AMApr 2
to Gabriel Brito, Olga Sharonova, Guido Urdaneta, Fredrik Hernqvist, Henrik Andreasson, Sunggook Chue, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Andrew Rayskiy, Rijubrata Bhaumik, Simon Hangl, jophba...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, srahim...@chromium.org, chfreme...@chromium.org, feature-me...@chromium.org, rmcelra...@chromium.org
Attention needed from Fredrik Hernqvist, Gabriel Brito, Guido Urdaneta, Henrik Andreasson, Olga Sharonova and Sunggook Chue

Elad Alon added 17 comments

Commit Message
Line 7, Patchset 15 (Latest):[WIP] Application audio capture prototype for Windows
Elad Alon . unresolved

Still WIP?

File chrome/browser/media/webrtc/desktop_capture_devices_util.cc
Line 187, Patchset 15 (Latest): return l10n_util::GetStringFUTF16(
IDS_MEDIA_WINDOW_CAPTURE_WITH_AUDIO_NOTIFICATION_TEXT,
application_title);
Elad Alon . unresolved

Let's wrap this in `#if BUILDFLAG(IS_WIN)` for now.

Line 295, Patchset 15 (Latest): if (media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) {
Elad Alon . unresolved

This block is growing too long; please refactor it into a helper:
```
out_devices.audio_device = SomeHelper(...);
```
For bonus points, have this mini-refactor in a separate CL. (Optional)

Line 309, Patchset 15 (Latest): request.audio_type, application_id.value(), "Application Audio");
Elad Alon . unresolved

Are we exposing this to (i) the render process and/or (ii) the JS application? The first would be bad and the second worse.

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.h
Line 30, Patchset 15 (Latest):// window
// with the "Windows.UI.Core.CoreWindow" class name.
Elad Alon . unresolved

Auto-formatting error here.

Line 27, Patchset 15 (Latest):// created the windows identified by the provided HWND. Depending on the type of
Elad Alon . unresolved

s/windows/window

Line 25, Patchset 15 (Latest):// Given a window's HWND pointer, returns the PID of the application's "main
// process" for audio capture purposes. let "window process" be the process that
Elad Alon . unresolved

Following the logic of my earlier comment, this could have been your first sentence.

Line 26, Patchset 15 (Latest):// process" for audio capture purposes. let "window process" be the process that
Elad Alon . unresolved

Everything from here on out is the implementation detail, and does not belong in the header file.

Also: s/let/Let

Line 15, Patchset 15 (Latest):// creates and owns the window might not be the same that plays renders audio -
Elad Alon . unresolved

I think you meant to erase one of these verbs and keep the other.

Line 11, Patchset 15 (Latest):
Elad Alon . unresolved

This is great documentation - thank you for you diligence!

Just a pointer - start out with what the function does, and only explain why or how thereafter. It's easier for readers when a traditional structure is followed, even if it requires (briefly) stating the obvious; in this case, this could be "given a ID of a window, return the ID of the process with which the window is associated." When you *then* explain why a process ID is useful, the reader already has the right frame of mind.

File chrome/browser/media/webrtc/desktop_capture_devices_util_win.cc
Line 18, Patchset 15 (Latest):constexpr wchar_t kApplicationFrameHostName[] = L"ApplicationFrameHost.exe";
constexpr wchar_t kUWPAppCoreWindowClassName[] = L"Windows.UI.Core.CoreWindow";
Elad Alon . unresolved

Each of these is only used once, so please consider if it's really helpful to define them in file-scope, requiring the reader to skip around in the file to find them. (If you think there's is explanatory value in named constants instead of string literals, you can still define them closer to where they are used.)

Line 23, Patchset 15 (Latest):// window is found, this function should return false, signaling to
Elad Alon . unresolved

\`false\`

Line 27, Patchset 15 (Latest):BOOL CALLBACK IsUWPAppCoreWindow(HWND hwnd, LPARAM lParam) {
Elad Alon . unresolved

nit: Should you be returning `FALSE`/`TRUE` then?

Line 64, Patchset 15 (Latest): std::array<wchar_t, MAX_PATH + 1> executable_path_buffer;
Elad Alon . unresolved

Is this the one defined in `base/win/windows_types.h`? Can you #include the right header?

Line 66, Patchset 15 (Latest): if (QueryFullProcessImageName(process_handle, 0,
Elad Alon . unresolved

Invert the condition and use early-exit if it fails. This reduces complexity and indentation.

File media/audio/audio_features.cc
Line 27, Patchset 15 (Latest):// the user the option to also capture app-audio for window screen captures.
Elad Alon . unresolved

Remove "also", or else readers might understand it as "in addition to just capturing the window's own audio."

File media/audio/win/core_audio_util_win.cc
Line 388, Patchset 15 (Latest): DCHECK(!(AudioDeviceDescription::IsApplicationLoopbackDevice(device_id) &&
data_flow != eCapture));
Elad Alon . unresolved

New DCHECKs are discouraged (CHECKs are encouraged) unless the condition is expensive to evaluate. Is that the case?

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
  • Gabriel Brito
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 02 Apr 2025 09:10:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages