From 32d79cd4d0ac431878ea5b78eb2de04c5f29bb87 Mon Sep 17 00:00:00 2001 From: lxmou666 <772765102@qq.com> Date: Sat, 13 Feb 2021 14:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=BD=95=E5=88=B6=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JianGongYun/TRTC/LiveClassroom.cs | 28 +++++++++------- .../TRTC/ViewModels/SettingWindowViewModel.cs | 33 +++++++++++++++++++ JianGongYun/TRTC/Windows/LiveWindow.xaml | 10 +++--- JianGongYun/TRTC/Windows/LiveWindow.xaml.cs | 16 +++++---- JianGongYun/TRTC/Windows/SettingWindow.xaml | 19 +++++++---- 5 files changed, 77 insertions(+), 29 deletions(-) diff --git a/JianGongYun/TRTC/LiveClassroom.cs b/JianGongYun/TRTC/LiveClassroom.cs index f6cb088..f1c3c3a 100644 --- a/JianGongYun/TRTC/LiveClassroom.cs +++ b/JianGongYun/TRTC/LiveClassroom.cs @@ -204,7 +204,7 @@ namespace JianGongYun.TRTC lTRTCCloud.startLocalPreview(IntPtr.Zero); liveWinMode.CameraRunning = true; var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeBig, true); - if (liveWinMode.IsLive) + if (liveWinMode.IsLive && settingWindowViewModel.LocalRecorder) { view.OnRenderVideoFrameHandler += (data, w, h) => { @@ -255,7 +255,7 @@ namespace JianGongYun.TRTC SelectVieoSub(); lTRTCCloud.startScreenCapture(IntPtr.Zero, TRTCVideoStreamType.TRTCVideoStreamTypeSub, settingWindowViewModel.SubEncParams); var view = AddCustomVideoView(parent, CurrentClassroomEntity.TeacherId, TRTCVideoStreamType.TRTCVideoStreamTypeSub, true); - if (liveWinMode.IsLive) + if (liveWinMode.IsLive && settingWindowViewModel.LocalRecorder) { view.OnRenderVideoFrameHandler += (data, w, h) => { @@ -338,7 +338,10 @@ namespace JianGongYun.TRTC { liveWinMode.MicRunning = true; lTRTCCloud.startLocalAudio(settingWindowViewModel.LiveAudioLevel); - StartRecordAudio(); + if (settingWindowViewModel.LocalRecorder) + { + StartRecordAudio(); + } StartMUX(); } @@ -372,7 +375,10 @@ namespace JianGongYun.TRTC if (liveWinMode.MicRunning) { liveWinMode.MicRunning = false; - StopRecordAudio(); + if (settingWindowViewModel.LocalRecorder) + { + StopRecordAudio(); + } lTRTCCloud.stopLocalAudio(); } } @@ -721,13 +727,13 @@ namespace JianGongYun.TRTC ITRTCCloud.destroyTRTCShareInstance();//销毁TRTC实例 lTRTCCloud.Dispose(); lTRTCCloud = null; - if (CallerWindow == null) - { - //关闭程序 - Application.Current.Shutdown(); - return; - } - CallerWindow.Close();//直接关闭 + //if (CallerWindow == null) + //{ + // //关闭程序 + // Application.Current.Shutdown(); + // return; + //} + //CallerWindow.Close();//直接关闭 Application.Current.Shutdown(); } diff --git a/JianGongYun/TRTC/ViewModels/SettingWindowViewModel.cs b/JianGongYun/TRTC/ViewModels/SettingWindowViewModel.cs index bda8fe4..b1da095 100644 --- a/JianGongYun/TRTC/ViewModels/SettingWindowViewModel.cs +++ b/JianGongYun/TRTC/ViewModels/SettingWindowViewModel.cs @@ -428,6 +428,38 @@ namespace JianGongYun.TRTC.ViewModels // } //} + + /// + /// 本地录制 + /// + private bool _LocalRecorder = false; + public bool LocalRecorder + { + get + { + var localRecorder = storage.GetValue(INI_ROOT_KEY, INI_KEY_SCREEN_LOCALRECORDER);//本地缓存 + if (string.IsNullOrEmpty(localRecorder)) + { + storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_LOCALRECORDER, _LocalRecorder.ToString());//生成初始数据 + } + else + { + _LocalRecorder = bool.Parse(localRecorder); + } + return _LocalRecorder; + } + set + { + _LocalRecorder = value; + storage.SetValue(INI_ROOT_KEY, INI_KEY_SCREEN_LOCALRECORDER, value.ToString());//生成保存本地 + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs("LocalRecorder")); + } + } + } + + /// /// 录制倒计时 /// @@ -899,6 +931,7 @@ namespace JianGongYun.TRTC.ViewModels //private const string INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE = "INI_KEY_SCREEN_RECORDING_AUDIO_BITRATE";//音频码率 //private const string INI_KEY_SCREEN_RECORDING_AUDIO_FREQ = "INI_KEY_SCREEN_RECORDING_AUDIO_FREQ";//音频采样率 //private const string INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL = "INI_KEY_SCREEN_RECORDING_PROFILE_LEVEL";//编码级别 + private const string INI_KEY_SCREEN_LOCALRECORDER = "INI_KEY_SCREEN_LOCALRECORDER";//本地录制 private const string INI_KEY_SCREEN_RECORDING_COUNTDOWN = "INI_KEY_SCREEN_RECORDING_COUNTDOWN";//录制倒计时 private const string INI_KEY_SCREEN_RECORDING_DIR = "INI_KEY_SCREEN_RECORDING_DIR";//录制保存路径 //直播 diff --git a/JianGongYun/TRTC/Windows/LiveWindow.xaml b/JianGongYun/TRTC/Windows/LiveWindow.xaml index 8467fc9..aa31eb4 100644 --- a/JianGongYun/TRTC/Windows/LiveWindow.xaml +++ b/JianGongYun/TRTC/Windows/LiveWindow.xaml @@ -137,7 +137,7 @@ 摄像头预览 - + + - + - + diff --git a/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs b/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs index 83010f7..45ceb5d 100644 --- a/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs +++ b/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs @@ -48,7 +48,7 @@ namespace JianGongYun.TRTC.Windows base.OnActivated(e); //颜色前台设置无效,手动调用才行 var color = (SolidColorBrush)(new BrushConverter().ConvertFrom("#cccccc")); - Rad1.Foreground = color; + //Rad1.Foreground = color; Rad2.Foreground = color; Rad3.Foreground = color; Rad4.Foreground = color; @@ -155,7 +155,10 @@ namespace JianGongYun.TRTC.Windows LiveClassroom.StartVideoSub(AfterLiveSubViewWrap); } LiveClassroom.StartMic(); - LiveClassroom.VideoRecordTask(ref onEnd);//启动录制 + if (SettingWindowViewModel.LocalRecorder) + { + LiveClassroom.VideoRecordTask(ref onEnd);//启动录制 + } LiveClassroom.SetMicMute(false); }, SettingWindowViewModel.ScreenRecordingCountdown); @@ -169,12 +172,11 @@ namespace JianGongYun.TRTC.Windows LiveClassroom.StopVideoMain(AfterLiveViewWrap); LiveClassroom.StopVideoSub(AfterLiveSubViewWrap); - this.Hide(); - if (LiveClassroom.CallerWindow == null) { - Application.Current.Shutdown(); - return; + if (onEnd == null) + { + this.Close(); } - LiveClassroom.CallerWindow.Show();//还原调用者窗口 + //LiveClassroom.CallerWindow.Show();//还原调用者窗口 } } diff --git a/JianGongYun/TRTC/Windows/SettingWindow.xaml b/JianGongYun/TRTC/Windows/SettingWindow.xaml index d0a287c..2084c52 100644 --- a/JianGongYun/TRTC/Windows/SettingWindow.xaml +++ b/JianGongYun/TRTC/Windows/SettingWindow.xaml @@ -100,6 +100,13 @@ --> + + 本地录制 + + + + + 录制倒计时 @@ -153,17 +160,17 @@ 摄像头画质 - - - + + + 屏幕分享画质 - - - + + +