Skip to content

Commit 89ccf99

Browse files
authored
browser(firefox): screencast for Mac headful (#2985)
1 parent 056f0e2 commit 89ccf99

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

browser_patches/firefox/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1129
2-
Changed: [email protected] Wed Jul 15 23:55:13 GMTST 2020
1+
1130
2+
Changed: [email protected] Thu Jul 16 15:31:21 PDT 2020

browser_patches/firefox/juggler/protocol/PageHandler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ class PageHandler {
296296
const docShell = this._pageTarget._gBrowser.ownerGlobal.docShell;
297297
// Exclude address bar and navigation control from the video.
298298
const rect = this._pageTarget.linkedBrowser().getBoundingClientRect();
299-
this._videoSessionId = screencast.startVideoRecording(docShell, file, width, height, scale || 0, rect.top);
299+
const devicePixelRatio = this._pageTarget._window.devicePixelRatio;
300+
this._videoSessionId = screencast.startVideoRecording(docShell, file, width, height, scale || 0, devicePixelRatio * rect.top);
300301
}
301302

302303
stopVideoRecording() {

browser_patches/firefox/juggler/screencast/nsScreencastService.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,14 @@ rtc::scoped_refptr<webrtc::VideoCaptureModule> CreateWindowCapturer(nsIWidget* w
3737
HeadlessWidget* headlessWidget = static_cast<HeadlessWidget*>(widget);
3838
return HeadlessWindowCapturer::Create(headlessWidget);
3939
}
40-
#ifdef MOZ_WIDGET_GTK
41-
mozilla::widget::CompositorWidgetInitData initData;
42-
widget->GetCompositorWidgetInitData(&initData);
43-
const mozilla::widget::GtkCompositorWidgetInitData& gtkInitData = initData.get_GtkCompositorWidgetInitData();
44-
nsCString windowId;
45-
# ifdef MOZ_X11
46-
windowId.AppendPrintf("%lu", gtkInitData.XWindow());
47-
return webrtc::DesktopCaptureImpl::Create(sessionId, windowId.get(), webrtc::CaptureDeviceType::Window);
48-
# else
49-
// TODO: support in wayland
50-
fprintf(stderr, "Video capture for Wayland is not implemented\n");
51-
return nullptr;
52-
# endif
53-
#elif defined(_WIN32)
54-
mozilla::widget::CompositorWidgetInitData initData;
55-
widget->GetCompositorWidgetInitData(&initData);
56-
const mozilla::widget::WinCompositorWidgetInitData& winInitData = initData.get_WinCompositorWidgetInitData();
40+
uintptr_t rawWindowId = reinterpret_cast<uintptr_t>(widget->GetNativeData(NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID));
41+
if (!rawWindowId) {
42+
fprintf(stderr, "Failed to get native window id\n");
43+
return nullptr;
44+
}
5745
nsCString windowId;
58-
windowId.AppendPrintf("%lu", winInitData.hWnd());
46+
windowId.AppendPrintf("%" PRIuPTR, rawWindowId);
5947
return webrtc::DesktopCaptureImpl::Create(sessionId, windowId.get(), webrtc::CaptureDeviceType::Window);
60-
#else
61-
fprintf(stderr, "Video capture is not implemented on this platform\n");
62-
return nullptr;
63-
#endif
6448
}
6549
}
6650

0 commit comments

Comments
 (0)