Skip to main content

Enable WebRTC on QtWebEngine for Raspberry Pi 3

WebRTC is a web technology to enable peer to peer communication in real-time. It mainly uses to create video conferencing and chat applications using web browsers. In this post, we describe how to enable this technology in QtWebEngine on Raspberry Pi 3 platform.

QtWebEngine is an embedded browser component which comes with the Qt framework. This component is based on Google Chromium browser and it supports most of the Chromium features including WebRTC. In PC, WebRTC applications run smoothly on QtWebEngine component. But in Raspberry Pi platform situation is different and none of the WebRTC application is work with the QtWebEngine. The only thing which we can see is a black box in an HTML5 video tag area. At the time of writing this problem exists in Qt version 5.6, 5.7 and 5.8.

This article explains how to resolve this problem in Qt 5.6.2, but this can be applied for other Qt versions which released recently.

In this article, we use Ubuntu 16.04 (AMD64) based PC to cross compile the Qt framework and Raspberry Pi 3 Model B board is used as a target platform. We are not sure how this works with other Raspberry Pi platforms.

  • In host PC create a working directory and get Raspberry Pi tool-chain:
    mkdir ~/raspi
    cd ~/raspi
    git clone https://github.com/raspberrypi/tools
    
  • In Raspberry Pi open /etc/apt/sources.list and un-comment the deb-src line.
  • Execute the following set of commands in Raspberry Pi:
    sudo apt-get update
    sudo apt-get build-dep qt4-x11
    sudo apt-get build-dep libqt5gui5
    sudo apt-get install libudev-dev libinput-dev libts-dev \
    libxcb-xinerama0-dev libxcb-xinerama0
     
    sudo mkdir /usr/local/qt5pi
    sudo chown pi:pi /usr/local/qt5pi
    
  • After setting up above packages in Raspberry Pi execute following commands in host PC. (In below commands replace IP-ADDRESS with actual Raspberry Pi IP address).
    mkdir sysroot sysroot/usr sysroot/opt
    rsync -avz pi@IP-ADDRESS:/lib sysroot
    rsync -avz pi@IP-ADDRESS:/usr/include sysroot/usr
    rsync -avz pi@IP-ADDRESS:/usr/lib sysroot/usr
    rsync -avz pi@IP-ADDRESS:/opt/vc sysroot/opt
    
    wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/ \
    sysroot-relativelinks.py
    
    chmod +x sysroot-relativelinks.py
    ./sysroot-relativelinks.py sysroot
    
    ./configure -release -opengl es2 -device linux-rasp-pi2-g++ 
    -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-\
    arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- 
    -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs 
    -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi 
    -hostprefix ~/raspi/qt5 -v
    
    make
    make install
    
  • After compiling qtbase compile qtdeclarative, qtconnectivity, qtlocation, and qtwebchannel with following commands:
    cd  qtdeclarative
    ~/raspi/qt5/bin/qmake
    make
    make install
    
  • After compiling above libraries execute install-build-deps.sh file in ~/raspi/qt/qtwebengine/src/3rdparty/chromium/build directory to install chromium build tools/packages in host PC.
  • Change directory to qtWebEngine directory and execute the following set of commands:
    ~/raspi/qt5/bin/qmake WEBENGINE_CONFIG+=use_proprietary_codecs
    make
    make install
    
  • Now synchronize Raspberry Pi from the host with the following command:
    rsync -avz qt5pi pi@IP-ADDRESS:/usr/local
    
  • After synchronization, execute the following set of commands in Raspberry Pi:
    sudo rm /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 
    /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
    sudo ln -s /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
    sudo ln -s /opt/vc/lib/libGLESv2.so 
    /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
    
    sudo ln -s /opt/vc/lib/libEGL.so /opt/vc/lib/libEGL.so.1
    sudo ln -s /opt/vc/lib/libGLESv2.so /opt/vc/lib/libGLESv2.so.2
    
