- Documentation
- Voice Call
- Resources & Reference
- Sample code
- Download
Guidelines for Running Sample Codes
Prerequisites
Please ensure that the development environment meets the following technical requirements:
- Windows: Windows 7 or above, with Visual Studio 2019 or above.
- macOS: macOS 11.0 or above, with Xcode 13 or above.
- Linux: Any Linux distro with GLIBC 2.16 or above, supporting x86_64, aarch64, armhf architectures
- CMake has been installed.
- Qt (5.9 ~ 5.15) have been installed. For details please refer to Getting Started with Qt.
- External devices that support audio and video functions such as microphones and cameras are normal.
- The Linux RTC SDK only supports custom video rendering, and does not support SDK automatic rendering (that is, the ZegoCanvas parameters for preview and streaming are invalid), so the demo can not display video except for custom video rendering topics.
- You can refer to the Custom Video Rendering document and the sample code
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:
- Modify Environment Variables: add
C:\Program Files\CMake\bin
to Path. - Modify Environment Variables: add
C:\Qt\Qt5.9.8\5.9.8\msvc201d5\bin
to Path. - Add User Variables: add
QTDIR
user variable asC:\Qt\Qt5.12.12\5.12.12\msvc2017
.
- Modify Environment Variables: add
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"
Sample Codes Directory Structure
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
...
Run the Sample Codes
- The AppID, userID and token required for SDK initialization are missing in the sample code. You need to modify the "/ZegoExpressExample/KeyCenter.cpp" file. Please fill in the AppID and Token obtained in Prerequisites correctly, otherwise the sample codes will not run normally.
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 thenmake
command.Execute
cd ..
to return to the parent directory and deploy the Qt App through thewindeployqt .\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 themake
command to build the project.Execute the
cd ..
command to return to the parent directory, and deploy the Qt App through themacdeployqt ./bin/release/ZegoExpressExample.app
command.
Linux
- Open terminal and cd to the directory where this file is located
cd /path/to/this/folder
- Select the build environment
- Native compile (support x86_64, aarch64, armhf)
- Execute
qmake ZegoExpressExample/ZegoExpressExample.pro CONFIG+=x86_64 -o ./build/Makefile
generate Makefile with qmake cd build
and executemake
to build the project- Find the
ZegoExpressExample
project file in thebin/release
directory of the upper directory and run it
- Execute
- Cross compile
- Currently supports cross-compiling for aarch64 or armhf target platform in x86_64 environment (if you need to support other environments, you can modify the project configuration
ZegoExpressExample.pro
by yourself) - Make sure your machine has
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
directory - Execute
export TARGET_LINUX_ARCH=aarch64
, this environment variable is forZegoExpressExample.pro
to identify the current target platform to build - Execute
/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 target cd build
to enter the build directory and executemake
to build the project- Copy the products in the
bin/release
directory and the/usr/aarch64-linux-gnu/Qt-5.12.12/lib
directory to your target platform and run
- Currently supports cross-compiling for aarch64 or armhf target platform in x86_64 environment (if you need to support other environments, you can modify the project configuration
- Native compile (support x86_64, aarch64, armhf)
- Open terminal and cd to the directory where this file is located
Experience Real-time Audio and Video Call/Live Streaming Functions
We 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.