void joinRoom(long roomId, String peerIdentifier, boolean isVideo) { QavsdkControl qavsdkControl = ((FacekallApplication) mContext).getQavsdkControl(); if ((qavsdkControl != null) && (qavsdkControl.getAVContext() != null)) { qavsdkControl.setPeerIdentifier(peerIdentifier); Log.e(TAG, "WL_DEBUG joinRoom peerIdentifier = " + peerIdentifier); Log.e(TAG, "WL_DEBUG joinRoom roomId = " + roomId); AVRoom.Info roomInfo = new AVRoom.Info( AVRoom.AV_ROOM_PAIR, roomId, 0, isVideo ? AVRoom.AV_MODE_VIDEO : AVRoom.AV_MODE_AUDIO, peerIdentifier, null, 0); // create room qavsdkControl.getAVContext().joinRoom(mRoomDelegate, roomInfo); mIsInJoinRoom = true; mIsVideo = isVideo; } else { Log.e(TAG, "WL_DEBUG joinRoom qavsdkControl = " + (qavsdkControl == null)); mIsInJoinRoom = false; mIsVideo = false; } }
/** 关闭房间 */ int closeRoom() { Log.e(TAG, "WL_DEBUG closeRoom"); QavsdkControl qavsdk = ((FacekallApplication) mContext).getQavsdkControl(); if ((qavsdk != null) && (qavsdk.getAVContext() != null)) { AVContext avContext = qavsdk.getAVContext(); mIsInCloseRoom = true; int result = avContext.closeRoom(mCloseRoomCompleteCallback); return result; } else { Log.e(TAG, "WL_DEBUG joinRoom qavsdkControl = " + (qavsdk == null)); mIsInCloseRoom = false; return -1; } }
// 创建房间成功回调 protected void OnRoomCreateComplete(int result) { Log.e(TAG, "WL_DEBUG mRoomDelegate.OnRoomCreateComplete result = " + result); mIsInCreateRoom = false; QavsdkControl qavsdkControl = ((FacekallApplication) mContext).getQavsdkControl(); AVRoomPair roomPair = (AVRoomPair) qavsdkControl.getRoom(); if (roomPair != null && result == AVConstants.AV_ERROR_OK) { mRoomId = roomPair.getRoomId(); qavsdkControl.inviteIntenal(); Log.d(TAG, "OnRoomCreateComplete. roomId = " + mRoomId); } else { mRoomId = 0; Log.e(TAG, "OnRoomCreateComplete. mRoomPair == null"); } mContext.sendBroadcast( new Intent(AVUtil.ACTION_ROOM_CREATE_COMPLETE) .putExtra(AVUtil.EXTRA_ROOM_ID, mRoomId) .putExtra(AVUtil.EXTRA_AV_ERROR_RESULT, result)); }