Quickly run the ARTC Linux SDK Golang example project to experience real-time audio and video features.
Get Example Source Code
Download the latest version of the ARTC Linux SDK from the SDK download page. Extract the package and navigate to the Go folder. The deliverables include the following:
artc_linux_go/
├── alirtc
│ ├── AliRTCEngine.go
│ ├── AliRTCEngineImpl.go
│ ├── AliRTCLinuxSdkDefine.go
│ ├── go.mod
│ └── lib
│ ├── AliRtcCoreService
│ ├── libAliRtcLinuxEngine.so
│ └── libonnxruntime.so.1.16.3
├── demo.go
├── go.mod
└── README.md
-
The alirtc directory contains the SDK dynamic link library and Go interface wrappers that implement RTC stream ingest and pulling, consistent with the C++ interface.
-
demo.go provides a simple example. Replace ALIRTC_APPID, ALIRTC_APPKEY, and LIBPATH to run it.
Prerequisites
Before running the example project, ensure you meet the following requirements:
-
Your Linux kernel version must be 2.6 or later, and your Go runtime must be version 1.22.5 or later. If you plan to extend development based on the C++ interface, ensure your GCC version is 4.8 or later.
-
Obtain the AppID and AppKey for your ApsaraVideo Real-time Communication application. For details, see Get Development Parameters.
Procedure
Configure the Example Project
Open a terminal. Navigate to the Go directory. Edit demo.go to configure your APPID and APPKEY, and specify the path to AliRtcCoreService.
-
Obtain the APPID and APPKEY from the console after creating an application.
-
AliRtcCoreService is located at AliRTCSDK_Linux-7.10.2/Go/alirtc/lib/AliRtcCoreService.

Run the Demo
Configure your Go environment as described in the prerequisites.
Run the following command to start the demo:
go run demo.go
If the terminal displays the following output, the client has successfully joined the channel and started stream ingest.
# Joined channel successfully
[Go] on join channel result. Channel: 123123, user: linux, result: 0
# Stream ingest successful
[Go] on audio publish state changed, oldState: 0, newState: 2
[Go] on video publish state changed, oldState: 0, newState: 2
[Go] on audio publish state changed, oldState: 2, newState: 3
[Go] on video publish state changed, oldState: 2, newState: 3
# Remote user web is online
[Go] on remote user online: web
# Received audio and video streams from remote user abcd
[Go] on audio subscribe state of web, oldState: 0, newState: 2
[Go] on video subscribe state of web, oldState: 0, newState: 2
[Go] on audio subscribe state of web, oldState: 2, newState: 3
[Go] on video subscribe state of web, oldState: 2, newState: 3
When you select the AudioFormatMixedPcm mode for audio subscription, an audio callback is triggered when you join the meeting, regardless of whether other users are present. When you select the AudioFormatPcmBeforMixing mode, an audio callback is triggered only if other users are in the meeting and publishing an audio stream.
If "go run demo.go" reports an error, delete the go.mod file in the current directory and the go.mod file in the alirtc directory. Change to the alirtc directory and run "go mod init alirtc". Then, change to the directory containing demo.go and run the following commands in sequence: "go mod init demo", "go mod edit -replace alirtc=./alirtc", "go mod tidy", and "go run demo.go".