After the above steps target Raspberry Pi is ready to run hardware accelerated OpenGL (with EGLFS) Qt application with QWebEngine.

To test the WebRTC functionality we create simple Qt widgets application using QWebEngine. In this test application we load AppRTC (http://appr.tc) into QwebEngine to test the WebRTC functionality.

QWebEngineView *_webEngine = new QWebEngineView();
_webEngine->load(QUrl("https://appr.tc/"));

In above application we make sure to handle QwebEnginePage::featurePermissionRequested signal to authorize camera / multimedia devices for QwebEngine. In our test application above signal is handled as follows:

_webEngine->page()->setFeaturePermission(securityOrigin, feature, 
QWebEnginePage::PermissionGrantedByUser);

With above command test application allows QwebEngine to access any camera /multimedia device it requests.

In hardware accelerated OpenGL mode some Qt application getting crash due to lack of GPU memory. To fix this add 'gpu_mem=512' to the bottom of the /boot/config.txt file in Raspberry Pi.

For this setup we use Raspberry Pi 3 with Raspbian Jessie (in console mode). Above described sample Qt application is tested with Logitech C270 USB web camera.

Comments

jhon said…
last fourteen years. We use all our experience to produce quality products. We also manufacture other products such as auto dealer, security alarm burglary alarm and solar systems. We apply our best expertise and our rich experience to manufacture quality products.Complete Alarms CCTV & Alarm Systems

Popular posts from this blog

CD2003 - yet another simple FM radio receiver

In the last few days, we are looking for some simple FM radio receiver to integrate into one of our ongoing projects. For that, we try several FM radio receiver ICs including TDA7000, CD2003/TA2003/TA8164, CXA1019, and KA22429. Out of all those chips we select CD2003 (or TA2003/TA8164) based receiver for our project because of its simplicity and outstanding performance. Except to CD2003, Sony CXA1019 also perform well but we drop it because of its higher component count. We design our receiver based on Toshiba TA2003 datasheet and later we try TA8164 and CD2003 with the same circuit. Either CD2003 or TA8164 can directly replace TA2003 IC, and as per our observations, TA8164 gives excellent results out of those 3 chips. A prototype version of CD2003 FM radio receiver The PCB design and schematic which we used in our prototype project are available to download at google drive (including pin-outs of crystal filters and inductors ). Except for CD2003 IC, this receiver consist

Arduino superheterodyne receiver

In this project, we extend the shortwave superheterodyne receiver we developed a few years ago . Like the previous design, this receiver operates on the traditional superheterodyne principle.  In this upgrade, we enhanced the local oscillator with Si5351 clock generator module and Arduino control circuit. Compared to the old design, this new receiver uses an improved version of an intermediate frequency amplifier with 3 I.F transformers. In this new design, we divide this receiver into several blocks, which include, mixer with a detector, a local oscillator, and an I.F amplifier. The I.F amplifier builds into one PCB. The filter stage, mixer, and detector stages place in another PCB. Prototype version of 455kHz I.F amplifier. In this prototype build, the Si5351 clock generator drives using an Arduino Uno board. With the given sketch, the user can tune and switch the shortwave meter bands using a rotary encoder. The supplied sketch support clock generation from 5205kHz (tuner frequ

Calculator for audio output transformers

Audio output transformers are heavily used in a vacuum tube and some (older) transistor base audio power amplifiers, but these days output transformer are quite hard to find and expensive item. For homebrew projects, the best option is to construct those transformers by ourselves and this script helps to calculate winding parameters for those transformers. This " AF output transformer calculator " script is written using Python and it works with most of the commonly available Python interpreters . The script is available to download at google drive under the terms of GNU General Public License version 3.0 . Homebrewed 25k: 4 output transformer Once supplied the input parameters this script provides a winding ratio, the number of turns required for primary and secondary winding and required copper wire gauges for both primary and secondary windings, etc. We construct several AF output transformers based on results of this script, which including transformers for M