Java

更新时间:
复制 MD 格式

Quickly run the ARTC Linux SDK Java sample project to try out real-time audio and video features.

Get sample source code

Download the latest ARTC Linux SDK from SDK download. Extract the package and open the Java folder. The deliverables include libs and Demo/MainTest.java.

|   README.md
|
+---com
|   \---alivc
|       \---rtc
|           \---multiprocess ## This directory contains the source code for alirtc_linux_java_multiprocess.jar. You can customize the logic and replace the jar package in libs.
|                   AliRTCLinuxEngine.java
|                   AliRTCLinuxEngineListener.java
|
+---Demo
|       MainTest.java ## Sample program code
|       run.sh ## Run the sample program using this file
|
\---libs ## This directory contains the jar and .so libraries required by the business execution program
        AliRtcCoreService
        alirtc_linux_java_multiprocess.jar
        gson-2.11.0.jar
        libAliRtcLinuxEngine.so
        libonnxruntime.so.1.16.3
        libPluginOpus.so
  • The libs folder contains the JAR and .so libraries required by the application.

  • MainTest.java is the sample program source code.

Prerequisites

Before running the sample project, ensure the following requirements are met:

  • Application preparation: Obtain the AppID and AppKey for your real-time audio and video application. For details, see Get development parameters.

Procedure

Specify the ELF file directory

The SDK’s underlying layer is implemented in C++. The Java interface manages multiple RTC engine instances through a multi-process approach. The alirtc_linux_java_multiprocess.jar file in the libs directory bridges the Java layer and the C++ engine. To start the process, the compiled ELF file libs/AliRtcCoreService is required. Set the correct path to this file to ensure subsequent operations run properly.

String coreServicePath = "/mnt/AliRTCSDK_Linux-v6.11.2/Java/libs/AliRtcCoreService";

AliRtcCoreService is located at AliRTCSDK_Linux-7.10.2/Java/libs/AliRtcCoreService.

Configure AppID and AppKey

image.png

Run the sample program

Run the sample program by executing Demo/run.sh.

sh run.sh

Exit the meeting

To exit the sample program, enter exit.