Sunflower v2.7.0版本的 MD5 值为:0696e8ce118febedd4bd019622cb23b1
以下内容为反编译后的 AliRtcEngineImpl.java 源代码,内容仅作参考
package com.alivc.rtc;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import com.alivc.rtc.AliRtcEngine;
import com.alivc.rtc.AppFrontBackHelper;
import com.king.zxing.util.LogUtils;
import com.ut.device.UTDevice;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONObject;
import org.webrtc.ali.ContextUtils;
import org.webrtc.ali.USBMediaDevice;
import org.webrtc.ali.voiceengine.WebRtcAudioUtils;
import org.webrtc.alirtcInterface.ALI_RTC_INTERFACE;
import org.webrtc.alirtcInterface.AliParticipantInfo;
import org.webrtc.alirtcInterface.AliStatusInfo;
import org.webrtc.alirtcInterface.AliSubscriberInfo;
import org.webrtc.alirtcInterface.AliUnPublisherInfo;
import org.webrtc.alirtcInterface.CollectStatusListener;
import org.webrtc.alirtcInterface.ErrorCodes;
import org.webrtc.alirtcInterface.PublisherInfo;
import org.webrtc.alirtcInterface.SophonEngine;
import org.webrtc.alirtcInterface.SophonEventListener;
import org.webrtc.audio.AppRTCAudioManager;
import org.webrtc.sdk.SophonSurfaceView;
import org.webrtc.utils.AlivcLog;
public class AliRtcEngineImpl extends AliRtcEngine implements USBMediaDevice.USBMediaDeviceEvent {
private static final String FAKE_SESSION = "123456ALIBABAFAKESESSIONID";
private static final int SDK_RESULT_PUBLISH_ALREADY_EXIST = 16974594;
private static final String TAG = "AliRTCEngine";
private static String VERSION = "";
private static ArrayList<AliRtcEngine.AliRtcRemoteTextureInfo> aliRtcRemoteTextureInfos = new ArrayList<>();
private AlbumOrientationEventListener mAlbumOrientationEventListener;
private AliRtcConfig mAliRtcConfig;
private volatile boolean mApiPass;
private AppFrontBackHelper mAppFrontBackHelper;
private Context mContext;
private boolean mDetectedUsbDevice;
private AliRtcEngineEventListener mEventListener;
private String mExtras;
private final Object mLock;
private AliRtcEngineNotify mNotifyListener;
private ProcessCpuTracker mProcessCpuTracker;
private SophonEngine mSophonEngine;
private SophonEventListener mSophonEventListener;
private boolean mUsbCameraStatus;
private AliRtcUsbDeviceEvent mUsbDeviceEvent;
private Handler mainHandler;
static {
System.loadLibrary("wukong_ua");
}
@Override
public int onUSBDeviceConnect() {
try {
this.mUsbCameraStatus = true;
if (this.mSophonEngine == null) {
this.mSophonEngine = SophonEngine.create(this.mContext.getApplicationContext(), this.mExtras, this.mSophonEventListener);
}
} catch (Exception e) {
e.printStackTrace();
}
if (this.mUsbDeviceEvent != null) {
AlivcLog.i(TAG, "[API][Callback]onUSBDeviceConnect:ret:0");
this.mUsbDeviceEvent.onUSBDeviceConnect(0);
AlivcLog.i(TAG, "[API][End][Callback]onUSBDeviceConnect");
}
return 0;
}
@Override
public void onUSBDeviceDisconnect() {
if (this.mUsbDeviceEvent != null) {
AlivcLog.i(TAG, "[API][Callback]onUSBDeviceDisconnect");
this.mUsbDeviceEvent.onUSBDeviceDisconnect();
AlivcLog.i(TAG, "[API][End][Callback]onUSBDeviceDisconnect");
}
}
@Override
public void onUSBDeviceCancel() {
try {
if (this.mSophonEngine == null) {
this.mSophonEngine = SophonEngine.create(this.mContext.getApplicationContext(), this.mExtras, this.mSophonEventListener);
}
} catch (Exception e) {
e.printStackTrace();
}
if (this.mUsbDeviceEvent != null) {
AlivcLog.i(TAG, "[API][Callback]onUSBDeviceCancel");
this.mUsbDeviceEvent.onUSBDeviceCancel();
AlivcLog.i(TAG, "[API][End][Callback]onUSBDeviceCancel");
}
}
@Override
public void setUsbDeviceEvent(AliRtcUsbDeviceEvent aliRtcUsbDeviceEvent) {
if (aliRtcUsbDeviceEvent != null) {
AlivcLog.i(TAG, "[API]setUsbDeviceEvent:" + aliRtcUsbDeviceEvent);
this.mUsbDeviceEvent = aliRtcUsbDeviceEvent;
AlivcLog.i(TAG, "[API][End]setUsbDeviceEvent");
}
}
@Override
public AliRtcUsbDeviceEvent getUsbDeviceEvent() {
AlivcLog.i(TAG, "[API]getUsbDeviceEvent");
return this.mUsbDeviceEvent;
}
@Override
public boolean isUsbDeviceDetected() {
AlivcLog.i(TAG, "[API]isUsbDeviceDetected");
return this.mDetectedUsbDevice;
}
public AliRtcEngineImpl(Context context, String str) {
this.mAliRtcConfig = new AliRtcConfig();
this.mainHandler = new Handler(Looper.getMainLooper());
this.mLock = new Object();
this.mExtras = "";
this.mUsbCameraStatus = false;
this.mDetectedUsbDevice = false;
this.mApiPass = true;
this.mSophonEventListener = new SophonEventListener() {
@Override
public void onGslbResult(int i) {
super.onGslbResult(i);
}
@Override
public void onJoinChannelResult(int i) {
super.onJoinChannelResult(i);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setInCall(true);
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoPublish()) {
AliRtcEngineImpl.this.publish();
}
} else {
AliRtcEngineImpl.this.mAliRtcConfig.setInCall(false);
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onJoinChannelResult:result:" + i);
AliRtcEngineImpl.this.mEventListener.onJoinChannelResult(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onJoinChannelResult");
}
}
@Override
public void onLeaveChannelResult(int i) {
super.onLeaveChannelResult(i);
synchronized (AliRtcEngineImpl.this.mLock) {
AliRtcEngineImpl.this.mLock.notify();
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onLeaveChannelResult:result:" + i);
AliRtcEngineImpl.this.mAliRtcConfig.setPublishIsGoing(false);
AliRtcEngineImpl.this.mEventListener.onLeaveChannelResult(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onLeaveChannelResult");
}
if (i != ErrorCodes.SDK_RESULT_WRONG_STATE_ERROR) {
AlivcLog.uploadChannelLog();
}
}
@Override
public void onPublishResult(int i, String str2) {
super.onPublishResult(i, str2);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(str2, true);
AliRtcEngineImpl.this.mAliRtcConfig.setPublishIsGoing(false);
if (AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalMic()) {
AliRtcEngineImpl.this.muteLocalMic(true);
}
if (!AliRtcEngineImpl.this.mAliRtcConfig.isAudioOnly() && AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalCameraVideo()) {
AliRtcEngineImpl.this.muteLocalCamera(true, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
}
AliRtcEngineImpl.this.mainHandler.post(new Runnable() {
@Override
public void run() {
AliRtcEngineImpl.this.enableSpeakerphone(AliRtcEngineImpl.this.mAliRtcConfig.isSpeakerOn());
}
});
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onPublishResult:result:" + i + "&&callId" + str2);
AliRtcEngineImpl.this.mEventListener.onPublishResult(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onPublishResult");
}
}
@Override
public void onRepublishResult(int i, String str2) {
super.onRepublishResult(i, str2);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(str2, true);
if (AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalMic()) {
AliRtcEngineImpl.this.muteLocalMic(true);
}
if (!AliRtcEngineImpl.this.mAliRtcConfig.isAudioOnly() && AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalCameraVideo()) {
AliRtcEngineImpl.this.muteLocalCamera(true, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
}
AliRtcEngineImpl.this.mainHandler.post(new Runnable() {
@Override
public void run() {
AliRtcEngineImpl.this.enableSpeakerphone(AliRtcEngineImpl.this.mAliRtcConfig.isSpeakerOn());
}
});
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onPublishResult:result:" + i + "&&callId" + str2);
AliRtcEngineImpl.this.mEventListener.onPublishResult(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onPublishResult");
}
}
@Override
public void onUnpublishResult(int i, String str2) {
super.onUnpublishResult(i, str2);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(null, true);
} else {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(AliRtcEngineImpl.this.mAliRtcConfig.getTmpLocalCallID());
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onUnpublishResult:result:" + i + "&&callId" + str2);
AliRtcEngineImpl.this.mEventListener.onUnpublishResult(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onUnpublishResult");
}
}
@Override
public void onSubscribeResult(int i, String str2) {
super.onSubscribeResult(i, str2);
}
@Override
public void onResubscribeResult(int i, String str2) {
super.onResubscribeResult(i, str2);
}
@Override
public void onUnsubscribeResult(int i, String str2) {
super.onUnsubscribeResult(i, str2);
RemoteParticipant findParticipantByCallID = AliRtcEngineImpl.this.findParticipantByCallID(str2);
if (findParticipantByCallID != null) {
int length = findParticipantByCallID.getVideoSubscribed().length;
for (int i2 = 0; i2 < length; i2++) {
AliRtcEngineImpl.this.removeRemoteDisplayWindow(str2, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i2]);
}
findParticipantByCallID.clearSubedStatus();
}
if (AliRtcEngineImpl.this.mEventListener == null || findParticipantByCallID == null) {
return;
}
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onUnsubscribeResult:result:" + i + "&&userId" + findParticipantByCallID.getUserID());
AliRtcEngineImpl.this.mEventListener.onUnsubscribeResult(i, findParticipantByCallID.getUserID());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onUnsubscribeResult");
}
@Override
public void onParticipantJoinNotify(AliParticipantInfo[] aliParticipantInfoArr, int i) {
RemoteParticipant remoteParticipant;
super.onParticipantJoinNotify(aliParticipantInfoArr, i);
for (AliParticipantInfo aliParticipantInfo : aliParticipantInfoArr) {
if (AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().containsKey(aliParticipantInfo.getUser_id())) {
remoteParticipant = AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().get(aliParticipantInfo.getUser_id());
} else {
remoteParticipant = new RemoteParticipant();
remoteParticipant.clearAll();
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoSubscribe()) {
AliRtcEngineImpl.this.configRemoteParticipantDefaultValues(remoteParticipant);
}
AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().put(aliParticipantInfo.getUser_id(), remoteParticipant);
}
remoteParticipant.setUserID(aliParticipantInfo.getUser_id());
remoteParticipant.setSessionID(aliParticipantInfo.getSession());
remoteParticipant.setDisplayName(aliParticipantInfo.getUser_name());
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteUserOnLineNotify:userId:" + aliParticipantInfo.getUser_id());
AliRtcEngineImpl.this.mNotifyListener.onRemoteUserOnLineNotify(aliParticipantInfo.getUser_id());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteUserOnLineNotify");
}
}
}
@Override
public void onParticipantLeaveNotify(AliParticipantInfo[] aliParticipantInfoArr, int i) {
super.onParticipantLeaveNotify(aliParticipantInfoArr, i);
for (int i2 = 0; i2 < i; i2++) {
AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().remove(aliParticipantInfoArr[i2].getUser_id());
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteUserOffLineNotify:uid:" + aliParticipantInfoArr[i2].getUser_id());
AliRtcEngineImpl.this.mNotifyListener.onRemoteUserOffLineNotify(aliParticipantInfoArr[i2].getUser_id());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteUserOffLineNotify");
}
}
}
@Override
public void onParticipantPublishNotify(PublisherInfo[] publisherInfoArr, int i) {
RemoteParticipant remoteParticipant;
super.onParticipantPublishNotify(publisherInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "onPublishNotify count: " + i);
for (PublisherInfo publisherInfo : publisherInfoArr) {
if (AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().containsKey(publisherInfo.getUser_id())) {
remoteParticipant = AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().get(publisherInfo.getUser_id());
} else {
remoteParticipant = new RemoteParticipant();
remoteParticipant.clearAll();
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoSubscribe()) {
AliRtcEngineImpl.this.configRemoteParticipantDefaultValues(remoteParticipant);
}
AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().put(publisherInfo.getUser_id(), remoteParticipant);
}
remoteParticipant.setCallID(publisherInfo.getCall_id());
remoteParticipant.setUserID(publisherInfo.getUser_id());
remoteParticipant.setSessionID(TextUtils.isEmpty(publisherInfo.getSession()) ? AliRtcEngineImpl.FAKE_SESSION : publisherInfo.getSession());
remoteParticipant.setDisplayName(publisherInfo.getDisplay());
remoteParticipant.setStreamLabel(publisherInfo.getStream_label());
remoteParticipant.setAudioTrackLabel(publisherInfo.getAudio_track_label());
remoteParticipant.setVideoTrackLabels(publisherInfo.getVideo_track_labels());
if (TextUtils.isEmpty(publisherInfo.getCall_id())) {
AlivcLog.e(AliRtcEngineImpl.TAG, "onParticipantPublishNotify callid is null, uid = " + publisherInfo.getUser_id());
} else {
AliRtcEngineImpl.this.mAliRtcConfig.getRemotePublishParticipants().put(publisherInfo.getCall_id(), remoteParticipant);
}
AliRtcEngineImpl.this.removeRemoteNullTracksDisplayWindow(publisherInfo.getCall_id(), publisherInfo.video_track_labels);
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AliRtcEngine.AliRtcAudioTrack audioTrack = RemoteParticipant.getAudioTrack(publisherInfo.getAudio_track_label());
AliRtcEngine.AliRtcVideoTrack videoTrack = RemoteParticipant.getVideoTrack(publisherInfo.getVideo_track_labels());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteTrackAvailableNotify:userid: " + remoteParticipant.getUserID() + "&&audioTrack: " + audioTrack + "&&videoTrack: " + videoTrack);
AliRtcEngineImpl.this.mNotifyListener.onRemoteTrackAvailableNotify(remoteParticipant.getUserID(), audioTrack, videoTrack);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteTrackAvailableNotify");
}
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoSubscribe()) {
AliRtcEngineImpl.this.configRemoteAudio(remoteParticipant.getUserID(), remoteParticipant.isUcAudeoSubed());
AliRtcEngineImpl.this.configRemoteCameraTrack(remoteParticipant.getUserID(), remoteParticipant.isUcVideoSubedMaster(), remoteParticipant.isUcVideoSubed());
AliRtcEngineImpl.this.configRemoteScreenTrack(remoteParticipant.getUserID(), remoteParticipant.isUcScreenSubed());
AliRtcEngineImpl.this.subscribe(remoteParticipant.getUserID());
}
}
}
@Override
public void onParticipantUnpublishNotify(AliUnPublisherInfo[] aliUnPublisherInfoArr, int i) {
super.onParticipantUnpublishNotify(aliUnPublisherInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "onParticipantUnpublishNotify count: " + i);
if (aliUnPublisherInfoArr == null) {
AlivcLog.e(AliRtcEngineImpl.TAG, "onParticipantUnpublishNotify unpublisherList is null ");
return;
}
for (int i2 = 0; i2 < i; i2++) {
RemoteParticipant remoteParticipant = null;
if (i2 < aliUnPublisherInfoArr.length && aliUnPublisherInfoArr[i2] != null && AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().containsKey(aliUnPublisherInfoArr[i2].getUser_id())) {
remoteParticipant = AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().get(aliUnPublisherInfoArr[i2].getUser_id());
}
if (remoteParticipant != null) {
int length = remoteParticipant.getVideoTrackLabels().length;
for (int i3 = 0; i3 < length; i3++) {
AliRtcEngineImpl.this.removeRemoteDisplayWindow(remoteParticipant.getCallID(), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i3]);
}
remoteParticipant.clearStreams();
remoteParticipant.setFirstSubscribe(true);
if (aliUnPublisherInfoArr[i2] != null && !TextUtils.isEmpty(aliUnPublisherInfoArr[i2].getCall_id())) {
AliRtcEngineImpl.this.mAliRtcConfig.getRemotePublishParticipants().remove(aliUnPublisherInfoArr[i2].getCall_id());
} else {
AlivcLog.i(AliRtcEngineImpl.TAG, "onParticipantUnpublishNotify callid is null");
}
}
if (AliRtcEngineImpl.this.mNotifyListener != null && remoteParticipant != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteUserUnPublish:rtcEngine" + AliRtcEngineImpl.this + "userid: " + remoteParticipant.getUserID());
AliRtcEngineImpl.this.mNotifyListener.onRemoteUserUnPublish(AliRtcEngineImpl.this, remoteParticipant.getUserID());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteUserUnPublish");
}
}
}
@Override
public void onParticipantSubscribeNotify(AliSubscriberInfo[] aliSubscriberInfoArr, int i) {
super.onParticipantSubscribeNotify(aliSubscriberInfoArr, i);
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onParticipantSubscribeNotify:AliSubscriberInfo" + aliSubscriberInfoArr[0].user_id + "feedCount: " + i);
AliRtcEngineImpl.this.mNotifyListener.onParticipantSubscribeNotify(aliSubscriberInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onParticipantSubscribeNotify");
}
}
@Override
public void onParticipantUnsubscribeNotify(AliParticipantInfo[] aliParticipantInfoArr, int i) {
super.onParticipantUnsubscribeNotify(aliParticipantInfoArr, i);
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onParticipantUnsubscribeNotify:AliParticipantInfo" + aliParticipantInfoArr[0].user_id + "feedCount: " + i);
AliRtcEngineImpl.this.mNotifyListener.onParticipantUnsubscribeNotify(aliParticipantInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onParticipantUnsubscribeNotify");
}
}
@Override
public void onParticipantStatusNotify(AliStatusInfo[] aliStatusInfoArr, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onParticipantUnsubscribeNotify:AliStatusInfo" + aliStatusInfoArr[0].user_id + "&&count: " + i);
AliRtcEngineImpl.this.mNotifyListener.onParticipantStatusNotify(aliStatusInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onParticipantUnsubscribeNotify");
}
}
@Override
public void onAliRtcStats(ALI_RTC_INTERFACE.AliRtcStats aliRtcStats) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onAliRtcStats:AliRtcStats:" + aliRtcStats.toString());
if (AliRtcEngineImpl.this.mProcessCpuTracker != null) {
AliRtcEngineImpl.this.mProcessCpuTracker.updateCpuUsages(AliRtcEngineImpl.this.mContext.getApplicationContext());
aliRtcStats.setCpu_usage(AliRtcEngineImpl.this.mProcessCpuTracker.getMyPicCpuPercent());
aliRtcStats.setSystem_cpu_usage(AliRtcEngineImpl.this.mProcessCpuTracker.getTotalSysCpuPercent());
}
AliRtcEngineImpl.this.mNotifyListener.onAliRtcStats(aliRtcStats);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onAliRtcStats:");
}
}
@Override
public void onSubscribeResult2(int i, String str2, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig2) {
super.onSubscribeResult2(i, str2, aliSubscribeConfig, aliSubscribeConfig2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onSubscribeResult2 result: " + i + " callID: " + str2 + "reqConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig) + "curConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig2));
RemoteParticipant findParticipantByCallID = AliRtcEngineImpl.this.findParticipantByCallID(str2);
if (findParticipantByCallID == null) {
return;
}
if (i == 0) {
int length = aliSubscribeConfig2.video_track_labels.length;
for (int i2 = 0; i2 < length; i2++) {
if (!TextUtils.isEmpty(aliSubscribeConfig2.video_track_labels[i2])) {
AliRtcEngineImpl.this.addRemoteDisplayWindow(str2, findParticipantByCallID.getVideoCanvas(i2), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i2]);
}
}
findParticipantByCallID.setAudioSubscribed(aliSubscribeConfig2.audio_track_label);
findParticipantByCallID.setVideoSubscribed(aliSubscribeConfig2.video_track_labels);
findParticipantByCallID.setVideoSubscribedCached(aliSubscribeConfig2.video_track_labels);
findParticipantByCallID.setFirstSubscribe(false);
AliRtcEngineImpl.this.mSophonEngine.enableRemoteAudio(str2, !findParticipantByCallID.isMuteAudioPlaying());
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AliRtcEngine.AliRtcAudioTrack audioTrack = RemoteParticipant.getAudioTrack(aliSubscribeConfig2.audio_track_label);
AliRtcEngine.AliRtcVideoTrack videoTrack = RemoteParticipant.getVideoTrack(aliSubscribeConfig2.video_track_labels);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onSubscribeResult:userID:" + findParticipantByCallID.getUserID() + "&&result: " + i + "&&VideoTrack: " + videoTrack + "&&AudioTrack: " + audioTrack);
AliRtcEngineImpl.this.mEventListener.onSubscribeResult(findParticipantByCallID.getUserID(), i, videoTrack, audioTrack);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onSubscribeResult");
}
}
@Override
public void onResubscribeResult2(int i, String str2, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig2) {
super.onResubscribeResult2(i, str2, aliSubscribeConfig, aliSubscribeConfig2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onReSubscribeResult2:result:" + i + "&&callID: " + str2 + "&&reqConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig) + "&&curConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig2));
RemoteParticipant findParticipantByCallID = AliRtcEngineImpl.this.findParticipantByCallID(str2);
if (findParticipantByCallID == null) {
return;
}
if (i == 0) {
int length = aliSubscribeConfig2.video_track_labels.length;
for (int i2 = 0; i2 < length; i2++) {
if (TextUtils.isEmpty(aliSubscribeConfig2.video_track_labels[i2]) && !TextUtils.isEmpty(findParticipantByCallID.getVideoSubscribedCached()[i2])) {
AliRtcEngineImpl.this.removeRemoteDisplayWindow(str2, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i2]);
}
}
int length2 = aliSubscribeConfig2.video_track_labels.length;
for (int i3 = 0; i3 < length2; i3++) {
if (!TextUtils.isEmpty(aliSubscribeConfig2.video_track_labels[i3]) && TextUtils.isEmpty(findParticipantByCallID.getVideoSubscribedCached()[i3])) {
AliRtcEngineImpl.this.addRemoteDisplayWindow(str2, findParticipantByCallID.getVideoCanvas(i3), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i3]);
}
}
findParticipantByCallID.setAudioSubscribed(aliSubscribeConfig2.audio_track_label);
findParticipantByCallID.setVideoSubscribed(aliSubscribeConfig2.video_track_labels);
findParticipantByCallID.setVideoSubscribedCached(aliSubscribeConfig2.video_track_labels);
AliRtcEngineImpl.this.mSophonEngine.enableRemoteAudio(str2, !findParticipantByCallID.isMuteAudioPlaying());
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AliRtcEngine.AliRtcAudioTrack audioTrack = RemoteParticipant.getAudioTrack(aliSubscribeConfig2.audio_track_label);
AliRtcEngine.AliRtcVideoTrack videoTrack = RemoteParticipant.getVideoTrack(aliSubscribeConfig2.video_track_labels);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onSubscribeResult:userID:" + findParticipantByCallID.getUserID() + "&&result: " + i + "&&VideoTrack: " + videoTrack + "&&AudioTrack: " + audioTrack);
AliRtcEngineImpl.this.mEventListener.onSubscribeResult(findParticipantByCallID.getUserID(), i, videoTrack, audioTrack);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onSubscribeResult");
}
}
@Override
public void onChannelReleaseNotify() {
super.onChannelReleaseNotify();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onChannelReleaseNotify");
}
@Override
public void onConnectionChange(int i) {
super.onConnectionChange(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "onConnectionChange:mediaConState: " + i);
ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState fromNativeIndex = ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState.fromNativeIndex(i);
if (fromNativeIndex == null || AliRtcEngineImpl.this.mEventListener == null) {
return;
}
int i2 = AnonymousClass7.$SwitchMap$org$webrtc$alirtcInterface$ALI_RTC_INTERFACE$AliRTCMediaConnectionReConnectState[fromNativeIndex.ordinal()];
if (i2 == 1) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionLost");
AliRtcEngineImpl.this.mEventListener.onConnectionLost();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionLost");
} else if (i2 == 2) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionRecovery");
AliRtcEngineImpl.this.mEventListener.onConnectionRecovery();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionRecovery");
} else {
if (i2 != 3) {
return;
}
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onTryToReconnect");
AliRtcEngineImpl.this.mEventListener.onTryToReconnect();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onTryToReconnect");
}
}
@Override
public void onWarning(int i, String str2) {
super.onWarning(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onWarning event: " + i);
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onOccurWarning: warningEvent:" + i + "&¶ms" + str2);
AliRtcEngineImpl.this.mEventListener.onOccurWarning(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onOccurWarning");
}
}
@Override
public void onError(int i, String str2) {
super.onError(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onError event: " + i);
if (AliRtcEngineImpl.this.mEventListener != null) {
if (i == 17170689) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionLost");
AliRtcEngineImpl.this.mEventListener.onConnectionLost();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionLost");
} else if (i == 17170690) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionRecovery");
AliRtcEngineImpl.this.mEventListener.onConnectionRecovery();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionRecovery");
} else {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onOccurError");
AliRtcEngineImpl.this.mEventListener.onOccurError(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onOccurError");
}
}
}
@Override
public void onTransportStatusChange(String str2, ALI_RTC_INTERFACE.TransportType transportType, ALI_RTC_INTERFACE.TransportStatus transportStatus) {
super.onTransportStatusChange(str2, transportType, transportStatus);
}
@Override
public void onNetworkQualityChange(ArrayList<ALI_RTC_INTERFACE.AliTransportInfo> arrayList) {
AliRtcEngine.AliRtcNetworkQuality aliRtcNetworkQuality;
AliRtcEngine.AliRtcNetworkQuality aliRtcNetworkQuality2;
super.onNetworkQualityChange(arrayList);
if (AliRtcEngineImpl.this.mEventListener == null || arrayList == null || arrayList.isEmpty()) {
return;
}
int size = arrayList.size();
for (int i = 0; i < size; i++) {
ALI_RTC_INTERFACE.AliTransportInfo aliTransportInfo = arrayList.get(i);
if (aliTransportInfo != null) {
try {
aliRtcNetworkQuality = AliRtcEngine.AliRtcNetworkQuality.values()[aliTransportInfo.upQuality.getValue()];
} catch (Exception unused) {
aliRtcNetworkQuality = AliRtcEngine.AliRtcNetworkQuality.Network_Unknow;
}
try {
aliRtcNetworkQuality2 = AliRtcEngine.AliRtcNetworkQuality.values()[aliTransportInfo.downQuality.getValue()];
} catch (Exception unused2) {
aliRtcNetworkQuality2 = AliRtcEngine.AliRtcNetworkQuality.Network_Unknow;
}
AliRtcEngineImpl.this.mEventListener.onNetworkQualityChanged(aliTransportInfo.user_id, aliRtcNetworkQuality, aliRtcNetworkQuality2);
}
}
}
@Override
public void onLogMessage(String str2) {
super.onLogMessage(str2);
}
@Override
public void onMessage(String str2, String str3, String str4) {
super.onMessage(str2, str3, str4);
}
@Override
public void onBye(int i) {
super.onBye(i);
AliRtcEngineImpl.this.mAliRtcConfig = new AliRtcConfig();
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onBye: code:" + i);
AliRtcEngineImpl.this.mNotifyListener.onBye(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onBye");
}
}
@Override
public void onUplinkChannelMessage(int i, String str2, String str3) {
super.onUplinkChannelMessage(i, str2, str3);
}
@Override
public String onCollectPlatformProfile() {
return AliRtcEngineImpl.this.getOsInfo();
}
@Override
public String onFetchPerformanceInfo() {
JSONObject jSONObject = new JSONObject();
int i = 0;
try {
if (AliRtcEngineImpl.this.mProcessCpuTracker != null) {
AliRtcEngineImpl.this.mProcessCpuTracker.updateCpuUsages(AliRtcEngineImpl.this.mContext.getApplicationContext());
i = AliRtcEngineImpl.this.mProcessCpuTracker.getMyPicCpuPercent();
}
jSONObject.putOpt("cpu_usage", String.valueOf(i));
jSONObject.putOpt("mem_usage", String.valueOf(AliRtcEngineUtil.getRunningAppProcessInfo(AliRtcEngineImpl.this.mContext.getApplicationContext())));
} catch (Exception unused) {
}
return jSONObject.toString();
}
@Override
public boolean onFetchAudioPermissionInfo() {
if (AliRtcEngineImpl.this.mContext == null) {
return false;
}
if (Build.VERSION.SDK_INT >= 23) {
return WebRtcAudioUtils.hasPermission(AliRtcEngineImpl.this.mContext.getApplicationContext(), "android.permission.RECORD_AUDIO");
}
return true;
}
@Override
public String onFetchAudioDeviceInfo() {
JSONObject jSONObject = new JSONObject();
try {
int i = 0;
if (AliRtcEngineImpl.this.mUsbCameraStatus) {
i = 2;
} else if (AliRtcEngineImpl.this.mSophonEngine != null && AliRtcEngineImpl.this.mSophonEngine.getSelectAudioDevice() == AppRTCAudioManager.AudioDevice.BLUETOOTH) {
i = 1;
}
jSONObject.putOpt("AudioPortType", Integer.valueOf(i));
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFetchAudioDeviceInfo: CurrentPort type: " + i);
} catch (Exception unused) {
AlivcLog.e(AliRtcEngineImpl.TAG, "[API] [Callback]onFetchAudioDeviceInfo Error");
}
return jSONObject.toString();
}
@Override
public void onWindowRenderReady(String str2, int i) {
super.onWindowRenderReady(str2, i);
}
@Override
public void onUpdateRoleNotify(ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_Client_Role, ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_Client_Role2) {
super.onUpdateRoleNotify(aliRTCSDK_Client_Role, aliRTCSDK_Client_Role2);
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onUpdateRoleNotify: old_role:" + aliRTCSDK_Client_Role + "&&new_role:" + aliRTCSDK_Client_Role2);
AliRtcEngineImpl.this.mEventListener.onUpdateRoleNotify(aliRTCSDK_Client_Role, aliRTCSDK_Client_Role2);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onUpdateRoleNotify");
}
}
@Override
public void onFirstFramereceived(String str2, String str3, String str4, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFirstFramereceived: callId:" + str2 + "&&stream_label:" + str3 + "&&time_cost_ms:" + i);
AliRtcEngineImpl.this.mNotifyListener.onFirstFramereceived(str2, str3, str4, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onFirstFramereceived");
}
}
@Override
public void onFirstPacketSent(String str2, String str3, String str4, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFirstPacketSent: callId:" + str2 + "&&stream_label:" + str3 + "&&track_label:" + str4 + "&&time_cost_ms:" + i);
AliRtcEngineImpl.this.mNotifyListener.onFirstPacketSent(str2, str3, str4, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onFirstPacketSent");
}
}
@Override
public void onFirstPacketReceived(String str2, String str3, String str4, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFirstPacketReceived: callId:" + str2 + "&&stream_label:" + str3 + "&&track_label:" + str4 + "&&time_cost_ms:" + i);
AliRtcEngineImpl.this.mNotifyListener.onFirstPacketReceived(str2, str3, str4, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onFirstPacketReceived");
}
}
@Override
public int onFetchDeviceOrientation() {
if (AliRtcEngineImpl.this.mAlbumOrientationEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]getOrientation");
int orientation = AliRtcEngineImpl.this.mAlbumOrientationEventListener.getOrientation();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]getOrientation");
return orientation;
}
return super.onFetchDeviceOrientation();
}
};
try {
if (!TextUtils.isEmpty(str)) {
this.mExtras = str;
}
this.mContext = context;
ContextUtils.initialize(context.getApplicationContext());
initProcessCpuTracker();
LogWhenGoBackOrFront((Application) ContextUtils.getApplicationContext(), true);
enableOrientation(ContextUtils.getApplicationContext(), true);
DeviceConfig.initConfig();
SophonEngine.setH5CompatibleMode(EnableH5Compatible);
this.mDetectedUsbDevice = SophonEngine.setupUSBDevice(context, this) != 0;
AlivcLog.i(TAG, "AliRtcEngine init mDetectedUsbDevice = " + this.mDetectedUsbDevice);
if (this.mDetectedUsbDevice) {
return;
}
SophonEngine.closeUSBDevice();
if (this.mSophonEngine == null) {
this.mSophonEngine = SophonEngine.create(context.getApplicationContext(), this.mExtras, this.mSophonEventListener);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public AliRtcEngineImpl(Context context) {
this.mAliRtcConfig = new AliRtcConfig();
this.mainHandler = new Handler(Looper.getMainLooper());
this.mLock = new Object();
this.mExtras = "";
this.mUsbCameraStatus = false;
this.mDetectedUsbDevice = false;
this.mApiPass = true;
this.mSophonEventListener = new SophonEventListener() {
@Override
public void onGslbResult(int i) {
super.onGslbResult(i);
}
@Override
public void onJoinChannelResult(int i) {
super.onJoinChannelResult(i);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setInCall(true);
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoPublish()) {
AliRtcEngineImpl.this.publish();
}
} else {
AliRtcEngineImpl.this.mAliRtcConfig.setInCall(false);
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onJoinChannelResult:result:" + i);
AliRtcEngineImpl.this.mEventListener.onJoinChannelResult(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onJoinChannelResult");
}
}
@Override
public void onLeaveChannelResult(int i) {
super.onLeaveChannelResult(i);
synchronized (AliRtcEngineImpl.this.mLock) {
AliRtcEngineImpl.this.mLock.notify();
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onLeaveChannelResult:result:" + i);
AliRtcEngineImpl.this.mAliRtcConfig.setPublishIsGoing(false);
AliRtcEngineImpl.this.mEventListener.onLeaveChannelResult(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onLeaveChannelResult");
}
if (i != ErrorCodes.SDK_RESULT_WRONG_STATE_ERROR) {
AlivcLog.uploadChannelLog();
}
}
@Override
public void onPublishResult(int i, String str2) {
super.onPublishResult(i, str2);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(str2, true);
AliRtcEngineImpl.this.mAliRtcConfig.setPublishIsGoing(false);
if (AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalMic()) {
AliRtcEngineImpl.this.muteLocalMic(true);
}
if (!AliRtcEngineImpl.this.mAliRtcConfig.isAudioOnly() && AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalCameraVideo()) {
AliRtcEngineImpl.this.muteLocalCamera(true, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
}
AliRtcEngineImpl.this.mainHandler.post(new Runnable() {
@Override
public void run() {
AliRtcEngineImpl.this.enableSpeakerphone(AliRtcEngineImpl.this.mAliRtcConfig.isSpeakerOn());
}
});
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onPublishResult:result:" + i + "&&callId" + str2);
AliRtcEngineImpl.this.mEventListener.onPublishResult(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onPublishResult");
}
}
@Override
public void onRepublishResult(int i, String str2) {
super.onRepublishResult(i, str2);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(str2, true);
if (AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalMic()) {
AliRtcEngineImpl.this.muteLocalMic(true);
}
if (!AliRtcEngineImpl.this.mAliRtcConfig.isAudioOnly() && AliRtcEngineImpl.this.mAliRtcConfig.isMuteLocalCameraVideo()) {
AliRtcEngineImpl.this.muteLocalCamera(true, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
}
AliRtcEngineImpl.this.mainHandler.post(new Runnable() {
@Override
public void run() {
AliRtcEngineImpl.this.enableSpeakerphone(AliRtcEngineImpl.this.mAliRtcConfig.isSpeakerOn());
}
});
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onPublishResult:result:" + i + "&&callId" + str2);
AliRtcEngineImpl.this.mEventListener.onPublishResult(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onPublishResult");
}
}
@Override
public void onUnpublishResult(int i, String str2) {
super.onUnpublishResult(i, str2);
if (i == 0) {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(null, true);
} else {
AliRtcEngineImpl.this.mAliRtcConfig.setLocalCallID(AliRtcEngineImpl.this.mAliRtcConfig.getTmpLocalCallID());
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onUnpublishResult:result:" + i + "&&callId" + str2);
AliRtcEngineImpl.this.mEventListener.onUnpublishResult(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onUnpublishResult");
}
}
@Override
public void onSubscribeResult(int i, String str2) {
super.onSubscribeResult(i, str2);
}
@Override
public void onResubscribeResult(int i, String str2) {
super.onResubscribeResult(i, str2);
}
@Override
public void onUnsubscribeResult(int i, String str2) {
super.onUnsubscribeResult(i, str2);
RemoteParticipant findParticipantByCallID = AliRtcEngineImpl.this.findParticipantByCallID(str2);
if (findParticipantByCallID != null) {
int length = findParticipantByCallID.getVideoSubscribed().length;
for (int i2 = 0; i2 < length; i2++) {
AliRtcEngineImpl.this.removeRemoteDisplayWindow(str2, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i2]);
}
findParticipantByCallID.clearSubedStatus();
}
if (AliRtcEngineImpl.this.mEventListener == null || findParticipantByCallID == null) {
return;
}
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onUnsubscribeResult:result:" + i + "&&userId" + findParticipantByCallID.getUserID());
AliRtcEngineImpl.this.mEventListener.onUnsubscribeResult(i, findParticipantByCallID.getUserID());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onUnsubscribeResult");
}
@Override
public void onParticipantJoinNotify(AliParticipantInfo[] aliParticipantInfoArr, int i) {
RemoteParticipant remoteParticipant;
super.onParticipantJoinNotify(aliParticipantInfoArr, i);
for (AliParticipantInfo aliParticipantInfo : aliParticipantInfoArr) {
if (AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().containsKey(aliParticipantInfo.getUser_id())) {
remoteParticipant = AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().get(aliParticipantInfo.getUser_id());
} else {
remoteParticipant = new RemoteParticipant();
remoteParticipant.clearAll();
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoSubscribe()) {
AliRtcEngineImpl.this.configRemoteParticipantDefaultValues(remoteParticipant);
}
AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().put(aliParticipantInfo.getUser_id(), remoteParticipant);
}
remoteParticipant.setUserID(aliParticipantInfo.getUser_id());
remoteParticipant.setSessionID(aliParticipantInfo.getSession());
remoteParticipant.setDisplayName(aliParticipantInfo.getUser_name());
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteUserOnLineNotify:userId:" + aliParticipantInfo.getUser_id());
AliRtcEngineImpl.this.mNotifyListener.onRemoteUserOnLineNotify(aliParticipantInfo.getUser_id());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteUserOnLineNotify");
}
}
}
@Override
public void onParticipantLeaveNotify(AliParticipantInfo[] aliParticipantInfoArr, int i) {
super.onParticipantLeaveNotify(aliParticipantInfoArr, i);
for (int i2 = 0; i2 < i; i2++) {
AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().remove(aliParticipantInfoArr[i2].getUser_id());
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteUserOffLineNotify:uid:" + aliParticipantInfoArr[i2].getUser_id());
AliRtcEngineImpl.this.mNotifyListener.onRemoteUserOffLineNotify(aliParticipantInfoArr[i2].getUser_id());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteUserOffLineNotify");
}
}
}
@Override
public void onParticipantPublishNotify(PublisherInfo[] publisherInfoArr, int i) {
RemoteParticipant remoteParticipant;
super.onParticipantPublishNotify(publisherInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "onPublishNotify count: " + i);
for (PublisherInfo publisherInfo : publisherInfoArr) {
if (AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().containsKey(publisherInfo.getUser_id())) {
remoteParticipant = AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().get(publisherInfo.getUser_id());
} else {
remoteParticipant = new RemoteParticipant();
remoteParticipant.clearAll();
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoSubscribe()) {
AliRtcEngineImpl.this.configRemoteParticipantDefaultValues(remoteParticipant);
}
AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().put(publisherInfo.getUser_id(), remoteParticipant);
}
remoteParticipant.setCallID(publisherInfo.getCall_id());
remoteParticipant.setUserID(publisherInfo.getUser_id());
remoteParticipant.setSessionID(TextUtils.isEmpty(publisherInfo.getSession()) ? AliRtcEngineImpl.FAKE_SESSION : publisherInfo.getSession());
remoteParticipant.setDisplayName(publisherInfo.getDisplay());
remoteParticipant.setStreamLabel(publisherInfo.getStream_label());
remoteParticipant.setAudioTrackLabel(publisherInfo.getAudio_track_label());
remoteParticipant.setVideoTrackLabels(publisherInfo.getVideo_track_labels());
if (TextUtils.isEmpty(publisherInfo.getCall_id())) {
AlivcLog.e(AliRtcEngineImpl.TAG, "onParticipantPublishNotify callid is null, uid = " + publisherInfo.getUser_id());
} else {
AliRtcEngineImpl.this.mAliRtcConfig.getRemotePublishParticipants().put(publisherInfo.getCall_id(), remoteParticipant);
}
AliRtcEngineImpl.this.removeRemoteNullTracksDisplayWindow(publisherInfo.getCall_id(), publisherInfo.video_track_labels);
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AliRtcEngine.AliRtcAudioTrack audioTrack = RemoteParticipant.getAudioTrack(publisherInfo.getAudio_track_label());
AliRtcEngine.AliRtcVideoTrack videoTrack = RemoteParticipant.getVideoTrack(publisherInfo.getVideo_track_labels());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteTrackAvailableNotify:userid: " + remoteParticipant.getUserID() + "&&audioTrack: " + audioTrack + "&&videoTrack: " + videoTrack);
AliRtcEngineImpl.this.mNotifyListener.onRemoteTrackAvailableNotify(remoteParticipant.getUserID(), audioTrack, videoTrack);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteTrackAvailableNotify");
}
if (AliRtcEngineImpl.this.mAliRtcConfig.isAutoSubscribe()) {
AliRtcEngineImpl.this.configRemoteAudio(remoteParticipant.getUserID(), remoteParticipant.isUcAudeoSubed());
AliRtcEngineImpl.this.configRemoteCameraTrack(remoteParticipant.getUserID(), remoteParticipant.isUcVideoSubedMaster(), remoteParticipant.isUcVideoSubed());
AliRtcEngineImpl.this.configRemoteScreenTrack(remoteParticipant.getUserID(), remoteParticipant.isUcScreenSubed());
AliRtcEngineImpl.this.subscribe(remoteParticipant.getUserID());
}
}
}
@Override
public void onParticipantUnpublishNotify(AliUnPublisherInfo[] aliUnPublisherInfoArr, int i) {
super.onParticipantUnpublishNotify(aliUnPublisherInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "onParticipantUnpublishNotify count: " + i);
if (aliUnPublisherInfoArr == null) {
AlivcLog.e(AliRtcEngineImpl.TAG, "onParticipantUnpublishNotify unpublisherList is null ");
return;
}
for (int i2 = 0; i2 < i; i2++) {
RemoteParticipant remoteParticipant = null;
if (i2 < aliUnPublisherInfoArr.length && aliUnPublisherInfoArr[i2] != null && AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().containsKey(aliUnPublisherInfoArr[i2].getUser_id())) {
remoteParticipant = AliRtcEngineImpl.this.mAliRtcConfig.getRemoteParticipants().get(aliUnPublisherInfoArr[i2].getUser_id());
}
if (remoteParticipant != null) {
int length = remoteParticipant.getVideoTrackLabels().length;
for (int i3 = 0; i3 < length; i3++) {
AliRtcEngineImpl.this.removeRemoteDisplayWindow(remoteParticipant.getCallID(), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i3]);
}
remoteParticipant.clearStreams();
remoteParticipant.setFirstSubscribe(true);
if (aliUnPublisherInfoArr[i2] != null && !TextUtils.isEmpty(aliUnPublisherInfoArr[i2].getCall_id())) {
AliRtcEngineImpl.this.mAliRtcConfig.getRemotePublishParticipants().remove(aliUnPublisherInfoArr[i2].getCall_id());
} else {
AlivcLog.i(AliRtcEngineImpl.TAG, "onParticipantUnpublishNotify callid is null");
}
}
if (AliRtcEngineImpl.this.mNotifyListener != null && remoteParticipant != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onRemoteUserUnPublish:rtcEngine" + AliRtcEngineImpl.this + "userid: " + remoteParticipant.getUserID());
AliRtcEngineImpl.this.mNotifyListener.onRemoteUserUnPublish(AliRtcEngineImpl.this, remoteParticipant.getUserID());
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onRemoteUserUnPublish");
}
}
}
@Override
public void onParticipantSubscribeNotify(AliSubscriberInfo[] aliSubscriberInfoArr, int i) {
super.onParticipantSubscribeNotify(aliSubscriberInfoArr, i);
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onParticipantSubscribeNotify:AliSubscriberInfo" + aliSubscriberInfoArr[0].user_id + "feedCount: " + i);
AliRtcEngineImpl.this.mNotifyListener.onParticipantSubscribeNotify(aliSubscriberInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onParticipantSubscribeNotify");
}
}
@Override
public void onParticipantUnsubscribeNotify(AliParticipantInfo[] aliParticipantInfoArr, int i) {
super.onParticipantUnsubscribeNotify(aliParticipantInfoArr, i);
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onParticipantUnsubscribeNotify:AliParticipantInfo" + aliParticipantInfoArr[0].user_id + "feedCount: " + i);
AliRtcEngineImpl.this.mNotifyListener.onParticipantUnsubscribeNotify(aliParticipantInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onParticipantUnsubscribeNotify");
}
}
@Override
public void onParticipantStatusNotify(AliStatusInfo[] aliStatusInfoArr, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onParticipantUnsubscribeNotify:AliStatusInfo" + aliStatusInfoArr[0].user_id + "&&count: " + i);
AliRtcEngineImpl.this.mNotifyListener.onParticipantStatusNotify(aliStatusInfoArr, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onParticipantUnsubscribeNotify");
}
}
@Override
public void onAliRtcStats(ALI_RTC_INTERFACE.AliRtcStats aliRtcStats) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onAliRtcStats:AliRtcStats:" + aliRtcStats.toString());
if (AliRtcEngineImpl.this.mProcessCpuTracker != null) {
AliRtcEngineImpl.this.mProcessCpuTracker.updateCpuUsages(AliRtcEngineImpl.this.mContext.getApplicationContext());
aliRtcStats.setCpu_usage(AliRtcEngineImpl.this.mProcessCpuTracker.getMyPicCpuPercent());
aliRtcStats.setSystem_cpu_usage(AliRtcEngineImpl.this.mProcessCpuTracker.getTotalSysCpuPercent());
}
AliRtcEngineImpl.this.mNotifyListener.onAliRtcStats(aliRtcStats);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onAliRtcStats:");
}
}
@Override
public void onSubscribeResult2(int i, String str2, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig2) {
super.onSubscribeResult2(i, str2, aliSubscribeConfig, aliSubscribeConfig2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onSubscribeResult2 result: " + i + " callID: " + str2 + "reqConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig) + "curConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig2));
RemoteParticipant findParticipantByCallID = AliRtcEngineImpl.this.findParticipantByCallID(str2);
if (findParticipantByCallID == null) {
return;
}
if (i == 0) {
int length = aliSubscribeConfig2.video_track_labels.length;
for (int i2 = 0; i2 < length; i2++) {
if (!TextUtils.isEmpty(aliSubscribeConfig2.video_track_labels[i2])) {
AliRtcEngineImpl.this.addRemoteDisplayWindow(str2, findParticipantByCallID.getVideoCanvas(i2), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i2]);
}
}
findParticipantByCallID.setAudioSubscribed(aliSubscribeConfig2.audio_track_label);
findParticipantByCallID.setVideoSubscribed(aliSubscribeConfig2.video_track_labels);
findParticipantByCallID.setVideoSubscribedCached(aliSubscribeConfig2.video_track_labels);
findParticipantByCallID.setFirstSubscribe(false);
AliRtcEngineImpl.this.mSophonEngine.enableRemoteAudio(str2, !findParticipantByCallID.isMuteAudioPlaying());
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AliRtcEngine.AliRtcAudioTrack audioTrack = RemoteParticipant.getAudioTrack(aliSubscribeConfig2.audio_track_label);
AliRtcEngine.AliRtcVideoTrack videoTrack = RemoteParticipant.getVideoTrack(aliSubscribeConfig2.video_track_labels);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onSubscribeResult:userID:" + findParticipantByCallID.getUserID() + "&&result: " + i + "&&VideoTrack: " + videoTrack + "&&AudioTrack: " + audioTrack);
AliRtcEngineImpl.this.mEventListener.onSubscribeResult(findParticipantByCallID.getUserID(), i, videoTrack, audioTrack);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onSubscribeResult");
}
}
@Override
public void onResubscribeResult2(int i, String str2, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig, ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig2) {
super.onResubscribeResult2(i, str2, aliSubscribeConfig, aliSubscribeConfig2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onReSubscribeResult2:result:" + i + "&&callID: " + str2 + "&&reqConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig) + "&&curConfig: " + AliRtcEngineImpl.this.getSubscribeConfigString(aliSubscribeConfig2));
RemoteParticipant findParticipantByCallID = AliRtcEngineImpl.this.findParticipantByCallID(str2);
if (findParticipantByCallID == null) {
return;
}
if (i == 0) {
int length = aliSubscribeConfig2.video_track_labels.length;
for (int i2 = 0; i2 < length; i2++) {
if (TextUtils.isEmpty(aliSubscribeConfig2.video_track_labels[i2]) && !TextUtils.isEmpty(findParticipantByCallID.getVideoSubscribedCached()[i2])) {
AliRtcEngineImpl.this.removeRemoteDisplayWindow(str2, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i2]);
}
}
int length2 = aliSubscribeConfig2.video_track_labels.length;
for (int i3 = 0; i3 < length2; i3++) {
if (!TextUtils.isEmpty(aliSubscribeConfig2.video_track_labels[i3]) && TextUtils.isEmpty(findParticipantByCallID.getVideoSubscribedCached()[i3])) {
AliRtcEngineImpl.this.addRemoteDisplayWindow(str2, findParticipantByCallID.getVideoCanvas(i3), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[i3]);
}
}
findParticipantByCallID.setAudioSubscribed(aliSubscribeConfig2.audio_track_label);
findParticipantByCallID.setVideoSubscribed(aliSubscribeConfig2.video_track_labels);
findParticipantByCallID.setVideoSubscribedCached(aliSubscribeConfig2.video_track_labels);
AliRtcEngineImpl.this.mSophonEngine.enableRemoteAudio(str2, !findParticipantByCallID.isMuteAudioPlaying());
}
if (AliRtcEngineImpl.this.mEventListener != null) {
AliRtcEngine.AliRtcAudioTrack audioTrack = RemoteParticipant.getAudioTrack(aliSubscribeConfig2.audio_track_label);
AliRtcEngine.AliRtcVideoTrack videoTrack = RemoteParticipant.getVideoTrack(aliSubscribeConfig2.video_track_labels);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onSubscribeResult:userID:" + findParticipantByCallID.getUserID() + "&&result: " + i + "&&VideoTrack: " + videoTrack + "&&AudioTrack: " + audioTrack);
AliRtcEngineImpl.this.mEventListener.onSubscribeResult(findParticipantByCallID.getUserID(), i, videoTrack, audioTrack);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onSubscribeResult");
}
}
@Override
public void onChannelReleaseNotify() {
super.onChannelReleaseNotify();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onChannelReleaseNotify");
}
@Override
public void onConnectionChange(int i) {
super.onConnectionChange(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "onConnectionChange:mediaConState: " + i);
ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState fromNativeIndex = ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState.fromNativeIndex(i);
if (fromNativeIndex == null || AliRtcEngineImpl.this.mEventListener == null) {
return;
}
int i2 = AnonymousClass7.$SwitchMap$org$webrtc$alirtcInterface$ALI_RTC_INTERFACE$AliRTCMediaConnectionReConnectState[fromNativeIndex.ordinal()];
if (i2 == 1) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionLost");
AliRtcEngineImpl.this.mEventListener.onConnectionLost();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionLost");
} else if (i2 == 2) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionRecovery");
AliRtcEngineImpl.this.mEventListener.onConnectionRecovery();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionRecovery");
} else {
if (i2 != 3) {
return;
}
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onTryToReconnect");
AliRtcEngineImpl.this.mEventListener.onTryToReconnect();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onTryToReconnect");
}
}
@Override
public void onWarning(int i, String str2) {
super.onWarning(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onWarning event: " + i);
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onOccurWarning: warningEvent:" + i + "&¶ms" + str2);
AliRtcEngineImpl.this.mEventListener.onOccurWarning(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onOccurWarning");
}
}
@Override
public void onError(int i, String str2) {
super.onError(i, str2);
AlivcLog.i(AliRtcEngineImpl.TAG, "onError event: " + i);
if (AliRtcEngineImpl.this.mEventListener != null) {
if (i == 17170689) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionLost");
AliRtcEngineImpl.this.mEventListener.onConnectionLost();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionLost");
} else if (i == 17170690) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onConnectionRecovery");
AliRtcEngineImpl.this.mEventListener.onConnectionRecovery();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onConnectionRecovery");
} else {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onOccurError");
AliRtcEngineImpl.this.mEventListener.onOccurError(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onOccurError");
}
}
}
@Override
public void onTransportStatusChange(String str2, ALI_RTC_INTERFACE.TransportType transportType, ALI_RTC_INTERFACE.TransportStatus transportStatus) {
super.onTransportStatusChange(str2, transportType, transportStatus);
}
@Override
public void onNetworkQualityChange(ArrayList<ALI_RTC_INTERFACE.AliTransportInfo> arrayList) {
AliRtcEngine.AliRtcNetworkQuality aliRtcNetworkQuality;
AliRtcEngine.AliRtcNetworkQuality aliRtcNetworkQuality2;
super.onNetworkQualityChange(arrayList);
if (AliRtcEngineImpl.this.mEventListener == null || arrayList == null || arrayList.isEmpty()) {
return;
}
int size = arrayList.size();
for (int i = 0; i < size; i++) {
ALI_RTC_INTERFACE.AliTransportInfo aliTransportInfo = arrayList.get(i);
if (aliTransportInfo != null) {
try {
aliRtcNetworkQuality = AliRtcEngine.AliRtcNetworkQuality.values()[aliTransportInfo.upQuality.getValue()];
} catch (Exception unused) {
aliRtcNetworkQuality = AliRtcEngine.AliRtcNetworkQuality.Network_Unknow;
}
try {
aliRtcNetworkQuality2 = AliRtcEngine.AliRtcNetworkQuality.values()[aliTransportInfo.downQuality.getValue()];
} catch (Exception unused2) {
aliRtcNetworkQuality2 = AliRtcEngine.AliRtcNetworkQuality.Network_Unknow;
}
AliRtcEngineImpl.this.mEventListener.onNetworkQualityChanged(aliTransportInfo.user_id, aliRtcNetworkQuality, aliRtcNetworkQuality2);
}
}
}
@Override
public void onLogMessage(String str2) {
super.onLogMessage(str2);
}
@Override
public void onMessage(String str2, String str3, String str4) {
super.onMessage(str2, str3, str4);
}
@Override
public void onBye(int i) {
super.onBye(i);
AliRtcEngineImpl.this.mAliRtcConfig = new AliRtcConfig();
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onBye: code:" + i);
AliRtcEngineImpl.this.mNotifyListener.onBye(i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onBye");
}
}
@Override
public void onUplinkChannelMessage(int i, String str2, String str3) {
super.onUplinkChannelMessage(i, str2, str3);
}
@Override
public String onCollectPlatformProfile() {
return AliRtcEngineImpl.this.getOsInfo();
}
@Override
public String onFetchPerformanceInfo() {
JSONObject jSONObject = new JSONObject();
int i = 0;
try {
if (AliRtcEngineImpl.this.mProcessCpuTracker != null) {
AliRtcEngineImpl.this.mProcessCpuTracker.updateCpuUsages(AliRtcEngineImpl.this.mContext.getApplicationContext());
i = AliRtcEngineImpl.this.mProcessCpuTracker.getMyPicCpuPercent();
}
jSONObject.putOpt("cpu_usage", String.valueOf(i));
jSONObject.putOpt("mem_usage", String.valueOf(AliRtcEngineUtil.getRunningAppProcessInfo(AliRtcEngineImpl.this.mContext.getApplicationContext())));
} catch (Exception unused) {
}
return jSONObject.toString();
}
@Override
public boolean onFetchAudioPermissionInfo() {
if (AliRtcEngineImpl.this.mContext == null) {
return false;
}
if (Build.VERSION.SDK_INT >= 23) {
return WebRtcAudioUtils.hasPermission(AliRtcEngineImpl.this.mContext.getApplicationContext(), "android.permission.RECORD_AUDIO");
}
return true;
}
@Override
public String onFetchAudioDeviceInfo() {
JSONObject jSONObject = new JSONObject();
try {
int i = 0;
if (AliRtcEngineImpl.this.mUsbCameraStatus) {
i = 2;
} else if (AliRtcEngineImpl.this.mSophonEngine != null && AliRtcEngineImpl.this.mSophonEngine.getSelectAudioDevice() == AppRTCAudioManager.AudioDevice.BLUETOOTH) {
i = 1;
}
jSONObject.putOpt("AudioPortType", Integer.valueOf(i));
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFetchAudioDeviceInfo: CurrentPort type: " + i);
} catch (Exception unused) {
AlivcLog.e(AliRtcEngineImpl.TAG, "[API] [Callback]onFetchAudioDeviceInfo Error");
}
return jSONObject.toString();
}
@Override
public void onWindowRenderReady(String str2, int i) {
super.onWindowRenderReady(str2, i);
}
@Override
public void onUpdateRoleNotify(ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_Client_Role, ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_Client_Role2) {
super.onUpdateRoleNotify(aliRTCSDK_Client_Role, aliRTCSDK_Client_Role2);
if (AliRtcEngineImpl.this.mEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onUpdateRoleNotify: old_role:" + aliRTCSDK_Client_Role + "&&new_role:" + aliRTCSDK_Client_Role2);
AliRtcEngineImpl.this.mEventListener.onUpdateRoleNotify(aliRTCSDK_Client_Role, aliRTCSDK_Client_Role2);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onUpdateRoleNotify");
}
}
@Override
public void onFirstFramereceived(String str2, String str3, String str4, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFirstFramereceived: callId:" + str2 + "&&stream_label:" + str3 + "&&time_cost_ms:" + i);
AliRtcEngineImpl.this.mNotifyListener.onFirstFramereceived(str2, str3, str4, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onFirstFramereceived");
}
}
@Override
public void onFirstPacketSent(String str2, String str3, String str4, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFirstPacketSent: callId:" + str2 + "&&stream_label:" + str3 + "&&track_label:" + str4 + "&&time_cost_ms:" + i);
AliRtcEngineImpl.this.mNotifyListener.onFirstPacketSent(str2, str3, str4, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onFirstPacketSent");
}
}
@Override
public void onFirstPacketReceived(String str2, String str3, String str4, int i) {
if (AliRtcEngineImpl.this.mNotifyListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]onFirstPacketReceived: callId:" + str2 + "&&stream_label:" + str3 + "&&track_label:" + str4 + "&&time_cost_ms:" + i);
AliRtcEngineImpl.this.mNotifyListener.onFirstPacketReceived(str2, str3, str4, i);
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]onFirstPacketReceived");
}
}
@Override
public int onFetchDeviceOrientation() {
if (AliRtcEngineImpl.this.mAlbumOrientationEventListener != null) {
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][Callback]getOrientation");
int orientation = AliRtcEngineImpl.this.mAlbumOrientationEventListener.getOrientation();
AlivcLog.i(AliRtcEngineImpl.TAG, "[API][End][Callback]getOrientation");
return orientation;
}
return super.onFetchDeviceOrientation();
}
};
try {
this.mContext = context;
ContextUtils.initialize(context.getApplicationContext());
initProcessCpuTracker();
LogWhenGoBackOrFront((Application) ContextUtils.getApplicationContext(), true);
enableOrientation(ContextUtils.getApplicationContext(), true);
DeviceConfig.initConfig();
SophonEngine.setH5CompatibleMode(EnableH5Compatible);
boolean z = SophonEngine.setupUSBDevice(context, this) != 0;
this.mDetectedUsbDevice = z;
if (z) {
return;
}
SophonEngine.closeUSBDevice();
if (this.mSophonEngine == null) {
this.mSophonEngine = SophonEngine.create(context.getApplicationContext(), this.mExtras, this.mSophonEventListener);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void initProcessCpuTracker() {
if (this.mProcessCpuTracker == null) {
this.mProcessCpuTracker = new ProcessCpuTracker();
}
this.mProcessCpuTracker.updateCpuUsages(this.mContext.getApplicationContext());
}
@Override
public void destroy() {
AlivcLog.i(TAG, "[API]destroy");
destroyEngine();
AlivcLog.i(TAG, "[API][End]destroy");
}
private void destroyEngine() {
this.mContext = null;
this.mDetectedUsbDevice = false;
LogWhenGoBackOrFront((Application) ContextUtils.getApplicationContext(), false);
enableOrientation(ContextUtils.getApplicationContext(), false);
if (this.mSophonEngine != null) {
if (this.mUsbCameraStatus) {
SophonEngine.closeUSBDevice();
this.mUsbCameraStatus = false;
}
this.mSophonEngine.destory();
this.mSophonEngine = null;
}
release();
}
private void LogWhenGoBackOrFront(Application application, boolean z) {
if (z) {
AppFrontBackHelper appFrontBackHelper = new AppFrontBackHelper();
this.mAppFrontBackHelper = appFrontBackHelper;
appFrontBackHelper.bindApplication(application, new AppFrontBackHelper.OnAppStatusListener() {
@Override
public void onFront() {
AlivcLog.i(AliRtcEngineImpl.TAG, "applicationWillBecomeActive ==");
if (AliRtcEngineImpl.this.mSophonEngine != null) {
AliRtcEngineImpl.this.mSophonEngine.applicationWillBecomeActive();
}
}
@Override
public void onBack() {
AlivcLog.i(AliRtcEngineImpl.TAG, "applicationWillResignActive ==");
if (AliRtcEngineImpl.this.mSophonEngine != null) {
AliRtcEngineImpl.this.mSophonEngine.applicationWillResignActive();
}
}
});
} else {
AppFrontBackHelper appFrontBackHelper2 = this.mAppFrontBackHelper;
if (appFrontBackHelper2 != null) {
appFrontBackHelper2.unBindApplication(application);
this.mAppFrontBackHelper = null;
}
}
}
private void enableOrientation(Context context, boolean z) {
if (z) {
if (this.mAlbumOrientationEventListener == null) {
this.mAlbumOrientationEventListener = new AlbumOrientationEventListener(context, 3);
}
if (this.mAlbumOrientationEventListener.canDetectOrientation()) {
this.mAlbumOrientationEventListener.enable();
return;
} else {
AlivcLog.e(TAG, "Can't Detect Orientation");
return;
}
}
AlbumOrientationEventListener albumOrientationEventListener = this.mAlbumOrientationEventListener;
if (albumOrientationEventListener != null) {
albumOrientationEventListener.disable();
this.mAlbumOrientationEventListener = null;
}
}
public int getDeviceOrientation() {
AlbumOrientationEventListener albumOrientationEventListener = this.mAlbumOrientationEventListener;
if (albumOrientationEventListener != null) {
return albumOrientationEventListener.getOrientation();
}
AlivcLog.e(TAG, "mAlbumOrientationEventListener is null");
return 0;
}
@Override
public String getSdkVersion() {
SophonEngine sophonEngine;
AlivcLog.i(TAG, "[API]getSdkVersion");
if (TextUtils.isEmpty(VERSION) && (sophonEngine = this.mSophonEngine) != null) {
VERSION = sophonEngine.getSDKVersion();
}
AlivcLog.i(TAG, "[API][End][Result]getSdkVersion");
return VERSION;
}
@Override
public int setAutoPublish(boolean z, boolean z2) {
AlivcLog.i(TAG, "[API]setAutoPublish:autoPub: " + z + "&&autoSub: " + z2);
if (this.mAliRtcConfig.isInCall()) {
AlivcLog.e(TAG, "setAutoPublish:should set before join channel.:-1");
AlivcLog.i(TAG, "[API][End][Result]setAutoPublish:autoPub: " + z + "&&autoSub: " + z2 + ":-1");
return -1;
}
this.mAliRtcConfig.setAutoPublish(z);
this.mAliRtcConfig.setAutoSubscribe(z2);
AlivcLog.i(TAG, "[API][End][Result]setAutoPublish:autoPub:0");
return 0;
}
@Override
public int setAudioOnlyMode(boolean z) {
AlivcLog.i(TAG, "[API]setAudioOnlyMode:audioOnly:" + z);
if (this.mAliRtcConfig.isInCall()) {
AlivcLog.e(TAG, "[API][Result]setAudioOnlyMode: should set before join channel.&&audioOnly: " + z + ":-1");
return -1;
}
this.mAliRtcConfig.setAudioOnly(z);
AlivcLog.i(TAG, "[API][End][Result]setAudioOnlyMode:audioOnly:0");
return 0;
}
@Override
public void setRenderSharedContext(long j) {
AlivcLog.i(TAG, "[API]setAudioOnlyMode:setSharedContext:" + j);
this.mAliRtcConfig.setSharedContext(j);
AlivcLog.i(TAG, "[API][End]setSharedContext");
}
@Override
public boolean isAutoPublish() {
boolean isAutoPublish = this.mAliRtcConfig.isAutoPublish();
AlivcLog.i(TAG, "[API][Result]isAutoPublish:" + isAutoPublish);
return isAutoPublish;
}
@Override
public boolean isAutoSubscribe() {
boolean isAutoSubscribe = this.mAliRtcConfig.isAutoSubscribe();
AlivcLog.i(TAG, "[API][Result]isAutoSubscribe:" + isAutoSubscribe);
return isAutoSubscribe;
}
@Override
public boolean isAudioOnly() {
boolean isAudioOnly = this.mAliRtcConfig.isAudioOnly();
AlivcLog.i(TAG, "[API][Result]isAudioOnly:" + isAudioOnly);
return isAudioOnly;
}
@Override
public void joinChannel(AliRtcAuthInfo aliRtcAuthInfo, String str) {
AlivcLog.i(TAG, "[API]joinChannel:authInfo" + aliRtcAuthInfo.toString() + "&userName:" + str);
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API]joinChannel:mSophonEngine is null");
return;
}
this.mAliRtcConfig.setCachedAuthorInfo(aliRtcAuthInfo);
ALI_RTC_INTERFACE.AuthInfo authInfo = new ALI_RTC_INTERFACE.AuthInfo();
authInfo.channel = aliRtcAuthInfo.getConferenceId();
authInfo.user_id = aliRtcAuthInfo.getUserId();
authInfo.appid = aliRtcAuthInfo.getAppid();
authInfo.nonce = aliRtcAuthInfo.getNonce();
authInfo.timestamp = aliRtcAuthInfo.getTimestamp();
authInfo.token = aliRtcAuthInfo.getToken();
authInfo.gslb = aliRtcAuthInfo.getGslb();
authInfo.agent = aliRtcAuthInfo.getAgent();
AlivcLog.enableUpload(true);
AlivcLog.setUploadAppID(aliRtcAuthInfo.getAppid());
this.mSophonEngine.joinChannel(authInfo, str);
AlivcLog.i(TAG, "[API][End]joinChannel");
}
@Override
public void leaveChannel() {
AlivcLog.i(TAG, "[API]leaveChannel");
leaveChannel(1000L);
AlivcLog.i(TAG, "[API][End]leaveChannel");
}
private void leaveChannel(long j) {
AliRtcEngine.AliVideoCanvas localVideoCanvas;
AliRtcConfig aliRtcConfig;
synchronized (this.mLock) {
try {
try {
if (this.mSophonEngine != null) {
if (!this.mApiPass) {
AlivcLog.e(TAG, "leaveChannel double call, return it !");
return;
} else {
this.mApiPass = false;
this.mSophonEngine.leaveChannel(j);
this.mLock.wait(j);
}
}
this.mApiPass = true;
int preCameraType = getPreCameraType();
localVideoCanvas = this.mAliRtcConfig.getLocalVideoCanvas();
AliRtcConfig aliRtcConfig2 = new AliRtcConfig();
this.mAliRtcConfig = aliRtcConfig2;
aliRtcConfig2.setCameraType(preCameraType);
aliRtcConfig = this.mAliRtcConfig;
} catch (Exception e) {
e.printStackTrace();
this.mApiPass = true;
int preCameraType2 = getPreCameraType();
localVideoCanvas = this.mAliRtcConfig.getLocalVideoCanvas();
AliRtcConfig aliRtcConfig3 = new AliRtcConfig();
this.mAliRtcConfig = aliRtcConfig3;
aliRtcConfig3.setCameraType(preCameraType2);
aliRtcConfig = this.mAliRtcConfig;
}
aliRtcConfig.setLocalVideoCanvas(localVideoCanvas);
} finally {
this.mApiPass = true;
int preCameraType3 = getPreCameraType();
AliRtcEngine.AliVideoCanvas localVideoCanvas2 = this.mAliRtcConfig.getLocalVideoCanvas();
AliRtcConfig aliRtcConfig4 = new AliRtcConfig();
this.mAliRtcConfig = aliRtcConfig4;
aliRtcConfig4.setCameraType(preCameraType3);
this.mAliRtcConfig.setLocalVideoCanvas(localVideoCanvas2);
}
}
}
@Override
public boolean isInCall() {
AliRtcConfig aliRtcConfig = this.mAliRtcConfig;
if (aliRtcConfig == null) {
return false;
}
boolean isInCall = aliRtcConfig.isInCall();
AlivcLog.i(TAG, "[API]isInCall:" + isInCall);
return isInCall;
}
@Override
public int enableHighDefinitionPreview(boolean z) {
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine == null) {
return -1;
}
int enableHighDefinitionPreview = sophonEngine.enableHighDefinitionPreview(z);
Log.e(TAG, "enableHighDefinitionPreview:" + enableHighDefinitionPreview);
AlivcLog.i(TAG, "[API]enableHighDefinitionPreview:enable" + z);
return enableHighDefinitionPreview;
}
@Override
public int setLocalViewConfig(AliRtcEngine.AliVideoCanvas aliVideoCanvas, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
AlivcLog.e(TAG, "[API]setLocalViewConfig:viewConfig:" + aliVideoCanvas.toString() + "&&videoTrack:" + aliRtcVideoTrack);
if (aliRtcVideoTrack != AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera) {
AlivcLog.e(TAG, "[API][Result]setLocalViewConfig:viewConfig:" + aliVideoCanvas.toString() + "&&videoTrack:" + aliRtcVideoTrack + ":-1");
return -1;
}
if (aliVideoCanvas == null || (aliVideoCanvas.textureId == 0 && aliVideoCanvas.view == null)) {
AlivcLog.e(TAG, "[API][Result]setLocalViewConfig:setLocalViewConfig:view is null:-1");
return -1;
}
aliVideoCanvas.flip = getIsFlip(aliVideoCanvas.mirrorMode, getPreCameraType(), false);
if (this.mAliRtcConfig.getLocalVideoCanvas() != null) {
AlivcLog.d(TAG, "mAliRtcConfig getLocalVideoCanvas not null");
if (aliVideoCanvas.textureId != this.mAliRtcConfig.getLocalVideoCanvas().textureId || aliVideoCanvas.view != this.mAliRtcConfig.getLocalVideoCanvas().view) {
AlivcLog.e(TAG, "mAliRtcConfig setLocalViewConfig addLocalDisplayWindow");
removeLocalDisplayWindow();
addLocalDisplayWindow(aliVideoCanvas);
} else {
updateDisplayWindow(aliVideoCanvas);
}
}
this.mAliRtcConfig.setLocalVideoCanvas(aliVideoCanvas);
AlivcLog.i(TAG, "[API][End][Result]setLocalViewConfig:0");
return 0;
}
@Override
public int startPreview() {
AlivcLog.i(TAG, "[API]startPreview");
if (this.mAliRtcConfig.getLocalVideoCanvas() == null) {
AlivcLog.e(TAG, "[API][Result]startPreview: view is null error:-1");
return -1;
}
if (this.mAliRtcConfig.getLocalVideoCanvas().textureId == 0 && this.mAliRtcConfig.getLocalVideoCanvas().view == null) {
AlivcLog.e(TAG, "[API][Result]startPreview: view is null error:-1");
return -1;
}
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "[API][End][Result]startPreview: audio only mode error:-1");
return -1;
}
if (startCapture() != 0) {
AlivcLog.e(TAG, "[API][End][Result]startPreview:startCapture error:-1");
return -1;
}
addLocalDisplayWindow(this.mAliRtcConfig.getLocalVideoCanvas());
AlivcLog.i(TAG, "[API][End][Result]startPreview:0");
return 0;
}
@Override
public int stopPreview() {
AlivcLog.i(TAG, "[API]stopPreview:");
removeLocalDisplayWindow();
stopCapture();
AlivcLog.i(TAG, "[API][End][Result]stopPreview:0");
return 0;
}
private int startCapture() {
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "startCapture: SDK is null");
return -1;
}
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "startCapture: audio only mode");
return -1;
}
ALI_RTC_INTERFACE.AliCameraConfig aliCameraConfig = new ALI_RTC_INTERFACE.AliCameraConfig();
aliCameraConfig.video_source = this.mAliRtcConfig.getCameraType();
aliCameraConfig.autoFocus = this.mAliRtcConfig.isCamAutoFocus();
aliCameraConfig.flash = this.mAliRtcConfig.isCamFlash();
aliCameraConfig.sharedContext = this.mAliRtcConfig.getSharedContext();
aliCameraConfig.context = this.mContext;
aliCameraConfig.preferWidth = this.mAliRtcConfig.getCamVideoProfile().getWidth();
aliCameraConfig.preferHeight = this.mAliRtcConfig.getCamVideoProfile().getHeight();
aliCameraConfig.preferFps = this.mAliRtcConfig.getCamVideoProfile().getFPS();
this.mAliRtcConfig.setCameraOn(true);
AlivcLog.i(TAG, "openCamera,config.video_source:" + aliCameraConfig.video_source + "config.autoFocus:" + aliCameraConfig.autoFocus + "config.flash:" + aliCameraConfig.flash + "config.sharedContext:" + aliCameraConfig.sharedContext + "config.context:" + aliCameraConfig.context + "config.preferWidth:" + aliCameraConfig.preferWidth + "config.preferHeight:" + aliCameraConfig.preferHeight + "config.preferFps:" + aliCameraConfig.preferFps);
this.mSophonEngine.openCamera(aliCameraConfig);
return 0;
}
private int stopCapture() {
AlivcLog.d(TAG, "stopCapture");
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "stopCapture: SDK is null");
return -1;
}
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "stopCapture: audio only mode");
return -1;
}
this.mAliRtcConfig.setCameraOn(false);
this.mSophonEngine.closeCamera();
return 0;
}
@Override
public int muteLocalCamera(boolean z, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
AlivcLog.i(TAG, "[API]muteLocalCamera:mute:" + z + "&&VideoTrack:" + aliRtcVideoTrack);
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API][End][Result]muteLocalCamera: SDK is null:-1");
return -1;
}
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "[API][End][Result]muteLocalCamera: audio only mode:-1");
return -1;
}
if (aliRtcVideoTrack.getValue() != AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera.getValue() && aliRtcVideoTrack.getValue() != AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth.getValue()) {
StringBuilder sb = new StringBuilder();
sb.append("muteLocalCamera: error video track");
sb.append(aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
sb.append(aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth);
AlivcLog.e(TAG, sb.toString());
return -1;
}
this.mAliRtcConfig.setMuteLocalCameraVideo(z);
if (this.mAliRtcConfig.hasPublished()) {
this.mSophonEngine.enableLocalVideo(ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge, !z);
if (this.mAliRtcConfig.isDualStream()) {
this.mSophonEngine.enableLocalVideo(ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraSmall, !z);
}
}
AlivcLog.i(TAG, "[API][End][Result]muteLocalCamera:mute:0");
return 0;
}
@Override
public boolean isCameraOn() {
boolean isCameraOn = this.mAliRtcConfig.isCameraOn();
AlivcLog.i(TAG, "[API][Result]isCameraOn:" + isCameraOn);
return isCameraOn;
}
@Override
public int muteLocalMic(boolean z) {
AlivcLog.i(TAG, "[API]muteLocalMic:mute:" + z);
this.mAliRtcConfig.setMuteLocalMic(z);
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API][Result]muteLocalMic: SDK is null&&mute:" + z + "-1");
return -1;
}
if (this.mAliRtcConfig.hasPublished()) {
this.mSophonEngine.enableLocalAudio(!z);
}
AlivcLog.i(TAG, "[API][End][Result]muteLocalMic:0");
return 0;
}
@Override
public void publish() {
AlivcLog.i(TAG, "[API]publish");
if (!this.mAliRtcConfig.isInCall()) {
AlivcLog.e(TAG, "[API]publish:not in call");
return;
}
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API]publish:SDK is null");
return;
}
ALI_RTC_INTERFACE.AliPublishConfig config = getConfig();
if (!this.mAliRtcConfig.isPublishAudio() && ((!this.mAliRtcConfig.isPublishCameraTrack() && !this.mAliRtcConfig.isPublishScreenTrack()) || this.mAliRtcConfig.isAudioOnly())) {
AlivcLog.i(TAG, "[API]unpublish");
this.mAliRtcConfig.setCameraOn(false);
this.mSophonEngine.unpublish();
this.mAliRtcConfig.setLocalCallID(null, false);
return;
}
if (TextUtils.isEmpty(this.mAliRtcConfig.getLocalCallID()) && !this.mAliRtcConfig.isPublishIsGoing()) {
AlivcLog.i(TAG, "[API]publish");
this.mSophonEngine.publish(config);
this.mAliRtcConfig.setPublishIsGoing(true);
} else {
AlivcLog.i(TAG, "[API]republish");
this.mSophonEngine.republish(config);
}
AliRtcConfig aliRtcConfig = this.mAliRtcConfig;
aliRtcConfig.setCameraOn(aliRtcConfig.isPublishCameraTrack());
AlivcLog.i(TAG, "[API][End]publish");
}
@Override
public void setVideoProfile(AliRtcEngine.AliRtcVideoProfile aliRtcVideoProfile, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
AlivcLog.i(TAG, "[API]setVideoProfile:VideoProfile:" + aliRtcVideoProfile.toString() + "&&VideoTrack:" + aliRtcVideoTrack);
if (this.mAliRtcConfig.isAudioOnly()) {
return;
}
if (aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth) {
this.mAliRtcConfig.setCamVideoProfile(aliRtcVideoProfile);
this.mAliRtcConfig.setScreenVideoProfile(aliRtcVideoProfile);
} else if (aliRtcVideoTrack.getValue() == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera.getValue()) {
AlivcLog.i(TAG, "setVideoProfileprofile:" + aliRtcVideoProfile.getId() + "track:" + aliRtcVideoTrack.getValue());
this.mAliRtcConfig.setCamVideoProfile(aliRtcVideoProfile);
} else if (aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen) {
this.mAliRtcConfig.setScreenVideoProfile(aliRtcVideoProfile);
}
AlivcLog.i(TAG, "[API][End]setVideoProfile");
}
@Override
public AliRtcEngine.AliRtcVideoProfile getVideoProfile(AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
AlivcLog.i(TAG, "[API]getVideoProfile:VideoTrack:" + aliRtcVideoTrack);
AliRtcEngine.AliRtcVideoProfile camVideoProfile = this.mAliRtcConfig.getCamVideoProfile();
if (aliRtcVideoTrack != AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth) {
if (aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera) {
camVideoProfile = this.mAliRtcConfig.getCamVideoProfile();
} else if (aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen) {
camVideoProfile = this.mAliRtcConfig.getScreenVideoProfile();
}
}
AlivcLog.i(TAG, "[API][End][Result]getVideoProfile:VideoTrack:" + aliRtcVideoTrack + LogUtils.COLON + camVideoProfile.toString());
return camVideoProfile;
}
@Override
public int setRemoteViewConfig(AliRtcEngine.AliVideoCanvas aliVideoCanvas, String str, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
AlivcLog.i(TAG, "[API]setRemoteViewConfig:canvas:" + aliVideoCanvas.toString() + "&&uid:" + str + "&&VideoTrack" + aliRtcVideoTrack);
if (aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo || aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth) {
AlivcLog.e(TAG, "[API][Result]setRemoteViewConfig: error video track:-1");
return -1;
}
if (aliVideoCanvas == null || (aliVideoCanvas.textureId == 0 && aliVideoCanvas.view == null)) {
AlivcLog.e(TAG, "[API][Result]setRemoteViewConfig: canvas is null:-1");
return -1;
}
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API][Result]setRemoteViewConfig: SDK is null:-1");
return -1;
}
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant == null) {
AlivcLog.e(TAG, "[API][Result]setRemoteViewConfig: remote user is null:-1");
return -1;
}
int subVideoSurceIndex = remoteParticipant.getSubVideoSurceIndex(aliRtcVideoTrack);
if (subVideoSurceIndex == -1) {
return 0;
}
if (aliVideoCanvas.textureId > 0 && remoteParticipant.getVideoCanvas(subVideoSurceIndex) != null && remoteParticipant.getVideoCanvas(subVideoSurceIndex).textureId == aliVideoCanvas.textureId) {
if (aliRtcVideoTrack == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera) {
removeRemoteDisplayWindow(remoteParticipant.getCallID(), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge);
} else {
removeRemoteDisplayWindow(remoteParticipant.getCallID(), ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_ScreenShare);
}
remoteParticipant.getVideoCanvas(subVideoSurceIndex).textureId = 0;
}
if (!this.mAliRtcConfig.isInCall()) {
remoteParticipant.setVideoCanvas(aliRtcVideoTrack, aliVideoCanvas);
return 0;
}
ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type aliRTCSdk_VideSource_Type = ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.values()[subVideoSurceIndex];
if (!TextUtils.isEmpty(remoteParticipant.getVideoSubscribed()[subVideoSurceIndex])) {
aliVideoCanvas.flip = getIsFlip(aliVideoCanvas.mirrorMode, getPreCameraType(), true);
if (remoteParticipant.getVideoCanvas(subVideoSurceIndex) != null) {
if (aliVideoCanvas.textureId != remoteParticipant.getVideoCanvas(subVideoSurceIndex).textureId || remoteParticipant.getVideoCanvas(subVideoSurceIndex).view != aliVideoCanvas.view) {
AlivcLog.e(TAG, "setRemoteViewConfig: remove and add ");
removeRemoteDisplayWindow(remoteParticipant.getCallID(), aliRTCSdk_VideSource_Type);
addRemoteDisplayWindow(remoteParticipant.getCallID(), aliVideoCanvas, aliRTCSdk_VideSource_Type);
} else {
updateDisplayWindow(aliVideoCanvas);
}
} else {
addRemoteDisplayWindow(remoteParticipant.getCallID(), aliVideoCanvas, aliRTCSdk_VideSource_Type);
}
remoteParticipant.setVideoCanvas(aliRtcVideoTrack, aliVideoCanvas);
}
AlivcLog.i(TAG, "[API][End][Result]setRemoteViewConfig:0");
return 0;
}
@Override
public int muteRemoteAudioPlaying(String str, boolean z) {
AlivcLog.i(TAG, "[API]muteRemoteAudioPlaying:uid:" + str + "&&mute:" + z);
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API][End][Result]muteRemoteAudioPlaying: SDK is null-1");
return -1;
}
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant == null) {
if (this.mAliRtcConfig.getRemoteParticipants() != null && this.mAliRtcConfig.getRemoteParticipants().size() > 0) {
for (Map.Entry<String, RemoteParticipant> entry : this.mAliRtcConfig.getRemoteParticipants().entrySet()) {
AlivcLog.e(TAG, "[API]muteRemoteAudioPlaying: mAliRtcConfig.getRemoteParticipants() uid is:" + entry.getKey() + ",value:" + entry.getValue());
}
}
AlivcLog.e(TAG, "[API][End][Result]muteRemoteAudioPlaying: remote user can not found user " + str + ":-1");
return -1;
}
if (TextUtils.isEmpty(remoteParticipant.getCallID())) {
AlivcLog.e(TAG, "[API][End][Result]muteRemoteAudioPlaying: callid is null:-1");
return -1;
}
if (remoteParticipant.isMuteAudioPlaying() != z) {
remoteParticipant.setMuteAudioPlaying(z);
this.mSophonEngine.enableRemoteAudio(remoteParticipant.getCallID(), !z);
}
AlivcLog.i(TAG, "[API][End][Result]muteRemoteAudioPlaying:0");
return 0;
}
@Override
public int subscribe(String str) {
AlivcLog.i(TAG, "[API]subscribe: uid:" + str);
if (this.mSophonEngine == null) {
AlivcLog.e(TAG, "[API][End][Result]subscribe: SDK is null:-1");
return -1;
}
if (TextUtils.isEmpty(str)) {
AlivcLog.e(TAG, "[API][End][Result]subscribe: uid is null:-1");
return -1;
}
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant == null) {
AlivcLog.e(TAG, "[API][End][Result]subscribe: remote user is null:-1");
return -1;
}
if (TextUtils.isEmpty(remoteParticipant.getCallID())) {
AlivcLog.e(TAG, "[API][End][Result]subscribe: remote callId is null:-1");
return -1;
}
ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig = new ALI_RTC_INTERFACE.AliSubscribeConfig();
aliSubscribeConfig.stream_label = remoteParticipant.getStreamLabel();
if (!this.mAliRtcConfig.isAudioOnly()) {
aliSubscribeConfig.video_track_labels = remoteParticipant.getAvailableVideoSubed();
aliSubscribeConfig.audio_track_label = remoteParticipant.getAvailableAudioSubed();
} else {
aliSubscribeConfig.audio_track_label = remoteParticipant.getAvailableAudioSubed();
Arrays.fill(aliSubscribeConfig.video_track_labels, "");
}
if (RemoteParticipant.getAudioTrack(aliSubscribeConfig.audio_track_label) == AliRtcEngine.AliRtcAudioTrack.AliRtcAudioTrackNo && RemoteParticipant.getVideoTrack(aliSubscribeConfig.video_track_labels) == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo) {
AlivcLog.i(TAG, "unsubscribe callId: " + remoteParticipant.getCallID());
this.mSophonEngine.unsubscribe(remoteParticipant.getCallID());
return 0;
}
if (!remoteParticipant.isFirstSubscribe()) {
AlivcLog.i(TAG, "subscribe callId: " + remoteParticipant.getCallID() + " reSubscribeConfig: " + getSubscribeConfigString(aliSubscribeConfig));
this.mSophonEngine.resubscribe(remoteParticipant.getCallID(), aliSubscribeConfig);
return 0;
}
AlivcLog.i(TAG, "subscribe callId: " + remoteParticipant.getCallID() + " subscribeConfig: " + getSubscribeConfigString(aliSubscribeConfig));
this.mSophonEngine.subscribe(remoteParticipant.getCallID(), aliSubscribeConfig);
remoteParticipant.setFirstSubscribe(false);
AlivcLog.e(TAG, "[API][End][Result]subscribe: :0");
return 0;
}
@Override
public void configLocalCameraPublish(boolean z) {
AlivcLog.e(TAG, "[API]configLocalCameraPublish:" + z);
this.mAliRtcConfig.setPublishCameraTrack(z);
AlivcLog.e(TAG, "[API][End]configLocalCameraPublish");
}
@Override
public boolean isLocalCameraPublishEnabled() {
boolean isPublishCameraTrack = this.mAliRtcConfig.isPublishCameraTrack();
AlivcLog.e(TAG, "[API][Result]isLocalCameraPublishEnabled:" + isPublishCameraTrack);
return isPublishCameraTrack;
}
@Override
public void configLocalScreenPublish(boolean z) {
AlivcLog.e(TAG, "[API]configLocalScreenPublish:enable:" + z);
this.mAliRtcConfig.setPublishScreenTrack(z);
AlivcLog.e(TAG, "[API][End]configLocalScreenPublish");
}
@Override
public boolean isLocalScreenPublishEnabled() {
AlivcLog.e(TAG, "[API]isLocalScreenPublishEnabled");
boolean isPublishScreenTrack = this.mAliRtcConfig.isPublishScreenTrack();
AlivcLog.e(TAG, "[API][End][Result]isLocalScreenPublishEnabled:" + isPublishScreenTrack);
return isPublishScreenTrack;
}
@Override
public void configLocalAudioPublish(boolean z) {
AlivcLog.e(TAG, "[API]configLocalAudioPublish:enable:" + z);
this.mAliRtcConfig.setPublishAudio(z);
AlivcLog.e(TAG, "[API][End]configLocalAudioPublish");
}
@Override
public boolean isLocalAudioPublishEnabled() {
boolean isPublishAudio = this.mAliRtcConfig.isPublishAudio();
AlivcLog.e(TAG, "[API][Result]isLocalAudioPublishEnabled:" + isPublishAudio);
return isPublishAudio;
}
@Override
public int configLocalSimulcast(boolean z, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
AlivcLog.i(TAG, "[API]configLocalSimulcast: enable:" + z + "&&videoTrack: " + aliRtcVideoTrack.toString());
if (aliRtcVideoTrack != AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera) {
AlivcLog.e(TAG, "configLocalSimulcast: error videoTrack");
return -1;
}
this.mAliRtcConfig.setDualStream(z);
AlivcLog.i(TAG, "[API][End][Result]configLocalSimulcast: enable:" + z + "&&videoTrack: " + aliRtcVideoTrack.toString() + ":0");
return 0;
}
@Override
public boolean isLocalSimulcastEnabled() {
boolean isDualStream = this.mAliRtcConfig.isDualStream();
AlivcLog.e(TAG, "[API][Result]isLocalSimulcastEnabled:" + isDualStream);
return isDualStream;
}
@Override
public void configRemoteAudio(String str, boolean z) {
AlivcLog.i(TAG, "[API]configRemoteAudio:uid: " + str + "&&enable: " + z);
if (str == null && !isInCall()) {
DefaultValueConstant.SUB_AUDIO = z;
return;
}
if (TextUtils.isEmpty(str)) {
AlivcLog.e(TAG, "configRemoteAudio: uid is null");
return;
}
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant != null) {
remoteParticipant.setAudioSubscribed(z ? remoteParticipant.getAudioTrackLabel() : "");
remoteParticipant.setUcAudeoSubed(z);
}
AlivcLog.i(TAG, "[API][End]configRemoteAudio");
}
@Override
public void configRemoteCameraTrack(String str, boolean z, boolean z2) {
AlivcLog.d(TAG, "[API]configRemoteCameraTrack uid: " + str + "&&master: " + z + "&&enable: " + z2);
if (str == null && !isInCall()) {
DefaultValueConstant.SUB_CAMERA_MASTER = z;
DefaultValueConstant.SUB_CAMERA = z2;
return;
}
if (TextUtils.isEmpty(str)) {
AlivcLog.e(TAG, "configRemoteCameraTrack: uid is null");
return;
}
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant != null) {
String[] videoTrackLabels = remoteParticipant.getVideoTrackLabels();
String[] videoSubscribed = remoteParticipant.getVideoSubscribed();
boolean isSupportSuperStream = DeviceConfig.isSupportSuperStream();
int ordinal = ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge.ordinal();
int ordinal2 = ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraSmall.ordinal();
int ordinal3 = ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraSuper.ordinal();
videoSubscribed[ordinal] = "";
videoSubscribed[ordinal2] = "";
videoSubscribed[ordinal3] = "";
if (z2) {
if (!z) {
videoSubscribed[ordinal2] = videoTrackLabels[ordinal2];
} else if (isSupportSuperStream) {
if (!TextUtils.isEmpty(videoTrackLabels[ordinal3])) {
videoSubscribed[ordinal3] = videoTrackLabels[ordinal3];
} else {
videoSubscribed[ordinal] = videoTrackLabels[ordinal];
}
} else {
videoSubscribed[ordinal] = videoTrackLabels[ordinal];
}
}
remoteParticipant.setUcVideoSubed(z2);
remoteParticipant.setUcVideoSubedMaster(z);
AlivcLog.d(TAG, "[API][End]configRemoteCameraTrack");
}
}
@Override
public void configRemoteScreenTrack(String str, boolean z) {
AlivcLog.i(TAG, "[API]configRemoteScreenTrack uid: " + str + "&&enable: " + z);
if (str == null && !isInCall()) {
DefaultValueConstant.SUB_SCREEN = z;
return;
}
if (TextUtils.isEmpty(str)) {
AlivcLog.e(TAG, "configRemoteScreenTrack: uid is null");
return;
}
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant != null) {
String[] videoTrackLabels = remoteParticipant.getVideoTrackLabels();
String[] videoSubscribed = remoteParticipant.getVideoSubscribed();
int ordinal = ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_ScreenShare.ordinal();
videoSubscribed[ordinal] = z ? videoTrackLabels[ordinal] : "";
remoteParticipant.setUcScreenSubed(z);
}
AlivcLog.i(TAG, "[API][End]configRemoteScreenTrack");
}
@Override
public String[] getOnlineRemoteUsers() {
ArrayList arrayList = new ArrayList();
for (Map.Entry<String, RemoteParticipant> entry : this.mAliRtcConfig.getRemoteParticipants().entrySet()) {
if (entry.getValue().isOnline()) {
arrayList.add(entry.getKey());
}
}
String[] strArr = new String[arrayList.size()];
AlivcLog.i(TAG, "[API][End]getOnlineRemoteUsers: " + arrayList.toArray(strArr));
return (String[]) arrayList.toArray(strArr);
}
@Override
public AliRtcRemoteUserInfo getUserInfo(String str) {
AlivcLog.i(TAG, "[API]getUserInfo:uid:" + str);
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant == null) {
return null;
}
AliRtcRemoteUserInfo aliRtcRemoteUserInfo = new AliRtcRemoteUserInfo();
aliRtcRemoteUserInfo.setUserID(remoteParticipant.getUserID());
aliRtcRemoteUserInfo.setCallID(remoteParticipant.getCallID());
aliRtcRemoteUserInfo.setSessionID(remoteParticipant.getSessionID());
aliRtcRemoteUserInfo.setDisplayName(remoteParticipant.getDisplayName());
aliRtcRemoteUserInfo.setStreamLabel(remoteParticipant.getStreamLabel());
aliRtcRemoteUserInfo.setFirstSubscribe(remoteParticipant.isFirstSubscribe());
aliRtcRemoteUserInfo.setOnline(remoteParticipant.isOnline());
aliRtcRemoteUserInfo.setMuteAudioPlaying(remoteParticipant.isMuteAudioPlaying());
aliRtcRemoteUserInfo.setCameraCanvas(remoteParticipant.getCameraCanvas());
aliRtcRemoteUserInfo.setScreenCanvas(remoteParticipant.getScreenCanvas());
aliRtcRemoteUserInfo.setHasAudio(remoteParticipant.isHasAudioStream());
aliRtcRemoteUserInfo.setHasCameraMaster(remoteParticipant.isHasVideoSuperStream() || remoteParticipant.isHasVideoLargeStream());
aliRtcRemoteUserInfo.setHasCameraSlave(remoteParticipant.isHasVideoSmallStream());
aliRtcRemoteUserInfo.setHasScreenSharing(remoteParticipant.isHasScreenShareStream());
aliRtcRemoteUserInfo.setSubAudio(remoteParticipant.isAudioSubscribed());
aliRtcRemoteUserInfo.setSubCameraMaster(remoteParticipant.isSubVideoSuperStream() || remoteParticipant.isSubVideoLargeStream());
aliRtcRemoteUserInfo.setSubCamera(remoteParticipant.isVideoSubscribed());
aliRtcRemoteUserInfo.setSubScreenSharing(remoteParticipant.isSubShcreenShareStream());
aliRtcRemoteUserInfo.setRequestSubAudio(remoteParticipant.isUcAudeoSubed());
aliRtcRemoteUserInfo.setRequestCameraMaster(remoteParticipant.isUcVideoSubedMaster());
aliRtcRemoteUserInfo.setRequestCamera(remoteParticipant.isUcVideoSubed());
aliRtcRemoteUserInfo.setRequestScreenSharing(remoteParticipant.isUcScreenSubed());
AlivcLog.i(TAG, "[API][End][Result]getUserInfo:" + aliRtcRemoteUserInfo.toString());
return aliRtcRemoteUserInfo;
}
@Override
public boolean isUserOnline(String str) {
RemoteParticipant remoteParticipant = this.mAliRtcConfig.getRemoteParticipants().get(str);
if (remoteParticipant == null) {
return false;
}
boolean isOnline = remoteParticipant.isOnline();
AlivcLog.i(TAG, "[API][End][Result]isUserOnline:uid: " + str + LogUtils.COLON + isOnline);
return isOnline;
}
@Override
public int enableSpeakerphone(boolean z) {
AlivcLog.i(TAG, "[API]enableSpeakerphone:enable: " + z);
if (this.mSophonEngine == null) {
AlivcLog.i(TAG, "[API][Result]enableSpeakerphone: SDK is null: -1");
return -1;
}
this.mAliRtcConfig.setSpeakerOn(z);
this.mSophonEngine.selectSpeakePhone(z);
this.mSophonEngine.setSpeakerStatus(z);
AlivcLog.i(TAG, "[API][End][Result]enableSpeakerphone:enable: 0");
return 0;
}
@Override
public boolean isSpeakerOn() {
AlivcLog.i(TAG, "[API]isSpeakerOn");
boolean isSpeakerOn = this.mAliRtcConfig.isSpeakerOn();
AlivcLog.i(TAG, "[API][End][Result]isSpeakerOn:" + isSpeakerOn);
return isSpeakerOn;
}
@Override
public int switchCamera() {
SophonEngine sophonEngine;
AlivcLog.i(TAG, "[API]switchCamera");
if (this.mAliRtcConfig.isAudioOnly() || (sophonEngine = this.mSophonEngine) == null) {
return -1;
}
int switchCramer = sophonEngine.switchCramer();
if (switchCramer == 0) {
if (this.mAliRtcConfig.getCameraType() == AliRtcEngine.AliRTCCameraType.AliRTCCameraBack.getCameraType()) {
this.mAliRtcConfig.setCameraType(AliRtcEngine.AliRTCCameraType.AliRTCCameraFront.getCameraType());
} else {
this.mAliRtcConfig.setCameraType(AliRtcEngine.AliRTCCameraType.AliRTCCameraBack.getCameraType());
}
setLocalViewConfig(this.mAliRtcConfig.getLocalVideoCanvas(), AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
}
AlivcLog.i(TAG, "[API][End][Result]switchCamera:" + switchCramer);
return switchCramer;
}
@Override
public AliRtcEngine.AliRTCCameraType getCurrentCameraType() {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]getCurrentCameraType");
AliRtcEngine.AliRTCCameraType aliRTCCameraType = AliRtcEngine.AliRTCCameraType.values()[this.mSophonEngine.getCaptureType().ordinal()];
AlivcLog.i(TAG, "[API][End][Result]getCurrentCameraType:" + aliRTCCameraType);
return aliRTCCameraType;
}
return AliRtcEngine.AliRTCCameraType.AliRTCCameraInvalid;
}
@Override
public void setPreCameraType(int i) {
AlivcLog.i(TAG, "[API]setPreCameraType:faceTo:" + i);
this.mAliRtcConfig.setCameraType(i);
AlivcLog.i(TAG, "[API][End]setPreCameraType");
}
@Override
public int getPreCameraType() {
AlivcLog.i(TAG, "[API]getPreCameraType");
int cameraType = this.mAliRtcConfig.getCameraType();
AlivcLog.i(TAG, "[API][End][Result]getPreCameraType:" + cameraType);
return cameraType;
}
@Override
public int setCameraZoom(float f, boolean z, boolean z2) {
AlivcLog.i(TAG, "[API]setCameraZoom:zoom: " + f + "&&flash: " + z + "&&autoFocus: " + z2);
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "setCameraZoom: audio only mode");
return -1;
}
this.mAliRtcConfig.setCamZoom(f);
this.mAliRtcConfig.setCamFlash(z);
this.mAliRtcConfig.setCamAutoFocus(z2);
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine != null) {
sophonEngine.setFlash(this.mAliRtcConfig.isCamFlash());
this.mSophonEngine.setCameraZoom(this.mAliRtcConfig.getCamZoom());
}
AlivcLog.i(TAG, "[API][End][Result]setCameraZoom:0");
return 0;
}
@Override
public float getCameraZoom() {
AlivcLog.i(TAG, "[API]getCameraZoom");
float camZoom = this.mAliRtcConfig.getCamZoom();
AlivcLog.d(TAG, "[API][End][Result]getCameraZoom:" + camZoom);
return camZoom;
}
@Override
public boolean isCameraFlash() {
AlivcLog.i(TAG, "[API]isCameraFlash");
boolean isCamFlash = this.mAliRtcConfig.isCamFlash();
AlivcLog.i(TAG, "[API][End][Result]isCameraFlash:" + isCamFlash);
return isCamFlash;
}
@Override
public boolean isCameraAutoFocus() {
AlivcLog.i(TAG, "[API]isCameraAutoFocus");
boolean isCamAutoFocus = this.mAliRtcConfig.isCamAutoFocus();
AlivcLog.i(TAG, "[API][End][Result]isCameraAutoFocus:" + isCamAutoFocus);
return isCamAutoFocus;
}
@Override
public boolean isCameraSupportFocusPoint() {
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "isCameraSupportFocusPoint: audio only mode");
return false;
}
if (this.mSophonEngine == null) {
return false;
}
AlivcLog.i(TAG, "[API]isCameraSupportFocusPoint");
boolean isCameraSupportFocusPoint = this.mSophonEngine.isCameraSupportFocusPoint();
AlivcLog.i(TAG, "[API][End][Result]isCameraSupportFocusPoint:" + isCameraSupportFocusPoint);
return isCameraSupportFocusPoint;
}
@Override
public boolean isCameraSupportExposurePoint() {
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "isCameraSupportExposurePoint: audio only mode");
return false;
}
if (this.mSophonEngine == null) {
return false;
}
AlivcLog.i(TAG, "[API]isCameraSupportExposurePoint");
boolean isCameraSupportExposurePoint = this.mSophonEngine.isCameraSupportExposurePoint();
AlivcLog.i(TAG, "[API][End][Result]isCameraSupportExposurePoint:" + isCameraSupportExposurePoint);
return isCameraSupportExposurePoint;
}
@Override
public int setCameraFocusPoint(float f, float f2) {
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "setCameraFocusPoint: audio only mode");
return -1;
}
if (this.mSophonEngine == null) {
return 0;
}
AlivcLog.i(TAG, "[API]setCameraFocusPoint:x:" + f + "&&y:" + f2);
this.mSophonEngine.setCameraFocusPoint(f, f2);
AlivcLog.i(TAG, "[API][End][Result]setCameraFocusPoint:0");
return 0;
}
@Override
public int setCameraExposurePoint(float f, float f2) {
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.e(TAG, "setCameraExposurePoint: audio only mode");
return -1;
}
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]setCameraExposurePoint:x:" + f + "&&y: " + f2);
this.mSophonEngine.setCameraExposurePoint(f, f2);
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]setCameraExposurePoint:");
sb.append(-1);
AlivcLog.i(TAG, sb.toString());
}
return -1;
}
@Override
public int setRecordingVolume(int i) {
if (this.mSophonEngine == null) {
return 0;
}
AlivcLog.i(TAG, "[API]setRecordingVolume: volume:" + i);
return this.mSophonEngine.setRecordingVolume(i);
}
@Override
public int setPlayoutVolume(int i) {
if (this.mSophonEngine == null) {
return 0;
}
AlivcLog.i(TAG, "[API]setPlayoutVolume: volume:" + i);
return this.mSophonEngine.setPlayoutVolume(i);
}
@Override
public void setLogLevel(AliRtcEngine.AliRtcLogLevel aliRtcLogLevel) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]setLogLevel:logLevel:" + aliRtcLogLevel);
this.mSophonEngine.changeLogLevel(ALI_RTC_INTERFACE.AliRTCSDKLogLevel.values()[aliRtcLogLevel.ordinal()]);
AlivcLog.i(TAG, "[API][End][Result]setLogLevel");
}
}
@Override
public void uploadLog() {
AlivcLog.i(TAG, "[API]uploadLog");
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine != null) {
sophonEngine.uploadLop();
AlivcLog.i(TAG, "[API][End]uploadLog");
}
}
@Override
public void setRtcEngineEventListener(AliRtcEngineEventListener aliRtcEngineEventListener) {
if (aliRtcEngineEventListener != null) {
StringBuilder sb = new StringBuilder();
sb.append("[API]setRtcEngineEventListener:listener:");
sb.append(aliRtcEngineEventListener != null ? aliRtcEngineEventListener.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mEventListener = aliRtcEngineEventListener;
AlivcLog.i(TAG, "[API][End]setRtcEngineEventListener");
}
}
@Override
public void setRtcEngineNotify(AliRtcEngineNotify aliRtcEngineNotify) {
if (aliRtcEngineNotify != null) {
StringBuilder sb = new StringBuilder();
sb.append("[API]setRtcEngineNotify:listener:");
sb.append(aliRtcEngineNotify != null ? aliRtcEngineNotify.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mNotifyListener = aliRtcEngineNotify;
AlivcLog.i(TAG, "[API][End]setRtcEngineNotify");
}
}
@Override
public void RegisterAudioObserver(ALI_RTC_INTERFACE.AliAudioType aliAudioType, ALI_RTC_INTERFACE.AliAudioObserver aliAudioObserver) {
if (this.mSophonEngine != null) {
StringBuilder sb = new StringBuilder();
sb.append("[API]RegisterAudioObserver:AliAudioType:");
sb.append(aliAudioType);
sb.append("&&observer:");
sb.append(aliAudioObserver != null ? aliAudioObserver.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mSophonEngine.RegisterAudioObserver(aliAudioType, aliAudioObserver);
}
}
@Override
public void UnRegisterAudioObserver(ALI_RTC_INTERFACE.AliAudioType aliAudioType) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]UnRegisterAudioObserver:AliAudioType:" + aliAudioType);
this.mSophonEngine.UnRegisterAudioObserver(aliAudioType);
}
}
@Override
public void RegisterVideoSampleObserver(final ALI_RTC_INTERFACE.AliVideoObserver aliVideoObserver) {
if (this.mSophonEngine != null) {
StringBuilder sb = new StringBuilder();
sb.append("[API]RegisterVideoSampleObserver:&&observer");
sb.append(aliVideoObserver != null ? aliVideoObserver.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mSophonEngine.RegisterVideoObserver(new ALI_RTC_INTERFACE.AliVideoObserver() {
@Override
public void onLocalVideoSample(ALI_RTC_INTERFACE.AliVideoSourceType aliVideoSourceType, ALI_RTC_INTERFACE.AliVideoSample aliVideoSample) {
aliVideoObserver.onLocalVideoSample(aliVideoSourceType, aliVideoSample);
}
@Override
public void onRemoteVideoSample(String str, ALI_RTC_INTERFACE.AliVideoSourceType aliVideoSourceType, ALI_RTC_INTERFACE.AliVideoSample aliVideoSample) {
aliVideoObserver.onRemoteVideoSample(str, aliVideoSourceType, aliVideoSample);
}
});
}
}
@Override
public void UnRegisterVideoSampleObserver() {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]UnRegisterVideoSampleObserver");
this.mSophonEngine.UnRegisterVideoObserver();
}
}
@Override
public void RegisterPreprocessVideoObserver(ALI_RTC_INTERFACE.AliDetectObserver aliDetectObserver) {
StringBuilder sb = new StringBuilder();
sb.append("[API]RegisterPreprocessVideoObserver:observer: ");
sb.append(aliDetectObserver != null ? aliDetectObserver.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine != null) {
sophonEngine.RegisterPreprocessVideoObserver(aliDetectObserver);
}
AlivcLog.i(TAG, "[API][End]RegisterPreprocessVideoObserver");
}
@Override
public void UnRegisterPreprocessVideoObserver() {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]UnRegisterPreprocessVideoObserver");
this.mSophonEngine.UnRegisterPreprocessVideoObserver();
AlivcLog.i(TAG, "[API][End]UnRegisterPreprocessVideoObserver");
}
}
@Override
public void RegisterTexturePreObserver(String str, final ALI_RTC_INTERFACE.AliTextureObserver aliTextureObserver) {
if (this.mSophonEngine != null) {
String callID = (str == null || str.equals("") || this.mAliRtcConfig.getRemoteParticipants().get(str) == null) ? str : this.mAliRtcConfig.getRemoteParticipants().get(str).getCallID();
StringBuilder sb = new StringBuilder();
sb.append("[API]RegisterTexturePreObserver:userId:");
sb.append(str);
sb.append("&&observer: ");
sb.append(aliTextureObserver != null ? aliTextureObserver.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mSophonEngine.RegisterTexturePreObserver(callID, new ALI_RTC_INTERFACE.AliTextureObserver() {
@Override
public void onTextureCreate(String str2, long j) {
if (str2 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str2 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
aliTextureObserver.onTextureCreate(str2, j);
}
@Override
public int onTexture(String str2, int i, int i2, int i3, int i4, int i5, long j) {
String str3 = str2;
if (str3 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str3 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
return aliTextureObserver.onTexture(str3, i, i2, i3, i4, i5, j);
}
@Override
public void onTextureDestroy(String str2) {
if (str2 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str2 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
aliTextureObserver.onTextureDestroy(str2);
}
});
}
}
@Override
public void UnRegisterTexturePreObserver(String str) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "UnRegisterTexturePreObserver: callID:" + str);
this.mSophonEngine.UnRegisterTexturePreObserver(str);
}
}
@Override
public void RegisterTexturePostObserver(String str, final ALI_RTC_INTERFACE.AliTextureObserver aliTextureObserver) {
if (this.mSophonEngine != null) {
String callID = (str == null || str.equals("") || this.mAliRtcConfig.getRemoteParticipants().get(str) == null) ? str : this.mAliRtcConfig.getRemoteParticipants().get(str).getCallID();
StringBuilder sb = new StringBuilder();
sb.append("[API]RegisterTexturePostObserver: userId:");
sb.append(str);
sb.append("&&observer: ");
sb.append(aliTextureObserver != null ? aliTextureObserver.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mSophonEngine.RegisterTexturePostObserver(callID, new ALI_RTC_INTERFACE.AliTextureObserver() {
@Override
public void onTextureCreate(String str2, long j) {
if (str2 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str2 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
aliTextureObserver.onTextureCreate(str2, j);
}
@Override
public int onTexture(String str2, int i, int i2, int i3, int i4, int i5, long j) {
String str3 = str2;
if (str3 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str3 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
return aliTextureObserver.onTexture(str3, i, i2, i3, i4, i5, j);
}
@Override
public void onTextureDestroy(String str2) {
if (str2 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str2 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
aliTextureObserver.onTextureDestroy(str2);
}
});
}
}
@Override
public void UnRegisterTexturePostObserver(String str) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]UnRegisterTexturePostObserver: callId:" + str);
this.mSophonEngine.UnRegisterTexturePostObserver(str);
}
}
@Override
public void RegisterRGBAObserver(String str, final ALI_RTC_INTERFACE.AliRenderDataObserver aliRenderDataObserver) {
if (this.mSophonEngine != null) {
String callID = (str == null || str.equals("") || this.mAliRtcConfig.getRemoteParticipants().get(str) == null) ? str : this.mAliRtcConfig.getRemoteParticipants().get(str).getCallID();
StringBuilder sb = new StringBuilder();
sb.append("[API]RegisterRGBAObserver: userId:");
sb.append(str);
sb.append("&&observer: ");
sb.append(aliRenderDataObserver != null ? aliRenderDataObserver.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mSophonEngine.RegisterRGBAObserver(callID, new ALI_RTC_INTERFACE.AliRenderDataObserver() {
@Override
public void onRenderData(String str2, long j, int i, int i2, int i3, int i4, int i5, long j2) {
String str3 = str2;
if (str3 != null && !str2.equals("") && AliRtcEngineImpl.this.findParticipantByCallID(str2) != null) {
str3 = AliRtcEngineImpl.this.findParticipantByCallID(str2).getUserID();
}
aliRenderDataObserver.onRenderData(str3, j, i, i2, i3, i4, i5, j2);
}
});
}
}
@Override
public void UnRegisterRGBAObserver(String str) {
AlivcLog.i(TAG, "UnRegisterRGBAObserver observer: ");
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]UnRegisterRGBAObserver: callId:" + str);
this.mSophonEngine.UnRegisterRGBAObserver(str);
}
}
@Override
public void enableBackgroundAudioRecording(boolean z) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]enableBackgroundAudioRecording: enable:" + z);
this.mSophonEngine.enableBackgroundAudioRecording(z);
AlivcLog.i(TAG, "[API][End]enableBackgroundAudioRecording");
}
}
@Override
public boolean isEnableBackgroundAudioRecording() {
if (this.mSophonEngine == null) {
return false;
}
AlivcLog.i(TAG, "[API]isEnableBackgroundAudioRecording:");
boolean isEnableBackgroundAudioRecording = this.mSophonEngine.isEnableBackgroundAudioRecording();
AlivcLog.i(TAG, "[API][End][Result]isEnableBackgroundAudioRecording:" + isEnableBackgroundAudioRecording);
return isEnableBackgroundAudioRecording;
}
@Override
public void setCollectStatusListener(CollectStatusListener collectStatusListener) {
if (this.mSophonEngine != null) {
StringBuilder sb = new StringBuilder();
sb.append("[API]setCollectStatusListener:collectStatusListener:");
sb.append(collectStatusListener != null ? collectStatusListener.hashCode() : 0);
AlivcLog.i(TAG, sb.toString());
this.mSophonEngine.setCollectStatusListener(collectStatusListener);
}
}
@Override
public ALI_RTC_INTERFACE.VideoRawDataInterface registerVideoRawDataInterface(ALI_RTC_INTERFACE.AliRawDataStreamType aliRawDataStreamType) {
if (this.mSophonEngine == null) {
return null;
}
AlivcLog.i(TAG, "[API]registerVideoRawDataInterface:streamType:" + aliRawDataStreamType);
return this.mSophonEngine.registerVideoRawDataInterface(aliRawDataStreamType);
}
@Override
public void unRegisterVideoRawDataInterface(ALI_RTC_INTERFACE.AliRawDataStreamType aliRawDataStreamType) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]unRegisterVideoRawDataInterface:streamType:" + aliRawDataStreamType);
this.mSophonEngine.unRegisterVideoRawDataInterface(aliRawDataStreamType);
}
}
public void configRemoteParticipantDefaultValues(RemoteParticipant remoteParticipant) {
remoteParticipant.setUcAudeoSubed(DefaultValueConstant.SUB_AUDIO);
remoteParticipant.setUcVideoSubed(DefaultValueConstant.SUB_CAMERA);
remoteParticipant.setUcVideoSubedMaster(DefaultValueConstant.SUB_CAMERA_MASTER);
remoteParticipant.setUcScreenSubed(DefaultValueConstant.SUB_SCREEN);
}
private ALI_RTC_INTERFACE.AliPublishConfig getConfig() {
boolean z;
boolean z2;
boolean z3;
boolean isPublishAudio = this.mAliRtcConfig.isPublishAudio();
boolean isDualStream = this.mAliRtcConfig.isDualStream();
boolean z4 = true;
if (this.mAliRtcConfig.isAudioOnly()) {
z = false;
z2 = false;
z4 = false;
z3 = false;
} else {
if (this.mAliRtcConfig.isPublishCameraTrack()) {
z2 = DeviceConfig.isSupportSuperStream();
if (isDualStream) {
z = true;
z3 = true;
if (!this.mAliRtcConfig.isPublishScreenTrack()) {
z4 = false;
}
} else {
z = true;
}
} else {
z = false;
z2 = false;
}
z3 = false;
if (!this.mAliRtcConfig.isPublishScreenTrack()) {
}
}
ALI_RTC_INTERFACE.AliPublishConfig aliPublishConfig = new ALI_RTC_INTERFACE.AliPublishConfig();
int value = ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_MAX.getValue();
boolean[] zArr = new boolean[value];
zArr[ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge.ordinal()] = z;
zArr[ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraSmall.ordinal()] = z3;
zArr[ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_ScreenShare.ordinal()] = z4;
zArr[ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraSuper.ordinal()] = z2;
aliPublishConfig.audio_track = isPublishAudio;
aliPublishConfig.video_tracks = zArr;
int[] iArr = new int[ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_MAX.getValue()];
for (int i = 0; i < value; i++) {
if (zArr[i]) {
iArr[i] = this.mAliRtcConfig.getCamVideoProfile().getId();
AlivcLog.i(TAG, "videotrack index : " + i + ", videoprofile : " + this.mAliRtcConfig.getCamVideoProfile().toString());
}
}
aliPublishConfig.video_track_profile = iArr;
return aliPublishConfig;
}
public RemoteParticipant findParticipantByCallID(String str) {
return this.mAliRtcConfig.getRemotePublishParticipants().get(str);
}
public void addRemoteDisplayWindow(String str, AliRtcEngine.AliVideoCanvas aliVideoCanvas, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type aliRTCSdk_VideSource_Type) {
if (aliVideoCanvas == null || (aliVideoCanvas.textureId == 0 && aliVideoCanvas.view == null)) {
AlivcLog.e(TAG, "addRemoteDisplayWindow: canvas is null");
return;
}
SophonEngine.AliRendererConfig aliRendererConfig = new SophonEngine.AliRendererConfig();
if (aliVideoCanvas.textureId > 0) {
AlivcLog.e(TAG, "addRemoteDisplayWindow: videoCanvas.textureId != 0 videoCanvas.textureId is = " + aliVideoCanvas.textureId + "aliRendererConfig.sharedContext" + aliVideoCanvas.sharedContext);
aliRendererConfig.textureId = aliVideoCanvas.textureId;
aliRendererConfig.textureWidth = aliVideoCanvas.textureWidth;
aliRendererConfig.textureHeight = aliVideoCanvas.textureHeight;
aliRendererConfig.sharedContext = aliVideoCanvas.sharedContext;
} else {
SophonSurfaceView sophonSurfaceView = aliVideoCanvas.view;
if (sophonSurfaceView != null) {
aliRendererConfig.displayView = sophonSurfaceView;
aliRendererConfig.width = sophonSurfaceView.getWidth();
aliRendererConfig.height = sophonSurfaceView.getHeight();
}
}
aliRendererConfig.displayMode = aliVideoCanvas.renderMode.ordinal();
aliVideoCanvas.flip = getIsFlip(aliVideoCanvas.mirrorMode, getPreCameraType(), true);
aliRendererConfig.flip = aliVideoCanvas.flip;
aliRendererConfig.sharedContext = this.mAliRtcConfig.getSharedContext();
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine != null) {
sophonEngine.addRemoteDisplayWindow(str, aliRTCSdk_VideSource_Type, aliRendererConfig);
}
}
public void removeRemoteNullTracksDisplayWindow(String str, String[] strArr) {
if (TextUtils.isEmpty(str) || strArr == null) {
return;
}
String arrays = Arrays.toString(strArr);
if (!arrays.contains(ALI_RTC_INTERFACE.CAMERA_STRING) && !arrays.contains(ALI_RTC_INTERFACE.SMALL_STRING) && !arrays.contains(ALI_RTC_INTERFACE.SUPER_STRING)) {
removeRemoteDisplayWindow(str, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge);
}
if (arrays.contains(ALI_RTC_INTERFACE.SCREEN_STRING)) {
return;
}
removeRemoteDisplayWindow(str, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_ScreenShare);
}
public void removeRemoteDisplayWindow(String str, ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type aliRTCSdk_VideSource_Type) {
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine != null) {
sophonEngine.removeRemoteDisplayWindow(str, aliRTCSdk_VideSource_Type);
}
}
public void addLocalDisplayWindow(AliRtcEngine.AliVideoCanvas aliVideoCanvas) {
if (aliVideoCanvas.textureId <= 0 && aliVideoCanvas.view == null) {
AlivcLog.e(TAG, "addLocalDisplayWindow: canvas is null");
return;
}
SophonEngine.AliRendererConfig aliRendererConfig = new SophonEngine.AliRendererConfig();
if (aliVideoCanvas.textureId > 0) {
AlivcLog.e(TAG, "addLocalDisplayWindow: videoCanvas.textureId != 0 videoCanvas.textureId is = " + aliVideoCanvas.textureId + "videoCanvas.textureWidth:" + aliVideoCanvas.textureWidth + "videoCanvas.textureHeight" + aliVideoCanvas.textureHeight);
aliRendererConfig.textureId = aliVideoCanvas.textureId;
StringBuilder sb = new StringBuilder();
sb.append("addLocalDisplayWindow1: config.textureId is = ");
sb.append(aliRendererConfig.textureId);
AlivcLog.e(TAG, sb.toString());
aliRendererConfig.textureWidth = aliVideoCanvas.textureWidth;
aliRendererConfig.textureHeight = aliVideoCanvas.textureHeight;
} else if (this.mAliRtcConfig.getLocalVideoCanvas().view != null) {
aliRendererConfig.displayView = this.mAliRtcConfig.getLocalVideoCanvas().view;
aliRendererConfig.width = aliRendererConfig.displayView.getWidth();
aliRendererConfig.height = aliRendererConfig.displayView.getHeight();
AlivcLog.e(TAG, "addLocalDisplayWindow: textureId is = " + aliVideoCanvas.textureId + " ,w:" + aliRendererConfig.width + " ,h:" + aliRendererConfig.height);
}
aliRendererConfig.displayMode = aliVideoCanvas.renderMode.ordinal();
aliVideoCanvas.flip = getIsFlip(aliVideoCanvas.mirrorMode, getPreCameraType(), false);
aliRendererConfig.flip = aliVideoCanvas.flip;
aliRendererConfig.sharedContext = aliVideoCanvas.sharedContext;
aliRendererConfig.enableBeauty = aliVideoCanvas.enableBeauty;
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]addLocalDisplayWindow: VideSource_Type:" + ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge + "&&config:" + aliRendererConfig.toString());
this.mSophonEngine.addLocalDisplayWindow(ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge, aliRendererConfig);
}
}
private void removeLocalDisplayWindow() {
if (this.mAliRtcConfig.getLocalVideoCanvas() == null || (this.mAliRtcConfig.getLocalVideoCanvas().view == null && this.mAliRtcConfig.getLocalVideoCanvas().textureId <= 0)) {
AlivcLog.e(TAG, "removeLocalDisplayWindow: canvas is null");
return;
}
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]addLocalDisplayWindow: VideSource_Type:" + ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge);
this.mSophonEngine.removeLocalDisplayWindow(ALI_RTC_INTERFACE.AliRTCSdk_VideSource_Type.AliRTCSDK_VideoSource_Type_CameraLarge);
}
}
private void updateDisplayWindow(AliRtcEngine.AliVideoCanvas aliVideoCanvas) {
if (this.mSophonEngine != null) {
SophonEngine.AliRendererConfig aliRendererConfig = new SophonEngine.AliRendererConfig();
aliRendererConfig.displayMode = aliVideoCanvas.renderMode.ordinal();
if (aliVideoCanvas.textureId > 0) {
aliRendererConfig.textureId = aliVideoCanvas.textureId;
aliRendererConfig.textureWidth = aliVideoCanvas.textureWidth;
aliRendererConfig.textureHeight = aliVideoCanvas.textureHeight;
aliRendererConfig.width = aliVideoCanvas.textureWidth;
aliRendererConfig.height = aliVideoCanvas.textureHeight;
AlivcLog.e(TAG, "updateDisplayWindow videoCanvas.textureId" + aliVideoCanvas.textureId);
}
if (aliVideoCanvas.view != null) {
aliRendererConfig.displayView = aliVideoCanvas.view;
aliRendererConfig.width = aliVideoCanvas.view.getWidth();
aliRendererConfig.height = aliVideoCanvas.view.getHeight();
AlivcLog.e(TAG, "updateDisplayWindow view != null");
} else {
AlivcLog.e(TAG, "updateDisplayWindow view == null");
}
aliRendererConfig.flip = aliVideoCanvas.flip;
AlivcLog.i(TAG, "[API][Callback]addLocalDisplayWindow: config:" + aliRendererConfig.toString());
this.mSophonEngine.updateDisplayWindow(aliRendererConfig);
}
}
private boolean getIsFlip(AliRtcEngine.AliRtcRenderMirrorMode aliRtcRenderMirrorMode, int i, boolean z) {
if (aliRtcRenderMirrorMode == null) {
return true;
}
int i2 = AnonymousClass7.$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcRenderMirrorMode[aliRtcRenderMirrorMode.ordinal()];
if (i2 != 1) {
if (i2 == 2) {
return true;
}
} else if (i == AliRtcEngine.AliRTCCameraType.AliRTCCameraFront.getCameraType() && !z) {
return true;
}
return false;
}
public String getSubscribeConfigString(ALI_RTC_INTERFACE.AliSubscribeConfig aliSubscribeConfig) {
StringBuffer stringBuffer = new StringBuffer();
if (aliSubscribeConfig != null) {
stringBuffer.append(aliSubscribeConfig.stream_label);
stringBuffer.append(",");
if (aliSubscribeConfig.video_track_labels != null) {
for (int i = 0; i < aliSubscribeConfig.video_track_labels.length; i++) {
stringBuffer.append(aliSubscribeConfig.video_track_labels[i]);
stringBuffer.append(",");
}
}
stringBuffer.append(aliSubscribeConfig.audio_track_label);
}
return stringBuffer.toString();
}
public String getOsInfo() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.putOpt(AliRtcConstants.OS_NAME, AliRtcConstants.ANDROID);
jSONObject.putOpt(AliRtcConstants.OS_SDK, Integer.valueOf(Build.VERSION.SDK_INT));
jSONObject.putOpt(AliRtcConstants.OS_VERSION, Build.VERSION.RELEASE);
jSONObject.putOpt(AliRtcConstants.OS_CPUABI, Build.CPU_ABI);
jSONObject.putOpt(AliRtcConstants.DEVICENAME, Build.MODEL);
jSONObject.putOpt(AliRtcConstants.BRAND, Build.BRAND);
jSONObject.putOpt(AliRtcConstants.PLATFORM, Build.HARDWARE);
jSONObject.putOpt(AliRtcConstants.ACCESS, AliRtcEngineUtil.getNetWorkStatus(this.mContext));
jSONObject.putOpt(AliRtcConstants.CARRIER, AliRtcEngineUtil.getOperators(this.mContext));
jSONObject.putOpt(AliRtcConstants.CPU_TYPE, "");
jSONObject.putOpt(AliRtcConstants.UDID, UTDevice.getUtdid(this.mContext));
jSONObject.putOpt(AliRtcConstants.SCREEN_RESOLUTION, AliRtcEngineUtil.getWindowHeight(this.mContext) + "x" + AliRtcEngineUtil.getWindowWidth(this.mContext));
} catch (Exception e) {
e.printStackTrace();
}
return jSONObject.toString();
}
@Override
public void setTraceId(String str) {
if (this.mSophonEngine != null) {
AlivcLog.i(TAG, "[API]setTraceId: traceId:" + str);
this.mSophonEngine.setTraceId(str);
AlivcLog.i(TAG, "[API][End]setTraceId");
}
}
@Override
public String getMediaInfoWithUserId(String str, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack, String[] strArr) {
AlivcLog.i(TAG, "[API]getMediaInfoWithUserId: &&userCallId" + str + "&&traceId:" + aliRtcVideoTrack.toString() + "&&keys:" + Arrays.toString(strArr));
String str2 = null;
if (this.mSophonEngine != null) {
RemoteParticipant remoteParticipant = str != null ? this.mAliRtcConfig.getRemoteParticipants().get(str) : null;
String str3 = "";
String callID = remoteParticipant != null ? remoteParticipant.getCallID() : "";
if (TextUtils.isEmpty(callID)) {
aliRtcVideoTrack = null;
}
if (aliRtcVideoTrack != null) {
int i = AnonymousClass7.$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcVideoTrack[aliRtcVideoTrack.ordinal()];
if (i == 1) {
str3 = DeviceConfig.isSupportSuperStream() ? ALI_RTC_INTERFACE.SUPER_STRING : ALI_RTC_INTERFACE.CAMERA_STRING;
} else if (i == 2 || i == 3) {
str3 = ALI_RTC_INTERFACE.SCREEN_STRING;
}
}
str2 = this.mSophonEngine.getMediaInfo(callID, str3, strArr);
}
AlivcLog.i(TAG, "[API][End][Result]getMediaInfoWithUserId:" + str2);
return str2;
}
@Override
public int startAudioCapture() {
AlivcLog.i(TAG, "[API]startAudioCapture");
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine == null) {
return -1;
}
int startAudioCapture = sophonEngine.startAudioCapture();
AlivcLog.i(TAG, "[API][End][Result]startAudioCapture:" + startAudioCapture);
return startAudioCapture;
}
@Override
public int stopAudioCapture() {
AlivcLog.i(TAG, "[API]stopAudioCapture");
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine == null) {
return -1;
}
int startAudioCapture = sophonEngine.startAudioCapture();
AlivcLog.i(TAG, "[API][End][Result]stopAudioCapture:" + startAudioCapture);
return startAudioCapture;
}
@Override
public int startAudioPlayer() {
AlivcLog.i(TAG, "[API]startAudioPlayer");
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine == null) {
return -1;
}
int startAudioPlayer = sophonEngine.startAudioPlayer();
AlivcLog.i(TAG, "[API][End][Result]startAudioPlayer:" + startAudioPlayer);
return startAudioPlayer;
}
@Override
public int stopAudioPlayer() {
AlivcLog.i(TAG, "[API]stopAudioPlayer");
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine == null) {
return -1;
}
int stopAudioPlayer = sophonEngine.stopAudioPlayer();
AlivcLog.i(TAG, "[API][End][Result]stopAudioPlayer:" + stopAudioPlayer);
return stopAudioPlayer;
}
@Override
public void setDeviceOrientationMode(AliRtcEngine.AliRtcOrientationMode aliRtcOrientationMode) {
if (this.mSophonEngine != null) {
AlivcLog.e(TAG, "[API]setDeviceOrientationMode: " + aliRtcOrientationMode.ordinal());
ALI_RTC_INTERFACE.Ali_RTC_Device_Orientation_Mode ali_RTC_Device_Orientation_Mode = ALI_RTC_INTERFACE.Ali_RTC_Device_Orientation_Mode.Ali_RTC_Device_Orientation_0;
int i = AnonymousClass7.$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcOrientationMode[aliRtcOrientationMode.ordinal()];
if (i == 1) {
ali_RTC_Device_Orientation_Mode = ALI_RTC_INTERFACE.Ali_RTC_Device_Orientation_Mode.Ali_RTC_Device_Orientation_0;
} else if (i == 2) {
ali_RTC_Device_Orientation_Mode = ALI_RTC_INTERFACE.Ali_RTC_Device_Orientation_Mode.Ali_RTC_Device_Orientation_90;
} else if (i == 3) {
ali_RTC_Device_Orientation_Mode = ALI_RTC_INTERFACE.Ali_RTC_Device_Orientation_Mode.Ali_RTC_Device_Orientation_270;
} else if (i == 4) {
ali_RTC_Device_Orientation_Mode = ALI_RTC_INTERFACE.Ali_RTC_Device_Orientation_Mode.Ali_RTC_Device_Orientation_Adaptive;
}
this.mSophonEngine.setDeviceOrientationMode(ali_RTC_Device_Orientation_Mode);
AlivcLog.e(TAG, "[API][End]setDeviceOrientationMode");
}
}
public static class AnonymousClass7 {
static final int[] $SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcOrientationMode;
static final int[] $SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcRenderMirrorMode;
static final int[] $SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcVideoTrack;
static final int[] $SwitchMap$org$webrtc$alirtcInterface$ALI_RTC_INTERFACE$AliRTCMediaConnectionReConnectState;
static {
int[] iArr = new int[AliRtcEngine.AliRtcOrientationMode.values().length];
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcOrientationMode = iArr;
try {
iArr[AliRtcEngine.AliRtcOrientationMode.AliRtcOrientationModePortrait.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcOrientationMode[AliRtcEngine.AliRtcOrientationMode.AliRtcOrientationModeLandscapeLeft.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcOrientationMode[AliRtcEngine.AliRtcOrientationMode.AliRtcOrientationModeLandscapeRight.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcOrientationMode[AliRtcEngine.AliRtcOrientationMode.AliRtcOrientationModeAuto.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
int[] iArr2 = new int[AliRtcEngine.AliRtcVideoTrack.values().length];
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcVideoTrack = iArr2;
try {
iArr2[AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera.ordinal()] = 1;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcVideoTrack[AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen.ordinal()] = 2;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcVideoTrack[AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth.ordinal()] = 3;
} catch (NoSuchFieldError unused7) {
}
int[] iArr3 = new int[AliRtcEngine.AliRtcRenderMirrorMode.values().length];
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcRenderMirrorMode = iArr3;
try {
iArr3[AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeOnlyFront.ordinal()] = 1;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcRenderMirrorMode[AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled.ordinal()] = 2;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$alivc$rtc$AliRtcEngine$AliRtcRenderMirrorMode[AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllDisable.ordinal()] = 3;
} catch (NoSuchFieldError unused10) {
}
int[] iArr4 = new int[ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState.values().length];
$SwitchMap$org$webrtc$alirtcInterface$ALI_RTC_INTERFACE$AliRTCMediaConnectionReConnectState = iArr4;
try {
iArr4[ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState.AliRTC_MeidaConnection_ReConnect_Failed.ordinal()] = 1;
} catch (NoSuchFieldError unused11) {
}
try {
$SwitchMap$org$webrtc$alirtcInterface$ALI_RTC_INTERFACE$AliRTCMediaConnectionReConnectState[ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState.AliRTC_MeidaConnection_ReConnect_Connected.ordinal()] = 2;
} catch (NoSuchFieldError unused12) {
}
try {
$SwitchMap$org$webrtc$alirtcInterface$ALI_RTC_INTERFACE$AliRTCMediaConnectionReConnectState[ALI_RTC_INTERFACE.AliRTCMediaConnectionReConnectState.AliRTC_MeidaConnection_ReConnect_Connecting.ordinal()] = 3;
} catch (NoSuchFieldError unused13) {
}
}
}
@Override
public int startAudioAccompany(String str, boolean z, boolean z2, int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.e(TAG, "[API]startAudioAccompany:fileName:" + str + "&&onlyLocalPlay:" + z + "&&replaceMic" + z2 + "&&loopCycles" + i);
int startAudioAccompany = this.mSophonEngine.startAudioAccompany(str, z, z2, i);
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]startAudioAccompany:");
sb.append(startAudioAccompany);
AlivcLog.i(TAG, sb.toString());
return startAudioAccompany;
}
@Override
public int stopAudioAccompany() {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]stopAudioAccompany");
int stopAudioAccompany = this.mSophonEngine.stopAudioAccompany();
AlivcLog.i(TAG, "[API][End]stopAudioAccompany:" + stopAudioAccompany);
return stopAudioAccompany;
}
@Override
public int setAudioAccompanyVolume(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]setAudioAccompanyVolume:volume:" + i);
int audioAccompanyVolume = this.mSophonEngine.setAudioAccompanyVolume(i);
AlivcLog.i(TAG, "[API][End][Result]setAudioAccompanyVolume:" + audioAccompanyVolume);
return audioAccompanyVolume;
}
@Override
public int setAudioAccompanyPublishVolume(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]setAudioAccompanyPublishVolume:volume:" + i);
int SetAudioAccompanyPublishVolume = this.mSophonEngine.SetAudioAccompanyPublishVolume(i);
AlivcLog.i(TAG, "[API][End][Result]setAudioAccompanyPublishVolume:" + SetAudioAccompanyPublishVolume);
return SetAudioAccompanyPublishVolume;
}
@Override
public int getAudioAccompanyPublishVolume() {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]GetAudioAccompanyPublishVolume");
int GetAudioAccompanyPublishVolume = this.mSophonEngine.GetAudioAccompanyPublishVolume();
AlivcLog.i(TAG, "[API][End][Result]GetAudioAccompanyPublishVolume:" + GetAudioAccompanyPublishVolume);
return GetAudioAccompanyPublishVolume;
}
@Override
public int setAudioAccompanyPlayoutVolume(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]setAudioAccompanyPlayoutVolume:volume:" + i);
int SetAudioAccompanyPlayoutVolume = this.mSophonEngine.SetAudioAccompanyPlayoutVolume(i);
AlivcLog.i(TAG, "[API][End][Result]setAudioAccompanyPlayoutVolume:" + SetAudioAccompanyPlayoutVolume);
return SetAudioAccompanyPlayoutVolume;
}
@Override
public int getAudioAccompanyPlayoutVolume() {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]GetAudioAccompanyPlayoutVolume");
int GetAudioAccompanyPlayoutVolume = this.mSophonEngine.GetAudioAccompanyPlayoutVolume();
AlivcLog.i(TAG, "[API][End][Result]GetAudioAccompanyPlayoutVolume:" + GetAudioAccompanyPlayoutVolume);
return GetAudioAccompanyPlayoutVolume;
}
@Override
public int pauseAudioAccompany() {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]pauseAudioAccompany");
int PauseAudioMixing = this.mSophonEngine.PauseAudioMixing();
AlivcLog.i(TAG, "[API][End][Result]pauseAudioAccompany:" + PauseAudioMixing);
return PauseAudioMixing;
}
@Override
public int resumeAudioAccompany() {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]resumeAudioAccompany");
int ResumeAudioMixing = this.mSophonEngine.ResumeAudioMixing();
AlivcLog.i(TAG, "[API][End][Result]resumeAudioAccompany:" + ResumeAudioMixing);
return ResumeAudioMixing;
}
@Override
public int preloadAudioEffect(int i, String str) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]preloadAudioEffect:soundId:" + i + "&&filePath:" + str);
int PreloadAudioEffect = this.mSophonEngine.PreloadAudioEffect(i, str);
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]preloadAudioEffect:");
sb.append(PreloadAudioEffect);
AlivcLog.i(TAG, sb.toString());
return PreloadAudioEffect;
}
@Override
public int unloadAudioEffect(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]UnloadAudioEffect:soundId:" + i);
int UnloadAudioEffect = this.mSophonEngine.UnloadAudioEffect(i);
AlivcLog.i(TAG, "[API][End][Result]UnloadAudioEffect:" + UnloadAudioEffect);
return UnloadAudioEffect;
}
@Override
public int playAudioEffect(int i, String str, int i2, boolean z) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]playAudioEffect:soundId:" + i + "&&filePath:" + str + "&&cycles:" + i2 + "&&publish:" + z);
int PlayAudioEffect = this.mSophonEngine.PlayAudioEffect(i, str, i2, z);
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]playAudioEffect:");
sb.append(PlayAudioEffect);
AlivcLog.i(TAG, sb.toString());
return PlayAudioEffect;
}
@Override
public int stopAudioEffect(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]StopAudioEffect:soundId:" + i);
int StopAudioEffect = this.mSophonEngine.StopAudioEffect(i);
AlivcLog.i(TAG, "[API][Result]StopAudioEffect:" + StopAudioEffect);
return StopAudioEffect;
}
@Override
public int setAudioEffectPublishVolume(int i, int i2) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]SetAudioEffectPublishVolume:soundId:" + i + "&&volume" + i2);
int SetAudioEffectPublishVolume = this.mSophonEngine.SetAudioEffectPublishVolume(i, i2);
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]SetAudioEffectPublishVolume:");
sb.append(SetAudioEffectPublishVolume);
AlivcLog.i(TAG, sb.toString());
return SetAudioEffectPublishVolume;
}
@Override
public int getAudioEffectPublishVolume(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]GetAudioEffectPublishVolume:soundId:" + i);
int GetAudioEffectPublishVolume = this.mSophonEngine.GetAudioEffectPublishVolume(i);
AlivcLog.i(TAG, "[API][End][Result]GetAudioEffectPublishVolume:" + GetAudioEffectPublishVolume);
return GetAudioEffectPublishVolume;
}
@Override
public int setAudioEffectPlayoutVolume(int i, int i2) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]SetAudioEffectPlayoutVolume:soundId:" + i + "&&volume" + i2);
int SetAudioEffectPlayoutVolume = this.mSophonEngine.SetAudioEffectPlayoutVolume(i, i2);
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]SetAudioEffectPlayoutVolume:");
sb.append(SetAudioEffectPlayoutVolume);
AlivcLog.i(TAG, sb.toString());
return SetAudioEffectPlayoutVolume;
}
@Override
public int getAudioEffectPlayoutVolume(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]GetAudioEffectPlayoutVolume:soundId:" + i);
int GetAudioEffectPlayoutVolume = this.mSophonEngine.GetAudioEffectPlayoutVolume(i);
AlivcLog.i(TAG, "[API][End][Result]GetAudioEffectPlayoutVolume:" + GetAudioEffectPlayoutVolume);
return GetAudioEffectPlayoutVolume;
}
@Override
public int pauseAudioEffect(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]PauseAudioEffect:soundId:" + i);
int PauseAudioEffect = this.mSophonEngine.PauseAudioEffect(i);
AlivcLog.i(TAG, "[API][End][Result]PauseAudioEffect:" + PauseAudioEffect);
return PauseAudioEffect;
}
@Override
public int resumeAudioEffect(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]ResumeAudioEffect:soundId:" + i);
int ResumeAudioEffect = this.mSophonEngine.ResumeAudioEffect(i);
AlivcLog.i(TAG, "[API][End][Result]ResumeAudioEffect:" + ResumeAudioEffect);
return ResumeAudioEffect;
}
@Override
public int enableEarBack(boolean z) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]EnableEarBack:enable:" + z);
int EnableEarBack = this.mSophonEngine.EnableEarBack(z);
AlivcLog.i(TAG, "[API][End][Result]EnableEarBack:" + EnableEarBack);
return EnableEarBack;
}
@Override
public int setEarBackVolume(int i) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]SetEarBackVolume:volume:" + i);
int SetEarBackVolume = this.mSophonEngine.SetEarBackVolume(i);
AlivcLog.i(TAG, "[API][End][Result]SetEarBackVolume:" + SetEarBackVolume);
return SetEarBackVolume;
}
@Override
public int setChannelProfile(ALI_RTC_INTERFACE.AliRTCSDK_Channel_Profile aliRTCSDK_Channel_Profile) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]SetChannelProfile:channel_profile:" + aliRTCSDK_Channel_Profile.getValue());
int SetChannelProfile = this.mSophonEngine.SetChannelProfile(aliRTCSDK_Channel_Profile);
AlivcLog.i(TAG, "[API][End][Result]SetChannelProfile:" + SetChannelProfile);
return SetChannelProfile;
}
@Override
public int setClientRole(ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_Client_Role) {
SophonEngine sophonEngine = this.mSophonEngine;
if (sophonEngine == null) {
return -1;
}
int SetClientRole = sophonEngine.SetClientRole(aliRTCSDK_Client_Role);
AlivcLog.i(TAG, "[API][Result]SetClientRole:client_role:" + aliRTCSDK_Client_Role + LogUtils.COLON + SetClientRole);
return SetClientRole;
}
@Override
public int generateTexture() {
if (this.mSophonEngine == null) {
return -1;
}
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.i(TAG, "[API][Result]generateTexture: audio only mode error:-1");
return -1;
}
int generateTexture = this.mSophonEngine.generateTexture();
AlivcLog.i(TAG, "generateTexture = " + generateTexture);
return generateTexture;
}
@Override
public int setTexture(AliRtcEngine.AliRtcTextureInfo aliRtcTextureInfo, int i, String str) {
if (this.mSophonEngine == null) {
return -1;
}
if (aliRtcTextureInfo.textureId <= 0) {
AlivcLog.i(TAG, "[API] setTexture invalid textureInfo id" + aliRtcTextureInfo.textureId);
return -1;
}
if (this.mAliRtcConfig.isAudioOnly()) {
AlivcLog.i(TAG, "[API][Result]setTexture: audio only mode error:-1");
return -1;
}
AliRtcEngine.AliVideoCanvas aliVideoCanvas = new AliRtcEngine.AliVideoCanvas();
aliVideoCanvas.textureId = aliRtcTextureInfo.textureId;
aliVideoCanvas.textureWidth = 720;
aliVideoCanvas.textureHeight = 1280;
aliVideoCanvas.renderMode = AliRtcEngine.AliRtcRenderMode.AliRtcRenderModeAuto;
aliVideoCanvas.mirrorMode = aliRtcTextureInfo.mirrorMode;
aliVideoCanvas.view = null;
AliRtcEngine.AliRtcRemoteTextureInfo aliRtcRemoteTextureInfo = new AliRtcEngine.AliRtcRemoteTextureInfo();
aliRtcRemoteTextureInfo.aliVideoCanvas = aliVideoCanvas;
aliRtcRemoteTextureInfo.userId = str;
aliRtcRemoteTextureInfo.videoTrack = i;
aliRtcRemoteTextureInfos.add(aliRtcRemoteTextureInfo);
AlivcLog.i(TAG, "[API] setTexture uid = " + str + " videoTrack" + i + "textureId" + aliRtcTextureInfo.textureId + "mirrorMode" + aliRtcTextureInfo.mirrorMode);
StringBuilder sb = new StringBuilder();
sb.append("userId isEmpty = ");
sb.append(TextUtils.isEmpty(str));
Log.d(TAG, sb.toString());
if (TextUtils.isEmpty(str)) {
return setLocalViewConfig(aliVideoCanvas, swapTrack(i));
}
return setRemoteViewConfig(aliVideoCanvas, str, swapTrack(i));
}
private static AliRtcEngine.AliRtcVideoTrack swapTrack(int i) {
if (i == 0) {
return AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo;
}
if (i == 1) {
return AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera;
}
if (i == 2) {
return AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen;
}
if (i == 4) {
return AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth;
}
throw new IllegalStateException("Unexpected value: " + i);
}
@Override
public void removeTexture(int i) {
if (this.mSophonEngine == null || aliRtcRemoteTextureInfos.isEmpty()) {
return;
}
AliRtcEngine.AliRtcRemoteTextureInfo aliRtcRemoteTextureInfo = null;
Iterator<AliRtcEngine.AliRtcRemoteTextureInfo> it = aliRtcRemoteTextureInfos.iterator();
while (it.hasNext()) {
AliRtcEngine.AliRtcRemoteTextureInfo next = it.next();
if (next.aliVideoCanvas.textureId == i) {
if (TextUtils.isEmpty(next.userId)) {
setLocalViewConfig(next.aliVideoCanvas, swapTrack(next.videoTrack));
} else {
setRemoteViewConfig(next.aliVideoCanvas, next.userId, swapTrack(next.videoTrack));
}
aliRtcRemoteTextureInfo = next;
}
}
aliRtcRemoteTextureInfos.remove(aliRtcRemoteTextureInfo);
}
@Override
public int startAudioFileRecording(String str, AliRtcEngine.AliRtcAudioSampleRate aliRtcAudioSampleRate, AliRtcEngine.AliRtcAudioCodecQualityType aliRtcAudioCodecQualityType) {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]StartAudioFileRecording: filename:" + str + " sample_Rate:" + aliRtcAudioSampleRate + " quality:" + aliRtcAudioCodecQualityType.getId());
int StartAudioFileRecording = this.mSophonEngine.StartAudioFileRecording(str, aliRtcAudioSampleRate.getId(), aliRtcAudioCodecQualityType.getId());
StringBuilder sb = new StringBuilder();
sb.append("[API][End][Result]StartAudioFileRecording:");
sb.append(StartAudioFileRecording);
AlivcLog.i(TAG, sb.toString());
return StartAudioFileRecording;
}
@Override
public int stopAudioFileRecording() {
if (this.mSophonEngine == null) {
return -1;
}
AlivcLog.i(TAG, "[API]StopAudioFileRecording");
int StopAudioFileRecording = this.mSophonEngine.StopAudioFileRecording();
AlivcLog.i(TAG, "[API][End][Result]StopAudioFileRecording ret:" + StopAudioFileRecording);
return StopAudioFileRecording;
}
}