зеркало из https://github.com/electron/electron.git
fix: instantiate tab video tracks from BrowserCaptureMediaStreamTrack (#39074)
return BrowserCaptureMediaStreamTrack instead of MediaStreamTrack
This commit is contained in:
Родитель
e1d63794e5
Коммит
2481f94b4e
|
@ -580,7 +580,7 @@ void ElectronBrowserContext::DisplayMediaDeviceChosen(
|
|||
blink::MediaStreamDevice video_device(request.video_type, id, name);
|
||||
video_device.display_media_info = DesktopMediaIDToDisplayMediaInformation(
|
||||
nullptr, url::Origin::Create(request.security_origin),
|
||||
content::DesktopMediaID::Parse(request.requested_video_device_id));
|
||||
content::DesktopMediaID::Parse(video_device.id));
|
||||
devices.video_device = video_device;
|
||||
} else if (result_dict.Get("video", &rfh)) {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
|
@ -592,7 +592,7 @@ void ElectronBrowserContext::DisplayMediaDeviceChosen(
|
|||
base::UTF16ToUTF8(web_contents->GetTitle()));
|
||||
video_device.display_media_info = DesktopMediaIDToDisplayMediaInformation(
|
||||
web_contents, url::Origin::Create(request.security_origin),
|
||||
content::DesktopMediaID::Parse(request.requested_video_device_id));
|
||||
content::DesktopMediaID::Parse(video_device.id));
|
||||
devices.video_device = video_device;
|
||||
} else {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
|
|
|
@ -283,6 +283,29 @@ describe('setDisplayMediaRequestHandler', () => {
|
|||
expect(ok).to.be.true(message);
|
||||
});
|
||||
|
||||
it('returns a MediaStream with BrowserCaptureMediaStreamTrack when the current tab is selected', async () => {
|
||||
const ses = session.fromPartition('' + Math.random());
|
||||
let requestHandlerCalled = false;
|
||||
ses.setDisplayMediaRequestHandler((request, callback) => {
|
||||
requestHandlerCalled = true;
|
||||
callback({ video: w.webContents.mainFrame });
|
||||
});
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: ses } });
|
||||
await w.loadURL(serverUrl);
|
||||
const { ok, message } = await w.webContents.executeJavaScript(`
|
||||
navigator.mediaDevices.getDisplayMedia({
|
||||
preferCurrentTab: true,
|
||||
video: true,
|
||||
audio: false,
|
||||
}).then(stream => {
|
||||
const [videoTrack] = stream.getVideoTracks();
|
||||
return { ok: videoTrack instanceof BrowserCaptureMediaStreamTrack, message: null };
|
||||
}, e => ({ok: false, message: e.message}))
|
||||
`, true);
|
||||
expect(requestHandlerCalled).to.be.true();
|
||||
expect(ok).to.be.true(message);
|
||||
});
|
||||
|
||||
ifit(!(process.platform === 'darwin' && process.arch === 'x64'))('can supply a screen response to preferCurrentTab', async () => {
|
||||
const ses = session.fromPartition('' + Math.random());
|
||||
let requestHandlerCalled = false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче