logo
Video Call
Other Features
On this page

Running Example Source Code


Warning

This example source code is a simple command-line program. You can refer to the cross-platform desktop C++ Example Source Code Documentation to get richer Qt example source code.

This article introduces how to quickly run through the example source code and experience basic audio/video call services.

Prepare Environment

Before starting to integrate ZEGO Express SDK, please ensure that the development environment meets the following requirements:

  • Any Linux distribution system with GLIBC 2.16 or higher version, supporting x86_64, aarch64, armhf, armel architectures.
  • libasound (ALSA).
  • libv4l2 (v4l utils).
  • CMake 3.7 or higher version.
Note
  • SDK depends on libasound (ALSA) and libv4l2 (v4l utils).
  • CentOS (RHEL/Fedora) can be installed by executing yum install alsa-lib-devel libv4l-devel command.
  • Ubuntu (Debian/Deepin) can be installed by executing apt install libasound2-dev libv4l-dev command.
  • For other platforms and systems, please install by yourself.
  • If cross-compilation is needed, please refer to How to cross-compile Linux alsa-lib dependency library? and How to cross-compile Linux v4l-utils dependency library? documents. At the same time, the target machine needs to have libasound and libv4l2 dependency libraries installed.

Prerequisites

You have created a project in the ZEGOCLOUD Console and applied for a valid AppID and AppSign.

Warning

SDK also supports Token authentication. If you need to upgrade the authentication method, please refer to How to upgrade from AppSign authentication to Token authentication.

Build Example Source Code Project

Get Example Source Code

Example Source Code Directory Structure

The following structure is the file structure of the project directory. The file paths involved below are all relative to this directory.

.
├── README.md
├── README_zh.md
└── ZegoExpressExample
    ├── .gitignore
    ├── Broadcaster.cc # Camera live streaming example
    ├── Broadcaster.h
    ├── CMakeLists.txt
    ├── ExampleBase.h
    ├── MediaPublisher.cpp # Media data publisher example
    ├── MediaPublisher.h
    ├── Options.h
    ├── libs
    ├── main.cpp # Program entry
    └── wingetopt

Before Building Example Source Code, Check Whether Dependencies Are Satisfied

Find the directory of SDK Native dynamic libraries for the corresponding architecture (i.e., the directory storing libZegoExpressEngine.so), open a terminal and execute the following command to check the output. If there is information such as not found, it means dependencies are not satisfied. Please check and install missing dependencies.

Note

This project is a CMake project. You can use VS Code or any other IDE to open the ./ZegoExpressExample directory to view the source code.

$ ldd libZegoExpressEngine.so

Method 1: Native Compilation (supports x86_64, aarch64, armhf and armel)

  1. Execute cd ./ZegoExpressExample command to enter the project root directory (i.e., the directory where the "main.cpp" file is located).

  2. Generate Makefile to the "build" directory of the current directory through CMake.

    $ cmake -B"build"
  3. Compile the example code project through Make.

    $ make -C ./build

Method 2: Cross-Compilation

  1. Currently supports cross-compiling for aarch64, armhf or armel target platforms in x86_64 environment (if you need to support other environments, please modify the configuration in CMakeLists.txt by yourself).

  2. Confirm that your machine has installed gcc/g++ for cross-compilation for the target platform. The following assumes cross-compilation for aarch64 target platform.

  3. Execute export TARGET_LINUX_ARCH=aarch64. This environment variable is for CMakeLists.txt to identify the current target platform to build.

  4. Generate Makefile to the "build" directory of the current directory through CMake.

    $ cmake -B"build"
  5. Compile the example code project through Make.

    $ make -C ./build

Run Example Source Code

  1. After successful build, the executable binary file of the example code will be generated to the "./ZegoExpressExample/out" directory.

  2. Open a terminal, execute the executable binary file of the example code, and then continue operating according to the printed help information.

    The running effect is as follows:

Experience Real-Time Audio/Video Functions

Run the project on a real device. After successful running, you can see the local video image.

For convenience of experience, ZEGO provides a Web platform for debugging. On this page, enter the same AppID and RoomID, enter different UserIDs, and the corresponding Token, then you can join the same room to interoperate with the real device. When the audio/video call starts successfully, you can hear the remote audio and see the remote video image.

Previous

Common Error Codes

Next

Integrating SDK