This article shows how to integrate the Linux Server C++ SDK and run the sample project.
Make sure your server meets the following requirements.
Operating system
CPU architecture
If you need to run the SDK on other architectures, submit a ticket to contact technical support.
Performance
Network
*.agora.io
and *.agoralab.co
.If you are using Ubuntu, taking Ubuntu 20.04.3 LTS as an example, install the following dependencies in your server:
# Install aptitude
sudo apt install aptitude
# Install build-essential libx11-dev libxcomposite-dev libxext-dev libxfixes-dev libxdamage-dev cmake
sudo aptitude install libx11-dev libxcomposite-dev libxext-dev libxfixes-dev libxdamage-dev cmake
If you are using CentOS, taking CentOS 7.9.2009 as an example, install the following dependencies in your server:
sudo yum groupinstall "Development Tools"
sudo yum install wget
sudo yum groupinstall X11
See Get Started with Agora to learn how to get an Agora App ID and an RTC temporary token.
Run the following command to get the latest x86-64 SDK package and decompress the file. If you need to get the SDK build on other architectures, submit a ticket to contact technical support.
# Get SDK
wget https://download.agora.io/sdk/release/Agora-RTC-x86_64-linux-gnu-v3.8.202.20-20220627_152601-214165.tgz
# Decompress the tgz file
tar xvf Agora-RTC-x86_64-linux-gnu-v3.8.202.20-20220627_152601-214165.tgz
Run the following commands to compile the sample project:
# Switch to the sample project folder
cd agora_rtc_sdk/example
# Build the sample project
./build-x86_64.sh
# Sync and video/audio data needed by the project
cd out
../sync-data.sh
# Export the libraries from the SDK to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=../../agora_sdk:$LD_LIBRARY_PATH
This section uses the sample_send_h264_pcm project to demonstrate sending media streams from the server.
Run the sample_send_h264_pcm sample project. Replace YOUR_RTC_TOKEN
, the parameter value of --token
, with your RTC temporary token. Replace the parameter value of --channelId
with the value of your RTC channel ID. In this page, the value of --channelId
is set to demo_channel
.
# Run sample_send_h264_pcm to send video in H.264 format and audio in PCM format
./sample_send_h264_pcm --token YOUR_RTC_TOKEN --channelId demo_channel --videoFile test_data/send_video.h264 --audioFile test_data/send_audio_16k_1ch.pcm
Use a PC or mobile device to open the Agora RTC Web SDK sample project and specify the following fields:
demo_channel
.Click Join to receive media streams from the server.
This section uses the sample_send_h264_pcm project to demonstrate receiving media streams from the client.
Run the sample_receive_h264_pcm project. Replace YOUR_RTC_TOKEN
, the parameter value of --token
, with your RTC temporary token. Replace the parameter value of --channelId
with the value of your RTC channel ID. In this page, the value of --channelId
is set to demo_channel
.
# Run sample_receive_h264_pcm to receive video in H.264 format and audio in PCM format
./sample_receive_h264_pcm --token YOUR_RTC_TOKEN --channelId demo_channel
When the sample project is running, the console prints the following information:
[ APP_LOG_INFO ] Subscribe streams from all remote users
[ APP_LOG_INFO ] Start receiving audio & video data ...
[ APP_LOG_INFO ] Created file received_audio.pcm to save received PCM samples
[ APP_LOG_INFO ] onUserAudioTrackStateChanged: userId 4088243221, state 1, reason 0
[ APP_LOG_INFO ] onUserAudioTrackStateChanged: userId 4088243221, state 2, reason 6
[ APP_LOG_INFO ] onUserInfoUpdated: userId 4088243221, msg 0, val 0
[ APP_LOG_INFO ] onUserInfoUpdated: userId 4088243221, msg 4, val 1
[ APP_LOG_INFO ] onUserInfoUpdated: userId 4088243221, msg 8, val 1
[ APP_LOG_INFO ] onUserInfoUpdated: userId 4088243221, msg 1, val 1
demo_channel
.Click Join to receive media streams to the server.
When the sample project is running, the console prints the following information:
[ APP_LOG_INFO ] onUserInfoUpdated: userId 436868190, msg 0, val 1
[ APP_LOG_INFO ] onUserInfoUpdated: userId 436868190, msg 4, val 1
[ APP_LOG_INFO ] onUserInfoUpdated: userId 436868190, msg 8, val 1
[ APP_LOG_INFO ] onUserInfoUpdated: userId 436868190, msg 1, val 1
[ APP_LOG_INFO ] onUserInfoUpdated: userId 436868190, msg 0, val 0
[ APP_LOG_INFO ] onUserInfoUpdated: userId 436868190, msg 1, val 0
[ APP_LOG_INFO ] onUserVideoTrackSubscribed: userId 436868190, codecType 1, encodedFrameOnly 1
[ APP_LOG_INFO ] onUserAudioTrackStateChanged: userId 436868190, state 1, reason 0
[ APP_LOG_INFO ] onUserAudioTrackStateChanged: userId 436868190, state 2, reason 6
[ APP_LOG_INFO ] Created file received_video.h264 to save received H264 frames
[ APP_LOG_INFO ] onUserAudioTrackStateChanged: userId 436868190, state 0, reason 7
The received video and audio are saved in the received_video.h264
file and the received_audio.pcm
file, respectively.