trtc roomId 获取方式优化
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.yizhuan.xchat_android_core.manager.trtc;
|
||||
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils;
|
||||
|
||||
public class RoomIdHelper {
|
||||
/**
|
||||
* trtr的房间id只能是int!
|
||||
* @param roomId
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
public static int getRoomId(String roomId, int uid) {
|
||||
int intRoomId = StringUtils.toInt(roomId, 0);
|
||||
return intRoomId == 0 ? uid : intRoomId;
|
||||
}
|
||||
}
|
@@ -193,7 +193,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onError(int errCode, String errMsg, Bundle extraInfo) {
|
||||
LogUtils.d(TAG, " errCode:" + errCode + " errMsg:" + errMsg);
|
||||
LogUtils.d(TAG, " errCode:" + errCode + " errMsg:" + errMsg);
|
||||
int tmpErrCode;
|
||||
switch (errCode) {
|
||||
case ERR_NULL:
|
||||
@@ -234,7 +234,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onUserVideoAvailable(final String uid, final boolean available) {
|
||||
LogUtils.d(TAG, " uid:" + uid + " available:" + available);
|
||||
LogUtils.d(TAG, " uid:" + uid + " available:" + available);
|
||||
try {
|
||||
Integer cnt = remoteVideoAvaibleCnt.get(uid);
|
||||
if (cnt == null) {
|
||||
@@ -251,14 +251,14 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
TRTCEngineAdapterListener.onUserMuteVideo(Integer.parseInt(uid), !available);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + uid);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + uid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstVideoFrame(String userId, int streamType, int width, int height) {
|
||||
LogUtils.d(TAG, " uid:" + userId + " streamType:" + streamType + " width:" + width + " height:" + height);
|
||||
LogUtils.d(TAG, " uid:" + userId + " streamType:" + streamType + " width:" + width + " height:" + height);
|
||||
int elapsed = (int) (System.currentTimeMillis() - joinRoomTime);
|
||||
try {
|
||||
if (userId != null) {
|
||||
@@ -268,34 +268,34 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
TRTCEngineAdapterListener.onFirstLocalVideoFrame(width, height, elapsed);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstAudioFrame(String userId) {
|
||||
LogUtils.d(TAG, " uid:" + userId);
|
||||
LogUtils.d(TAG, " uid:" + userId);
|
||||
int elapsed = (int) (System.currentTimeMillis() - joinRoomTime);
|
||||
try {
|
||||
if (userId != null) {
|
||||
TRTCEngineAdapterListener.onFirstRemoteAudioFrame(Integer.parseInt(userId), elapsed);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserEnterRoom(String userId) {
|
||||
LogUtils.d(TAG, " uid:" + userId);
|
||||
LogUtils.d(TAG, " uid:" + userId);
|
||||
int elapsed = (int) (System.currentTimeMillis() - joinRoomTime);
|
||||
try {
|
||||
users.add(userId);
|
||||
TRTCEngineAdapterListener.onUserJoined(Integer.parseInt(userId), elapsed);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
if (setLiveTransCodingFlag) {
|
||||
@@ -305,7 +305,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onRemoteUserLeaveRoom(String userId, int reason) {
|
||||
LogUtils.d(TAG, " uid:" + userId + " reason:" + reason);
|
||||
LogUtils.d(TAG, " uid:" + userId + " reason:" + reason);
|
||||
try {
|
||||
TRTCEngineAdapterListener.onUserOffline(Integer.parseInt(userId), reason);
|
||||
users.remove(userId);
|
||||
@@ -315,14 +315,14 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
sInstance.setLiveTranscoding(currentTranscodingConfig);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterRoom(long elapsed) {
|
||||
LogUtils.d(TAG, " elapsed:" + elapsed);
|
||||
LogUtils.d(TAG, " elapsed:" + elapsed);
|
||||
joinRoomTime = System.currentTimeMillis();
|
||||
try {
|
||||
String channelName = "";
|
||||
@@ -332,7 +332,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
channel = new JSONObject(mTRTCParams.businessInfo);
|
||||
channelName = channel.getString("strGroupId");
|
||||
} catch (JSONException e) {
|
||||
LogUtils.d(TAG, "onEnterRoom parse json error: " + mTRTCParams.businessInfo);
|
||||
LogUtils.d(TAG, "onEnterRoom parse json error: " + mTRTCParams.businessInfo);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -341,20 +341,20 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
}
|
||||
TRTCEngineAdapterListener.onJoinChannelSuccess(channelName, Integer.parseInt(mTRTCParams.userId), (int) elapsed);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + mTRTCParams.userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + mTRTCParams.userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExitRoom(int reason) {
|
||||
LogUtils.d(TAG, " reason:" + reason);
|
||||
LogUtils.d(TAG, " reason:" + reason);
|
||||
TRTCEngineAdapterListener.onLeaveChannel(lastStats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchRole(int errCode, String errMsg) {
|
||||
LogUtils.d(TAG, "errCode=" + errCode + " errMsg=" + errMsg);
|
||||
LogUtils.d(TAG, "errCode=" + errCode + " errMsg=" + errMsg);
|
||||
TRTCEngineAdapterListener.onClientRoleChanged(
|
||||
userRole == TRTCRoleAnchor ? CLIENT_ROLE_AUDIENCE : CLIENT_ROLE_BROADCASTER,
|
||||
userRole == TRTCRoleAnchor ? CLIENT_ROLE_BROADCASTER : CLIENT_ROLE_AUDIENCE);
|
||||
@@ -415,7 +415,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onUserAudioAvailable(String userId, boolean available) {
|
||||
LogUtils.d(TAG, " userId:" + userId + " available:" + available);
|
||||
LogUtils.d(TAG, " userId:" + userId + " available:" + available);
|
||||
try {
|
||||
Integer cnt = remoteVideoAvaibleCnt.get(userId);
|
||||
if (cnt == null) {
|
||||
@@ -431,7 +431,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
TRTCEngineAdapterListener.onUserMuteAudio(Integer.parseInt(userId), available);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -444,7 +444,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
|
||||
public void onApiCallExecuted(int error, String api, String result) {
|
||||
LogUtils.d(TAG, " error:" + error + "api:" + api + " result:" + result);
|
||||
LogUtils.d(TAG, " error:" + error + "api:" + api + " result:" + result);
|
||||
TRTCEngineAdapterListener.onApiCallExecuted(error, api, result);
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
try {
|
||||
TRTCEngineAdapterListener.onNetworkQuality(Integer.parseInt(qualityInfo.userId), localQuality.quality, qualityInfo.quality);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + qualityInfo.userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + qualityInfo.userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -529,7 +529,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
TRTCEngineAdapterListener.onAudioQuality(Integer.parseInt(sUid), getNetworkQuality(statics.rtt, statics.downLoss), (short) statics.rtt, (short) statics.downLoss);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:");
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -551,35 +551,35 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onRecvCustomCmdMsg(String userId, int cmdID, int seq, byte[] message) {
|
||||
LogUtils.d(TAG, " userId:" + userId + " cmdID:" + cmdID + " seq:" + seq);
|
||||
LogUtils.d(TAG, " userId:" + userId + " cmdID:" + cmdID + " seq:" + seq);
|
||||
try {
|
||||
TRTCEngineAdapterListener.onStreamMessage(Integer.parseInt(userId), cmdID, message);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMissCustomCmdMsg(String userId, int cmdID, int errCode, int missed) {
|
||||
LogUtils.d(TAG, " userId:" + userId + " cmdID:" + cmdID + " errCode:" + errCode + " missed:" + missed);
|
||||
LogUtils.d(TAG, " userId:" + userId + " cmdID:" + cmdID + " errCode:" + errCode + " missed:" + missed);
|
||||
try {
|
||||
TRTCEngineAdapterListener.onStreamMessageError(Integer.parseInt(userId), cmdID, errCode, missed, 0);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartPublishCDNStream(int err, String errMsg) {
|
||||
LogUtils.d(TAG, " err:" + err + " errMsg:" + errMsg);
|
||||
LogUtils.d(TAG, " err:" + err + " errMsg:" + errMsg);
|
||||
TRTCEngineAdapterListener.onStreamPublished("", err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioRouteChanged(int newRoute, int oldRoute) {
|
||||
LogUtils.d(TAG, " newRoute:" + newRoute + " oldRoute:" + oldRoute);
|
||||
LogUtils.d(TAG, " newRoute:" + newRoute + " oldRoute:" + oldRoute);
|
||||
int route;
|
||||
if (newRoute == TRTCCloudDef.TRTC_AUDIO_ROUTE_SPEAKER) {
|
||||
route = AUDIO_ROUTE_SPEAKERPHONE;
|
||||
@@ -593,19 +593,19 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onConnectionLost() {
|
||||
LogUtils.d(TAG, "TRTC net status:" + new Exception().getStackTrace()[0].getMethodName());
|
||||
LogUtils.d(TAG, "TRTC net status:" + new Exception().getStackTrace()[0].getMethodName());
|
||||
TRTCEngineAdapterListener.onError(ERR_CONNECTION_LOST);
|
||||
TRTCEngineAdapterListener.onConnectionInterrupted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTryToReconnect() {
|
||||
LogUtils.d(TAG, "TRTC net status:" + new Exception().getStackTrace()[0].getMethodName());
|
||||
LogUtils.d(TAG, "TRTC net status:" + new Exception().getStackTrace()[0].getMethodName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionRecovery() {
|
||||
LogUtils.d(TAG, "TRTC net status:" + new Exception().getStackTrace()[0].getMethodName());
|
||||
LogUtils.d(TAG, "TRTC net status:" + new Exception().getStackTrace()[0].getMethodName());
|
||||
}
|
||||
//以后几个回调函数为TRTC独有
|
||||
|
||||
@@ -629,24 +629,24 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void onConnectOtherRoom(final String userID, final int err, final String errMsg) {
|
||||
LogUtils.d(TAG, " userID:" + userID + " err:" + err + " errMsg:" + errMsg);
|
||||
LogUtils.d(TAG, " userID:" + userID + " err:" + err + " errMsg:" + errMsg);
|
||||
try {
|
||||
TRTCEngineAdapterListener.onConnectOtherRoom(Integer.parseInt(userID), err, errMsg);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userID);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisConnectOtherRoom(final int err, final String errMsg) {
|
||||
LogUtils.d(TAG, " err:" + err + " errMsg:" + errMsg);
|
||||
LogUtils.d(TAG, " err:" + err + " errMsg:" + errMsg);
|
||||
TRTCEngineAdapterListener.onDisConnectOtherRoom(err, errMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioEffectFinished(int effectId, int code) {
|
||||
// TRTCEngineAdapterListener.onAudioEffectFinished(effectId);
|
||||
// TRTCEngineAdapterListener.onAudioEffectFinished(effectId);
|
||||
}
|
||||
};
|
||||
private TRTCEffectManager sTRTCEffectManager;
|
||||
@@ -732,7 +732,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
}
|
||||
|
||||
public static TRTCEngineAdapter create(Context context, String appId, IRTCEngineHandler listener) {
|
||||
LogUtils.d(TAG, " appId:" + appId);
|
||||
LogUtils.d(TAG, " appId:" + appId);
|
||||
if (sInstance == null) {
|
||||
sInstance = new TRTCEngineAdapter(context, appId, listener);
|
||||
}
|
||||
@@ -1000,12 +1000,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
mTRTCParams.sdkAppId = TRTCAppId;
|
||||
mTRTCParams.role = userRole;
|
||||
//由于新注册的云信的roomId超过了Integer.MAX_VALUE,所以超过的使用我们自己的的uid当做trtc的roomId
|
||||
try {
|
||||
mTRTCParams.roomId = Integer.parseInt(channelName);
|
||||
} catch (Exception e) {
|
||||
//我们自己的uid生成规则理论上不会超过Integer.MAX_VALUE,除非用户数量到达Integer.MAX_VALUE!
|
||||
mTRTCParams.roomId = (int) AvRoomDataManager.get().getRoomUid();
|
||||
}
|
||||
mTRTCParams.roomId = RoomIdHelper.getRoomId(channelName, uid);
|
||||
sUid = String.valueOf(uid);
|
||||
users.add(sUid);
|
||||
trtcCloud.enterRoom(mTRTCParams, appScene);
|
||||
@@ -1353,7 +1348,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
totalBgmcycle = cycle;
|
||||
sTRTCEffectManager.stopEffect(mBGMId);
|
||||
mBGMId++;
|
||||
sTRTCEffectManager.playEffect(mBGMId,filePath,0,0,0,0,true);
|
||||
sTRTCEffectManager.playEffect(mBGMId, filePath, 0, 0, 0, 0, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1403,7 +1398,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
if (!enableAudioFlag) {
|
||||
return -1;
|
||||
}
|
||||
sTRTCEffectManager.setVolumeOfEffect(mBGMId,volume);
|
||||
sTRTCEffectManager.setVolumeOfEffect(mBGMId, volume);
|
||||
mMusicPlayoutVolume = volume;
|
||||
return 0;
|
||||
}
|
||||
@@ -1413,7 +1408,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
if (!enableAudioFlag) {
|
||||
return -1;
|
||||
}
|
||||
sTRTCEffectManager.setVolumeOfEffect(mBGMId,volume);
|
||||
sTRTCEffectManager.setVolumeOfEffect(mBGMId, volume);
|
||||
mMusicPublishVolume = volume;
|
||||
return 0;
|
||||
}
|
||||
@@ -1509,7 +1504,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setVideoQualityParameters(boolean preferFrameRateOverImageQuality) {
|
||||
LogUtils.d(TAG, " preferFrameRateOverImageQuality:" + preferFrameRateOverImageQuality);
|
||||
LogUtils.d(TAG, " preferFrameRateOverImageQuality:" + preferFrameRateOverImageQuality);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1526,7 +1521,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setVideoProfile(int width, int height, int frameRate, int bitrate) {
|
||||
LogUtils.d(TAG, " width:" + width + " height:" + height + " frameRate:" + frameRate + " bitrate:" + bitrate);
|
||||
LogUtils.d(TAG, " width:" + width + " height:" + height + " frameRate:" + frameRate + " bitrate:" + bitrate);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1544,7 +1539,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
jsonFuncParam.put("params", jsonParam);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LogUtils.d(TAG, "setVideoProfile err :JSONException");
|
||||
LogUtils.d(TAG, "setVideoProfile err :JSONException");
|
||||
return -1;
|
||||
}
|
||||
videoEncoderConfiguration.orientationMode = ORIENTATION_MODE_ADAPTIVE;
|
||||
@@ -1559,7 +1554,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setVideoEncoderConfiguration(VideoEncoderConfiguration config) {
|
||||
LogUtils.d(TAG, " config:" + config + " width:" + config.dimensions.width + " height:" + config.dimensions.height
|
||||
LogUtils.d(TAG, " config:" + config + " width:" + config.dimensions.width + " height:" + config.dimensions.height
|
||||
+ " fps:" + config.frameRate + " bitrate:" + config.bitrate + " orientationMode:" + config.orientationMode);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
@@ -1614,7 +1609,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
jsonFuncParam.put("params", jsonParam);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LogUtils.d(TAG, "setVideoEncoderConfiguration err :JSONException");
|
||||
LogUtils.d(TAG, "setVideoEncoderConfiguration err :JSONException");
|
||||
return -1;
|
||||
}
|
||||
videoEncoderConfiguration.orientationMode = config.orientationMode;
|
||||
@@ -1639,7 +1634,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setupLocalVideo(VideoCanvas local) {
|
||||
LogUtils.d(TAG, " local:" + local);
|
||||
LogUtils.d(TAG, " local:" + local);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1656,7 +1651,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setupRemoteVideo(VideoCanvas remote) {
|
||||
LogUtils.d(TAG, " remote:" + remote);
|
||||
LogUtils.d(TAG, " remote:" + remote);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1675,7 +1670,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setLocalRenderMode(int mode) {
|
||||
LogUtils.d(TAG, " mode:" + mode);
|
||||
LogUtils.d(TAG, " mode:" + mode);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1695,7 +1690,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setRemoteRenderMode(int uid, int mode) {
|
||||
LogUtils.d(TAG, " uid:" + uid + " mode:" + mode);
|
||||
LogUtils.d(TAG, " uid:" + uid + " mode:" + mode);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1734,7 +1729,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int enableLocalVideo(boolean enabled) {
|
||||
LogUtils.d(TAG, " enabled:" + enabled);
|
||||
LogUtils.d(TAG, " enabled:" + enabled);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1748,7 +1743,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int muteLocalVideoStream(boolean muted) {
|
||||
LogUtils.d(TAG, " muted:" + muted);
|
||||
LogUtils.d(TAG, " muted:" + muted);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1758,7 +1753,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int muteRemoteVideoStream(int uid, boolean muted) {
|
||||
LogUtils.d(TAG, " uid:" + uid + " muted:" + muted);
|
||||
LogUtils.d(TAG, " uid:" + uid + " muted:" + muted);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1768,7 +1763,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int muteAllRemoteVideoStreams(boolean muted) {
|
||||
LogUtils.d(TAG, " muted:" + muted);
|
||||
LogUtils.d(TAG, " muted:" + muted);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1778,7 +1773,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setDefaultMuteAllRemoteVideoStreams(boolean muted) {
|
||||
LogUtils.d(TAG, " muted:" + muted);
|
||||
LogUtils.d(TAG, " muted:" + muted);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1787,7 +1782,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setBeautyEffectOptions(boolean enabled, BeautyOptions options) {
|
||||
LogUtils.d(TAG, " enabled:" + enabled + " smoothnessLevel:" + options.smoothnessLevel + " lighteningLevel:" + options.lighteningLevel + " rednessLevel:" + options.rednessLevel);
|
||||
LogUtils.d(TAG, " enabled:" + enabled + " smoothnessLevel:" + options.smoothnessLevel + " lighteningLevel:" + options.lighteningLevel + " rednessLevel:" + options.rednessLevel);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1820,7 +1815,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setLocalVideoMirrorMode(int mode) {
|
||||
LogUtils.d(TAG, " mode:" + mode);
|
||||
LogUtils.d(TAG, " mode:" + mode);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1831,7 +1826,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
@Override
|
||||
public int switchCamera() {
|
||||
if (!enableVideoFlag && !isStartPreview) {
|
||||
LogUtils.d(TAG, "switchCamera error enableVideoFlag:" + enableVideoFlag + " isStartPreview:" + isStartPreview);
|
||||
LogUtils.d(TAG, "switchCamera error enableVideoFlag:" + enableVideoFlag + " isStartPreview:" + isStartPreview);
|
||||
}
|
||||
trtcCloud.switchCamera();
|
||||
return 0;
|
||||
@@ -1887,7 +1882,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setCameraExposurePosition(float positionXinView, float positionYinView) {
|
||||
LogUtils.d(TAG, " positionXinView:" + positionXinView + " positionYinView:" + positionYinView);
|
||||
LogUtils.d(TAG, " positionXinView:" + positionXinView + " positionYinView:" + positionYinView);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1897,7 +1892,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setCameraTorchOn(boolean isOn) {
|
||||
LogUtils.d(TAG, " isOn:" + isOn);
|
||||
LogUtils.d(TAG, " isOn:" + isOn);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1907,7 +1902,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setCameraAutoFocusFaceModeEnabled(boolean enabled) {
|
||||
LogUtils.d(TAG, " enabled:" + enabled);
|
||||
LogUtils.d(TAG, " enabled:" + enabled);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1934,7 +1929,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void setExternalVideoSource(boolean enable, boolean useTexture, boolean pushMode) {
|
||||
LogUtils.d(TAG, " enable:" + enable + " useTexture:" + useTexture + " pushMode:" + pushMode);
|
||||
LogUtils.d(TAG, " enable:" + enable + " useTexture:" + useTexture + " pushMode:" + pushMode);
|
||||
enableExternalVideo = enable;
|
||||
externalVideoUseTexture = useTexture;
|
||||
this.pushmode = pushMode;
|
||||
@@ -1943,7 +1938,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public boolean pushExternalVideoFrame(AgoraVideoFrame videoFrame) {
|
||||
LogUtils.d(TAG, " videoFrame:" + videoFrame);
|
||||
LogUtils.d(TAG, " videoFrame:" + videoFrame);
|
||||
if (!enableVideoFlag || !enableExternalVideo) {
|
||||
return false;
|
||||
}
|
||||
@@ -2015,7 +2010,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
@Override
|
||||
public int setLocalVideoRenderer(IVideoSink render) {
|
||||
if (!enableVideoFlag || render == null) {
|
||||
LogUtils.d(TAG, "setLocalVideoRenderer error enableVideoFlag:" + enableVideoFlag + " render:" + render);
|
||||
LogUtils.d(TAG, "setLocalVideoRenderer error enableVideoFlag:" + enableVideoFlag + " render:" + render);
|
||||
return -1;
|
||||
}
|
||||
localVideoRender = render;
|
||||
@@ -2065,7 +2060,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setRemoteVideoRenderer(int uid, IVideoSink render) {
|
||||
LogUtils.d(TAG, " uid:" + uid);
|
||||
LogUtils.d(TAG, " uid:" + uid);
|
||||
if (!enableVideoFlag) {
|
||||
return -1;
|
||||
}
|
||||
@@ -2089,7 +2084,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
LogUtils.d(TAG, "uid is not Integer type uid:" + userId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2151,12 +2146,12 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setExternalAudioSource(boolean enabled, int sampleRate, int channels) {
|
||||
LogUtils.d(TAG, " enabled:" + enabled + " sampleRate:" + sampleRate + " channels:" + channels);
|
||||
LogUtils.d(TAG, " enabled:" + enabled + " sampleRate:" + sampleRate + " channels:" + channels);
|
||||
if (!enableAudioFlag) {
|
||||
return -1;
|
||||
}
|
||||
if (sampleRate != 48000) {
|
||||
LogUtils.d(TAG, "setExternalAudioSource unsupport sampleRate: " + sampleRate);
|
||||
LogUtils.d(TAG, "setExternalAudioSource unsupport sampleRate: " + sampleRate);
|
||||
return -1;
|
||||
}
|
||||
externalAudioSampleRate = sampleRate;
|
||||
@@ -2168,9 +2163,9 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int pushExternalAudioFrame(byte[] data, long timeStamp) {
|
||||
LogUtils.d(TAG, " timeStamp:" + timeStamp);
|
||||
LogUtils.d(TAG, " timeStamp:" + timeStamp);
|
||||
if (!enableAudioFlag || !bSetExternalAudioSource) {
|
||||
LogUtils.d(TAG, "pushExternalAudioFrame error: enableAudioFlag:" + enableAudioFlag + " bSetExternalAudioSource:" + bSetExternalAudioSource);
|
||||
LogUtils.d(TAG, "pushExternalAudioFrame error: enableAudioFlag:" + enableAudioFlag + " bSetExternalAudioSource:" + bSetExternalAudioSource);
|
||||
return -1;
|
||||
}
|
||||
TRTCCloudDef.TRTCAudioFrame frame = new TRTCCloudDef.TRTCAudioFrame();
|
||||
@@ -2315,7 +2310,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int enableDualStreamMode(boolean enable) {
|
||||
LogUtils.d(TAG, " enable:" + enable);
|
||||
LogUtils.d(TAG, " enable:" + enable);
|
||||
TRTCCloudDef.TRTCVideoEncParam smallVideoEncParam = new TRTCCloudDef.TRTCVideoEncParam();
|
||||
smallVideoEncParam.videoResolution = TRTC_VIDEO_RESOLUTION_320_240;
|
||||
smallVideoEncParam.videoResolutionMode = TRTC_VIDEO_RESOLUTION_MODE_LANDSCAPE;
|
||||
@@ -2339,7 +2334,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
jsonFuncParam.put("params", jsonParam);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LogUtils.d(TAG, "enableDualStreamMode err :JSONException");
|
||||
LogUtils.d(TAG, "enableDualStreamMode err :JSONException");
|
||||
return -1;
|
||||
}
|
||||
trtcCloud.callExperimentalAPI(jsonFuncParam.toString());
|
||||
@@ -2352,7 +2347,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setRemoteVideoStreamType(int uid, int streamType) {
|
||||
LogUtils.d(TAG, " uid:" + uid + " streamType:" + streamType);
|
||||
LogUtils.d(TAG, " uid:" + uid + " streamType:" + streamType);
|
||||
int tmpStreamType = TRTC_VIDEO_STREAM_TYPE_BIG;////VIDEO_STREAM_HIGH = 0
|
||||
if (1 == streamType) {
|
||||
tmpStreamType = TRTC_VIDEO_STREAM_TYPE_SMALL;////VIDEO_STREAM_LOW = 1
|
||||
@@ -2363,7 +2358,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setRemoteDefaultVideoStreamType(int streamType) {
|
||||
LogUtils.d(TAG, " streamType:" + streamType);
|
||||
LogUtils.d(TAG, " streamType:" + streamType);
|
||||
int tmpStreamType = TRTC_VIDEO_STREAM_TYPE_BIG;//VIDEO_STREAM_HIGH = 0
|
||||
if (1 == streamType) {
|
||||
tmpStreamType = TRTC_VIDEO_STREAM_TYPE_SMALL;//VIDEO_STREAM_LOW = 1
|
||||
@@ -2374,7 +2369,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int addPublishStreamUrl(String url, boolean transcodingEnabled) {
|
||||
LogUtils.d(TAG, " url:" + url + " transcodingEnabled:" + transcodingEnabled);
|
||||
LogUtils.d(TAG, " url:" + url + " transcodingEnabled:" + transcodingEnabled);
|
||||
TRTCCloudDef.TRTCPublishCDNParam param = new TRTCCloudDef.TRTCPublishCDNParam();
|
||||
param.appId = SDKConfig.TX_APPID;
|
||||
param.bizId = SDKConfig.TX_BIZID;
|
||||
@@ -2386,7 +2381,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int removePublishStreamUrl(String url) {
|
||||
LogUtils.d(TAG, " url:" + url);
|
||||
LogUtils.d(TAG, " url:" + url);
|
||||
trtcCloud.stopPublishCDNStream();
|
||||
return 0;
|
||||
}
|
||||
@@ -2435,7 +2430,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int createDataStream(boolean reliable, boolean ordered) {
|
||||
LogUtils.d(TAG, "reliable:" + reliable + " ordered:" + ordered);
|
||||
LogUtils.d(TAG, "reliable:" + reliable + " ordered:" + ordered);
|
||||
dataStreamReliable = reliable;
|
||||
dataStreamOrdered = ordered;
|
||||
curSendStreamCnt++;
|
||||
@@ -2447,7 +2442,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int sendStreamMessage(int cmdID, byte[] data) {
|
||||
LogUtils.d(TAG, "cmdID:" + cmdID);
|
||||
LogUtils.d(TAG, "cmdID:" + cmdID);
|
||||
sendStreamSizeInSecond += data.length;
|
||||
if (0 == lastSecondSendStreamTime) {
|
||||
lastSecondSendStreamTime = System.currentTimeMillis();
|
||||
@@ -2474,14 +2469,14 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setLogFile(String filePath) {
|
||||
LogUtils.d(TAG, " filePath:" + filePath);
|
||||
LogUtils.d(TAG, " filePath:" + filePath);
|
||||
TRTCCloud.setLogDirPath(filePath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setLogFilter(int filter) {
|
||||
LogUtils.d(TAG, " filter:" + filter);
|
||||
LogUtils.d(TAG, " filter:" + filter);
|
||||
int logFilter = TRTC_LOG_LEVEL_DEBUG;
|
||||
switch (filter) {
|
||||
case LOG_FILTER_OFF:
|
||||
@@ -2512,7 +2507,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public int setLogFileSize(int fileSizeInKBytes) {
|
||||
LogUtils.d(TAG, " fileSizeInKBytes:" + fileSizeInKBytes);
|
||||
LogUtils.d(TAG, " fileSizeInKBytes:" + fileSizeInKBytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2722,7 +2717,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
needAdjust = true;
|
||||
}
|
||||
}
|
||||
LogUtils.d(TAG, " inputWidth:" + inputWidth + " inputHeight:" + inputHeight + " needAdjust:" + needAdjust + " adjustWidth:" + adjustWidth + " adjustHeight:" + adjustHeight);
|
||||
LogUtils.d(TAG, " inputWidth:" + inputWidth + " inputHeight:" + inputHeight + " needAdjust:" + needAdjust + " adjustWidth:" + adjustWidth + " adjustHeight:" + adjustHeight);
|
||||
if (needAdjust) {
|
||||
JSONObject jsonFuncParam = new JSONObject();
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
@@ -2738,12 +2733,12 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
jsonFuncParam.put("params", jsonParam);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LogUtils.d(TAG, "setVideoEncodeParamEx err :JSONException");
|
||||
LogUtils.d(TAG, "setVideoEncodeParamEx err :JSONException");
|
||||
return -1;
|
||||
}
|
||||
videoEncoderConfiguration.dimensions.width = adjustWidth;
|
||||
videoEncoderConfiguration.dimensions.height = adjustHeight;
|
||||
LogUtils.d(TAG, "call callExperimentalAPI to set video encoder param.");
|
||||
LogUtils.d(TAG, "call callExperimentalAPI to set video encoder param.");
|
||||
trtcCloud.callExperimentalAPI(jsonFuncParam.toString());
|
||||
}
|
||||
return 0;
|
||||
@@ -2753,7 +2748,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void consumeByteBufferFrame(ByteBuffer buffer, int format, int width, int height, int rotation, long timestamp) {
|
||||
LogUtils.d(TAG, "format:" + format + "width:" + width + " height:" + height + " rotation:" + rotation + " timestamp:" + timestamp);
|
||||
LogUtils.d(TAG, "format:" + format + "width:" + width + " height:" + height + " rotation:" + rotation + " timestamp:" + timestamp);
|
||||
if (rotation == 90 || rotation == 270) {
|
||||
checkEncoderConfiguration(height, width);//旋转之后宽高对调
|
||||
} else {
|
||||
@@ -2822,7 +2817,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
// }
|
||||
@Override
|
||||
public void consumeByteArrayFrame(byte[] data, int format, int width, int height, int rotation, long timestamp) {
|
||||
LogUtils.d(TAG, "format:" + format + "width:" + width + " height:" + height + " rotation:" + rotation + " timestamp:" + timestamp);
|
||||
LogUtils.d(TAG, "format:" + format + "width:" + width + " height:" + height + " rotation:" + rotation + " timestamp:" + timestamp);
|
||||
//writeYUV(data);
|
||||
if (rotation == 90 || rotation == 270) {
|
||||
checkEncoderConfiguration(height, width);//旋转之后宽高对调
|
||||
@@ -2881,7 +2876,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
||||
|
||||
@Override
|
||||
public void consumeTextureFrame(int textureId, int format, int width, int height, int rotation, long timestamp, float[] matrix) {
|
||||
LogUtils.d(TAG, "format:" + format + "width:" + width + " height:" + height + " rotation:" + rotation + " timestamp:" + timestamp);
|
||||
LogUtils.d(TAG, "format:" + format + "width:" + width + " height:" + height + " rotation:" + rotation + " timestamp:" + timestamp);
|
||||
if (rotation == 90 || rotation == 270) {
|
||||
checkEncoderConfiguration(height, width);//旋转之后宽高对调
|
||||
} else {
|
||||
|
@@ -135,7 +135,12 @@ public class TRtcEngineManager extends BaseEngine {
|
||||
@Override
|
||||
public void connectOtherRoom(String roomId, long userUid) {
|
||||
if (mRtcEngine != null) {
|
||||
mRtcEngine.ConnectOtherRoom(String.format("{\"strRoomId\":\"%s\",\"userId\":\"%s\"}", roomId, userUid));
|
||||
mRtcEngine.ConnectOtherRoom(
|
||||
String.format(
|
||||
"{\"strRoomId\":\"%s\",\"userId\":\"%s\"}",
|
||||
RoomIdHelper.getRoomId(roomId, (int) userUid),
|
||||
userUid)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user