feat: add enableLocalEcho flag to setDisplayMediaRequestHandler() callback (#37315)

This commit is contained in:
Theo Gravity 2023-03-01 02:37:19 -08:00 committed by GitHub
parent 5e25d23794
commit 49df19214e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -916,6 +916,10 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
Specifying a loopback device will capture system audio, and is Specifying a loopback device will capture system audio, and is
currently only supported on Windows. If a WebFrameMain is specified, currently only supported on Windows. If a WebFrameMain is specified,
will capture audio from that frame. will capture audio from that frame.
* `enableLocalEcho` Boolean (optional) - If `audio` is a [WebFrameMain](web-frame-main.md)
and this is set to `true`, then local playback of audio will not be muted (e.g. using `MediaRecorder`
to record `WebFrameMain` with this flag set to `true` will allow audio to pass through to the speakers
while recording). Default is `false`.
This handler will be called when web content requests access to display media This handler will be called when web content requests access to display media
via the `navigator.mediaDevices.getDisplayMedia` API. Use the via the `navigator.mediaDevices.getDisplayMedia` API. Use the

View file

@ -501,11 +501,14 @@ void ElectronBrowserContext::DisplayMediaDeviceChosen(
devices.audio_device = devices.audio_device =
blink::MediaStreamDevice(request.audio_type, id, name); blink::MediaStreamDevice(request.audio_type, id, name);
} else if (result_dict.Get("audio", &rfh)) { } else if (result_dict.Get("audio", &rfh)) {
devices.audio_device = blink::MediaStreamDevice( bool enable_local_echo = false;
request.audio_type, result_dict.Get("enableLocalEcho", &enable_local_echo);
content::WebContentsMediaCaptureId(rfh->GetProcess()->GetID(), bool disable_local_echo = !enable_local_echo;
rfh->GetRoutingID(), devices.audio_device =
/* disable_local_echo= */ true) blink::MediaStreamDevice(request.audio_type,
content::WebContentsMediaCaptureId(
rfh->GetProcess()->GetID(),
rfh->GetRoutingID(), disable_local_echo)
.ToString(), .ToString(),
"Tab audio"); "Tab audio");
} else if (result_dict.Get("audio", &id)) { } else if (result_dict.Get("audio", &id)) {