Skip to content

Commit

Permalink
Screencast for Mac headful
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Jul 16, 2020
1 parent 811b240 commit 6088dab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
3 changes: 2 additions & 1 deletion juggler/protocol/PageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ class PageHandler {
const docShell = this._pageTarget._gBrowser.ownerGlobal.docShell;
// Exclude address bar and navigation control from the video.
const rect = this._pageTarget.linkedBrowser().getBoundingClientRect();
this._videoSessionId = screencast.startVideoRecording(docShell, file, width, height, scale || 0, rect.top);
const devicePixelRatio = this._pageTarget._window.devicePixelRatio;
this._videoSessionId = screencast.startVideoRecording(docShell, file, width, height, scale || 0, devicePixelRatio * rect.top);
}

stopVideoRecording() {
Expand Down
28 changes: 6 additions & 22 deletions juggler/screencast/nsScreencastService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,14 @@ rtc::scoped_refptr<webrtc::VideoCaptureModule> CreateWindowCapturer(nsIWidget* w
HeadlessWidget* headlessWidget = static_cast<HeadlessWidget*>(widget);
return HeadlessWindowCapturer::Create(headlessWidget);
}
#ifdef MOZ_WIDGET_GTK
mozilla::widget::CompositorWidgetInitData initData;
widget->GetCompositorWidgetInitData(&initData);
const mozilla::widget::GtkCompositorWidgetInitData& gtkInitData = initData.get_GtkCompositorWidgetInitData();
nsCString windowId;
# ifdef MOZ_X11
windowId.AppendPrintf("%lu", gtkInitData.XWindow());
return webrtc::DesktopCaptureImpl::Create(sessionId, windowId.get(), webrtc::CaptureDeviceType::Window);
# else
// TODO: support in wayland
fprintf(stderr, "Video capture for Wayland is not implemented\n");
return nullptr;
# endif
#elif defined(_WIN32)
mozilla::widget::CompositorWidgetInitData initData;
widget->GetCompositorWidgetInitData(&initData);
const mozilla::widget::WinCompositorWidgetInitData& winInitData = initData.get_WinCompositorWidgetInitData();
uintptr_t rawWindowId = reinterpret_cast<uintptr_t>(widget->GetNativeData(NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID));
if (!rawWindowId) {
fprintf(stderr, "Failed to get native window id\n");
return nullptr;
}
nsCString windowId;
windowId.AppendPrintf("%lu", winInitData.hWnd());
windowId.AppendPrintf("%" PRIuPTR, rawWindowId);
return webrtc::DesktopCaptureImpl::Create(sessionId, windowId.get(), webrtc::CaptureDeviceType::Window);
#else
fprintf(stderr, "Video capture is not implemented on this platform\n");
return nullptr;
#endif
}
}

Expand Down

0 comments on commit 6088dab

Please sign in to comment.