Please ensure that the development environment meets the following technical requirements:
ZegoExpressExample/Examples/AdvancedVideoProcessing/CustomVideoRendering
in this demo to render the preview or the playing stream on Linux Qt.QtCreator versions earlier than 8.0.1 may encounter the problem that the camera and microphone permissions cannot be requested on macOS 12 Monterey or above when running this demo, which may cause the demo to crash. Please refer to this issue.
To solve the problem, you can download and install QtCreator 8.0.2 or above, instead of using the QtCreator that comes with the Qt5 installation package.
You can download it from the QtCreator Github Release or the Qt official website, or install it through HomeBrew: brew update && brew install --cask qt-creator
.
A project has been created in ZEGOCLOUD Admin Console and a valid AppID has been applied.
A token has been generated. For details, please refer to Use Tokens for authentication. You can also obtain a temporary token (valid for 24 hours) in the ZEGOCLOUD Admin Console.
After installing CMake and Qt, you need to add environment variables:
The CMake and Qt paths provided below are for reference only, and users need to fill in according to the actual path on their device.
Windows system:
C:\Program Files\CMake\bin
to Path.C:\Qt\Qt5.9.8\5.9.8\msvc201d5\bin
to Path.QTDIR
user variable as C:\Qt\Qt5.12.12\5.12.12\msvc2017
.macOS system:
export PATH="$PATH:$HOME/Qt5.12.12/5.12.12/clang_64/bin"
export QTDIR="$HOME/Qt5.12.12/5.12.12/clang_64"
Linux system:
export QTDIR="/usr/local/Qt-5.12.12"
export PATH="$PATH:$QTDIR/bin"
export LD_LIBRARY_PATH="$QTDIR/lib:$LD_LIBRARY_PATH"
The directory tree is showed below, the paths given later will the relative to this directory :
.
├── README_zh.md
├── README.md
├── libs
│ ├── ScreenCapture
│ └── ZegoExpress
│ ├── linux # ZegoExpressVideo Linux SDK
│ ├── mac # ZegoExpressVideo Mac SDK
│ │ └── ZegoExpressEngine.xcframework
│ └── win # ZegoExpressVideo Windows SDK
│ ├── x64
│ └── x86
└── ZegoExpressExample
├── KeyCenter.cpp # Fill in the applied AppID and token
├── KeyCenter.h
├── ZegoExpressExample.pro # Qt project
├── Examples
├── HomePage
...
To facilitate the sample codes testing, the ZEGOCLOUD Admin Console provides the function of generating temporary tokens. You can directly obtain temporary tokens for use. However, in the your own online environment, the token must be generated through your own server.
// Developers can get appID from admin console.
// https://console.zego.im/dashboard
// for example: 123456789;
unsigned int KeyCenter::getAppID() {
return ; //Input AppID here
}
// Developers should customize a user ID.
// for example: "zego_benjamin";
std::string KeyCenter::getUserID() {
return ; //Input UserID here
}
// Developers can get token from admin console.
// https://console.zego.im/dashboard
// Note: The user ID used to generate the token needs to be the same as the userID filled in above!
// for example: "04AAAAAxxxxxxxxxxxxxx";
std::string KeyCenter::getToken() {
return ; //Input Token here
}
Open the project.
Use Qt Creator to open the "./ZegoExpressExample/ZegoExpressExample.pro" project file.
Compile and run the project.
Method 1: Run or Build the project directly through QtCreator.
After opening the Qt project, click the "Run", "Debug", and "Build" buttons in the lower left corner to build and run the Demo.
Method 2: Build the project with qmake and make
Windows
Open cmd.exe and execute the cd \path\to\this\folder
command to go to the directory where this file is located.
Find the path to "vcvarsall.bat" (for example, the VS 2019 version is at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat").
Execute the call "\path\to\your\vcvarsall.bat" x86
command to set up the MSVC environment.
Execute the qmake ZegoExpressExample\ZegoExpressExample.pro CONFIG+=Win32 -o .\build\Makefile
command to generate the Makefile through qmake.
Execute cd build
to enter the build directory and build the project with the nmake
command.
Execute cd ..
to return to the parent directory and deploy the Qt App through the windeployqt .\bin\release\ZegoExpressExample.exe
command.
macOS
Open Terminal and execute the cd /path/to/this/folder
command to go to the directory where this file is located.
Execute the qmake ZegoExpressExample/ZegoExpressExample.pro CONFIG+=x86_64 -o ./build/Makefile
command to generate the Makefile through qmake.
Execute the cd build
command to enter the build directory, and use the make
command to build the project.
Execute the cd ..
command to return to the parent directory, and deploy the Qt App through the macdeployqt ./bin/release/ZegoExpressExample.app
command.
Linux
cd /path/to/this/folder
qmake ZegoExpressExample/ZegoExpressExample.pro CONFIG+=x86_64 -o ./build/Makefile
generate Makefile with qmakecd build
and execute make
to build the projectZegoExpressExample
project file in the bin/release
directory of the upper directory and run itZegoExpressExample.pro
by yourself)Qt everywhere
installed for the target platform cross-compilation, the following assumes cross-compile for the aarch64 target and the corresponding Qt has been installed in the /usr/aarch64-linux-gnu/Qt-5.12.12
directoryexport TARGET_LINUX_ARCH=aarch64
, this environment variable is for ZegoExpressExample.pro
to identify the current target platform to build/usr/aarch64-linux-gnu/Qt-5.12.12/bin/qmake ZegoExpressExample/ZegoExpressExample.pro -o ./build/Makefile -spec linux-aarch64-gnu-g++
generate Makefile with qmake for the aarch64 targetcd build
to enter the build directory and execute make
to build the projectbin/release
directory and the /usr/aarch64-linux-gnu/Qt-5.12.12/lib
directory to your target platform and runWe recommend you run your project on a real device. If your app runs successfully, you should hear the sound and see the video captured locally from your device.
To test out the real-time audio and video features, visit the ZEGO Express Web Demo, and enter the same AppID
, Server
and RoomID
to join the same room. If it runs successfully, you should be able to view the video from both the local side and the remote side, and hear the sound from both sides as well.
In audio-only scenarios, no video will be captured and displayed.