Qt Webengine featurePermissionRequested signal not emitted

  • I am trying to load a page https://webrtc.github.io/samples/src/content/getusermedia/getdisplaymedia which do WebRTC screen sharing,

    And I have to apply permission to capture the desktop using the code

    webPage->setFeaturePermission(QUrl(url), QWebEnginePage::DesktopVideoCapture, QWebEnginePage::PermissionGrantedByUser);

    And the doc here https://doc.qt.io/qt-5/qwebenginepage.html#setFeaturePermission says I can call it when the signal featurePermissionRequested emitted. I have connect the signal with a slot but it's not getting called when I load the page.

    I am getting following error when try to capture the screen

    [2228:3460:0424/114301.567:INFO:CONSOLE(74)] "Start capturing.", source: https://webrtc.github.io/samples/src/content/getusermedia/getdisplaymedia/js/main.js (74)
    js: Uncaught (in promise) NotAllowedError: Invalid state
    [2228:3460:0424/114301.599:INFO:CONSOLE(99)] "Uncaught (in promise) NotAllowedError: Invalid state", source: https://webrtc.github.io/samples/src/content/getusermedia/getdisplaymedia/js/main.js (99)

    Here is the code

        QString  url ="https://webrtc.github.io/samples/src/content/getusermedia/getdisplaymedia/";
        QWebEngineView *webEngineView =  new QWebEngineView(parent);
        connect(webEngineView->page(), SIGNAL(featurePermissionRequested(const QUrl&, 
        QWebEnginePage::Feature)), this,SLOT(featurePermissionRequestedSlot(const QUrl&, QWebEnginePage::Feature)));

    When I click start screen capture the slot featurePermissionRequestedSlot not called, what could be the reason.

  • @haris123 This page uses getDisplayMedia() but that is not supported by QtWebEngine, and I think that is the cause of the error. Try this page "https://test.webrtc.org/" and this code: https://stackoverflow.com/a/49312976/6622587

  • @eyllanesc Thanks for the feed, basically I need to create a screen sharing application using Qt, I found that the webRTC has the functionality for that, the client will access the screen using browser, but in server PC(screen sharing PC) I need to do using QT. Is there any other way.

  • Can try:

    QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true);

Log in to reply