tencent cloud

TRTC Plug-In Integration

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-05-21 11:45:04

Dependency Configuration

//Introduce the new version SDK of TRTC
implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
//Multiple Network Acceleration SDK
implementation 'com.tencent.linkboost:mpacc:2.9.4'
//TRTC acceleration plug-in
implementation 'com.tencent.linkboost:trtc-acc-plugin:1.0.2'

Sample Code

Enable/disable acceleration services after TRTC room entry and exit.

//Upon entering the room successfully, enable acceleration
protected class TRTCCloudImplListener extends TRTCCloudListener {
@Override
public void onEnterRoom(long result) {
//trigger acceleration
MpAccManager.getSingleInstance(context).startMpAcc();
...
}
}

private void exitRoom() {
//disable acceleration when leaving the room
MpAccManager.getSingleInstance(context).stopMpAcc();
...
}
Use the TRTC proxy plugin to perform acceleration.
//Multiple Network Acceleration management class
public class MpAccManager {

private MpAccManager(Context context) {
initMpAcc(context);
}
private void initMpAcc(Context context) {
// The datakey applied in the Tencent Cloud console
MpAccClient.setDataKey("test-123456", "*");
mpAccClient = MpAccClient.getInstance(context);
//Get the plugin instance
TRTCAccPlugin accProxy = new TRTCAccPlugin(context);
//Add the TRTC acceleration plug-in
AccPluginManager.getInstance().setAccProxyPlugin(accProxy);
}
//Start acceleration
public void startMpAcc() {
//Refer to the AccConfig class description for updating initialization parameters
AccConfig accConfig = new AccConfig();
accConfig.setAccMode(3) //1: aggregation acceleration 2: dual acceleration 3: fast switch acceleration
.setPingInterval(3)
.setEnableSocks(true)
try {
//Register acceleration result callback
mpAccClient.registerAccCallback(accCallback);
mpAccClient.startAcc(accConfig);
} catch (MpAccSDKException e) {
e.printStackTrace();
}
}

//stop acceleration
public void stopMpAcc() {
try {
mpAccClient.unregisterAccCallback(accCallback);
mpAccClient.stopAcc();
} catch (MpAccSDKException e) {
e.printStackTrace();
}
}
}


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan