1.注释优化

2.视频逻辑优化
This commit is contained in:
fuenmao 2024-12-05 16:19:25 +08:00
parent cc268cc00d
commit 5d194ad054
1 changed files with 57 additions and 55 deletions

View File

@ -133,12 +133,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
}
}
///
Future<void> doHttpSetCamer() async {
await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid);
}
/// --------------------------
/// ------------------------------------------------------------------------------
///
Future<void> doHttpApplySpeak() async {
await getClient().applySpeak(state.roomNumber.value);
@ -147,14 +142,19 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
///
Future<void> doHttpCancelSpeak() async {
await getClient().cancelSpeak(state.meetingRoomInfo.value!.id, state.meetingRoomInfo.value!.roomNum, UserStore.to.userInfoEntity.value!.uid);
setClientRole("观众");
/*setClientRole("观众");
setMicrophoneOpen(false);
setCameraOpen(false);
setScreenShareOpen(false);
changePageState(0);
changePageState(0);*/
}
/// ------------------------------------------------------------------------------
///
Future<void> doHttpSetMicr() async {
await getClient().setMicr(state.roomNumber.value, state.isOpenMicrophone.value, UserStore.to.userInfoEntity.value!.uid);
}
/// --------------------------
///
Future<void> setMicrophoneOpen(bool isOpen) async{
state.isOpenMicrophone.value = isOpen;
@ -167,39 +167,27 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
doHttpSetMicr();
}
///
Future<void> doHttpSetMicr() async {
await getClient().setMicr(state.roomNumber.value, state.isOpenMicrophone.value, UserStore.to.userInfoEntity.value!.uid);
/// -------------------------------------------------------------------------------
///
Future<void> doHttpSetCamer() async {
await getClient().setCamera(state.roomNumber.value, state.isOpenCamera.value, UserStore.to.userInfoEntity.value!.uid);
}
///
///
void setCameraOpen(bool isOpen){
if(isOpen == true){
state.isOpenCamera.value = true;
setEnableVideo();
setStartPreview();
setClientRole("主播");
changePageState(1);
}else{
state.isOpenCamera.value = false;
setDisablePreview();
}
if(state.isOpenMicrophone.value == false){
setMicrophoneOpen(isOpen);
}
state.isOpenCamera.value = isOpen;
doHttpSetCamer();
}
///
void hangUpVideo(){
setDisableVideo();
setDisablePreview();
stopPreview();
state.isOpenCamera.value = false;
changePageState(0);
doHttpSetCamer();
}
///
///
Future<void> doHttpGetTvAnchor() async {
BaseStructureResult res = await getClient().getTvAnchor(state.roomNumber.value);
state.remoteUid.value = res.data!.toString();
@ -247,7 +235,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
}
}
/// --------------------------signalR Socket相关
/// ------------------------------------------------------------------------------signalR Socket相关
/// Socket长连接
Future<void> signalRSocket() async {
state.hubConnection.value = HubConnectionBuilder()
@ -263,7 +251,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
joinMeetingToSocket();
/// --------------------------
/// ------------------------------------------------------------------------------
///
state.hubConnection.value?.on("ManagerRefresh", (e){
// var jsonStr = const Utf8Decoder().convert(json.encode(e?[0]).runes.toList());
@ -297,15 +285,17 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
if(UserStore.to.userInfoEntity.value!.uid == meetingRoomUser.uid){
state.isSpeak.value = false;
state.isOpenMicrophone.value = false;
state.isOpenCamera.value = false;
setClientRole("观众");
debugPrint("wgs输出===Socket-关闭发言权限:观众");
}
}
doHttpSetMicr();
doHttpSetCamer();
update();
});
/// --------------------------
/// ------------------------------------------------------------------------------
///
state.hubConnection.value?.on("OperAllMicr", (e){
if(e?[0] == true){
@ -338,7 +328,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
state.isOpenMicrophone.value = true;
//
state.rctEngine.value?.muteLocalAudioStream(false);
muteLocalAudioStream(false);
}
}else{
debugPrint("wgs输出===Socket-用户单独闭麦");
@ -351,12 +341,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
state.isOpenMicrophone.value = false;
//
state.rctEngine.value?.muteLocalAudioStream(true);
muteLocalAudioStream(true);
}
}
});
/// --------------------------
/// ------------------------------------------------------------------------------
///
state.hubConnection.value?.on("UserJoined", (e){
// var jsonStr = const Utf8Decoder().convert(json.encode(user).runes.toList());
@ -400,7 +390,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
ToastUtils.showSuccess("会议已结束");
});
/// --------------------------
/// ------------------------------------------------------------------------------
///
state.hubConnection.value?.on("ReceiveMessage", (e){
// var jsonStr = const Utf8Decoder().convert(json.encode(e).runes.toList());
@ -415,7 +405,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
debugPrint("wgs输出===Socket-会议室接收消息:$jsonStr");
});
/// --------------------------
/// ------------------------------------------------------------------------------
///
state.hubConnection.value?.on("OperCamera", (e){
// var jsonStr = const Utf8Decoder().convert(json.encode(e?[0]).runes.toList());
@ -423,7 +413,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
var listDynamic = jsonDecode(jsonStr);
MeetingRoomUser meetingRoomUser = MeetingRoomUser.fromJson(listDynamic);
if(meetingRoomUser.enableCamera == true){
debugPrint("wgs输出===Socket-单独用户开摄像头");
debugPrint("wgs输出===Socket-用户单独开摄像头");
for(MeetingRoomUser mru in state.cacheUsers.value){
if(mru.uid == meetingRoomUser.uid){
mru.enableCamera = true;
@ -431,9 +421,15 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
}
if(meetingRoomUser.uid == UserStore.to.userInfoEntity.value!.uid){
state.isOpenCamera.value = true;
//
muteLocalVideoStream(false);
//
startPreview();
changePageState(1);
}
}else{
debugPrint("wgs输出===Socket-单独用户闭摄像头");
debugPrint("wgs输出===Socket-用户单独闭摄像头");
for(MeetingRoomUser mru in state.cacheUsers.value){
if(mru.uid == meetingRoomUser.uid){
mru.enableCamera = false;
@ -441,6 +437,11 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
}
if(meetingRoomUser.uid == UserStore.to.userInfoEntity.value!.uid){
state.isOpenCamera.value = false;
//
muteLocalVideoStream(true);
//
stopPreview();
}
}
});
@ -483,7 +484,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
await state.hubConnection.value?.invoke("sendChannelMsg", args: [state.roomNumber.value, msg]);
}
/// --------------------------SDK相关
/// ------------------------------------------------------------------------------SDK相关
/// SDK
Future<void> initRtc() async {
//
@ -499,8 +500,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
));
//
// await state.rctEngine.value?.enableAudio();
//
//
enableVideo();
//
await state.rctEngine.value?.setDefaultAudioRouteToSpeakerphone(false);
//
@ -646,28 +648,28 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{
await state.rctEngine.value?.setEnableSpeakerphone(mode == 1 ? false : true);
}
///
Future<void> disableAudio() async {
await state.rctEngine.value?.disableAudio();
}
///
Future<void> setEnableVideo() async {
Future<void> enableVideo() async {
await state.rctEngine.value?.enableVideo();
}
///
Future<void> setDisableVideo() async {
await state.rctEngine.value?.disableVideo();
///
Future<void> muteLocalAudioStream(bool mute) async {
await state.rctEngine.value?.muteLocalAudioStream(mute);
}
///
Future<void> setStartPreview() async {
///
Future<void> muteLocalVideoStream(bool mute) async {
await state.rctEngine.value?.muteLocalVideoStream(mute);
}
///
Future<void> startPreview() async {
await state.rctEngine.value?.startPreview();
}
///
Future<void> setDisablePreview() async {
///
Future<void> stopPreview() async {
await state.rctEngine.value?.stopPreview();
}