智慧城市 v1.2.1版本的 MD5 值为:d4aeacb5153a2710d0b6882be5dd2b15
以下内容为反编译后的 UnInitState.java 源代码,内容仅作参考
package cn.rongcloud.rtc.engine;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Message;
import android.text.TextUtils;
import cn.rongcloud.rtc.RongRTCMessageRouter;
import cn.rongcloud.rtc.api.RCRTCConfig;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.stream.RCRTCAudioStreamConfig;
import cn.rongcloud.rtc.base.RTCErrorCode;
import cn.rongcloud.rtc.center.config.RCRTCConfigImpl;
import cn.rongcloud.rtc.center.config.RCServerConfig;
import cn.rongcloud.rtc.center.stream.RCAudioStreamConfigImpl;
import cn.rongcloud.rtc.center.stream.RCCameraOutputStreamImpl;
import cn.rongcloud.rtc.center.stream.RCMicOutputStreamImpl;
import cn.rongcloud.rtc.core.MediaCodecProperties;
import cn.rongcloud.rtc.core.audio.AudioEffectManager;
import cn.rongcloud.rtc.core.audio.AudioMixer;
import cn.rongcloud.rtc.core.rongRTC.DevicesUtils;
import cn.rongcloud.rtc.module.AudioDeviceManager;
import cn.rongcloud.rtc.module.camera.CameraManagerImpl;
import cn.rongcloud.rtc.monitor.NetworkConnectChangedReceiver;
import cn.rongcloud.rtc.signal.SignalEventListener;
import cn.rongcloud.rtc.signal.SignalManager;
import cn.rongcloud.rtc.utils.DeviceUtils;
import cn.rongcloud.rtc.utils.FinLog;
import cn.rongcloud.rtc.utils.ReportUtil;
import cn.rongcloud.rtc.utils.RongRTCSessionManager;
import cn.rongcloud.rtc.webrtc.IWebRTCCore;
import cn.rongcloud.rtc.webrtc.WebRTCCoreImpl;
import io.rong.common.RLog;
import io.rong.imlib.ConnectChangeReceiver;
import io.rong.imlib.ModuleManager;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class UnInitState extends AbstractBaseState {
private static final String TAG = "UnInitState";
boolean mCallInited;
private CountDownLatch mDownLatch;
boolean mIMConnected;
RongRTCMessageRouter mMessageRouter;
NetworkConnectChangedReceiver networkConnectChangedReceiver;
SignalEventListener signalEventListener;
@Override
public String getName() {
return TAG;
}
public UnInitState(RTCEngineImpl rTCEngineImpl) {
super(rTCEngineImpl);
this.mDownLatch = new CountDownLatch(1);
}
@Override
public void enter() {
super.enter();
if (this.mIMConnected) {
return;
}
this.mEngine.mUserId = "";
this.mEngine.mToken = "";
}
@Override
public boolean handleMessage(Message message, MsgObjectWraper msgObjectWraper) {
int i = message.what;
if (i == 1000) {
if (!this.mCallInited) {
ReportUtil.TAG tag = ReportUtil.TAG.RTCINIT;
ReportUtil.appStatus(tag, "model|platform|rtcSDK", DeviceUtils.getBuildModel(), "Android-" + Build.VERSION.RELEASE, "5.1.7.1");
this.mCallInited = true;
this.mEngine.mContext = (Context) msgObjectWraper.getData(0);
this.mEngine.mConfig = (RCRTCConfigImpl) msgObjectWraper.getData(1);
this.mEngine.mAudioConfig = (RCAudioStreamConfigImpl) msgObjectWraper.getData(2);
onPrepare(this.mEngine.mContext);
onNext();
}
notifyAndReInitCountDownLatch();
} else if (i != 1010) {
if (i != 1011) {
return false;
}
imSignOut();
this.mEngine.mUserId = "";
this.mEngine.mToken = "";
} else if (!this.mIMConnected) {
this.mIMConnected = true;
this.mEngine.mUserId = (String) msgObjectWraper.getData(0);
this.mEngine.mToken = (String) msgObjectWraper.getData(1);
doGetConfig();
onNext();
}
return true;
}
private void doGetConfig() {
SignalManager.getInstance().getRTCConfig(Build.MODEL, String.valueOf(Build.VERSION.SDK_INT), System.currentTimeMillis(), "5.1.7.1", new IRCRTCResultDataCallback<String>() {
@Override
public void onFailed(RTCErrorCode rTCErrorCode) {
}
@Override
public void onSuccess(String str) {
if (!TextUtils.isEmpty(str)) {
RCServerConfig.saveConfig(RongRTCSessionManager.getInstance(), str);
} else {
FinLog.e(UnInitState.TAG, "doGetConfig Failed data is Null");
}
}
});
}
private void onPrepare(Context context) {
RongRTCMessageRouter rongRTCMessageRouter = new RongRTCMessageRouter();
this.mMessageRouter = rongRTCMessageRouter;
ModuleManager.addMessageRouter(rongRTCMessageRouter);
registerNetWorkReceiver(context);
MediaCodecProperties.init();
this.mEngine.initFaceBeautyPlugin(context);
this.mEngine.initVoiceBeautyPlugin(context);
}
private void registerNetWorkReceiver(Context context) {
try {
NetworkConnectChangedReceiver networkConnectChangedReceiver = this.networkConnectChangedReceiver;
if (networkConnectChangedReceiver != null) {
context.unregisterReceiver(networkConnectChangedReceiver);
}
this.networkConnectChangedReceiver = new NetworkConnectChangedReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
intentFilter.addAction(ConnectChangeReceiver.RECONNECT_ACTION);
intentFilter.addAction("android.intent.action.USER_PRESENT");
context.registerReceiver(this.networkConnectChangedReceiver, intentFilter);
} catch (Exception e) {
RLog.e(TAG, "registerNetWorkReceiver failed: " + e.getMessage());
}
}
private void onNext() {
if (this.mIMConnected && this.signalEventListener == null) {
this.signalEventListener = new SignalEventListener();
SignalManager.getInstance().setRTCRoomEventListener(this.signalEventListener);
}
if (!this.mCallInited || this.mEngine.mContext == null || TextUtils.isEmpty(this.mEngine.mUserId) || TextUtils.isEmpty(this.mEngine.mToken)) {
return;
}
FinLog.d(TAG, "onNext --> enter");
onInitRTC();
this.mEngine.transitionTo(this.mEngine.mIdleState);
FinLog.d(TAG, "onNext --> over");
}
private void onInitRTC() {
RCRTCConfigImpl rCRTCConfigImpl = this.mEngine.mConfig;
if (rCRTCConfigImpl == null) {
rCRTCConfigImpl = (RCRTCConfigImpl) RCRTCConfig.Builder.create().build();
}
updateRTCDevice(rCRTCConfigImpl);
RCRTCAudioStreamConfig rCRTCAudioStreamConfig = this.mEngine.mAudioConfig;
if (rCRTCAudioStreamConfig == null) {
rCRTCAudioStreamConfig = RCRTCAudioStreamConfig.Builder.create().buildDefaultMode();
}
AudioDeviceManager audioDeviceManager = new AudioDeviceManager(this.mEngine.mContext, rCRTCConfigImpl, (RCAudioStreamConfigImpl) rCRTCAudioStreamConfig);
audioDeviceManager.setVoiceBeautifier(this.mEngine.mVoiceBeautifierPlugin);
AudioEffectManager audioEffectManager = new AudioEffectManager(this.mEngine.mContext, rCRTCConfigImpl.getAudioSampleRate(), rCRTCConfigImpl.isStereo() ? 2 : 1, 2);
CameraManagerImpl cameraManagerImpl = new CameraManagerImpl(rCRTCConfigImpl.isEncoderTexture(), this.mEngine.getEglBaseContext(), this.mEngine.mContext);
this.mEngine.mRTCCore = new WebRTCCoreImpl(this.mEngine.mContext, rCRTCConfigImpl, audioDeviceManager.getAudioDeviceModule(), audioDeviceManager.getAudioConstraints());
String str = this.mEngine.mUserId;
IWebRTCCore iWebRTCCore = this.mEngine.mRTCCore;
this.mEngine.mDefaultVideoStream = new RCCameraOutputStreamImpl(str, cameraManagerImpl);
this.mEngine.bindCameraBeauty();
iWebRTCCore.bindingTrack(this.mEngine.mDefaultVideoStream);
this.mEngine.mDefaultAudioStream = new RCMicOutputStreamImpl(str, audioDeviceManager, audioEffectManager);
AudioMixer.getInstance().setDefaultAudioStream(this.mEngine.mDefaultAudioStream);
}
@Deprecated
private void updateRTCDevice(RCRTCConfigImpl rCRTCConfigImpl) {
DevicesUtils.setHighProfile(rCRTCConfigImpl.isEncoderHighProfile());
DevicesUtils.setEnCodeColor(rCRTCConfigImpl.getEncoderColor());
DevicesUtils.setDeCodeColor(rCRTCConfigImpl.getDecoderColor());
DevicesUtils.setEnCodeBitRateMode(rCRTCConfigImpl.getEncoderBitMode());
DevicesUtils.setTexture(rCRTCConfigImpl.isEncoderTexture());
DevicesUtils.setCustomizedCameraParameter(rCRTCConfigImpl.getCustomizedCameraParameter());
DevicesUtils.setAudioSource(rCRTCConfigImpl.getAudioSource());
DevicesUtils.setAudioSampleRate(rCRTCConfigImpl.getAudioSampleRate());
DevicesUtils.setAudioStereo(rCRTCConfigImpl.isStereo());
}
public boolean waitIniComplete(long j) throws InterruptedException {
return this.mDownLatch.await(j, TimeUnit.MILLISECONDS);
}
public void notifyAndReInitCountDownLatch() {
this.mDownLatch.countDown();
this.mDownLatch = new CountDownLatch(1);
}
public void imSignOut() {
this.mIMConnected = false;
}
}